Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5df70a6

Browse files
authored
feat: add organization scope for shared ports (#18314)
1 parenteff2174 commit5df70a6

File tree

30 files changed

+1246
-812
lines changed

30 files changed

+1246
-812
lines changed

‎CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,7 @@ Read [cursor rules](.cursorrules).
101101

102102
##Frontend
103103

104+
The frontend is contained in the site folder.
105+
106+
For building Frontend refer to[this document](docs/contributing/frontend.md)
104107
For building Frontend refer to[this document](docs/about/contributing/frontend.md)

‎agent/proto/agent.pb.go

Lines changed: 722 additions & 713 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎agent/proto/agent.proto

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ message WorkspaceApp {
2424
OWNER=1;
2525
AUTHENTICATED=2;
2626
PUBLIC=3;
27+
ORGANIZATION=4;
2728
}
2829
SharingLevelsharing_level=10;
2930

@@ -401,10 +402,11 @@ message CreateSubAgentRequest {
401402
TAB=1;
402403
}
403404

404-
enumShare {
405+
enumSharingLevel {
405406
OWNER=0;
406407
AUTHENTICATED=1;
407408
PUBLIC=2;
409+
ORGANIZATION=3;
408410
}
409411

410412
stringslug=1;
@@ -417,7 +419,7 @@ message CreateSubAgentRequest {
417419
optionalstringicon=8;
418420
optionalOpenInopen_in=9;
419421
optionalint32order=10;
420-
optionalShareshare=11;
422+
optionalSharingLevelshare=11;
421423
optionalboolsubdomain=12;
422424
optionalstringurl=13;
423425
}

‎coderd/agentapi/subagent.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"database/sql"
66
"errors"
77
"fmt"
8+
"strings"
89

910
"github.com/google/uuid"
1011
"github.com/sqlc-dev/pqtype"
@@ -140,20 +141,15 @@ func (a *SubAgentAPI) CreateSubAgent(ctx context.Context, req *agentproto.Create
140141
health=database.WorkspaceAppHealthInitializing
141142
}
142143

143-
varsharingLevel database.AppSharingLevel
144-
switchapp.GetShare() {
145-
caseagentproto.CreateSubAgentRequest_App_OWNER:
146-
sharingLevel=database.AppSharingLevelOwner
147-
caseagentproto.CreateSubAgentRequest_App_AUTHENTICATED:
148-
sharingLevel=database.AppSharingLevelAuthenticated
149-
caseagentproto.CreateSubAgentRequest_App_PUBLIC:
150-
sharingLevel=database.AppSharingLevelPublic
151-
default:
144+
share:=app.GetShare()
145+
protoSharingLevel,ok:=agentproto.CreateSubAgentRequest_App_SharingLevel_name[int32(share)]
146+
if!ok {
152147
return codersdk.ValidationError{
153148
Field:"share",
154-
Detail:fmt.Sprintf("%q is not a valid app sharing level",app.GetShare()),
149+
Detail:fmt.Sprintf("%q is not a valid app sharing level",share.String()),
155150
}
156151
}
152+
sharingLevel:=database.AppSharingLevel(strings.ToLower(protoSharingLevel))
157153

158154
varopenIn database.WorkspaceAppOpenIn
159155
switchapp.GetOpenIn() {

‎coderd/apidoc/docs.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dump.sql

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
-- Drop the view that depends on the templates table
3+
DROPVIEW template_with_names;
4+
5+
-- Remove 'organization' from the app_sharing_level enum
6+
CREATETYPEnew_app_sharing_levelAS 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
14+
ALTERTABLE workspace_agent_port_share
15+
ALTER COLUMN share_level TYPE new_app_sharing_level USING (
16+
CASE
17+
WHEN share_level='organization' THEN'authenticated'::new_app_sharing_level
18+
ELSE share_level::text::new_app_sharing_level
19+
END
20+
);
21+
22+
-- Update workspace_apps table to use old enum
23+
-- Convert any 'organization' values to 'authenticated' during downgrade
24+
ALTERTABLE 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_levelSET 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+
ALTERTABLE 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'owner'::new_app_sharing_level
41+
ELSE max_port_sharing_level::text::new_app_sharing_level
42+
END
43+
),
44+
ALTER COLUMN max_port_sharing_levelSET DEFAULT'owner'::new_app_sharing_level;
45+
46+
-- Drop old enum and rename new one
47+
DROPTYPE app_sharing_level;
48+
ALTERTYPE new_app_sharing_level RENAME TO app_sharing_level;
49+
50+
-- Recreate the template_with_names view
51+
52+
CREATEVIEWtemplate_with_namesAS
53+
SELECTtemplates.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(visible_users.avatar_url,''::text)AS created_by_avatar_url,
83+
COALESCE(visible_users.username,''::text)AS created_by_username,
84+
COALESCE(visible_users.name,''::text)AS created_by_name,
85+
COALESCE(organizations.name,''::text)AS organization_name,
86+
COALESCE(organizations.display_name,''::text)AS organization_display_name,
87+
COALESCE(organizations.icon,''::text)AS organization_icon
88+
FROM ((templates
89+
LEFT JOIN visible_usersON ((templates.created_by=visible_users.id)))
90+
LEFT JOIN organizationsON ((templates.organization_id=organizations.id)));
91+
92+
COMMENT ON VIEW template_with_names IS'Joins in the display name information such as username, avatar, and organization name.';
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
-- Drop the view that depends on the templates table
2+
DROPVIEW template_with_names;
3+
4+
-- Add 'organization' to the app_sharing_level enum
5+
CREATETYPEnew_app_sharing_levelAS ENUM (
6+
'owner',
7+
'authenticated',
8+
'organization',
9+
'public'
10+
);
11+
12+
-- Update workspace_agent_port_share table to use new enum
13+
ALTERTABLE workspace_agent_port_share
14+
ALTER COLUMN share_level TYPE new_app_sharing_level USING (share_level::text::new_app_sharing_level);
15+
16+
-- Update workspace_apps table to use new enum
17+
ALTERTABLE workspace_apps
18+
ALTER COLUMN sharing_level DROP DEFAULT,
19+
ALTER COLUMN sharing_level TYPE new_app_sharing_level USING (sharing_level::text::new_app_sharing_level),
20+
ALTER COLUMN sharing_levelSET DEFAULT'owner'::new_app_sharing_level;
21+
22+
-- Update templates table to use new enum
23+
ALTERTABLE templates
24+
ALTER COLUMN max_port_sharing_level DROP DEFAULT,
25+
ALTER COLUMN max_port_sharing_level TYPE new_app_sharing_level USING (max_port_sharing_level::text::new_app_sharing_level),
26+
ALTER COLUMN max_port_sharing_levelSET DEFAULT'owner'::new_app_sharing_level;
27+
28+
-- Drop old enum and rename new one
29+
DROPTYPE app_sharing_level;
30+
ALTERTYPE new_app_sharing_level RENAME TO app_sharing_level;
31+
32+
-- Recreate the template_with_names view
33+
CREATEVIEWtemplate_with_namesAS
34+
SELECTtemplates.id,
35+
templates.created_at,
36+
templates.updated_at,
37+
templates.organization_id,
38+
templates.deleted,
39+
templates.name,
40+
templates.provisioner,
41+
templates.active_version_id,
42+
templates.description,
43+
templates.default_ttl,
44+
templates.created_by,
45+
templates.icon,
46+
templates.user_acl,
47+
templates.group_acl,
48+
templates.display_name,
49+
templates.allow_user_cancel_workspace_jobs,
50+
templates.allow_user_autostart,
51+
templates.allow_user_autostop,
52+
templates.failure_ttl,
53+
templates.time_til_dormant,
54+
templates.time_til_dormant_autodelete,
55+
templates.autostop_requirement_days_of_week,
56+
templates.autostop_requirement_weeks,
57+
templates.autostart_block_days_of_week,
58+
templates.require_active_version,
59+
templates.deprecated,
60+
templates.activity_bump,
61+
templates.max_port_sharing_level,
62+
templates.use_classic_parameter_flow,
63+
COALESCE(visible_users.avatar_url,''::text)AS created_by_avatar_url,
64+
COALESCE(visible_users.username,''::text)AS created_by_username,
65+
COALESCE(visible_users.name,''::text)AS created_by_name,
66+
COALESCE(organizations.name,''::text)AS organization_name,
67+
COALESCE(organizations.display_name,''::text)AS organization_display_name,
68+
COALESCE(organizations.icon,''::text)AS organization_icon
69+
FROM ((templates
70+
LEFT JOIN visible_usersON ((templates.created_by=visible_users.id)))
71+
LEFT JOIN organizationsON ((templates.organization_id=organizations.id)));
72+
73+
COMMENT ON VIEW template_with_names IS'Joins in the display name information such as username, avatar, and organization name.';

‎coderd/database/models.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp