Skip to content

Commit e448485

Browse files
committed
backend: support links
1 parent 8231de9 commit e448485

File tree

9 files changed

+393
-6
lines changed

9 files changed

+393
-6
lines changed

cli/deployment/config.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,15 @@ func newConfig() *codersdk.DeploymentConfig {
570570
Flag: "disable-password-auth",
571571
Default: false,
572572
},
573+
Support: &codersdk.SupportConfig{
574+
Links: &codersdk.DeploymentConfigField[[]codersdk.LinkConfig]{
575+
Name: "Support links",
576+
Usage: "Use custom support links",
577+
Flag: "support-links",
578+
Default: []codersdk.LinkConfig{},
579+
Enterprise: true,
580+
},
581+
},
573582
}
574583
}
575584

@@ -649,6 +658,10 @@ func setConfig(prefix string, vip *viper.Viper, target interface{}) {
649658
// Do not bind to CODER_GITAUTH, instead bind to CODER_GITAUTH_0_*, etc.
650659
values := readSliceFromViper[codersdk.GitAuthConfig](vip, prefix, value)
651660
val.FieldByName("Value").Set(reflect.ValueOf(values))
661+
case []codersdk.LinkConfig:
662+
// Do not bind to CODER_SUPPORT_LINKS, instead bind to CODER_SUPPORT_LINKS_0_*, etc.
663+
values := readSliceFromViper[codersdk.LinkConfig](vip, prefix, value)
664+
val.FieldByName("Value").Set(reflect.ValueOf(values))
652665
default:
653666
panic(fmt.Sprintf("unsupported type %T", value))
654667
}
@@ -824,6 +837,8 @@ func setFlags(prefix string, flagset *pflag.FlagSet, vip *viper.Viper, target in
824837
_ = flagset.DurationP(flg, shorthand, vip.GetDuration(prefix), usage)
825838
case []string:
826839
_ = flagset.StringSliceP(flg, shorthand, vip.GetStringSlice(prefix), usage)
840+
case []codersdk.LinkConfig:
841+
// Ignore this one!
827842
case []codersdk.GitAuthConfig:
828843
// Ignore this one!
829844
default:

coderd/apidoc/docs.go

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/deployment.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ type DeploymentConfig struct {
153153
Address *DeploymentConfigField[string] `json:"address" typescript:",notnull"`
154154
// DEPRECATED: Use Experiments instead.
155155
Experimental *DeploymentConfigField[bool] `json:"experimental" typescript:",notnull"`
156+
157+
Support *SupportConfig `json:"support" typescript:",notnull"`
156158
}
157159

158160
type DERP struct {
@@ -276,8 +278,18 @@ type DangerousConfig struct {
276278
AllowPathAppSiteOwnerAccess *DeploymentConfigField[bool] `json:"allow_path_app_site_owner_access" typescript:",notnull"`
277279
}
278280

281+
type SupportConfig struct {
282+
Links *DeploymentConfigField[[]LinkConfig] `json:"links" typescript:",notnull"`
283+
}
284+
285+
type LinkConfig struct {
286+
Name string `json:"name"`
287+
Target string `json:"target"`
288+
Icon string `json:"icon,omitempty"`
289+
}
290+
279291
type Flaggable interface {
280-
string | time.Duration | bool | int | []string | []GitAuthConfig
292+
string | time.Duration | bool | int | []string | []GitAuthConfig | []LinkConfig
281293
}
282294

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

353366
type ServiceBannerConfig struct {

docs/api/enterprise.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ curl -X GET http://coder-server:8080/api/v2/appearance \
2424
"background_color": "string",
2525
"enabled": true,
2626
"message": "string"
27-
}
27+
},
28+
"support_links": [
29+
{
30+
"icon": "string",
31+
"name": "string",
32+
"target": "string"
33+
}
34+
]
2835
}
2936
```
3037

@@ -59,7 +66,14 @@ curl -X PUT http://coder-server:8080/api/v2/appearance \
5966
"background_color": "string",
6067
"enabled": true,
6168
"message": "string"
62-
}
69+
},
70+
"support_links": [
71+
{
72+
"icon": "string",
73+
"name": "string",
74+
"target": "string"
75+
}
76+
]
6377
}
6478
```
6579

@@ -80,7 +94,14 @@ curl -X PUT http://coder-server:8080/api/v2/appearance \
8094
"background_color": "string",
8195
"enabled": true,
8296
"message": "string"
83-
}
97+
},
98+
"support_links": [
99+
{
100+
"icon": "string",
101+
"name": "string",
102+
"target": "string"
103+
}
104+
]
84105
}
85106
```
86107

docs/api/general.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,31 @@ curl -X GET http://coder-server:8080/api/v2/config/deployment \
879879
"usage": "string",
880880
"value": ["string"]
881881
},
882+
"support": {
883+
"links": {
884+
"default": [
885+
{
886+
"icon": "string",
887+
"name": "string",
888+
"target": "string"
889+
}
890+
],
891+
"enterprise": true,
892+
"flag": "string",
893+
"hidden": true,
894+
"name": "string",
895+
"secret": true,
896+
"shorthand": "string",
897+
"usage": "string",
898+
"value": [
899+
{
900+
"icon": "string",
901+
"name": "string",
902+
"target": "string"
903+
}
904+
]
905+
}
906+
},
882907
"swagger": {
883908
"enable": {
884909
"default": true,

0 commit comments

Comments
 (0)