Skip to content

Commit 408d70d

Browse files
committed
get claude off its nonsense
1 parent 4724f79 commit 408d70d

File tree

7 files changed

+91
-205
lines changed

7 files changed

+91
-205
lines changed

coderd/database/dump.sql

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,12 @@
1-
-- Remove 'organization' from the app_sharing_level enum
2-
3-
-- Drop the view that depends on the templates table
4-
DROP VIEW template_with_names;
5-
6-
CREATE TYPE new_app_sharing_level AS ENUM (
7-
'owner',
8-
'authenticated',
9-
'public'
10-
);
11-
12-
-- Update workspace_agent_port_share table to use old enum
13-
-- Convert any 'organization' values to 'authenticated' during downgrade
1+
-- Update columns to use the old enum, replacing 'organization' with 'owner'
142
ALTER TABLE workspace_agent_port_share
15-
ALTER COLUMN share_level TYPE new_app_sharing_level USING (
3+
ALTER COLUMN share_level TYPE app_sharing_level USING (
164
CASE
17-
WHEN share_level = 'organization' THEN 'authenticated'::new_app_sharing_level
18-
ELSE share_level::text::new_app_sharing_level
5+
WHEN share_level = 'organization' THEN 'owner'::app_sharing_level
6+
ELSE share_level::text::app_sharing_level
197
END
208
);
219

22-
-- Update workspace_apps table to use old enum
23-
-- Convert any 'organization' values to 'authenticated' during downgrade
24-
ALTER TABLE workspace_apps
25-
ALTER COLUMN sharing_level DROP DEFAULT,
26-
ALTER COLUMN sharing_level TYPE new_app_sharing_level USING (
27-
CASE
28-
WHEN sharing_level = 'organization' THEN 'authenticated'::new_app_sharing_level
29-
ELSE sharing_level::text::new_app_sharing_level
30-
END
31-
),
32-
ALTER COLUMN sharing_level SET DEFAULT 'owner'::new_app_sharing_level;
33-
34-
-- Update templates table to use old enum
35-
-- Convert any 'organization' values to 'authenticated' during downgrade
36-
ALTER TABLE templates
37-
ALTER COLUMN max_port_sharing_level DROP DEFAULT,
38-
ALTER COLUMN max_port_sharing_level TYPE new_app_sharing_level USING (
39-
CASE
40-
WHEN max_port_sharing_level = 'organization' THEN 'authenticated'::new_app_sharing_level
41-
ELSE max_port_sharing_level::text::new_app_sharing_level
42-
END
43-
),
44-
ALTER COLUMN max_port_sharing_level SET DEFAULT 'owner'::new_app_sharing_level;
45-
46-
-- Drop old enum and rename new one
47-
DROP TYPE app_sharing_level;
48-
ALTER TYPE new_app_sharing_level RENAME TO app_sharing_level;
49-
50-
-- Recreate the template_with_names view
51-
CREATE VIEW template_with_names AS
52-
SELECT
53-
templates.id,
54-
templates.created_at,
55-
templates.updated_at,
56-
templates.organization_id,
57-
templates.deleted,
58-
templates.name,
59-
templates.provisioner,
60-
templates.active_version_id,
61-
templates.description,
62-
templates.default_ttl,
63-
templates.created_by,
64-
templates.icon,
65-
templates.user_acl,
66-
templates.group_acl,
67-
templates.display_name,
68-
templates.allow_user_cancel_workspace_jobs,
69-
templates.allow_user_autostart,
70-
templates.allow_user_autostop,
71-
templates.failure_ttl,
72-
templates.time_til_dormant,
73-
templates.time_til_dormant_autodelete,
74-
templates.autostop_requirement_days_of_week,
75-
templates.autostop_requirement_weeks,
76-
templates.autostart_block_days_of_week,
77-
templates.require_active_version,
78-
templates.deprecated,
79-
templates.activity_bump,
80-
templates.max_port_sharing_level,
81-
templates.use_classic_parameter_flow,
82-
COALESCE(
83-
visible_users.avatar_url,
84-
''::text
85-
) AS created_by_avatar_url,
86-
COALESCE(
87-
visible_users.username,
88-
''::text
89-
) AS created_by_username,
90-
COALESCE(visible_users.name, ''::text) AS created_by_name,
91-
COALESCE(organizations.name, ''::text) AS organization_name,
92-
COALESCE(
93-
organizations.display_name,
94-
''::text
95-
) AS organization_display_name,
96-
COALESCE(organizations.icon, ''::text) AS organization_icon
97-
FROM (
98-
(
99-
templates
100-
LEFT JOIN visible_users ON (
101-
(
102-
templates.created_by = visible_users.id
103-
)
104-
)
105-
)
106-
LEFT JOIN organizations ON (
107-
(
108-
templates.organization_id = organizations.id
109-
)
110-
)
111-
);
11210

113-
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';
11+
-- Drop new enum
12+
DROP TYPE port_sharing_level;
Lines changed: 4 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,12 @@
11
-- Add 'organization' to the app_sharing_level enum
2-
3-
-- Drop the view that depends on the templates table
4-
DROP VIEW template_with_names;
5-
6-
CREATE TYPE new_app_sharing_level AS ENUM (
2+
CREATE TYPE port_sharing_level AS ENUM (
73
'owner',
84
'authenticated',
95
'organization',
106
'public'
117
);
128

13-
-- Update workspace_agent_port_share table to use new enum
14-
ALTER TABLE workspace_agent_port_share
15-
ALTER COLUMN share_level TYPE new_app_sharing_level USING (share_level::text::new_app_sharing_level);
16-
17-
-- Update workspace_apps table to use new enum
18-
ALTER TABLE workspace_apps
19-
ALTER COLUMN sharing_level DROP DEFAULT,
20-
ALTER COLUMN sharing_level TYPE new_app_sharing_level USING (sharing_level::text::new_app_sharing_level),
21-
ALTER COLUMN sharing_level SET DEFAULT 'owner'::new_app_sharing_level;
229

23-
-- Update templates table to use new enum
24-
ALTER TABLE templates
25-
ALTER COLUMN max_port_sharing_level DROP DEFAULT,
26-
ALTER COLUMN max_port_sharing_level TYPE new_app_sharing_level USING (max_port_sharing_level::text::new_app_sharing_level),
27-
ALTER COLUMN max_port_sharing_level SET DEFAULT 'owner'::new_app_sharing_level;
28-
29-
-- Drop old enum and rename new one
30-
DROP TYPE app_sharing_level;
31-
ALTER TYPE new_app_sharing_level RENAME TO app_sharing_level;
32-
33-
-- Recreate the template_with_names view
34-
CREATE VIEW template_with_names AS
35-
SELECT
36-
templates.id,
37-
templates.created_at,
38-
templates.updated_at,
39-
templates.organization_id,
40-
templates.deleted,
41-
templates.name,
42-
templates.provisioner,
43-
templates.active_version_id,
44-
templates.description,
45-
templates.default_ttl,
46-
templates.created_by,
47-
templates.icon,
48-
templates.user_acl,
49-
templates.group_acl,
50-
templates.display_name,
51-
templates.allow_user_cancel_workspace_jobs,
52-
templates.allow_user_autostart,
53-
templates.allow_user_autostop,
54-
templates.failure_ttl,
55-
templates.time_til_dormant,
56-
templates.time_til_dormant_autodelete,
57-
templates.autostop_requirement_days_of_week,
58-
templates.autostop_requirement_weeks,
59-
templates.autostart_block_days_of_week,
60-
templates.require_active_version,
61-
templates.deprecated,
62-
templates.activity_bump,
63-
templates.max_port_sharing_level,
64-
templates.use_classic_parameter_flow,
65-
COALESCE(
66-
visible_users.avatar_url,
67-
''::text
68-
) AS created_by_avatar_url,
69-
COALESCE(
70-
visible_users.username,
71-
''::text
72-
) AS created_by_username,
73-
COALESCE(visible_users.name, ''::text) AS created_by_name,
74-
COALESCE(organizations.name, ''::text) AS organization_name,
75-
COALESCE(
76-
organizations.display_name,
77-
''::text
78-
) AS organization_display_name,
79-
COALESCE(organizations.icon, ''::text) AS organization_icon
80-
FROM (
81-
(
82-
templates
83-
LEFT JOIN visible_users ON (
84-
(
85-
templates.created_by = visible_users.id
86-
)
87-
)
88-
)
89-
LEFT JOIN organizations ON (
90-
(
91-
templates.organization_id = organizations.id
92-
)
93-
)
94-
);
95-
96-
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';
10+
-- Update columns to use the new enum
11+
ALTER TABLE workspace_agent_port_share
12+
ALTER COLUMN share_level TYPE port_sharing_level USING (share_level::text::port_sharing_level);

coderd/database/models.go

Lines changed: 65 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaceapps/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func (p *DBTokenProvider) authorizeRequest(ctx context.Context, roles *rbac.Subj
319319
// For organization level path-based apps, block access if path app sharing is disabled
320320
// and the user is not in the same organization
321321
if isPathApp &&
322-
sharingLevel == database.AppSharingLevelOrganization &&
322+
sharingLevel == database.SharingLevelOrganization &&
323323
!p.DeploymentValues.Dangerous.AllowPathAppSharing.Value() {
324324
// Check if user is in the same organization as the workspace
325325
workspaceOrgID := dbReq.Workspace.OrganizationID

codersdk/workspaceagentportshare.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@ import (
99
"github.com/google/uuid"
1010
)
1111

12+
type WorkspaceAgentPortShareLevel string
13+
1214
const (
1315
WorkspaceAgentPortShareLevelOwner WorkspaceAgentPortShareLevel = "owner"
1416
WorkspaceAgentPortShareLevelAuthenticated WorkspaceAgentPortShareLevel = "authenticated"
1517
WorkspaceAgentPortShareLevelOrganization WorkspaceAgentPortShareLevel = "organization"
1618
WorkspaceAgentPortShareLevelPublic WorkspaceAgentPortShareLevel = "public"
19+
)
1720

21+
type WorkspaceAgentPortShareProtocol string
22+
23+
const (
1824
WorkspaceAgentPortShareProtocolHTTP WorkspaceAgentPortShareProtocol = "http"
1925
WorkspaceAgentPortShareProtocolHTTPS WorkspaceAgentPortShareProtocol = "https"
2026
)
2127

2228
type (
23-
WorkspaceAgentPortShareLevel string
24-
WorkspaceAgentPortShareProtocol string
2529
UpsertWorkspaceAgentPortShareRequest struct {
2630
AgentName string `json:"agent_name"`
2731
Port int32 `json:"port"`

0 commit comments

Comments
 (0)