Skip to content

feat: Enable custom support links #6313

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 13 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 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
Next Next commit
backend: support links
  • Loading branch information
mtojek committed Feb 22, 2023
commit e44848562ab4f30ef09e52c408b4350c49c5b079
15 changes: 15 additions & 0 deletions cli/deployment/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,15 @@ func newConfig() *codersdk.DeploymentConfig {
Flag: "disable-password-auth",
Default: false,
},
Support: &codersdk.SupportConfig{
Links: &codersdk.DeploymentConfigField[[]codersdk.LinkConfig]{
Name: "Support links",
Usage: "Use custom support links",
Flag: "support-links",
Default: []codersdk.LinkConfig{},
Enterprise: true,
},
},
}
}

Expand Down Expand Up @@ -649,6 +658,10 @@ func setConfig(prefix string, vip *viper.Viper, target interface{}) {
// Do not bind to CODER_GITAUTH, instead bind to CODER_GITAUTH_0_*, etc.
values := readSliceFromViper[codersdk.GitAuthConfig](vip, prefix, value)
val.FieldByName("Value").Set(reflect.ValueOf(values))
case []codersdk.LinkConfig:
// Do not bind to CODER_SUPPORT_LINKS, instead bind to CODER_SUPPORT_LINKS_0_*, etc.
values := readSliceFromViper[codersdk.LinkConfig](vip, prefix, value)
val.FieldByName("Value").Set(reflect.ValueOf(values))
default:
panic(fmt.Sprintf("unsupported type %T", value))
}
Expand Down Expand Up @@ -824,6 +837,8 @@ func setFlags(prefix string, flagset *pflag.FlagSet, vip *viper.Viper, target in
_ = flagset.DurationP(flg, shorthand, vip.GetDuration(prefix), usage)
case []string:
_ = flagset.StringSliceP(flg, shorthand, vip.GetStringSlice(prefix), usage)
case []codersdk.LinkConfig:
// Ignore this one!
case []codersdk.GitAuthConfig:
// Ignore this one!
default:
Expand Down
69 changes: 69 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ type DeploymentConfig struct {
Address *DeploymentConfigField[string] `json:"address" typescript:",notnull"`
// DEPRECATED: Use Experiments instead.
Experimental *DeploymentConfigField[bool] `json:"experimental" typescript:",notnull"`

Support *SupportConfig `json:"support" typescript:",notnull"`
}

type DERP struct {
Expand Down Expand Up @@ -276,8 +278,18 @@ type DangerousConfig struct {
AllowPathAppSiteOwnerAccess *DeploymentConfigField[bool] `json:"allow_path_app_site_owner_access" typescript:",notnull"`
}

type SupportConfig struct {
Links *DeploymentConfigField[[]LinkConfig] `json:"links" typescript:",notnull"`
}

type LinkConfig struct {
Name string `json:"name"`
Target string `json:"target"`
Icon string `json:"icon,omitempty"`
}

type Flaggable interface {
string | time.Duration | bool | int | []string | []GitAuthConfig
string | time.Duration | bool | int | []string | []GitAuthConfig | []LinkConfig
}

type DeploymentConfigField[T Flaggable] struct {
Expand Down Expand Up @@ -348,6 +360,7 @@ func (c *Client) DeploymentConfig(ctx context.Context) (DeploymentConfig, error)
type AppearanceConfig struct {
LogoURL string `json:"logo_url"`
ServiceBanner ServiceBannerConfig `json:"service_banner"`
SupportLinks []LinkConfig `json:"support_links,omitempty"`
}

type ServiceBannerConfig struct {
Expand Down
27 changes: 24 additions & 3 deletions docs/api/enterprise.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ curl -X GET http://coder-server:8080/api/v2/appearance \
"background_color": "string",
"enabled": true,
"message": "string"
}
},
"support_links": [
{
"icon": "string",
"name": "string",
"target": "string"
}
]
}
```

Expand Down Expand Up @@ -59,7 +66,14 @@ curl -X PUT http://coder-server:8080/api/v2/appearance \
"background_color": "string",
"enabled": true,
"message": "string"
}
},
"support_links": [
{
"icon": "string",
"name": "string",
"target": "string"
}
]
}
```

Expand All @@ -80,7 +94,14 @@ curl -X PUT http://coder-server:8080/api/v2/appearance \
"background_color": "string",
"enabled": true,
"message": "string"
}
},
"support_links": [
{
"icon": "string",
"name": "string",
"target": "string"
}
]
}
```

Expand Down
25 changes: 25 additions & 0 deletions docs/api/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,31 @@ curl -X GET http://coder-server:8080/api/v2/config/deployment \
"usage": "string",
"value": ["string"]
},
"support": {
"links": {
"default": [
{
"icon": "string",
"name": "string",
"target": "string"
}
],
"enterprise": true,
"flag": "string",
"hidden": true,
"name": "string",
"secret": true,
"shorthand": "string",
"usage": "string",
"value": [
{
"icon": "string",
"name": "string",
"target": "string"
}
]
}
},
"swagger": {
"enable": {
"default": true,
Expand Down
Loading