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
+5 -1
View File
@@ -49,6 +49,9 @@ type appearanceFetcher struct {
}
func newAppearanceFetcher(store database.Store, links []codersdk.LinkConfig, docsURL, coderVersion string) agpl.Fetcher {
if docsURL == "" {
docsURL = codersdk.DefaultDocsURL()
}
return &appearanceFetcher{
database: store,
supportLinks: links,
@@ -94,7 +97,8 @@ func (f *appearanceFetcher) Fetch(ctx context.Context) (codersdk.AppearanceConfi
ApplicationName: applicationName,
LogoURL: logoURL,
AnnouncementBanners: []codersdk.BannerConfig{},
SupportLinks: agpl.DefaultSupportLinks(f.docsURL),
SupportLinks: codersdk.DefaultSupportLinks(f.docsURL),
DocsURL: f.docsURL,
}
if announcementBannersJSON != "" {
+21 -3
View File
@@ -10,7 +10,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/coderd/appearance"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbfake"
@@ -230,6 +229,25 @@ func TestCustomSupportLinks(t *testing.T) {
require.Equal(t, supportLinks, appr.SupportLinks)
}
func TestCustomDocsURL(t *testing.T) {
t.Parallel()
testURLRawString := "http://google.com"
testURL, err := url.Parse(testURLRawString)
require.NoError(t, err)
cfg := coderdtest.DeploymentValues(t)
cfg.DocsURL = *serpent.URLOf(testURL)
adminClient, adminUser := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true, Options: &coderdtest.Options{DeploymentValues: cfg}})
anotherClient, _ := coderdtest.CreateAnotherUser(t, adminClient, adminUser.OrganizationID)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
defer cancel()
appr, err := anotherClient.Appearance(ctx)
require.NoError(t, err)
require.Equal(t, testURLRawString, appr.DocsURL)
}
func TestDefaultSupportLinksWithCustomDocsUrl(t *testing.T) {
t.Parallel()
@@ -247,7 +265,7 @@ func TestDefaultSupportLinksWithCustomDocsUrl(t *testing.T) {
appr, err := anotherClient.Appearance(ctx)
require.NoError(t, err)
require.Equal(t, appearance.DefaultSupportLinks(testURLRawString), appr.SupportLinks)
require.Equal(t, codersdk.DefaultSupportLinks(testURLRawString), appr.SupportLinks)
}
func TestDefaultSupportLinks(t *testing.T) {
@@ -262,5 +280,5 @@ func TestDefaultSupportLinks(t *testing.T) {
appr, err := anotherClient.Appearance(ctx)
require.NoError(t, err)
require.Equal(t, appearance.DefaultSupportLinks(""), appr.SupportLinks)
require.Equal(t, codersdk.DefaultSupportLinks(codersdk.DefaultDocsURL()), appr.SupportLinks)
}