mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add OpenIn option to coder_app (#15743)
This PR is the coder/coder part of [the open_in parameter issue](https://github.com/coder/terraform-provider-coder/issues/297) aiming to add a new optional parameter to choose how to open modules. This PR is heavily linked [to this PR](https://github.com/coder/terraform-provider-coder/pull/321). ℹ️ For now, some integrations tests can not be pushed as it requires a release on the terraform-provider repo.
This commit is contained in:
@@ -84,6 +84,7 @@ type agentAppAttributes struct {
|
||||
Healthcheck []appHealthcheckAttributes `mapstructure:"healthcheck"`
|
||||
Order int64 `mapstructure:"order"`
|
||||
Hidden bool `mapstructure:"hidden"`
|
||||
OpenIn string `mapstructure:"open_in"`
|
||||
}
|
||||
|
||||
type agentEnvAttributes struct {
|
||||
@@ -432,6 +433,16 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
|
||||
sharingLevel = proto.AppSharingLevel_PUBLIC
|
||||
}
|
||||
|
||||
openIn := proto.AppOpenIn_SLIM_WINDOW
|
||||
switch strings.ToLower(attrs.OpenIn) {
|
||||
case "slim-window":
|
||||
openIn = proto.AppOpenIn_SLIM_WINDOW
|
||||
case "window":
|
||||
openIn = proto.AppOpenIn_WINDOW
|
||||
case "tab":
|
||||
openIn = proto.AppOpenIn_TAB
|
||||
}
|
||||
|
||||
for _, agents := range resourceAgents {
|
||||
for _, agent := range agents {
|
||||
// Find agents with the matching ID and associate them!
|
||||
@@ -452,6 +463,7 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
|
||||
Healthcheck: healthcheck,
|
||||
Order: attrs.Order,
|
||||
Hidden: attrs.Hidden,
|
||||
OpenIn: openIn,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +182,7 @@ func TestConvertResources(t *testing.T) {
|
||||
DisplayName: "app1",
|
||||
// Subdomain defaults to false if unspecified.
|
||||
Subdomain: false,
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
{
|
||||
Slug: "app2",
|
||||
@@ -192,11 +193,13 @@ func TestConvertResources(t *testing.T) {
|
||||
Interval: 5,
|
||||
Threshold: 6,
|
||||
},
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
{
|
||||
Slug: "app3",
|
||||
DisplayName: "app3",
|
||||
Subdomain: false,
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
},
|
||||
Auth: &proto.Agent_Token{},
|
||||
@@ -217,10 +220,12 @@ func TestConvertResources(t *testing.T) {
|
||||
{
|
||||
Slug: "app1",
|
||||
DisplayName: "app1",
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
{
|
||||
Slug: "app2",
|
||||
DisplayName: "app2",
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
},
|
||||
Auth: &proto.Agent_Token{},
|
||||
@@ -243,6 +248,7 @@ func TestConvertResources(t *testing.T) {
|
||||
DisplayName: "app1",
|
||||
// Subdomain defaults to false if unspecified.
|
||||
Subdomain: false,
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
{
|
||||
Slug: "app2",
|
||||
@@ -253,6 +259,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Interval: 5,
|
||||
Threshold: 6,
|
||||
},
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
},
|
||||
Auth: &proto.Agent_Token{},
|
||||
@@ -271,6 +278,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Slug: "app3",
|
||||
DisplayName: "app3",
|
||||
Subdomain: false,
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
},
|
||||
Auth: &proto.Agent_Token{},
|
||||
@@ -454,6 +462,7 @@ func TestConvertResources(t *testing.T) {
|
||||
Slug: "code-server",
|
||||
DisplayName: "code-server",
|
||||
Url: "http://localhost:13337?folder=/home/coder",
|
||||
OpenIn: proto.AppOpenIn_SLIM_WINDOW,
|
||||
},
|
||||
},
|
||||
Auth: &proto.Agent_Token{},
|
||||
|
||||
Reference in New Issue
Block a user