From 9a84b09b7bb0a2625a8c038b9ba6773d3ceaeda7 Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Fri, 14 Jun 2024 14:53:22 -0700 Subject: [PATCH] Add node version status. Default: pending (#33) * Add node version status. Default: pending * Return status in mapper. * Fixed mapper. --- drip/api.gen.go | 164 ++++++++++-------- .../migrations/20240614213347_migration.sql | 2 + ent/migrate/migrations/atlas.sum | 3 +- ent/migrate/schema.go | 7 +- ent/mutation.go | 56 +++++- ent/nodeversion.go | 14 +- ent/nodeversion/nodeversion.go | 22 +++ ent/nodeversion/where.go | 31 ++++ ent/nodeversion_create.go | 71 ++++++++ ent/nodeversion_update.go | 45 +++++ ent/schema/node_version.go | 21 +++ go.sum | 8 + .../registry_integration_test.go | 8 +- mapper/node_version.go | 22 +++ openapi.yml | 12 +- 15 files changed, 402 insertions(+), 84 deletions(-) create mode 100644 ent/migrate/migrations/20240614213347_migration.sql diff --git a/drip/api.gen.go b/drip/api.gen.go index 1901c68..af66009 100644 --- a/drip/api.gen.go +++ b/drip/api.gen.go @@ -32,7 +32,14 @@ const ( NodeStatusActive NodeStatus = "NodeStatusActive" NodeStatusBanned NodeStatus = "NodeStatusBanned" NodeStatusDeleted NodeStatus = "NodeStatusDeleted" - NodeStatusPending NodeStatus = "NodeStatusPending" +) + +// Defines values for NodeVersionStatus. +const ( + NodeVersionStatusActive NodeVersionStatus = "NodeVersionStatusActive" + NodeVersionStatusBanned NodeVersionStatus = "NodeVersionStatusBanned" + NodeVersionStatusDeleted NodeVersionStatus = "NodeVersionStatusDeleted" + NodeVersionStatusPending NodeVersionStatus = "NodeVersionStatusPending" ) // ActionJobResult defines model for ActionJobResult. @@ -142,13 +149,17 @@ type NodeVersion struct { Deprecated *bool `json:"deprecated,omitempty"` // DownloadUrl [Output Only] URL to download this version of the node - DownloadUrl *string `json:"downloadUrl,omitempty"` - Id *string `json:"id,omitempty"` + DownloadUrl *string `json:"downloadUrl,omitempty"` + Id *string `json:"id,omitempty"` + Status *NodeVersionStatus `json:"status,omitempty"` // Version The version identifier, following semantic versioning. Must be unique for the node. Version *string `json:"version,omitempty"` } +// NodeVersionStatus defines model for NodeVersionStatus. +type NodeVersionStatus string + // NodeVersionUpdateRequest defines model for NodeVersionUpdateRequest. type NodeVersionUpdateRequest struct { // Changelog The changelog describing the version changes. @@ -3658,79 +3669,80 @@ func (sh *strictHandler) ListPublishersForUser(ctx echo.Context) error { // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "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",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- "QgOo28d09RDzPHY4reE+J30GOMzTRZE5Fb7O6X5xMEPhPcrJOsS/7rNRNYSYdj7voFUH3/TfbjvptiwY", - "wr6v7e/mg1ZmAn/whDAzCd9ZRtg9WcesWbzAXJIxjmX7sWXXuvCJK7uptS1zx8Ww8bK2UR5/BTlccaWR", - "PZfGFEbzKXBzWx8z1wza+1a4uecqfDW5vvdhmLKJGE5i0XAHl389sb0ZAqlP+ggmfTQRx4OB6cML1a2B", - "etVymf4Ui2lw0F1u7rd3irgy97my379n3VZnd1ybs2/Uu8/R77///vuLd+9evHnz8ddfj9+9O766+tfn", - "CD37+ejl3168PHrx8ujj0dGx/u9fz4P9yBPcfHX8aZ5g//TO2udAk5YxgLuccSP3xX9ho+Had/IHL98X", - "Ha/bdzPO8+B9wgbA+v76EpfBqxUVATESoNSViSNzc8ErLq7sEOjs9Erj95l4riDss0cDhE2RXtOLn4M3", - "D9pLFev3OJmrqZE9kKH+YU7XnP6GaRMS8zbk6/cbxI27L6ijnHLFg+awv7auZ7KAZTFBGl+9aJLlQ/19", - "VaJUOb8mTXoVmbvc98rcecx3v5X7h4S+Wm/3X+kz+Pl4iEMM5BbM8rxTd9VTp1sONOfliZAPuJlG96Bo", - "XKBnPvM9R2POZuZaKKtWzoj8NR8hc8mPyT3LRduRWGcg9U2Kj7gCYW/1rE32+3+su++3fgj82/XX685A", - "Bs5p09oMp6k7SaTvTZ7vLXQ8W+wt45uY1sMRY7t+xFgloJuLlliuxqiq3niE+hJUfaOl0pE4I31tS/YZ", - "n0R3N3f/DQAA//9WtbW7rIoAAA==", + "H4sIAAAAAAAC/+xd/3PbuLH/VzB8nblkniI717z+4N8c5+Jze3E8cZzO9eKngciVhIQEeABoV834f+/g", + "GwmKIEXZsiwlmuk0PgEEFtjdzy4WC+BbFLMsZxSoFNHRt0jEM8iw/vM4loTRv7PxBxBFKtVPOWc5cElA", + "V8C6wogXdEQS9UMCIuYkV79GR9FZAlSSCQGO2ATJGSBeUCRnRCCuW0RjSB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53mqhIowevBFGDek6rKug26eHha+uFv0e6JjinRt", + "ZYTKPu4G0avDVyHG5QxRJtGEFTRR1f7PDGpRV6Ryd1IkgN8ANxFUI7omRGFkgBO4AS0ECRGS0Fi2S4P+", + "+mBKpN3W6SNavKBigL6wsfl/u98gBtqL9FFWICwEi4nyH9EtkbOya9NbUBRPS1p6SOPiHpeWTJDxTLm1", + "WI22TTxN/bMk8qWxgRKhPtnilkilDYqQkzPTd7tmlA1cmk2XlSmggY2FlalwH54bFV2RBCNQjohSflam", + "YuyAZ8X+cyVjNj4umVo9aalv6yY3HkQAd142Y+gtk14G4zVMqF4JjdMi0es6TVBX75fkP20UHPYlYSXs", + "bfD1yaH2i9twr4Ntl7O9uFMfWANJJnF6rpnzfnKBp+AjuDehvSDbFCI1QEyo0vH+YNeK7iZisW58d7rl", + "I7oFTo3plCVmKrrxXAkuoRqh3cpVf4lwzJkwgF8umkQTsX8jQh6n6bnubQliX3hK68Vjhe75cTT3vOzN", + "9GSwouC0VNqWflNiTNC9FfbePVtUGY1dLLUBjVWEcb0KasbckJV3+N8kKzKPc2ZE3jia25Cl+PXSc72z", + "GlDuPLjBfFJwDlT6RiBIg4aGwCpB/dwYDb7BJMXjFNqbKtGluz1FVnd7vdCoTTMNzgTh4wanJEGE5oUc", + "OCwj5tdWdDoPwFJv+eniaX3PPjDCVeBOIVV9Ftyuo9m6ENF1hXoHAjDvs056KPhd6n722LfY8z9gfst4", + "ono0rKjG29Kl5dhKfuAeYfcIu0fYp0HYb+qfs+RuKcYqxbd5a6pljEQOMZmQuNy5bkQAzs0e/QKcakXW", + "YeNSjw0NnfGlda9olqtYkwvqdzcHRkj+ujkReMv4mCQJUE88N9OzHjbdCdlfFEs0nqOzN70U4IBQIXGa", + "dimC1S9nA6t1m/1Wj3+AgJQ5BiZzDumlXUmZDRU3debMNBPWm3sk8q1H1Rr2+nJhIH63tSAOOpsglhEp", + "IRn40+FlXrjt8rYISJWT5ZliLJVIREfR/3/+nPzv589D75+/PEL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VdWQbfpqGXjdkdSHl19Bo+XsBBMrdaptW2B", + "mH2e7W5Ff+opTEHT0L4w3zHRfkoTs6Gc9+9sNb9Hk90KISxDkxUMa/+AwvdoYPeBiRUCE4yjHcjsWwhQ", + "/CSQRfIVdCIHrrczu9JbT0FelNXe19VE7KqePGSnPMb0l4TIYASk15nFMunKm/191tUK20DexNUvM/Nv", + "0nhY+LkjCbzl0IT5etXc1132ZOtqQe3V+n1id6ruPS+VdzewjswNrKPy7tbuxwGsA1HruK2x66AWrzfo", + "05y7e86HIFMK4bu19VsbuthdrF3k9lptWDxIZDOgll+y13Q34bZsx0nzTsSk9ol6/bxxi2w20nWvDOl+", + "4Lp4vmB5HGynkDbc0LoOHwQ8/0/unR5a6eUzG2p7/rSxtk+hEwIbOaDw6cnPJgQoWGlx7LjpePn8HgcY", + "yjDcwtLPLLwZTc0rEtVt/Jgm3l35yLyqsHAdRKPvZk5tFef7sVX3cUKHwRcYniCc2HF0qcSkHQgsDvch", + "km3DzvUFF8PQpkbnY9vCufNVHZ2HxFe2Ogd2HxH54SIieo245Kxj82kcsdVi3O9IZeDBnxXzj4LPxvxY", + "N0nZMe+u3aif+Qwy1GpbSM+02KB3mOIpZGq8S0+FBqRuF9PVQ8rz2OG0lvec9B3gcJvOy8yp8HNO94uD", + "GQ7vUE7WPv51n4OqIYnp1vMeVvXgm/6330m6DQNDeO1r6V1/0MpM4A+eEGYm4TvLCLun6pg9ixeYSzLB", + "sey+tuxKVz52dde1t2XeuBi1PtY2LuKvIEdLnjSy99KYyuh2Bty81sfMM4P2vRVu3rkKP62u330YpWwq", + "RtNYtLzB5T+vbF+GQOqTIYLpEE3F0cGBoeGFIutAFbX0lRE5mmExCw7alrc+Iv6xetPF1Wnvpf21eP+d", + "eNucPXFt7r5RZZ+j33///fcX7969ePPm46+/Hr17d3R5+a/PEXr28+HLv714efji5eHHw8Mj/b9/PQ/S", + "USS4/en7kyLB/u2djc+BJh1jAPc441reu//CxqPVHk77wsYholnwIfqFt3EKoS8a0u3wIvhGshFg/f5+", + "JZfBpxUVAzESoMyViSNz88ArLp/sEOj05FLL7zPxXImwrx4tImyqDNoKfg6+PGgfVWy+42Se1kb2Qobm", + "hwVdcfpbpk1IzLskX5evUW7ce0E9ccpVD7rD/t66nslSLMsJ0vI1iKZ5MdLf1xGlrvkNNBnUMHeR9trc", + "ecp3v537h4S+PPS7x5rBz8dDHGIgN2C25525q9863XGhOa9uhHzAyzSagrJzgZ75yvccTTjLzLNQ1qyc", + "EvlrMUbmkR+Te1aIriuxTkHqlxQfcQfCvurZmOz3/1j13G/zEvi3q+/XnYIM3NOmrRlOU3eTyNCbPH+1", + "0PNusbeMr2Na91eMbfsVY7WAbiE6YrlaRlXzZkWoH0HVL1oqG4lzMtS+5JDxaXR3ffffAAAA//8aYjp6", + "bIsAAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/ent/migrate/migrations/20240614213347_migration.sql b/ent/migrate/migrations/20240614213347_migration.sql new file mode 100644 index 0000000..6920c11 --- /dev/null +++ b/ent/migrate/migrations/20240614213347_migration.sql @@ -0,0 +1,2 @@ +-- Modify "node_versions" table +ALTER TABLE "node_versions" ADD COLUMN "status" character varying NOT NULL DEFAULT 'pending'; diff --git a/ent/migrate/migrations/atlas.sum b/ent/migrate/migrations/atlas.sum index 96acbb8..6347a98 100644 --- a/ent/migrate/migrations/atlas.sum +++ b/ent/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:HOhe9nKwVDDwOgQNHByRPwIhEXJIKUqu/ZHpuXneY2c= +h1:gL4eSCEPcCC44jC0UQwTOwebM7CLl21L4lD+ZPuN/js= 20240526144817_migration.sql h1:sP6keX+oMyLL2qpIFx0Ns0WYfWM5hJ4zkFPmLWT68fM= 20240528220411_migration.sql h1:SR44sOEaWbDgYCKJZIKcGCI7Ta+LqL71z225Nhs2+HM= 20240528221846_migration.sql h1:EkUonGI9Bu689qWX4pG3PRC+On4f6u7UvwDbaR8mCNk= @@ -7,3 +7,4 @@ h1:HOhe9nKwVDDwOgQNHByRPwIhEXJIKUqu/ZHpuXneY2c= 20240613231838_migration.sql h1:fbgEWDDA7hcQP5gdX6WDpPWG+340dT40CgkwIG7KGxw= 20240614133606_migration.sql h1:ydCsnRUhSVP0WY7ey7DNHcNQnABPuOt7Z/b0mj7+s6M= 20240614211957_migration.sql h1:qUD4bs8JikDO/0TLD91fhkHzyesdyn2yKqmwkBcWVMc= +20240614213347_migration.sql h1:iz6Lzy1OdtArw2xgRICa0Kktj+BmBji0JUbi+k5WlU8= diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index b149649..3cb2a2a 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -145,6 +145,7 @@ var ( {Name: "changelog", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, {Name: "pip_dependencies", Type: field.TypeJSON, SchemaType: map[string]string{"postgres": "text"}}, {Name: "deprecated", Type: field.TypeBool, Default: false}, + {Name: "status", Type: field.TypeEnum, Enums: []string{"active", "banned", "deleted", "pending"}, Default: "pending"}, {Name: "node_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}}, {Name: "node_version_storage_file", Type: field.TypeUUID, Nullable: true}, } @@ -156,13 +157,13 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_versions_nodes_versions", - Columns: []*schema.Column{NodeVersionsColumns[7]}, + Columns: []*schema.Column{NodeVersionsColumns[8]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "node_versions_storage_files_storage_file", - Columns: []*schema.Column{NodeVersionsColumns[8]}, + Columns: []*schema.Column{NodeVersionsColumns[9]}, RefColumns: []*schema.Column{StorageFilesColumns[0]}, OnDelete: schema.SetNull, }, @@ -171,7 +172,7 @@ var ( { Name: "nodeversion_node_id_version", Unique: true, - Columns: []*schema.Column{NodeVersionsColumns[7], NodeVersionsColumns[3]}, + Columns: []*schema.Column{NodeVersionsColumns[8], NodeVersionsColumns[3]}, }, }, } diff --git a/ent/mutation.go b/ent/mutation.go index f352d71..a908a9a 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -4119,6 +4119,7 @@ type NodeVersionMutation struct { pip_dependencies *[]string appendpip_dependencies []string deprecated *bool + status *schema.NodeVersionStatus clearedFields map[string]struct{} node *string clearednode bool @@ -4513,6 +4514,42 @@ func (m *NodeVersionMutation) ResetDeprecated() { m.deprecated = nil } +// SetStatus sets the "status" field. +func (m *NodeVersionMutation) SetStatus(svs schema.NodeVersionStatus) { + m.status = &svs +} + +// Status returns the value of the "status" field in the mutation. +func (m *NodeVersionMutation) Status() (r schema.NodeVersionStatus, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the NodeVersion entity. +// If the NodeVersion object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NodeVersionMutation) OldStatus(ctx context.Context) (v schema.NodeVersionStatus, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// ResetStatus resets all changes to the "status" field. +func (m *NodeVersionMutation) ResetStatus() { + m.status = nil +} + // ClearNode clears the "node" edge to the Node entity. func (m *NodeVersionMutation) ClearNode() { m.clearednode = true @@ -4613,7 +4650,7 @@ func (m *NodeVersionMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *NodeVersionMutation) Fields() []string { - fields := make([]string, 0, 7) + fields := make([]string, 0, 8) if m.create_time != nil { fields = append(fields, nodeversion.FieldCreateTime) } @@ -4635,6 +4672,9 @@ func (m *NodeVersionMutation) Fields() []string { if m.deprecated != nil { fields = append(fields, nodeversion.FieldDeprecated) } + if m.status != nil { + fields = append(fields, nodeversion.FieldStatus) + } return fields } @@ -4657,6 +4697,8 @@ func (m *NodeVersionMutation) Field(name string) (ent.Value, bool) { return m.PipDependencies() case nodeversion.FieldDeprecated: return m.Deprecated() + case nodeversion.FieldStatus: + return m.Status() } return nil, false } @@ -4680,6 +4722,8 @@ func (m *NodeVersionMutation) OldField(ctx context.Context, name string) (ent.Va return m.OldPipDependencies(ctx) case nodeversion.FieldDeprecated: return m.OldDeprecated(ctx) + case nodeversion.FieldStatus: + return m.OldStatus(ctx) } return nil, fmt.Errorf("unknown NodeVersion field %s", name) } @@ -4738,6 +4782,13 @@ func (m *NodeVersionMutation) SetField(name string, value ent.Value) error { } m.SetDeprecated(v) return nil + case nodeversion.FieldStatus: + v, ok := value.(schema.NodeVersionStatus) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil } return fmt.Errorf("unknown NodeVersion field %s", name) } @@ -4817,6 +4868,9 @@ func (m *NodeVersionMutation) ResetField(name string) error { case nodeversion.FieldDeprecated: m.ResetDeprecated() return nil + case nodeversion.FieldStatus: + m.ResetStatus() + return nil } return fmt.Errorf("unknown NodeVersion field %s", name) } diff --git a/ent/nodeversion.go b/ent/nodeversion.go index 0222910..16574e5 100644 --- a/ent/nodeversion.go +++ b/ent/nodeversion.go @@ -7,6 +7,7 @@ import ( "fmt" "registry-backend/ent/node" "registry-backend/ent/nodeversion" + "registry-backend/ent/schema" "registry-backend/ent/storagefile" "strings" "time" @@ -35,6 +36,8 @@ type NodeVersion struct { PipDependencies []string `json:"pip_dependencies,omitempty"` // Deprecated holds the value of the "deprecated" field. Deprecated bool `json:"deprecated,omitempty"` + // Status holds the value of the "status" field. + Status schema.NodeVersionStatus `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the NodeVersionQuery when eager-loading is set. Edges NodeVersionEdges `json:"edges"` @@ -84,7 +87,7 @@ func (*NodeVersion) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case nodeversion.FieldDeprecated: values[i] = new(sql.NullBool) - case nodeversion.FieldNodeID, nodeversion.FieldVersion, nodeversion.FieldChangelog: + case nodeversion.FieldNodeID, nodeversion.FieldVersion, nodeversion.FieldChangelog, nodeversion.FieldStatus: values[i] = new(sql.NullString) case nodeversion.FieldCreateTime, nodeversion.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -157,6 +160,12 @@ func (nv *NodeVersion) assignValues(columns []string, values []any) error { } else if value.Valid { nv.Deprecated = value.Bool } + case nodeversion.FieldStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + nv.Status = schema.NodeVersionStatus(value.String) + } case nodeversion.ForeignKeys[0]: if value, ok := values[i].(*sql.NullScanner); !ok { return fmt.Errorf("unexpected type %T for field node_version_storage_file", values[i]) @@ -230,6 +239,9 @@ func (nv *NodeVersion) String() string { builder.WriteString(", ") builder.WriteString("deprecated=") builder.WriteString(fmt.Sprintf("%v", nv.Deprecated)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", nv.Status)) builder.WriteByte(')') return builder.String() } diff --git a/ent/nodeversion/nodeversion.go b/ent/nodeversion/nodeversion.go index 3507958..cdca0b7 100644 --- a/ent/nodeversion/nodeversion.go +++ b/ent/nodeversion/nodeversion.go @@ -3,6 +3,8 @@ package nodeversion import ( + "fmt" + "registry-backend/ent/schema" "time" "entgo.io/ent/dialect/sql" @@ -29,6 +31,8 @@ const ( FieldPipDependencies = "pip_dependencies" // FieldDeprecated holds the string denoting the deprecated field in the database. FieldDeprecated = "deprecated" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" // EdgeNode holds the string denoting the node edge name in mutations. EdgeNode = "node" // EdgeStorageFile holds the string denoting the storage_file edge name in mutations. @@ -61,6 +65,7 @@ var Columns = []string{ FieldChangelog, FieldPipDependencies, FieldDeprecated, + FieldStatus, } // ForeignKeys holds the SQL foreign-keys that are owned by the "node_versions" @@ -97,6 +102,18 @@ var ( DefaultID func() uuid.UUID ) +const DefaultStatus schema.NodeVersionStatus = "pending" + +// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. +func StatusValidator(s schema.NodeVersionStatus) error { + switch s { + case "active", "banned", "deleted", "pending": + return nil + default: + return fmt.Errorf("nodeversion: invalid enum value for status field: %q", s) + } +} + // OrderOption defines the ordering options for the NodeVersion queries. type OrderOption func(*sql.Selector) @@ -135,6 +152,11 @@ func ByDeprecated(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDeprecated, opts...).ToFunc() } +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + // ByNodeField orders the results by node field. func ByNodeField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/ent/nodeversion/where.go b/ent/nodeversion/where.go index 683c2eb..0fe9323 100644 --- a/ent/nodeversion/where.go +++ b/ent/nodeversion/where.go @@ -4,6 +4,7 @@ package nodeversion import ( "registry-backend/ent/predicate" + "registry-backend/ent/schema" "time" "entgo.io/ent/dialect/sql" @@ -381,6 +382,36 @@ func DeprecatedNEQ(v bool) predicate.NodeVersion { return predicate.NodeVersion(sql.FieldNEQ(FieldDeprecated, v)) } +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v schema.NodeVersionStatus) predicate.NodeVersion { + vc := v + return predicate.NodeVersion(sql.FieldEQ(FieldStatus, vc)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v schema.NodeVersionStatus) predicate.NodeVersion { + vc := v + return predicate.NodeVersion(sql.FieldNEQ(FieldStatus, vc)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...schema.NodeVersionStatus) predicate.NodeVersion { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.NodeVersion(sql.FieldIn(FieldStatus, v...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...schema.NodeVersionStatus) predicate.NodeVersion { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.NodeVersion(sql.FieldNotIn(FieldStatus, v...)) +} + // HasNode applies the HasEdge predicate on the "node" edge. func HasNode() predicate.NodeVersion { return predicate.NodeVersion(func(s *sql.Selector) { diff --git a/ent/nodeversion_create.go b/ent/nodeversion_create.go index 611fe2e..fcc0b35 100644 --- a/ent/nodeversion_create.go +++ b/ent/nodeversion_create.go @@ -8,6 +8,7 @@ import ( "fmt" "registry-backend/ent/node" "registry-backend/ent/nodeversion" + "registry-backend/ent/schema" "registry-backend/ent/storagefile" "time" @@ -100,6 +101,20 @@ func (nvc *NodeVersionCreate) SetNillableDeprecated(b *bool) *NodeVersionCreate return nvc } +// SetStatus sets the "status" field. +func (nvc *NodeVersionCreate) SetStatus(svs schema.NodeVersionStatus) *NodeVersionCreate { + nvc.mutation.SetStatus(svs) + return nvc +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (nvc *NodeVersionCreate) SetNillableStatus(svs *schema.NodeVersionStatus) *NodeVersionCreate { + if svs != nil { + nvc.SetStatus(*svs) + } + return nvc +} + // SetID sets the "id" field. func (nvc *NodeVersionCreate) SetID(u uuid.UUID) *NodeVersionCreate { nvc.mutation.SetID(u) @@ -185,6 +200,10 @@ func (nvc *NodeVersionCreate) defaults() { v := nodeversion.DefaultDeprecated nvc.mutation.SetDeprecated(v) } + if _, ok := nvc.mutation.Status(); !ok { + v := nodeversion.DefaultStatus + nvc.mutation.SetStatus(v) + } if _, ok := nvc.mutation.ID(); !ok { v := nodeversion.DefaultID() nvc.mutation.SetID(v) @@ -211,6 +230,14 @@ func (nvc *NodeVersionCreate) check() error { if _, ok := nvc.mutation.Deprecated(); !ok { return &ValidationError{Name: "deprecated", err: errors.New(`ent: missing required field "NodeVersion.deprecated"`)} } + if _, ok := nvc.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "NodeVersion.status"`)} + } + if v, ok := nvc.mutation.Status(); ok { + if err := nodeversion.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "NodeVersion.status": %w`, err)} + } + } if _, ok := nvc.mutation.NodeID(); !ok { return &ValidationError{Name: "node", err: errors.New(`ent: missing required edge "NodeVersion.node"`)} } @@ -274,6 +301,10 @@ func (nvc *NodeVersionCreate) createSpec() (*NodeVersion, *sqlgraph.CreateSpec) _spec.SetField(nodeversion.FieldDeprecated, field.TypeBool, value) _node.Deprecated = value } + if value, ok := nvc.mutation.Status(); ok { + _spec.SetField(nodeversion.FieldStatus, field.TypeEnum, value) + _node.Status = value + } if nodes := nvc.mutation.NodeIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -438,6 +469,18 @@ func (u *NodeVersionUpsert) UpdateDeprecated() *NodeVersionUpsert { return u } +// SetStatus sets the "status" field. +func (u *NodeVersionUpsert) SetStatus(v schema.NodeVersionStatus) *NodeVersionUpsert { + u.Set(nodeversion.FieldStatus, v) + return u +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *NodeVersionUpsert) UpdateStatus() *NodeVersionUpsert { + u.SetExcluded(nodeversion.FieldStatus) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -580,6 +623,20 @@ func (u *NodeVersionUpsertOne) UpdateDeprecated() *NodeVersionUpsertOne { }) } +// SetStatus sets the "status" field. +func (u *NodeVersionUpsertOne) SetStatus(v schema.NodeVersionStatus) *NodeVersionUpsertOne { + return u.Update(func(s *NodeVersionUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *NodeVersionUpsertOne) UpdateStatus() *NodeVersionUpsertOne { + return u.Update(func(s *NodeVersionUpsert) { + s.UpdateStatus() + }) +} + // Exec executes the query. func (u *NodeVersionUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -889,6 +946,20 @@ func (u *NodeVersionUpsertBulk) UpdateDeprecated() *NodeVersionUpsertBulk { }) } +// SetStatus sets the "status" field. +func (u *NodeVersionUpsertBulk) SetStatus(v schema.NodeVersionStatus) *NodeVersionUpsertBulk { + return u.Update(func(s *NodeVersionUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *NodeVersionUpsertBulk) UpdateStatus() *NodeVersionUpsertBulk { + return u.Update(func(s *NodeVersionUpsert) { + s.UpdateStatus() + }) +} + // Exec executes the query. func (u *NodeVersionUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/ent/nodeversion_update.go b/ent/nodeversion_update.go index 65dd779..dc37ae5 100644 --- a/ent/nodeversion_update.go +++ b/ent/nodeversion_update.go @@ -9,6 +9,7 @@ import ( "registry-backend/ent/node" "registry-backend/ent/nodeversion" "registry-backend/ent/predicate" + "registry-backend/ent/schema" "registry-backend/ent/storagefile" "time" @@ -112,6 +113,20 @@ func (nvu *NodeVersionUpdate) SetNillableDeprecated(b *bool) *NodeVersionUpdate return nvu } +// SetStatus sets the "status" field. +func (nvu *NodeVersionUpdate) SetStatus(svs schema.NodeVersionStatus) *NodeVersionUpdate { + nvu.mutation.SetStatus(svs) + return nvu +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (nvu *NodeVersionUpdate) SetNillableStatus(svs *schema.NodeVersionStatus) *NodeVersionUpdate { + if svs != nil { + nvu.SetStatus(*svs) + } + return nvu +} + // SetNode sets the "node" edge to the Node entity. func (nvu *NodeVersionUpdate) SetNode(n *Node) *NodeVersionUpdate { return nvu.SetNodeID(n.ID) @@ -191,6 +206,11 @@ func (nvu *NodeVersionUpdate) defaults() { // check runs all checks and user-defined validators on the builder. func (nvu *NodeVersionUpdate) check() error { + if v, ok := nvu.mutation.Status(); ok { + if err := nodeversion.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "NodeVersion.status": %w`, err)} + } + } if _, ok := nvu.mutation.NodeID(); nvu.mutation.NodeCleared() && !ok { return errors.New(`ent: clearing a required unique edge "NodeVersion.node"`) } @@ -232,6 +252,9 @@ func (nvu *NodeVersionUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := nvu.mutation.Deprecated(); ok { _spec.SetField(nodeversion.FieldDeprecated, field.TypeBool, value) } + if value, ok := nvu.mutation.Status(); ok { + _spec.SetField(nodeversion.FieldStatus, field.TypeEnum, value) + } if nvu.mutation.NodeCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -390,6 +413,20 @@ func (nvuo *NodeVersionUpdateOne) SetNillableDeprecated(b *bool) *NodeVersionUpd return nvuo } +// SetStatus sets the "status" field. +func (nvuo *NodeVersionUpdateOne) SetStatus(svs schema.NodeVersionStatus) *NodeVersionUpdateOne { + nvuo.mutation.SetStatus(svs) + return nvuo +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (nvuo *NodeVersionUpdateOne) SetNillableStatus(svs *schema.NodeVersionStatus) *NodeVersionUpdateOne { + if svs != nil { + nvuo.SetStatus(*svs) + } + return nvuo +} + // SetNode sets the "node" edge to the Node entity. func (nvuo *NodeVersionUpdateOne) SetNode(n *Node) *NodeVersionUpdateOne { return nvuo.SetNodeID(n.ID) @@ -482,6 +519,11 @@ func (nvuo *NodeVersionUpdateOne) defaults() { // check runs all checks and user-defined validators on the builder. func (nvuo *NodeVersionUpdateOne) check() error { + if v, ok := nvuo.mutation.Status(); ok { + if err := nodeversion.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "NodeVersion.status": %w`, err)} + } + } if _, ok := nvuo.mutation.NodeID(); nvuo.mutation.NodeCleared() && !ok { return errors.New(`ent: clearing a required unique edge "NodeVersion.node"`) } @@ -540,6 +582,9 @@ func (nvuo *NodeVersionUpdateOne) sqlSave(ctx context.Context) (_node *NodeVersi if value, ok := nvuo.mutation.Deprecated(); ok { _spec.SetField(nodeversion.FieldDeprecated, field.TypeBool, value) } + if value, ok := nvuo.mutation.Status(); ok { + _spec.SetField(nodeversion.FieldStatus, field.TypeEnum, value) + } if nvuo.mutation.NodeCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/ent/schema/node_version.go b/ent/schema/node_version.go index 26e95bd..2176fbb 100644 --- a/ent/schema/node_version.go +++ b/ent/schema/node_version.go @@ -32,6 +32,9 @@ func (NodeVersion) Fields() []ent.Field { dialect.Postgres: "text", }), field.Bool("deprecated").Default(false), + field.Enum("status"). + GoType(NodeVersionStatus("")). + Default(string(NodeVersionStatusPending)), } } @@ -53,3 +56,21 @@ func (NodeVersion) Indexes() []ent.Index { index.Fields("node_id", "version").Unique(), } } + +type NodeVersionStatus string + +const ( + NodeVersionStatusActive NodeVersionStatus = "active" + NodeVersionStatusDeleted NodeVersionStatus = "deleted" + NodeVersionStatusBanned NodeVersionStatus = "banned" + NodeVersionStatusPending NodeVersionStatus = "pending" +) + +func (NodeVersionStatus) Values() (types []string) { + return []string{ + string(NodeVersionStatusActive), + string(NodeVersionStatusBanned), + string(NodeVersionStatusDeleted), + string(NodeVersionStatusPending), + } +} diff --git a/go.sum b/go.sum index 94aceaa..d18389e 100644 --- a/go.sum +++ b/go.sum @@ -193,6 +193,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= @@ -213,6 +215,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= +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/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= @@ -241,6 +245,10 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +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/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/integration-tests/registry_integration_test.go b/integration-tests/registry_integration_test.go index 1616430..141c1bf 100644 --- a/integration-tests/registry_integration_test.go +++ b/integration-tests/registry_integration_test.go @@ -562,7 +562,9 @@ func TestRegistry(t *testing.T) { require.Equal(t, "test-url", *createNodeVersionResp.(drip.PublishNodeVersion201JSONResponse).SignedUrl, "should return signed url") require.Equal(t, dependencies, *createNodeVersionResp.(drip.PublishNodeVersion201JSONResponse).NodeVersion.Dependencies, "should return pip dependencies") require.Equal(t, changelog, *createNodeVersionResp.(drip.PublishNodeVersion201JSONResponse).NodeVersion.Changelog, "should return changelog") - createdNodeVersion = *createNodeVersionResp.(drip.PublishNodeVersion201JSONResponse).NodeVersion + versionStatus := drip.NodeVersionStatusPending + require.Equal(t, versionStatus, *createNodeVersionResp.(drip.PublishNodeVersion201JSONResponse).NodeVersion.Status, "should return pending status") + createdNodeVersion = *createNodeVersionResp.(drip.PublishNodeVersion201JSONResponse).NodeVersion // Needed for downstream tests. }) t.Run("Get not exist Node Version ", func(t *testing.T) { @@ -587,6 +589,7 @@ func TestRegistry(t *testing.T) { require.IsType(t, drip.ListNodeVersions200JSONResponse{}, resVersions, "should return 200") resVersions200 := resVersions.(drip.ListNodeVersions200JSONResponse) require.Len(t, resVersions200, 1, "should return only one version") + nodeVersionStatus := drip.NodeVersionStatusPending assert.Equal(t, drip.NodeVersion{ // generated attribute Id: resVersions200[0].Id, @@ -597,6 +600,7 @@ func TestRegistry(t *testing.T) { Changelog: &changelog, Dependencies: &dependencies, DownloadUrl: &downloadUrl, + Status: &nodeVersionStatus, }, resVersions200[0], "should be equal") }) @@ -619,6 +623,7 @@ func TestRegistry(t *testing.T) { require.IsType(t, drip.ListNodeVersions200JSONResponse{}, res, "should return 200") res200 := res.(drip.ListNodeVersions200JSONResponse) require.Len(t, res200, 1, "should return only one version") + status := drip.NodeVersionStatusPending updatedNodeVersion := drip.NodeVersion{ // generated attribute Id: res200[0].Id, @@ -629,6 +634,7 @@ func TestRegistry(t *testing.T) { Changelog: &updatedChangelog, Dependencies: &dependencies, DownloadUrl: &downloadUrl, + Status: &status, } assert.Equal(t, updatedNodeVersion, res200[0], "should be equal") createdNodeVersion = res200[0] diff --git a/mapper/node_version.go b/mapper/node_version.go index 6931453..978b6a3 100644 --- a/mapper/node_version.go +++ b/mapper/node_version.go @@ -4,6 +4,7 @@ import ( "fmt" "registry-backend/drip" "registry-backend/ent" + "registry-backend/ent/schema" "github.com/Masterminds/semver/v3" "github.com/google/uuid" @@ -60,6 +61,7 @@ func DbNodeVersionToApiNodeVersion(dbNodeVersion *ent.NodeVersion) *drip.NodeVer Deprecated: &dbNodeVersion.Deprecated, Dependencies: &dbNodeVersion.PipDependencies, CreatedAt: &dbNodeVersion.CreateTime, + Status: DbNodeVersionStatusToApiNodeVersionStatus(dbNodeVersion.Status), } } @@ -71,6 +73,7 @@ func DbNodeVersionToApiNodeVersion(dbNodeVersion *ent.NodeVersion) *drip.NodeVer Deprecated: &dbNodeVersion.Deprecated, Dependencies: &dbNodeVersion.PipDependencies, CreatedAt: &dbNodeVersion.CreateTime, + Status: DbNodeVersionStatusToApiNodeVersionStatus(dbNodeVersion.Status), } } @@ -78,3 +81,22 @@ func CheckValidSemv(version string) bool { _, err := semver.NewVersion(version) return err == nil } + +func DbNodeVersionStatusToApiNodeVersionStatus(status schema.NodeVersionStatus) *drip.NodeVersionStatus { + var nodeVersionStatus drip.NodeVersionStatus + + switch status { + case schema.NodeVersionStatusActive: + nodeVersionStatus = drip.NodeVersionStatusActive + case schema.NodeVersionStatusBanned: + nodeVersionStatus = drip.NodeVersionStatusBanned + case schema.NodeVersionStatusDeleted: + nodeVersionStatus = drip.NodeVersionStatusDeleted + case schema.NodeVersionStatusPending: + nodeVersionStatus = drip.NodeVersionStatusPending + default: + nodeVersionStatus = "" + } + + return &nodeVersionStatus +} diff --git a/openapi.yml b/openapi.yml index 25b12df..860889e 100644 --- a/openapi.yml +++ b/openapi.yml @@ -1676,6 +1676,9 @@ components: deprecated: type: boolean description: Indicates if this version is deprecated. + status: + $ref: "#/components/schemas/NodeVersionStatus" + description: The status of the node version. Error: type: object properties: @@ -1704,7 +1707,14 @@ components: - NodeStatusActive - NodeStatusDeleted - NodeStatusBanned - - NodeStatusPending + # Enum of Node Version Status + NodeVersionStatus: + type: string + enum: + - NodeVersionStatusActive + - NodeVersionStatusDeleted + - NodeVersionStatusBanned + - NodeVersionStatusPending securitySchemes: BearerAuth: