Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: deployment flags#4426

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
f0ssel merged 11 commits intomainfromf0ssel/new-flags
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
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
PrevPrevious commit
NextNext commit
add enterprise flags
  • Loading branch information
@f0ssel
f0ssel committedOct 10, 2022
commit7e735838f765593862194949db7cbb8339a770ae
44 changes: 36 additions & 8 deletionscli/deployment/flags.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -339,9 +339,45 @@ func NewFlags() codersdk.DeploymentFlags {
Shorthand: "v",
Description: "Enables verbose logging.",
},
AuditLogging: codersdk.BoolFlag{
Name: "Audit Logging",
Flag: "audit-logging",
EnvVar: "CODER_AUDIT_LOGGING",
Description: "Specifies whether audit logging is enabled.",
Default: true,
},
BrowserOnly: codersdk.BoolFlag{
Name: "Browser Only",
Flag: "browser-only",
EnvVar: "CODER_BROWSER_ONLY",
Description: "Whether Coder only allows connections to workspaces via the browser.",
},
ScimAuthHeader: codersdk.StringFlag{
Name: "SCIM Authentication Header",
Flag: "scim-auth-header",
EnvVar: "CODER_SCIM_API_KEY",
Description: "Enables SCIM and sets the authentication header for the built-in SCIM server. New users are automatically created with OIDC authentication.",
Default: "ed25519",
},
UserWorkspaceQuota: codersdk.IntFlag{
Name: "User Workspace Quota",
Flag: "user-workspace-quota",
EnvVar: "CODER_USER_WORKSPACE_QUOTA",
Description: "Enables and sets a limit on how many workspaces each user can create.",
Default: 0,
},
}
}

func RemoveSensitiveValues(df codersdk.DeploymentFlags) codersdk.DeploymentFlags {
df.Oauth2GithubClientSecret.Value = secretValue
df.OidcClientSecret.Value = secretValue
df.PostgresURL.Value = secretValue
df.ScimAuthHeader.Value = secretValue

return df
}

func StringFlag(flagset *pflag.FlagSet, fl *codersdk.StringFlag) {
cliflag.StringVarP(flagset,
&fl.Value,
Expand DownExpand Up@@ -409,11 +445,3 @@ func defaultCacheDir() string {

return filepath.Join(defaultCacheDir, "coder")
}

func RemoveSensitiveValues(df codersdk.DeploymentFlags) codersdk.DeploymentFlags {
df.Oauth2GithubClientSecret.Value = secretValue
df.OidcClientSecret.Value = secretValue
df.PostgresURL.Value = secretValue

return df
}
5 changes: 4 additions & 1 deletioncli/root.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,7 @@ import (
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/cli/config"
"github.com/coder/coder/cli/deployment"
"github.com/coder/coder/coderd"
"github.com/coder/coder/codersdk"
)
Expand DownExpand Up@@ -98,7 +99,9 @@ func Core() []*cobra.Command {
}

func AGPL() []*cobra.Command {
all := append(Core(), Server(func(_ context.Context, o *coderd.Options) (*coderd.API, error) {
df := deployment.NewFlags()
all := append(Core(), Server(df, func(_ context.Context, o *coderd.Options) (*coderd.API, error) {
o.DeploymentFlags = &df
return coderd.New(o), nil
}))
return all
Expand Down
6 changes: 1 addition & 5 deletionscli/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,11 +67,7 @@ import (
)

// nolint:gocyclo
func Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, error)) *cobra.Command {
var (
dflags = deployment.NewFlags()
)

func Server(dflags codersdk.DeploymentFlags, newAPI func(context.Context, *coderd.Options) (*coderd.API, error)) *cobra.Command {
root := &cobra.Command{
Use: "server",
Short: "Start a Coder server",
Expand Down
7 changes: 4 additions & 3 deletionscoderd/flags_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,8 @@ func TestDeploymentFlagSecrets(t *testing.T) {

df := deployment.NewFlags()
scrubbed := deployment.RemoveSensitiveValues(df)
require.Contains(t, scrubbed.Oauth2GithubClientSecret.Value, secretValue)
require.Contains(t, scrubbed.OidcClientSecret.Value, secretValue)
require.Contains(t, scrubbed.PostgresURL.Value, secretValue)
require.EqualValues(t, secretValue, scrubbed.Oauth2GithubClientSecret.Value)
require.EqualValues(t, secretValue, scrubbed.OidcClientSecret.Value)
require.EqualValues(t, secretValue, scrubbed.PostgresURL.Value)
require.EqualValues(t, secretValue, scrubbed.ScimAuthHeader.Value)
}
4 changes: 4 additions & 0 deletionscodersdk/deployment.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,6 +51,10 @@ type DeploymentFlags struct {
MetricsCacheRefreshInterval DurationFlag `json:"metrics_cache_refresh_interval"`
AgentStatRefreshInterval DurationFlag `json:"agent_stat_refresh_interval"`
Verbose BoolFlag `json:"verbose"`
AuditLogging BoolFlag `json:"audit_logging"`
BrowserOnly BoolFlag `json:"browser_only"`
ScimAuthHeader StringFlag `json:"scim_auth_header"`
UserWorkspaceQuota IntFlag `json:"user_workspace_quota"`
}

type StringFlag struct {
Expand Down
47 changes: 23 additions & 24 deletionsenterprise/cli/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,44 +5,43 @@ import (

"github.com/spf13/cobra"

"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/cli/deployment"
"github.com/coder/coder/enterprise/coderd"

agpl "github.com/coder/coder/cli"
agplcoderd "github.com/coder/coder/coderd"
)

func server() *cobra.Command {
var (
auditLogging bool
browserOnly bool
scimAuthHeader string
userWorkspaceQuota int
)
cmd := agpl.Server(func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, error) {
api, err := coderd.New(ctx, &coderd.Options{
AuditLogging: auditLogging,
BrowserOnly: browserOnly,
SCIMAPIKey: []byte(scimAuthHeader),
UserWorkspaceQuota: userWorkspaceQuota,
dflags := deployment.NewFlags()
cmd := agpl.Server(dflags, func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, error) {
options.DeploymentFlags = &dflags
o := &coderd.Options{
AuditLogging: dflags.AuditLogging.Value,
BrowserOnly: dflags.BrowserOnly.Value,
SCIMAPIKey: []byte(dflags.ScimAuthHeader.Value),
UserWorkspaceQuota: dflags.UserWorkspaceQuota.Value,
Options: options,
})
}
api, err := coderd.New(ctx, o)
if err != nil {
return nil, err
}
return api.AGPL, nil
})
enterpriseOnly := cliui.Styles.Keyword.Render("This is an Enterprise feature. Contact sales@coder.com for licensing")

cliflag.BoolVarP(cmd.Flags(), &auditLogging, "audit-logging", "", "CODER_AUDIT_LOGGING", true,
"Specifies whether audit logging is enabled. "+enterpriseOnly)
cliflag.BoolVarP(cmd.Flags(), &browserOnly, "browser-only", "", "CODER_BROWSER_ONLY", false,
"Whether Coder only allows connections to workspaces via the browser. "+enterpriseOnly)
cliflag.StringVarP(cmd.Flags(), &scimAuthHeader, "scim-auth-header", "", "CODER_SCIM_API_KEY", "",
"Enables SCIM and sets the authentication header for the built-in SCIM server. New users are automatically created with OIDC authentication. "+enterpriseOnly)
cliflag.IntVarP(cmd.Flags(), &userWorkspaceQuota, "user-workspace-quota", "", "CODER_USER_WORKSPACE_QUOTA", 0,
"A positive number applies a limit on how many workspaces each user can create. "+enterpriseOnly)

// append enterprise description to flags
enterpriseOnly := cliui.Styles.Keyword.Render(" This is an Enterprise feature. Contact sales@coder.com for licensing")
dflags.AuditLogging.Description += enterpriseOnly
dflags.BrowserOnly.Description += enterpriseOnly
dflags.ScimAuthHeader.Description += enterpriseOnly
dflags.UserWorkspaceQuota.Description += enterpriseOnly

deployment.BoolFlag(cmd.Flags(), &dflags.AuditLogging)
deployment.BoolFlag(cmd.Flags(), &dflags.BrowserOnly)
deployment.StringFlag(cmd.Flags(), &dflags.ScimAuthHeader)
deployment.IntFlag(cmd.Flags(), &dflags.UserWorkspaceQuota)

return cmd
}

[8]ページ先頭

©2009-2025 Movatter.jp