Skip to content

Commit

Permalink
Add Missing Optional Annotation for Port (#288)
Browse files Browse the repository at this point in the history
* add optional label

Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com>

* add migration

Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com>

* fix merge conflictsg

Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com>

* fix lint

Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com>

---------

Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com>
  • Loading branch information
sthwang-metal authored Feb 27, 2024
1 parent 9f8e7ee commit 77a0ab5
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 53 deletions.
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Start the load balancer Graph API",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
if pidFileName != "" {
if err := writePidFile(pidFileName); err != nil {
logger.Error("failed to write pid file", zap.Error(err))
Expand Down
7 changes: 7 additions & 0 deletions db/migrations/20240214095509_change_port_name_optional.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- +goose Up
-- modify "ports" table
ALTER TABLE "ports" ALTER COLUMN "name" DROP NOT NULL;

-- +goose Down
-- reverse: modify "ports" table
ALTER TABLE "ports" ALTER COLUMN "name" SET NOT NULL;
3 changes: 2 additions & 1 deletion db/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
h1:0KtiTooJCnoUsSF1CYnlRKEVEQFmH2Fj55S/41WmJr8=
h1:MujJgh8ifO4DK4QeukfFWRsa5OFI9Q0agyQwNlkI/3Q=
20230503185445_initial-migration.sql h1:4pqNp2MDBBRdGxU/H5mmZui9oi1SyjIiMVGatajrBeY=
20230615194819_drop_tenant_add_owner.sql h1:KGCsItU0NYhxYEkhZOaMQjfIrBMnek5rxC6D/LhnyCk=
20230629085916_drop_status_and_annotations.sql h1:kvDMoaMEjyoj/aRi6rw4XvCLxGH09vGGLbL0/p5tpPo=
20231017005257_add_origin_weight.sql h1:NuorUbcydDqcyPK8wgwlkQxaH+zGWfVtJW9UPL1Vn+E=
20240207205734_audit-fields.sql h1:cplFCBB7laCP5Y+UAoxIfITMo56Hoc5XIVvgcfGL9o0=
20240208121103_softdelete.sql h1:rt3nHn/1KzxSAbJZ33fQJZi5emLk7Q2PCRcfxWUeveY=
20240214095509_change_port_name_optional.sql h1:ArlIsVK4Tgi6AW6NiRMbAqU43+5KFqDkaa+YmxSoBkE=
10 changes: 8 additions & 2 deletions internal/ent/generated/gql_mutation_input.go

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

8 changes: 8 additions & 0 deletions internal/ent/generated/gql_where_input.go

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

2 changes: 1 addition & 1 deletion internal/ent/generated/migrate/schema.go

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

19 changes: 19 additions & 0 deletions internal/ent/generated/mutation.go

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

10 changes: 10 additions & 0 deletions internal/ent/generated/port/where.go

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

11 changes: 8 additions & 3 deletions internal/ent/generated/port_create.go

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

34 changes: 34 additions & 0 deletions internal/ent/generated/port_update.go

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

3 changes: 2 additions & 1 deletion internal/ent/schema/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (Port) Fields() []ent.Field {
field.String("name").
Annotations(
entgql.OrderField("name"),
),
).
Optional(),
field.String("load_balancer_id").
GoType(gidx.PrefixedID("")).
Immutable().
Expand Down
48 changes: 36 additions & 12 deletions internal/graphapi/gen_server.go

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

2 changes: 1 addition & 1 deletion internal/graphapi/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestFullLoadBalancerLifecycle(t *testing.T) {
assert.Equal(t, ownerID, createdLB.Owner.ID)

createdPortResp, err := graphTestClient().LoadBalancerPortCreate(ctx, graphclient.CreateLoadBalancerPortInput{
Name: gofakeit.DomainName(),
Name: newString(gofakeit.DomainName()),
Number: 8080,
LoadBalancerID: createdLB.ID,
})
Expand Down
Loading

0 comments on commit 77a0ab5

Please sign in to comment.