Skip to content

feat: refactor deployment config #6347

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 89 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
6c29207
Initial scaffold
ammario Feb 25, 2023
12dcc45
Add Duration
ammario Feb 25, 2023
d1e2e15
Begin converting AccessURL
ammario Feb 25, 2023
8db4626
fixup! Begin converting AccessURL
ammario Feb 25, 2023
dc81f47
Start migrating Server
ammario Feb 25, 2023
d511001
Convert a couple more fields
ammario Feb 26, 2023
8cc406e
replace DeploymentConfig[T] with bigcli.[T]
ammario Feb 26, 2023
18b2552
Remove .Value calls
ammario Feb 26, 2023
bad7aca
Finish destroying newConfig
ammario Feb 26, 2023
f075ad5
delete deployment/
ammario Feb 26, 2023
69600d7
rewrite server.go
ammario Feb 26, 2023
63159a6
ugh
ammario Feb 26, 2023
03b08fa
Server boots
ammario Feb 26, 2023
e0d6c1e
Move critical options code into `codersdk`
ammario Feb 26, 2023
5bebd0f
DefaultCacheDir
ammario Feb 26, 2023
2c7b39d
Merge remote-tracking branch 'origin/main' into bigcli
ammario Feb 26, 2023
05b3a10
Fix config dir bug
ammario Feb 26, 2023
dcbd0d8
update golden --help
ammario Feb 26, 2023
fc06f64
Support NoOptDefValue
ammario Feb 26, 2023
d31fa37
Don't hide pflag.FlagSet
ammario Feb 26, 2023
0d7d557
Help template scaffold
ammario Feb 26, 2023
f3d45d3
Show env in help output
ammario Feb 26, 2023
d322114
Merge remote-tracking branch 'origin/main' into bigcli
ammario Feb 26, 2023
8f9d44b
Write more descriptions
ammario Feb 26, 2023
acac92d
Organize telemetry
ammario Feb 26, 2023
1c8359b
Finish grouping up flags
ammario Feb 26, 2023
8d0020f
Render subcommands
ammario Feb 26, 2023
882a80f
Convert Groups to first class bigcli feature
ammario Feb 26, 2023
ae858b4
deepMapNode?
ammario Feb 26, 2023
b34d481
Add YAML tags everywhere.......
ammario Feb 26, 2023
e0e113b
Minor changes
ammario Feb 26, 2023
02c8f6c
Group Enterprise flags
ammario Feb 26, 2023
000466f
Massive refactor to improve help formatting
ammario Feb 27, 2023
c6133f2
Improve help formatting again
ammario Feb 27, 2023
ab21e8f
Send group descriptions to YAML
ammario Feb 27, 2023
b816b1a
Fix YAML tests
ammario Feb 27, 2023
559b046
make gen
ammario Feb 27, 2023
3b24149
Pass linter
ammario Feb 27, 2023
e422c1d
Fix slim bugs
ammario Feb 27, 2023
ea6c3b7
Start frontend... about to go to sleep 🥱
ammario Feb 27, 2023
d4aa8d3
Merge remote-tracking branch 'origin/main' into bigcli
ammario Feb 27, 2023
58b6324
Fix remaining go compilation errors
ammario Feb 27, 2023
cae2eab
Do some type generation
ammario Feb 27, 2023
d4bd380
Fix most broken frontend code...
ammario Feb 27, 2023
8a493ef
Add envparse library
ammario Feb 27, 2023
84b59be
Add legacy git auth env support
ammario Feb 27, 2023
ac3507f
Fix Git Provider rendering in frontend
ammario Feb 27, 2023
95db142
Remove unused lint rules
ammario Feb 27, 2023
790f45a
Update golden files
ammario Feb 27, 2023
360b600
Fix all stories
ammario Feb 28, 2023
2344013
Fix server tests
ammario Feb 28, 2023
394fbfa
Merge remote-tracking branch 'origin/main' into bigcli
ammario Feb 28, 2023
ac909b5
Disable clidocsgen.. for now
ammario Feb 28, 2023
8a2637d
Server tests pass?
ammario Feb 28, 2023
3ed919e
Start figuring out CLI array bug
ammario Feb 28, 2023
d397839
bigcli: fix slice parsing
ammario Feb 28, 2023
957500b
fix remaining calls to deprecated "experimental"
ammario Feb 28, 2023
0890005
Fix more tests
ammario Feb 28, 2023
622df7f
make gen
ammario Feb 28, 2023
362618e
Fix another server test bug
ammario Feb 28, 2023
2fa8b78
Fix logger!
ammario Feb 28, 2023
28e4b07
fix access url test
ammario Feb 28, 2023
410ad26
make gen
ammario Feb 28, 2023
5c3f648
fix frontend!
ammario Feb 28, 2023
f29889f
Merge remote-tracking branch 'origin/main' into bigcli
ammario Feb 28, 2023
6ced9cf
Debug log gitAuthConfigs
ammario Feb 28, 2023
d9d1592
No more implicit options
ammario Mar 1, 2023
74c6da2
Re-enable cli docs gen
ammario Mar 1, 2023
9e53c96
De-pointer DeploymentValues
ammario Mar 1, 2023
06f82b5
Decompose DeploymentConfig
ammario Mar 1, 2023
2f5a522
Some comments
ammario Mar 1, 2023
53e92fc
Move envparse into bigcli
ammario Mar 6, 2023
e9e2908
Minor changes
ammario Mar 6, 2023
c3a11fd
Add context to clitest.Start
ammario Mar 6, 2023
a090cd4
Remove dead function
ammario Mar 6, 2023
d9a8da6
Merge remote-tracking branch 'origin/main' into bigcli
ammario Mar 6, 2023
e53367a
Fix FE
ammario Mar 6, 2023
6252316
make lint passes
ammario Mar 6, 2023
bf1a099
Pass highlyConfigurable
ammario Mar 6, 2023
274d5c5
Context bug
ammario Mar 6, 2023
a213d25
Rename to clibase
ammario Mar 6, 2023
2938980
fix slim build
ammario Mar 6, 2023
140438e
Merge remote-tracking branch 'origin/main' into bigcli
ammario Mar 7, 2023
46936f5
Fix merge issues
ammario Mar 7, 2023
06277c4
Set max token lifetime correctly
ammario Mar 7, 2023
fc8e6ca
Command -> Cmd
ammario Mar 7, 2023
2a74445
Typo
ammario Mar 7, 2023
3cfb4bf
Show disabled badge in zero option table
ammario Mar 7, 2023
4d8bc75
Merge remote-tracking branch 'origin/main' into bigcli
ammario Mar 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move envparse into bigcli
  • Loading branch information
ammario committed Mar 6, 2023
commit 53e92fcb09a5b08d52aeba527c5df0080a0f9283
42 changes: 42 additions & 0 deletions cli/bigcli/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package bigcli

import "strings"

// name returns the name of the environment variable.
func envName(line string) string {
return strings.ToUpper(
strings.SplitN(line, "=", 2)[0],
)
}

// value returns the value of the environment variable.
func envValue(line string) string {
tokens := strings.SplitN(line, "=", 2)
if len(tokens) < 2 {
return ""
}
return tokens[1]
}

// Var represents a single environment variable of form
// NAME=VALUE.
type EnvVar struct {
Name string
Value string
}

// EnvsWithPrefix returns all environment variables starting with
// prefix without said prefix.
func EnvsWithPrefix(environ []string, prefix string) []EnvVar {
var filtered []EnvVar
for _, line := range environ {
name := envName(line)
if strings.HasPrefix(name, prefix) {
filtered = append(filtered, EnvVar{
Name: strings.TrimPrefix(name, prefix),
Value: envValue(line),
})
}
}
return filtered
}
44 changes: 44 additions & 0 deletions cli/bigcli/env_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package bigcli_test

import (
"reflect"
"testing"

"github.com/coder/coder/cli/bigcli"
)

func TestFilterNamePrefix(t *testing.T) {
t.Parallel()
type args struct {
environ []string
prefix string
}
tests := []struct {
name string
args args
want []bigcli.EnvVar
}{
{"empty", args{[]string{}, "SHIRE"}, nil},
{
"ONE",
args{
[]string{
"SHIRE_BRANDYBUCK=hmm",
},
"SHIRE_",
},
[]bigcli.EnvVar{
{Name: "BRANDYBUCK", Value: "hmm"},
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := bigcli.EnvsWithPrefix(tt.args.environ, tt.args.prefix); !reflect.DeepEqual(got, tt.want) {
t.Errorf("EnvsWithPrefix() = %v, want %v", got, tt.want)
}
})
}
}
4 changes: 1 addition & 3 deletions cli/bigcli/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/spf13/pflag"
"golang.org/x/xerrors"

"github.com/coder/coder/cli/envparse"
)

// Option is a configuration option for a CLI application.
Expand Down Expand Up @@ -99,7 +97,7 @@ func (s *OptionSet) ParseEnv(globalPrefix string, environ []string) error {
// avoid N*M complexity when there are a lot of options and environment
// variables.
envs := make(map[string]string)
for _, v := range envparse.FilterNamePrefix(environ, globalPrefix) {
for _, v := range EnvsWithPrefix(environ, globalPrefix) {
envs[v.Name] = v.Value
}

Expand Down
51 changes: 0 additions & 51 deletions cli/envparse/envparse.go

This file was deleted.

77 changes: 0 additions & 77 deletions cli/envparse/envparse_test.go

This file was deleted.

3 changes: 1 addition & 2 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import (
"github.com/coder/coder/cli/bigcli"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/cli/config"
"github.com/coder/coder/cli/envparse"
"github.com/coder/coder/coderd"
"github.com/coder/coder/coderd/autobuild/executor"
"github.com/coder/coder/coderd/database"
Expand Down Expand Up @@ -92,7 +91,7 @@ func ReadGitAuthProvidersFromEnv(environ []string) ([]codersdk.GitAuthConfig, er
sort.Strings(environ)

var providers []codersdk.GitAuthConfig
for _, v := range envparse.FilterNamePrefix(environ, envPrefix+"GITAUTH_") {
for _, v := range bigcli.EnvsWithPrefix(environ, envPrefix+"GITAUTH_") {
tokens := strings.SplitN(v.Name, "_", 2)
if len(tokens) != 2 {
return nil, xerrors.Errorf("invalid env var: %s", v.Name)
Expand Down
4 changes: 2 additions & 2 deletions coderd/coderdtest/coderdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,8 @@ QastnN77KfUwdj3SJt44U/uh1jAIv4oSLBr8HYUkbnI8
-----END RSA PRIVATE KEY-----`

func DeploymentValues(t *testing.T) *codersdk.DeploymentValues {
cfg := codersdk.NewDeploymentValues()
var cfg codersdk.DeploymentValues
err := cfg.Options().SetDefaults()
require.NoError(t, err)
return cfg
return &cfg
}
8 changes: 0 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ require (
github.com/hashicorp/terraform-config-inspect v0.0.0-20211115214459-90acf1ca460f
github.com/hashicorp/terraform-json v0.14.0
github.com/hashicorp/yamux v0.0.0-20220718163420-dd80a7ee44ce
github.com/iancoleman/strcase v0.2.0
github.com/imulab/go-scim/pkg/v2 v2.2.0
github.com/jedib0t/go-pretty/v6 v6.4.0
github.com/jmoiron/sqlx v1.3.5
Expand All @@ -135,7 +134,6 @@ require (
github.com/spf13/afero v1.9.3
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.1
github.com/swaggo/http-swagger v1.3.3
github.com/swaggo/swag v1.8.6
Expand Down Expand Up @@ -181,7 +179,6 @@ require (
)

require (
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df // indirect
github.com/dgraph-io/badger/v3 v3.2103.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/flatbuffers v23.1.21+incompatible // indirect
Expand Down Expand Up @@ -230,7 +227,6 @@ require (
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/elastic/go-windows v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-gonic/gin v1.7.7 // indirect
Expand Down Expand Up @@ -280,7 +276,6 @@ require (
github.com/kr/fs v0.1.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
Expand All @@ -305,7 +300,6 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pion/transport v0.13.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -319,7 +313,6 @@ require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/tailscale/certstore v0.1.1-0.20220316223106-78d6e1c49d8d // indirect
Expand Down Expand Up @@ -357,7 +350,6 @@ require (
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
howett.net/plist v1.0.0 // indirect
inet.af/peercred v0.0.0-20210906144145-0893ea02156a // indirect
Expand Down
Loading