Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d20626a

Browse files
committed
Merge branch 'main' into 5574-cli-add-template-version-parameters
2 parents 1af7b9a + 8819f79 commit d20626a

File tree

245 files changed

+4313
-2507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+4313
-2507
lines changed

.github/workflows/coder.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ jobs:
556556
- name: Install node_modules
557557
run: ./scripts/yarn_install.sh
558558

559-
- run: yarn test:coverage
559+
- run: yarn test:ci
560560
working-directory: site
561561

562562
- uses: codecov/codecov-action@v3
@@ -575,7 +575,7 @@ jobs:
575575
name: "test/e2e/${{ matrix.os }}"
576576
needs:
577577
- changes
578-
if: false #needs.changes.outputs.docs-only == 'false'
578+
if: needs.changes.outputs.docs-only == 'false'
579579
runs-on: ${{ matrix.os }}
580580
timeout-minutes: 20
581581
strategy:

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ jobs:
214214
./build/*.rpm
215215
env:
216216
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217+
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.CODER_GPG_RELEASE_KEY_BASE64 }}
217218

218219
- name: Authenticate to Google Cloud
219220
uses: google-github-actions/auth@v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ cli/testdata/.gen-golden
3636
/dist/
3737
site/out/
3838

39+
# Bundle analysis
40+
site/stats/
41+
3942
*.tfstate
4043
*.tfstate.backup
4144
*.tfplan

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ cli/testdata/.gen-golden
3939
/dist/
4040
site/out/
4141

42+
# Bundle analysis
43+
site/stats/
44+
4245
*.tfstate
4346
*.tfstate.backup
4447
*.tfplan

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,9 @@ docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/me
490490
cd site
491491
yarn run format:write:only ../docs/admin/prometheus.md
492492

493-
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen -not \( -path './scripts/apidocgen/node_modules' -prune \) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) .swaggo
493+
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) .swaggo docs/manifest.json
494494
./scripts/apidocgen/generate.sh
495-
cd site
496-
yarn run format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
495+
yarn run --cwd=site format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
497496

498497
update-golden-files: cli/testdata/.gen-golden
499498
.PHONY: update-golden-files

buildinfo/buildinfo.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ var (
2121
version string
2222
readVersion sync.Once
2323

24-
// Injected with ldflags at build!
25-
tag string
24+
// Updated by buildinfo_slim.go on start.
25+
slim bool
26+
27+
// Injected with ldflags at build, see scripts/build_go.sh
28+
tag string
29+
agpl string // either "true" or "false", ldflags does not support bools
2630
)
2731

2832
const (
@@ -73,6 +77,16 @@ func IsDev() bool {
7377
return strings.HasPrefix(Version(), develPrefix)
7478
}
7579

80+
// IsSlim returns true if this is a slim build.
81+
func IsSlim() bool {
82+
return slim
83+
}
84+
85+
// IsAGPL returns true if this is an AGPL build.
86+
func IsAGPL() bool {
87+
return strings.Contains(agpl, "t")
88+
}
89+
7690
// ExternalURL returns a URL referencing the current Coder version.
7791
// For production builds, this will link directly to a release.
7892
// For development builds, this will link to a commit.

buildinfo/buildinfo_slim.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build slim
2+
3+
package buildinfo
4+
5+
func init() {
6+
slim = true
7+
}

cli/agent.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,26 @@ func workspaceAgent() *cobra.Command {
181181
cliflag.StringVarP(cmd.Flags(), &pprofAddress, "pprof-address", "", "CODER_AGENT_PPROF_ADDRESS", "127.0.0.1:6060", "The address to serve pprof.")
182182
return cmd
183183
}
184+
185+
func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler, addr, name string) (closeFunc func()) {
186+
logger.Debug(ctx, "http server listening", slog.F("addr", addr), slog.F("name", name))
187+
188+
// ReadHeaderTimeout is purposefully not enabled. It caused some issues with
189+
// websockets over the dev tunnel.
190+
// See: https://github.com/coder/coder/pull/3730
191+
//nolint:gosec
192+
srv := &http.Server{
193+
Addr: addr,
194+
Handler: handler,
195+
}
196+
go func() {
197+
err := srv.ListenAndServe()
198+
if err != nil && !xerrors.Is(err, http.ErrServerClosed) {
199+
logger.Error(ctx, "http server listen", slog.F("name", name), slog.Error(err))
200+
}
201+
}()
202+
203+
return func() {
204+
_ = srv.Close()
205+
}
206+
}

cli/deployment/config.go

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,19 @@ func newConfig() *codersdk.DeploymentConfig {
446446
Default: 512,
447447
},
448448
},
449+
// DEPRECATED: use Experiments instead.
449450
Experimental: &codersdk.DeploymentConfigField[bool]{
450-
Name: "Experimental",
451-
Usage: "Enable experimental features. Experimental features are not ready for production.",
452-
Flag: "experimental",
451+
Name: "Experimental",
452+
Usage: "Enable experimental features. Experimental features are not ready for production.",
453+
Flag: "experimental",
454+
Default: false,
455+
Hidden: true,
456+
},
457+
Experiments: &codersdk.DeploymentConfigField[[]string]{
458+
Name: "Experiments",
459+
Usage: "Enable one or more experiments. These are not ready for production. Separate multiple experiments with commas, or enter '*' to opt-in to all available experiments.",
460+
Flag: "experiments",
461+
Default: []string{},
453462
},
454463
UpdateCheck: &codersdk.DeploymentConfigField[bool]{
455464
Name: "Update Check",
@@ -491,6 +500,26 @@ func newConfig() *codersdk.DeploymentConfig {
491500
Default: "",
492501
},
493502
},
503+
Dangerous: &codersdk.DangerousConfig{
504+
AllowPathAppSharing: &codersdk.DeploymentConfigField[bool]{
505+
Name: "DANGEROUS: Allow Path App Sharing",
506+
Usage: "Allow workspace apps that are not served from subdomains to be shared. Path-based app sharing is DISABLED by default for security purposes. Path-based apps can make requests to the Coder API and pose a security risk when the workspace serves malicious JavaScript. Path-based apps can be disabled entirely with --disable-path-apps for further security.",
507+
Flag: "dangerous-allow-path-app-sharing",
508+
Default: false,
509+
},
510+
AllowPathAppSiteOwnerAccess: &codersdk.DeploymentConfigField[bool]{
511+
Name: "DANGEROUS: Allow Site Owners to Access Path Apps",
512+
Usage: "Allow site-owners to access workspace apps from workspaces they do not own. Owners cannot access path-based apps they do not own by default. Path-based apps can make requests to the Coder API and pose a security risk when the workspace serves malicious JavaScript. Path-based apps can be disabled entirely with --disable-path-apps for further security.",
513+
Flag: "dangerous-allow-path-app-site-owner-access",
514+
Default: false,
515+
},
516+
},
517+
DisablePathApps: &codersdk.DeploymentConfigField[bool]{
518+
Name: "Disable Path Apps",
519+
Usage: "Disable workspace apps that are not served from subdomains. Path-based apps can make requests to the Coder API and pose a security risk when the workspace serves malicious JavaScript. This is recommended for security purposes if a --wildcard-access-url is configured.",
520+
Flag: "disable-path-apps",
521+
Default: false,
522+
},
494523
}
495524
}
496525

@@ -557,12 +586,12 @@ func setConfig(prefix string, vip *viper.Viper, target interface{}) {
557586
// with a comma, but Viper only supports with a space. This
558587
// is a small hack around it!
559588
rawSlice := reflect.ValueOf(vip.GetStringSlice(prefix)).Interface()
560-
slice, ok := rawSlice.([]string)
589+
stringSlice, ok := rawSlice.([]string)
561590
if !ok {
562591
panic(fmt.Sprintf("string slice is of type %T", rawSlice))
563592
}
564-
value := make([]string, 0, len(slice))
565-
for _, entry := range slice {
593+
value := make([]string, 0, len(stringSlice))
594+
for _, entry := range stringSlice {
566595
value = append(value, strings.Split(entry, ",")...)
567596
}
568597
val.FieldByName("Value").Set(reflect.ValueOf(value))

cli/deployment/config_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,23 @@ func TestConfig(t *testing.T) {
232232
require.Equal(t, config.Prometheus.Enable.Value, true)
233233
require.Equal(t, config.Prometheus.Address.Value, config.Prometheus.Address.Default)
234234
},
235+
}, {
236+
Name: "Experiments - no features",
237+
Env: map[string]string{
238+
"CODER_EXPERIMENTS": "",
239+
},
240+
Valid: func(config *codersdk.DeploymentConfig) {
241+
require.Empty(t, config.Experiments.Value)
242+
},
243+
}, {
244+
Name: "Experiments - multiple features",
245+
Env: map[string]string{
246+
"CODER_EXPERIMENTS": "foo,bar",
247+
},
248+
Valid: func(config *codersdk.DeploymentConfig) {
249+
expected := []string{"foo", "bar"}
250+
require.ElementsMatch(t, expected, config.Experiments.Value)
251+
},
235252
}} {
236253
tc := tc
237254
t.Run(tc.Name, func(t *testing.T) {

0 commit comments

Comments
 (0)