fix: make cli respect deployment --docs-url (#14568)

This commit is contained in:
Ethan
2024-09-18 21:47:53 +10:00
committed by GitHub
parent 20a3801600
commit 37885e2e82
26 changed files with 201 additions and 108 deletions

View File

@ -2,10 +2,7 @@ package appearance
import (
"context"
"fmt"
"strings"
"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/codersdk"
)
@ -13,37 +10,6 @@ type Fetcher interface {
Fetch(ctx context.Context) (codersdk.AppearanceConfig, error)
}
func DefaultSupportLinks(docsURL string) []codersdk.LinkConfig {
version := buildinfo.Version()
if docsURL == "" {
docsURL = "https://coder.com/docs/@" + strings.Split(version, "-")[0]
}
buildInfo := fmt.Sprintf("Version: [`%s`](%s)", version, buildinfo.ExternalURL())
return []codersdk.LinkConfig{
{
Name: "Documentation",
Target: docsURL,
Icon: "docs",
},
{
Name: "Report a bug",
Target: "https://github.com/coder/coder/issues/new?labels=needs+grooming&body=" + buildInfo,
Icon: "bug",
},
{
Name: "Join the Coder Discord",
Target: "https://coder.com/chat?utm_source=coder&utm_medium=coder&utm_campaign=server-footer",
Icon: "chat",
},
{
Name: "Star the Repo",
Target: "https://github.com/coder/coder",
Icon: "star",
},
}
}
type AGPLFetcher struct {
docsURL string
}
@ -51,11 +17,15 @@ type AGPLFetcher struct {
func (f AGPLFetcher) Fetch(context.Context) (codersdk.AppearanceConfig, error) {
return codersdk.AppearanceConfig{
AnnouncementBanners: []codersdk.BannerConfig{},
SupportLinks: DefaultSupportLinks(f.docsURL),
SupportLinks: codersdk.DefaultSupportLinks(f.docsURL),
DocsURL: f.docsURL,
}, nil
}
func NewDefaultFetcher(docsURL string) Fetcher {
if docsURL == "" {
docsURL = codersdk.DefaultDocsURL()
}
return &AGPLFetcher{
docsURL: docsURL,
}