Skip to content

Commit 89c3f99

Browse files
committed
fix template problems
1 parent 345fc7e commit 89c3f99

File tree

9 files changed

+91
-271
lines changed

9 files changed

+91
-271
lines changed

cli/server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ func Server(newAPI func(*coderd.Options) *coderd.API) *cobra.Command {
296296
switch autoImportTemplate {
297297
case "kubernetes":
298298
v = coderd.AutoImportTemplateKubernetes
299-
case "kubernetes-multi-service":
300-
v = coderd.AutoImportTemplateKubernetesMultiService
301299
default:
302300
return xerrors.Errorf("auto import template %q is not supported", autoImportTemplate)
303301
}
@@ -770,7 +768,7 @@ func Server(newAPI func(*coderd.Options) *coderd.API) *cobra.Command {
770768
cliflag.BoolVarP(root.Flags(), &secureAuthCookie, "secure-auth-cookie", "", "CODER_SECURE_AUTH_COOKIE", false, "Specifies if the 'Secure' property is set on browser session cookies")
771769
cliflag.StringVarP(root.Flags(), &sshKeygenAlgorithmRaw, "ssh-keygen-algorithm", "", "CODER_SSH_KEYGEN_ALGORITHM", "ed25519", "Specifies the algorithm to use for generating ssh keys. "+
772770
`Accepted values are "ed25519", "ecdsa", or "rsa4096"`)
773-
cliflag.StringArrayVarP(root.Flags(), &autoImportTemplates, "auto-import-template", "", "CODER_TEMPLATE_AUTOIMPORT", []string{}, "Which templates to auto-import. Available auto-importable templates are: kubernetes, kubernetes-multi-service")
771+
cliflag.StringArrayVarP(root.Flags(), &autoImportTemplates, "auto-import-template", "", "CODER_TEMPLATE_AUTOIMPORT", []string{}, "Which templates to auto-import. Available auto-importable templates are: kubernetes")
774772
cliflag.BoolVarP(root.Flags(), &spooky, "spooky", "", "", false, "Specifies spookiness level")
775773
cliflag.BoolVarP(root.Flags(), &verbose, "verbose", "v", "CODER_VERBOSE", false, "Enables verbose logging.")
776774
_ = root.Flags().MarkHidden("spooky")

coderd/templates.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ var (
3434
type AutoImportTemplate string
3535

3636
const (
37-
AutoImportTemplateKubernetes AutoImportTemplate = "kubernetes"
38-
AutoImportTemplateKubernetesMultiService AutoImportTemplate = "kubernetes-multi-service"
37+
AutoImportTemplateKubernetes AutoImportTemplate = "kubernetes"
3938
)
4039

4140
// Returns a single template.

coderd/users.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,17 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
137137
// Determine which parameter values to use.
138138
parameters := map[string]string{}
139139
switch template {
140-
case AutoImportTemplateKubernetes, AutoImportTemplateKubernetesMultiService:
140+
case AutoImportTemplateKubernetes:
141141

142142
// Determine the current namespace we're in.
143143
const namespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
144144
namespace, err := os.ReadFile(namespaceFile)
145145
if err != nil {
146146
parameters["use_kubeconfig"] = "true" // use ~/.config/kubeconfig
147-
parameters["workspaces_namespace"] = "coder-workspaces"
147+
parameters["namespace"] = "coder-workspaces"
148148
} else {
149149
parameters["use_kubeconfig"] = "false" // use SA auth
150-
parameters["workspaces_namespace"] = string(bytes.TrimSpace(namespace))
150+
parameters["namespace"] = string(bytes.TrimSpace(namespace))
151151
}
152152

153153
default:

coderd/users_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func TestFirstUser(t *testing.T) {
6565
// also added to the switch statement below.
6666
autoImportTemplates := []coderd.AutoImportTemplate{
6767
coderd.AutoImportTemplateKubernetes,
68-
coderd.AutoImportTemplateKubernetesMultiService,
6968
}
7069
client := coderdtest.New(t, &coderdtest.Options{
7170
AutoImportTemplates: autoImportTemplates,
@@ -77,10 +76,9 @@ func TestFirstUser(t *testing.T) {
7776

7877
templates, err := client.TemplatesByOrganization(ctx, u.OrganizationID)
7978
require.NoError(t, err, "list templates")
80-
require.Len(t, templates, 2, "should have two templates")
79+
require.Len(t, templates, len(autoImportTemplates), "listed templates count does not match")
8180
require.ElementsMatch(t, autoImportTemplates, []coderd.AutoImportTemplate{
8281
coderd.AutoImportTemplate(templates[0].Name),
83-
coderd.AutoImportTemplate(templates[1].Name),
8482
}, "template names don't match")
8583

8684
for _, template := range templates {
@@ -91,9 +89,9 @@ func TestFirstUser(t *testing.T) {
9189
// Ensure all template parameters are present.
9290
expectedParams := map[string]bool{}
9391
switch template.Name {
94-
case "kubernetes", "kubernetes-multi-service":
92+
case "kubernetes":
9593
expectedParams["use_kubeconfig"] = false
96-
expectedParams["workspaces_namespace"] = false
94+
expectedParams["namespace"] = false
9795
default:
9896
t.Fatalf("unexpected template name %q", template.Name)
9997
}

enterprise/coderd/licenses.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var ValidMethods = []string{"EdDSA"}
3737

3838
// key20220812 is the Coder license public key with id 2022-08-12 used to validate licenses signed
3939
// by our signing infrastructure
40+
//
4041
//go:embed keys/2022-08-12
4142
var key20220812 []byte
4243

@@ -134,12 +135,12 @@ func (a *licenseAPI) handler() http.Handler {
134135
// postLicense adds a new Enterprise license to the cluster. We allow multiple different licenses
135136
// in the cluster at one time for several reasons:
136137
//
137-
// 1. Upgrades --- if the license format changes from one version of Coder to the next, during a
138-
// rolling update you will have different Coder servers that need different licenses to function.
139-
// 2. Avoid abrupt feature breakage --- when an admin uploads a new license with different features
140-
// we generally don't want the old features to immediately break without warning. With a grace
141-
// period on the license, features will continue to work from the old license until its grace
142-
// period, then the users will get a warning allowing them to gracefully stop using the feature.
138+
// 1. Upgrades --- if the license format changes from one version of Coder to the next, during a
139+
// rolling update you will have different Coder servers that need different licenses to function.
140+
// 2. Avoid abrupt feature breakage --- when an admin uploads a new license with different features
141+
// we generally don't want the old features to immediately break without warning. With a grace
142+
// period on the license, features will continue to work from the old license until its grace
143+
// period, then the users will get a warning allowing them to gracefully stop using the feature.
143144
func (a *licenseAPI) postLicense(rw http.ResponseWriter, r *http.Request) {
144145
if !a.auth.Authorize(r, rbac.ActionCreate, rbac.ResourceLicense) {
145146
httpapi.Forbidden(rw)

examples/templates/kubernetes-pod/README.md

Lines changed: 0 additions & 111 deletions
This file was deleted.

examples/templates/kubernetes-pod/main.tf

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)