From b1bab3e9492b05c774d92167e43acea7f411eec6 Mon Sep 17 00:00:00 2001 From: marco Date: Tue, 24 Sep 2024 16:30:31 +0200 Subject: [PATCH] CI: report error if the generated code has been modified, not generated or uncommitted --- .github/workflows/go-tests.yml | 12 ++++++++++++ pkg/database/ent/bouncer/where.go | 10 ---------- pkg/database/ent/bouncer_create.go | 11 +++-------- pkg/database/ent/bouncer_update.go | 18 ------------------ pkg/database/ent/migrate/schema.go | 2 +- pkg/database/ent/mutation.go | 19 ------------------- pkg/database/ent/schema/bouncer.go | 2 +- pkg/modelscapi/success_response.go | 3 +++ 8 files changed, 20 insertions(+), 57 deletions(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index d4e3a3d843a..a6c72a91af6 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -128,6 +128,18 @@ jobs: with: go-version: "1.22" + - name: Run "make generate" and check for changes + run: | + set -e + make generate 2>/dev/null + if [[ $(git status --porcelain) ]]; then + echo "Error: Uncommitted changes found after running 'make generate'. Please commit all generated code." + git diff + exit 1 + else + echo "No changes detected after running 'make generate'." + fi + - name: Create localstack streams run: | aws --endpoint-url=http://127.0.0.1:4566 --region us-east-1 kinesis create-stream --stream-name stream-1-shard --shard-count 1 diff --git a/pkg/database/ent/bouncer/where.go b/pkg/database/ent/bouncer/where.go index e02199bc0a9..63ae5f64809 100644 --- a/pkg/database/ent/bouncer/where.go +++ b/pkg/database/ent/bouncer/where.go @@ -734,16 +734,6 @@ func OsnameHasSuffix(v string) predicate.Bouncer { return predicate.Bouncer(sql.FieldHasSuffix(FieldOsname, v)) } -// OsnameIsNil applies the IsNil predicate on the "osname" field. -func OsnameIsNil() predicate.Bouncer { - return predicate.Bouncer(sql.FieldIsNull(FieldOsname)) -} - -// OsnameNotNil applies the NotNil predicate on the "osname" field. -func OsnameNotNil() predicate.Bouncer { - return predicate.Bouncer(sql.FieldNotNull(FieldOsname)) -} - // OsnameEqualFold applies the EqualFold predicate on the "osname" field. func OsnameEqualFold(v string) predicate.Bouncer { return predicate.Bouncer(sql.FieldEqualFold(FieldOsname, v)) diff --git a/pkg/database/ent/bouncer_create.go b/pkg/database/ent/bouncer_create.go index 29b23f87cf1..3f131f4d1a6 100644 --- a/pkg/database/ent/bouncer_create.go +++ b/pkg/database/ent/bouncer_create.go @@ -142,14 +142,6 @@ func (bc *BouncerCreate) SetOsname(s string) *BouncerCreate { return bc } -// SetNillableOsname sets the "osname" field if the given value is not nil. -func (bc *BouncerCreate) SetNillableOsname(s *string) *BouncerCreate { - if s != nil { - bc.SetOsname(*s) - } - return bc -} - // SetOsversion sets the "osversion" field. func (bc *BouncerCreate) SetOsversion(s string) *BouncerCreate { bc.mutation.SetOsversion(s) @@ -251,6 +243,9 @@ func (bc *BouncerCreate) check() error { if _, ok := bc.mutation.AuthType(); !ok { return &ValidationError{Name: "auth_type", err: errors.New(`ent: missing required field "Bouncer.auth_type"`)} } + if _, ok := bc.mutation.Osname(); !ok { + return &ValidationError{Name: "osname", err: errors.New(`ent: missing required field "Bouncer.osname"`)} + } return nil } diff --git a/pkg/database/ent/bouncer_update.go b/pkg/database/ent/bouncer_update.go index 620b006a49a..296de711762 100644 --- a/pkg/database/ent/bouncer_update.go +++ b/pkg/database/ent/bouncer_update.go @@ -170,12 +170,6 @@ func (bu *BouncerUpdate) SetNillableOsname(s *string) *BouncerUpdate { return bu } -// ClearOsname clears the value of the "osname" field. -func (bu *BouncerUpdate) ClearOsname() *BouncerUpdate { - bu.mutation.ClearOsname() - return bu -} - // SetOsversion sets the "osversion" field. func (bu *BouncerUpdate) SetOsversion(s string) *BouncerUpdate { bu.mutation.SetOsversion(s) @@ -305,9 +299,6 @@ func (bu *BouncerUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := bu.mutation.Osname(); ok { _spec.SetField(bouncer.FieldOsname, field.TypeString, value) } - if bu.mutation.OsnameCleared() { - _spec.ClearField(bouncer.FieldOsname, field.TypeString) - } if value, ok := bu.mutation.Osversion(); ok { _spec.SetField(bouncer.FieldOsversion, field.TypeString, value) } @@ -482,12 +473,6 @@ func (buo *BouncerUpdateOne) SetNillableOsname(s *string) *BouncerUpdateOne { return buo } -// ClearOsname clears the value of the "osname" field. -func (buo *BouncerUpdateOne) ClearOsname() *BouncerUpdateOne { - buo.mutation.ClearOsname() - return buo -} - // SetOsversion sets the "osversion" field. func (buo *BouncerUpdateOne) SetOsversion(s string) *BouncerUpdateOne { buo.mutation.SetOsversion(s) @@ -647,9 +632,6 @@ func (buo *BouncerUpdateOne) sqlSave(ctx context.Context) (_node *Bouncer, err e if value, ok := buo.mutation.Osname(); ok { _spec.SetField(bouncer.FieldOsname, field.TypeString, value) } - if buo.mutation.OsnameCleared() { - _spec.ClearField(bouncer.FieldOsname, field.TypeString) - } if value, ok := buo.mutation.Osversion(); ok { _spec.SetField(bouncer.FieldOsversion, field.TypeString, value) } diff --git a/pkg/database/ent/migrate/schema.go b/pkg/database/ent/migrate/schema.go index 986f5bc8c67..aeffdd5e10e 100644 --- a/pkg/database/ent/migrate/schema.go +++ b/pkg/database/ent/migrate/schema.go @@ -71,7 +71,7 @@ var ( {Name: "version", Type: field.TypeString, Nullable: true}, {Name: "last_pull", Type: field.TypeTime, Nullable: true}, {Name: "auth_type", Type: field.TypeString, Default: "api-key"}, - {Name: "osname", Type: field.TypeString, Nullable: true}, + {Name: "osname", Type: field.TypeString}, {Name: "osversion", Type: field.TypeString, Nullable: true}, {Name: "featureflags", Type: field.TypeString, Nullable: true}, } diff --git a/pkg/database/ent/mutation.go b/pkg/database/ent/mutation.go index 5c6596f3db4..fe2d0aa51c4 100644 --- a/pkg/database/ent/mutation.go +++ b/pkg/database/ent/mutation.go @@ -3018,22 +3018,9 @@ func (m *BouncerMutation) OldOsname(ctx context.Context) (v string, err error) { return oldValue.Osname, nil } -// ClearOsname clears the value of the "osname" field. -func (m *BouncerMutation) ClearOsname() { - m.osname = nil - m.clearedFields[bouncer.FieldOsname] = struct{}{} -} - -// OsnameCleared returns if the "osname" field was cleared in this mutation. -func (m *BouncerMutation) OsnameCleared() bool { - _, ok := m.clearedFields[bouncer.FieldOsname] - return ok -} - // ResetOsname resets all changes to the "osname" field. func (m *BouncerMutation) ResetOsname() { m.osname = nil - delete(m.clearedFields, bouncer.FieldOsname) } // SetOsversion sets the "osversion" field. @@ -3419,9 +3406,6 @@ func (m *BouncerMutation) ClearedFields() []string { if m.FieldCleared(bouncer.FieldLastPull) { fields = append(fields, bouncer.FieldLastPull) } - if m.FieldCleared(bouncer.FieldOsname) { - fields = append(fields, bouncer.FieldOsname) - } if m.FieldCleared(bouncer.FieldOsversion) { fields = append(fields, bouncer.FieldOsversion) } @@ -3454,9 +3438,6 @@ func (m *BouncerMutation) ClearField(name string) error { case bouncer.FieldLastPull: m.ClearLastPull() return nil - case bouncer.FieldOsname: - m.ClearOsname() - return nil case bouncer.FieldOsversion: m.ClearOsversion() return nil diff --git a/pkg/database/ent/schema/bouncer.go b/pkg/database/ent/schema/bouncer.go index 599c4c404fc..4991d5371d1 100644 --- a/pkg/database/ent/schema/bouncer.go +++ b/pkg/database/ent/schema/bouncer.go @@ -30,7 +30,7 @@ func (Bouncer) Fields() []ent.Field { field.String("version").Optional().StructTag(`json:"version"`), field.Time("last_pull").Nillable().Optional().StructTag(`json:"last_pull"`), field.String("auth_type").StructTag(`json:"auth_type"`).Default(types.ApiKeyAuthType), - field.String("osname").Optional(), + field.String("osname"), field.String("osversion").Optional(), field.String("featureflags").Optional(), } diff --git a/pkg/modelscapi/success_response.go b/pkg/modelscapi/success_response.go index a5599bb8714..e3dd53cb1e0 100644 --- a/pkg/modelscapi/success_response.go +++ b/pkg/modelscapi/success_response.go @@ -5,6 +5,9 @@ package modelscapi // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command + +// blah blah blah + import ( "context"