Skip to content

Commit

Permalink
Work towards enabling index generation
Browse files Browse the repository at this point in the history
Abstracted the index package format and the package's metadata.tar
format into `PackageCommon` to faciliate storing the required fields
into the DB to then, on the fly, generate the Package index for serving
to clients.

Also reworked the `.mise.toml` to add a new `mise run watch` command to
faciliate hot reloading of the server component.
  • Loading branch information
jaredallard committed May 5, 2024
1 parent ff26636 commit c4e951e
Show file tree
Hide file tree
Showing 16 changed files with 240 additions and 57 deletions.
11 changes: 10 additions & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ goreleaser = "latest"

[tasks.build]
description = "Build a binary for the current platform/architecture"
sources = ["cmd/**/*.go", "internal/**/*.go", "go.mod", "go.sum"]
outputs = ["./bin/binhost"]
run = "go build -trimpath -o ./bin/ -v ./cmd/..."

[tasks.test]
Expand All @@ -31,5 +33,12 @@ run = [
]

## <<Stencil::Block(custom)>>
[tasks.dev]
description = "Live reload target (use with `mise run watch`)"
depends = ["build"]
run = ["ENV=development ./bin/binhost"]

## <</Stencil::Block>>
[tasks.watch]
description = "Watch for changes"
run = ["mise watch -t dev --clear --restart"]
## <</Stencil::Block>>
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ targets.
- [License](#license)
<!-- /toc -->

## Developing

We use [mise]() to manage development versions and tasks.

```bash
mise run build
```

Now you can run the server with:

```bash
ENV=development ./bin/binhost
```

## API

Loose documentation of the API provided by `binhost` is below.
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
entgo.io/ent v0.13.1
github.com/caarlos0/env/v10 v10.0.0
github.com/charmbracelet/log v0.4.0
github.com/davecgh/go-spew v1.1.1
github.com/gofiber/fiber/v3 v3.0.0-20240322111812-5e8df0a348be
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.5.5
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
Expand All @@ -112,6 +114,10 @@ github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down Expand Up @@ -152,6 +158,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
3 changes: 2 additions & 1 deletion internal/dpi/dpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/minio/minio-go/v7/pkg/credentials"

entsql "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/schema"
_ "github.com/jackc/pgx/v5/stdlib" // Used by ent.
"github.com/jaredallard/binhost/internal/config"
"github.com/jaredallard/binhost/internal/ent"
Expand Down Expand Up @@ -77,7 +78,7 @@ func New(ctx context.Context, log *slog.Logger) (*Dependencies, error) {
}

client := ent.NewClient(ent.Driver(entsql.OpenDB(dialect.Postgres, db)))
if err := client.Schema.Create(ctx); err != nil {
if err := client.Schema.Create(ctx, schema.WithDropColumn(true), schema.WithDropIndex(true)); err != nil {
return nil, fmt.Errorf("failed creating schema resources: %w", err)
}

Expand Down
5 changes: 3 additions & 2 deletions internal/ent/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 69 additions & 14 deletions internal/ent/mutation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions internal/ent/pkg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/ent/pkg/pkg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions internal/ent/pkg_create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c4e951e

Please sign in to comment.