Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default node status active instead of pending. #32

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ent/migrate/migrations/20240614211957_migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "nodes" table
ALTER TABLE "nodes" ALTER COLUMN "status" SET DEFAULT 'active';
3 changes: 2 additions & 1 deletion ent/migrate/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
h1:qX0QvAnzEKgoQA76EtW//i99EEYfNXMQXZioom70Jts=
h1:HOhe9nKwVDDwOgQNHByRPwIhEXJIKUqu/ZHpuXneY2c=
20240526144817_migration.sql h1:sP6keX+oMyLL2qpIFx0Ns0WYfWM5hJ4zkFPmLWT68fM=
20240528220411_migration.sql h1:SR44sOEaWbDgYCKJZIKcGCI7Ta+LqL71z225Nhs2+HM=
20240528221846_migration.sql h1:EkUonGI9Bu689qWX4pG3PRC+On4f6u7UvwDbaR8mCNk=
20240528222851_migration.sql h1:VaQhEaDGe8M2kuNtKVjuMWMLJ9RhJVraVgSM4rm/XcQ=
20240601211932_migration.sql h1:zTofjRbLfoZZF8k6dvAMUDJGRENHAG3m1qqtLgTXUCQ=
20240613231838_migration.sql h1:fbgEWDDA7hcQP5gdX6WDpPWG+340dT40CgkwIG7KGxw=
20240614133606_migration.sql h1:ydCsnRUhSVP0WY7ey7DNHcNQnABPuOt7Z/b0mj7+s6M=
20240614211957_migration.sql h1:qUD4bs8JikDO/0TLD91fhkHzyesdyn2yKqmwkBcWVMc=
2 changes: 1 addition & 1 deletion ent/migrate/schema.go

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

4 changes: 2 additions & 2 deletions ent/node/node.go

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

4 changes: 1 addition & 3 deletions ent/schema/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (Node) Fields() []ent.Field {
field.Int64("total_review").Default(0),
field.Enum("status").
GoType(NodeStatus("")).
Default(string(NodeStatusPending)),
Default(string(NodeStatusActive)),
}
}

Expand All @@ -70,7 +70,6 @@ type NodeStatus string

const (
NodeStatusActive NodeStatus = "active"
NodeStatusPending NodeStatus = "pending"
NodeStatusDeleted NodeStatus = "deleted"
NodeStatusBanned NodeStatus = "banned"
)
Expand All @@ -80,6 +79,5 @@ func (NodeStatus) Values() (types []string) {
string(NodeStatusActive),
string(NodeStatusBanned),
string(NodeStatusDeleted),
string(NodeStatusPending),
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/deepmap/oapi-codegen/v2 v2.1.0
github.com/getkin/kin-openapi v0.123.0
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0
github.com/labstack/echo/v4 v4.11.4
github.com/lib/pq v1.10.9
Expand Down Expand Up @@ -57,7 +58,6 @@ require (
github.com/go-openapi/swag v0.22.9 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ 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=
Expand All @@ -215,8 +213,6 @@ 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=
Expand Down Expand Up @@ -245,10 +241,6 @@ 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=
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/registry_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func TestRegistry(t *testing.T) {
assert.Equal(t, nodeTags, *createNodeResponse.(drip.CreateNode201JSONResponse).Tags)
assert.Equal(t, icon, *createNodeResponse.(drip.CreateNode201JSONResponse).Icon)
assert.Equal(t, githubUrl, *createNodeResponse.(drip.CreateNode201JSONResponse).Repository)
assert.Equal(t, drip.NodeStatusPending, *createNodeResponse.(drip.CreateNode201JSONResponse).Status)
assert.Equal(t, drip.NodeStatusActive, *createNodeResponse.(drip.CreateNode201JSONResponse).Status)
real_node_id = createNodeResponse.(drip.CreateNode201JSONResponse).Id

})
Expand All @@ -332,7 +332,7 @@ func TestRegistry(t *testing.T) {
require.IsType(t, drip.GetNode200JSONResponse{}, res)
res200 := res.(drip.GetNode200JSONResponse)
expDl, expRate := 0, float32(0)
nodeStatus := drip.NodeStatusPending
nodeStatus := drip.NodeStatusActive
assert.Equal(t, drip.GetNode200JSONResponse{
Id: &nodeId,
Name: &nodeName,
Expand Down Expand Up @@ -364,7 +364,7 @@ func TestRegistry(t *testing.T) {
res200 := res.(drip.ListNodesForPublisher200JSONResponse)
require.Len(t, res200, 1)
expDl, expRate := 0, float32(0)
nodeStatus := drip.NodeStatusPending
nodeStatus := drip.NodeStatusActive
assert.Equal(t, drip.Node{
Id: &nodeId,
Name: &nodeName,
Expand Down Expand Up @@ -419,7 +419,7 @@ func TestRegistry(t *testing.T) {
require.IsType(t, drip.GetNode200JSONResponse{}, resUpdated)
res200Updated := resUpdated.(drip.GetNode200JSONResponse)
expDl, expRate := 0, float32(0)
nodeStatus := drip.NodeStatusPending
nodeStatus := drip.NodeStatusActive
assert.Equal(t, drip.GetNode200JSONResponse{
Id: &nodeId,
Description: &updateNodeDescription,
Expand Down Expand Up @@ -642,7 +642,7 @@ func TestRegistry(t *testing.T) {
assert.Len(t, *resNodes200.Nodes, 1, "should only contain 1 node")

expDl, expRate := 0, float32(0)
nodeStatus := drip.NodeStatusPending
nodeStatus := drip.NodeStatusActive
expectedNode := drip.Node{
Id: &nodeId,
Name: &nodeName,
Expand Down
2 changes: 0 additions & 2 deletions mapper/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ func DbNodeStatusToApiNodeStatus(status schema.NodeStatus) *drip.NodeStatus {
nodeStatus = drip.NodeStatusBanned
case schema.NodeStatusDeleted:
nodeStatus = drip.NodeStatusDeleted
case schema.NodeStatusPending:
nodeStatus = drip.NodeStatusPending
default:
nodeStatus = ""
}
Expand Down
Loading