Skip to content

Commit 9be2234

Browse files
committed
pr comments
1 parent 1ba035c commit 9be2234

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

coderd/database/modelmethods.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"github.com/coder/coder/v2/coderd/rbac"
1111
)
1212

13-
var DefaultDisplayApps = []DisplayApp{DisplayAppVscode, DisplayAppWebTerminal, DisplayAppSSHHelper, DisplayAppPortForwardingHelper}
14-
1513
type WorkspaceStatus string
1614

1715
const (

coderd/provisionerdserver/provisionerdserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ func TestInsertWorkspaceResource(t *testing.T) {
15281528
}, agent.DisplayApps)
15291529
})
15301530

1531-
t.Run("AllDefaultApps", func(t *testing.T) {
1531+
t.Run("AllDisplayApps", func(t *testing.T) {
15321532
t.Parallel()
15331533
db := dbfake.New()
15341534
job := uuid.New()

provisioner/terraform/resources.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
stringutil "github.com/coder/coder/v2/coderd/util/strings"
1616
"github.com/coder/coder/v2/codersdk"
1717
"github.com/coder/coder/v2/provisioner"
18+
"github.com/coder/coder/v2/provisionersdk"
1819
"github.com/coder/coder/v2/provisionersdk/proto"
1920
)
2021

@@ -192,16 +193,10 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
192193

193194
// If a user doesn't specify 'display_apps' then they default
194195
// into all apps except VSCode Insiders.
195-
displayApps := proto.DisplayApps{
196-
Vscode: true,
197-
VscodeInsiders: false,
198-
WebTerminal: true,
199-
PortForwardingHelper: true,
200-
SshHelper: true,
201-
}
196+
displayApps := provisionersdk.DefaultDisplayApps()
202197

203198
if len(attrs.DisplayApps) != 0 {
204-
displayApps = proto.DisplayApps{
199+
displayApps = &proto.DisplayApps{
205200
Vscode: attrs.DisplayApps[0].VSCode,
206201
VscodeInsiders: attrs.DisplayApps[0].VSCodeInsiders,
207202
WebTerminal: attrs.DisplayApps[0].WebTerminal,
@@ -226,7 +221,7 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
226221
ShutdownScript: attrs.ShutdownScript,
227222
ShutdownScriptTimeoutSeconds: attrs.ShutdownScriptTimeoutSeconds,
228223
Metadata: metadata,
229-
DisplayApps: &displayApps,
224+
DisplayApps: displayApps,
230225
}
231226
switch attrs.Auth {
232227
case "token":

provisionersdk/agent.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
_ "embed"
55
"fmt"
66
"strings"
7+
8+
"github.com/coder/coder/v2/provisionersdk/proto"
79
)
810

911
var (
@@ -35,11 +37,6 @@ var (
3537
"arm64": darwinScript,
3638
},
3739
}
38-
39-
// AllDisplayApps indicates that a user has not specified a 'display_apps' block in their template.
40-
// There is no way to distinguish between a nil array (unset) and an empty array in protobuf and an
41-
// empty array already signifies that all display apps should be disabled.
42-
AllDisplayApps = "*"
4340
)
4441

4542
// AgentScriptEnv returns a key-pair of scripts that are consumed
@@ -55,3 +52,15 @@ func AgentScriptEnv() map[string]string {
5552
}
5653
return env
5754
}
55+
56+
// DefaultDisplayApps returns the default display applications to enable
57+
// if none are specified in a template.
58+
func DefaultDisplayApps() *proto.DisplayApps {
59+
return &proto.DisplayApps{
60+
Vscode: true,
61+
VscodeInsiders: false,
62+
WebTerminal: true,
63+
PortForwardingHelper: true,
64+
SshHelper: true,
65+
}
66+
}

0 commit comments

Comments
 (0)