-
Notifications
You must be signed in to change notification settings - Fork 943
feat(agent/agentcontainers): support apps for dev container agents #18346
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
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
eb8a469
feat(agent/agentcontainers): support apps for dev container agents
DanielleMaywood 0dc5bb2
chore: copilot feedback
DanielleMaywood bcd6689
chore: more changes
DanielleMaywood 91fd4e7
chore: pass env variables + remove accidental commit
DanielleMaywood c273b23
chore: fix some tests
DanielleMaywood 8698100
chore: fix issues
DanielleMaywood 8ec61b6
chore: fix and update test
DanielleMaywood ab2e82e
chore: fix oopsie
DanielleMaywood 4db77af
test: add organization sharing level
DanielleMaywood d3a2583
chore: CODER_DEPLOYMENT_URL -> CODER_URL
DanielleMaywood 20e832a
chore: remove all the pointers
DanielleMaywood 336997b
ch
10000
ore: handle in CloneConfig as well
DanielleMaywood 0ae2616
chore: rename WithUserName and WithWorkspaceName to WithManifestInfo
DanielleMaywood e17b228
chore: just use PATH
DanielleMaywood d1da3a1
chore: app deduplication
DanielleMaywood c6652a1
chore: appease linter
DanielleMaywood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: remove all the pointers
- Loading branch information
commit 20e832a91620a6e41eb66f22cc536f9c69bf9758
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,19 +47,81 @@ func (s SubAgent) EqualConfig(other SubAgent) bool { | |
} | ||
|
||
type SubAgentApp struct { | ||
Slug string `json:"slug"` | ||
Command *string `json:"command"` | ||
DisplayName *string `json:"displayName"` | ||
External *bool `json:"external"` | ||
Group *string `json:"group"` | ||
HealthCheck *SubAgentHealthCheck `json:"healthCheck"` | ||
Hidden *bool `json:"hidden"` | ||
Icon *string `json:"icon"` | ||
OpenIn *codersdk.WorkspaceAppOpenIn `json:"openIn"` | ||
Order *int32 `json:"order"` | ||
Share *codersdk.WorkspaceAppSharingLevel `json:"share"` | ||
Subdomain *bool `json:"subdomain"` | ||
URL *string `json:"url"` | ||
Slug string `json:"slug"` | ||
Command string `json:"command"` | ||
DisplayName string `json:"displayName"` | ||
External bool `json:"external"` | ||
Group string `json:"group"` | ||
HealthCheck SubAgentHealthCheck `json:"healthCheck"` | ||
Hidden bool `json:"hidden"` | ||
Icon string `json:"icon"` | ||
OpenIn codersdk.WorkspaceAppOpenIn `json:"openIn"` | ||
Order int32 `json:"order"` | ||
Share codersdk.WorkspaceAppSharingLevel `json:"share"` | ||
Subdomain bool `json:"subdomain"` | ||
URL string `json:"url"` | ||
} | ||
|
||
func (app SubAgentApp) ToProtoApp() (*agentproto.CreateSubAgentRequest_App, error) { | ||
proto := agentproto.CreateSubAgentRequest_App{ | ||
Slug: app.Slug, | ||
External: &app.External, | ||
Hidden: &app.Hidden, | ||
Order: &app.Order, | ||
Subdomain: &app.Subdomain, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we check to see what the "defaults" when creating apps in terraform? |
||
|
||
if app.Command != "" { | ||
proto.Command = &app.Command | ||
} | ||
if app.DisplayName != "" { | ||
proto.DisplayName = &app.DisplayName | ||
} | ||
if app.Group != "" { | ||
proto.Group = &app.Group | ||
} | ||
if app.Icon != "" { | ||
proto.Icon = &app.Icon | ||
} | ||
if app.URL != "" { | ||
proto.Url = &app.URL | ||
} | ||
|
||
if app.HealthCheck.URL != "" { | ||
proto.Healthcheck = &agentproto.CreateSubAgentRequest_App_Healthcheck{ | ||
Interval: app.HealthCheck.Interval, | ||
Threshold: app.HealthCheck.Threshold, | ||
Url: app.HealthCheck.URL, | ||
} | ||
} | ||
|
||
if app.OpenIn != "" { | ||
switch app.OpenIn { | ||
case codersdk.WorkspaceAppOpenInSlimWindow: | ||
proto.OpenIn = agentproto.CreateSubAgentRequest_App_SLIM_WINDOW.Enum() | ||
case codersdk.WorkspaceAppOpenInTab: | ||
proto.OpenIn = agentproto.CreateSubAgentRequest_App_TAB.Enum() | ||
default: | ||
return nil, xerrors.Errorf("unexpected codersdk.WorkspaceAppOpenIn: %#v", app.OpenIn) | ||
} | ||
} | ||
|
||
if app.Share != "" { | ||
switch app.Share { | ||
case codersdk.WorkspaceAppSharingLevelAuthenticated: | ||
proto.Share = agentproto.CreateSubAgentRequest_App_AUTHENTICATED.Enum() | ||
case codersdk.WorkspaceAppSharingLevelOwner: | ||
proto.Share = agentproto.CreateSubAgentRequest_App_OWNER.Enum() | ||
case codersdk.WorkspaceAppSharingLevelPublic: | ||
proto.Share = agentproto.CreateSubAgentRequest_App_PUBLIC.Enum() | ||
case codersdk.WorkspaceAppSharingLevelOrganization: | ||
proto.Share = agentproto.CreateSubAgentRequest_App_ORGANIZATION.Enum() | ||
default: | ||
return nil, xerrors.Errorf("unexpected codersdk.WorkspaceAppSharingLevel: %#v", app.Share) | ||
} | ||
} | ||
|
||
return &proto, nil | ||
} | ||
|
||
type SubAgentHealthCheck struct { | ||
|
@@ -151,58 +213,12 @@ func (a *subAgentAPIClient) Create(ctx context.Context, agent SubAgent) (SubAgen | |
|
||
apps := make([]*agentproto.CreateSubAgentRequest_App, 0, len(agent.Apps)) | ||
for _, app := range agent.Apps { | ||
var healthCheck *agentproto.CreateSubAgentRequest_App_Healthcheck | ||
if app.HealthCheck != nil { | ||
healthCheck = &agentproto.CreateSubAgentRequest_App_Healthcheck{ | ||
Interval: app.HealthCheck.Interval, | ||
Threshold: app.HealthCheck.Threshold, | ||
Url: app.HealthCheck.URL, | ||
} | ||
} | ||
|
||
var openIn *agentproto.CreateSubAgentRequest_App_OpenIn | ||
if app.OpenIn != nil { | ||
switch *app.OpenIn { | ||
case codersdk.WorkspaceAppOpenInSlimWindow: | ||
openIn = agentproto.CreateSubAgentRequest_App_SLIM_WINDOW.Enum() | ||
case codersdk.WorkspaceAppOpenInTab: | ||
openIn = agentproto.CreateSubAgentRequest_App_TAB.Enum() | ||
default: | ||
return SubAgent{}, xerrors.Errorf("unexpected codersdk.WorkspaceAppOpenIn: %#v", app.OpenIn) | ||
} | ||
} | ||
|
||
var share *agentproto.CreateSubAgentRequest_App_SharingLevel | ||
if app.Share != nil { | ||
switch *app.Share { | ||
case codersdk.WorkspaceAppSharingLevelAuthenticated: | ||
share = agentproto.CreateSubAgentRequest_App_AUTHENTICATED.Enum() | ||
case codersdk.WorkspaceAppSharingLevelOwner: | ||
share = agentproto.CreateSubAgentRequest_App_OWNER.Enum() | ||
case codersdk.WorkspaceAppSharingLevelPublic: | ||
share = agentproto.CreateSubAgentRequest_App_PUBLIC.Enum() | ||
case codersdk.WorkspaceAppSharingLevelOrganization: | ||
share = agentproto.CreateSubAgentRequest_App_ORGANIZATION.Enum() | ||
default: | ||
return SubAgent{}, xerrors.Errorf("unexpected codersdk.WorkspaceAppSharingLevel: %#v", app.Share) | ||
} | ||
protoApp, err := app.ToProtoApp() | ||
if err != nil { | ||
return SubAgent{}, xerrors.Errorf("convert app: %w", err) | ||
} | ||
|
||
apps = append(apps, &agentproto.CreateSubAgentRequest_App{ | ||
Slug: app.Slug, | ||
Command: app.Command, | ||
DisplayName: app.DisplayName, | ||
External: app.External, | ||
Group: app.Group, | ||
Healthcheck: healthCheck, | ||
Hidden: app.Hidden, | ||
Icon: app.Icon, | ||
OpenIn: openIn, | ||
Order: app.Order, | ||
Share: share, | ||
Subdomain: app.Subdomain, | ||
Url: app.URL, | ||
}) | ||
apps = append(apps, protoApp) | ||
} | ||
|
||
resp, err := a.api.CreateSubAgent(ctx, &agentproto.CreateSubAgentRequest{ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Typically these methods exist in
agentsdk/convert.go
. Personally I think it makes sense to keep here though.