Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add 'hidden' option to 'coder_app' to hide app from UI #14570

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

Merged
merged 10 commits into from
Sep 9, 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
758 changes: 384 additions & 374 deletions agent/proto/agent.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions agent/proto/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ message WorkspaceApp {
UNHEALTHY = 4;
}
Health health = 12;
bool hidden = 13;
}

message WorkspaceAgentScript {
Expand Down
1 change: 1 addition & 0 deletions coderd/agentapi/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,6 @@ func dbAppToProto(dbApp database.WorkspaceApp, agent database.WorkspaceAgent, ow
Threshold: dbApp.HealthcheckThreshold,
},
Health: agentproto.WorkspaceApp_Health(healthRaw),
Hidden: dbApp.Hidden,
}, nil
}
5 changes: 5 additions & 0 deletions coderd/agentapi/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func TestGetManifest(t *testing.T) {
Subdomain: false,
SharingLevel: database.AppSharingLevelPublic,
Health: database.WorkspaceAppHealthDisabled,
Hidden: false,
},
{
ID: uuid.New(),
Expand All @@ -102,6 +103,7 @@ func TestGetManifest(t *testing.T) {
HealthcheckUrl: "http://localhost:4321/health",
HealthcheckInterval: 20,
HealthcheckThreshold: 5,
Hidden: true,
},
}
scripts = []database.WorkspaceAgentScript{
Expand Down Expand Up @@ -182,6 +184,7 @@ func TestGetManifest(t *testing.T) {
Threshold: apps[0].HealthcheckThreshold,
},
Health: agentproto.WorkspaceApp_HEALTHY,
Hidden: false,
},
{
Id: apps[1].ID[:],
Expand All @@ -200,6 +203,7 @@ func TestGetManifest(t *testing.T) {
Threshold: 0,
},
Health: agentproto.WorkspaceApp_DISABLED,
Hidden: false,
},
{
Id: apps[2].ID[:],
Expand All @@ -218,6 +222,7 @@ func TestGetManifest(t *testing.T) {
Threshold: apps[2].HealthcheckThreshold,
},
Health: agentproto.WorkspaceApp_UNHEALTHY,
Hidden: true,
},
}
protoScripts = []*agentproto.WorkspaceAgentScript{
Expand Down
3 changes: 3 additions & 0 deletions coderd/apidoc/docs.go

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

3 changes: 3 additions & 0 deletions coderd/apidoc/swagger.json

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

1 change: 1 addition & 0 deletions coderd/database/db2sdk/db2sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ func Apps(dbApps []database.WorkspaceApp, agent database.WorkspaceAgent, ownerNa
Threshold: dbApp.HealthcheckThreshold,
},
Health: codersdk.WorkspaceAppHealth(dbApp.Health),
Hidden: dbApp.Hidden,
})
}
return apps
Expand Down
1 change: 1 addition & 0 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ func WorkspaceApp(t testing.TB, db database.Store, orig database.WorkspaceApp) d
HealthcheckThreshold: takeFirst(orig.HealthcheckThreshold, 60),
Health: takeFirst(orig.Health, database.WorkspaceAppHealthHealthy),
DisplayOrder: takeFirst(orig.DisplayOrder, 1),
Hidden: orig.Hidden,
})
require.NoError(t, err, "insert app")
return resource
Expand Down
1 change: 1 addition & 0 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -7291,6 +7291,7 @@ func (q *FakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
HealthcheckInterval: arg.HealthcheckInterval,
HealthcheckThreshold: arg.HealthcheckThreshold,
Health: arg.Health,
Hidden: arg.Hidden,
DisplayOrder: arg.DisplayOrder,
}
q.workspaceApps = append(q.workspaceApps, workspaceApp)
Expand Down
5 changes: 4 additions & 1 deletion coderd/database/dump.sql

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

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE workspace_apps DROP COLUMN hidden;
4 changes: 4 additions & 0 deletions coderd/database/migrations/000249_workspace_app_hidden.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE workspace_apps ADD COLUMN hidden boolean NOT NULL DEFAULT false;

COMMENT ON COLUMN workspace_apps.hidden
IS 'Determines if the app is not shown in user interfaces.'
2 changes: 2 additions & 0 deletions coderd/database/models.go

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

20 changes: 14 additions & 6 deletions coderd/database/queries.sql.go

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

5 changes: 3 additions & 2 deletions coderd/database/queries/workspaceapps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ INSERT INTO
healthcheck_interval,
healthcheck_threshold,
health,
display_order
display_order,
hidden
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING *;
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) RETURNING *;

-- name: UpdateWorkspaceAppHealthByID :exec
UPDATE
Expand Down
1 change: 1 addition & 0 deletions coderd/provisionerdserver/provisionerdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
HealthcheckThreshold: app.Healthcheck.Threshold,
Health: health,
DisplayOrder: int32(app.Order),
Hidden: app.Hidden,
})
if err != nil {
return xerrors.Errorf("insert app: %w", err)
Expand Down
2 changes: 2 additions & 0 deletions codersdk/agentsdk/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func AppFromProto(protoApp *proto.WorkspaceApp) (codersdk.WorkspaceApp, error) {
Threshold: protoApp.Healthcheck.Threshold,
},
Health: health,
Hidden: protoApp.Hidden,
}, nil
}

Expand Down Expand Up @@ -274,6 +275,7 @@ func ProtoFromApp(a codersdk.WorkspaceApp) (*proto.WorkspaceApp, error) {
Threshold: a.Healthcheck.Threshold,
},
Health: proto.WorkspaceApp_Health(health),
Hidden: a.Hidden,
}, nil
}

Expand Down
2 changes: 2 additions & 0 deletions codersdk/agentsdk/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestManifest(t *testing.T) {
Threshold: 55555666,
},
Health: codersdk.WorkspaceAppHealthHealthy,
Hidden: false,
},
{
ID: uuid.New(),
Expand All @@ -62,6 +63,7 @@ func TestManifest(t *testing.T) {
Threshold: 22555666,
},
Health: codersdk.WorkspaceAppHealthInitializing,
Hidden: true,
},
},
DERPMap: &tailcfg.DERPMap{
Expand Down
1 change: 1 addition & 0 deletions codersdk/workspaceapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type WorkspaceApp struct {
// Healthcheck specifies the configuration for checking app health.
Healthcheck Healthcheck `json:"healthcheck"`
Health WorkspaceAppHealth `json:"health"`
Hidden bool `json:"hidden"`
}

type Healthcheck struct {
Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/agents.md

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

8 changes: 8 additions & 0 deletions docs/reference/api/builds.md

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

Loading
Loading