Fix wiki deploy
This commit is contained in:
@@ -47,6 +47,7 @@ const (
|
||||
DefaultTopDataWikiMarkerFormat = "html_comments"
|
||||
DefaultTopDataWikiPageMarkerPrefix = "sow-topdata-wiki"
|
||||
DefaultTopDataWikiTitlePrefixMinLength = 3
|
||||
DefaultTopDataWikiStatusListingScope = "all"
|
||||
DefaultWikiDeployManifest = ".wiki_deploy_manifest.json"
|
||||
DefaultWikiDeployEditSummary = "Auto-generated from native builder"
|
||||
DefaultTopDataPackageHAK = "sow_top.hak"
|
||||
@@ -249,6 +250,7 @@ func (p *Project) EffectiveConfig() EffectiveConfig {
|
||||
TemplatesDir: defaultString(p.Config.TopData.Wiki.TemplatesDir, DefaultTopDataWikiTemplatesDir),
|
||||
ManualSectionsDir: defaultString(p.Config.TopData.Wiki.ManualSectionsDir, DefaultTopDataWikiManualSectionsDir),
|
||||
TitlePrefixMinLength: defaultInt(p.Config.TopData.Wiki.TitlePrefixMinLength, DefaultTopDataWikiTitlePrefixMinLength),
|
||||
StatusListingScope: defaultString(p.Config.TopData.Wiki.StatusListingScope, DefaultTopDataWikiStatusListingScope),
|
||||
StalePages: TopDataWikiStalePagesConfig{
|
||||
Default: defaultString(p.Config.TopData.Wiki.StalePages.Default, DefaultTopDataWikiStaleDefault),
|
||||
LiveCleanup: defaultString(p.Config.TopData.Wiki.StalePages.LiveCleanup, DefaultTopDataWikiStaleLiveCleanup),
|
||||
@@ -485,6 +487,7 @@ func markMissingDefaults(provenance ConfigProvenance) {
|
||||
"topdata.wiki.templates_dir": DefaultTopDataWikiTemplatesDir,
|
||||
"topdata.wiki.manual_sections_dir": DefaultTopDataWikiManualSectionsDir,
|
||||
"topdata.wiki.title_prefix_min_length": "3",
|
||||
"topdata.wiki.status_listing_scope": DefaultTopDataWikiStatusListingScope,
|
||||
"topdata.wiki.stale_pages.default": DefaultTopDataWikiStaleDefault,
|
||||
"topdata.wiki.stale_pages.live_cleanup": DefaultTopDataWikiStaleLiveCleanup,
|
||||
"topdata.wiki.managed_region.marker_format": DefaultTopDataWikiMarkerFormat,
|
||||
|
||||
@@ -232,6 +232,7 @@ type TopDataWikiConfig struct {
|
||||
TemplatesDir string `json:"templates_dir" yaml:"templates_dir"`
|
||||
ManualSectionsDir string `json:"manual_sections_dir" yaml:"manual_sections_dir"`
|
||||
TitlePrefixMinLength int `json:"title_prefix_min_length" yaml:"title_prefix_min_length"`
|
||||
StatusListingScope string `json:"status_listing_scope" yaml:"status_listing_scope"`
|
||||
StalePages TopDataWikiStalePagesConfig `json:"stale_pages" yaml:"stale_pages"`
|
||||
ManagedRegion TopDataWikiManagedRegionConfig `json:"managed_region" yaml:"managed_region"`
|
||||
}
|
||||
@@ -594,6 +595,11 @@ func (p *Project) ValidateLayout() error {
|
||||
if effective.TopData.Wiki.TitlePrefixMinLength < 1 {
|
||||
failures = append(failures, fmt.Errorf("topdata.wiki.title_prefix_min_length must be at least 1"))
|
||||
}
|
||||
switch effective.TopData.Wiki.StatusListingScope {
|
||||
case "all", "namespace":
|
||||
default:
|
||||
failures = append(failures, fmt.Errorf("topdata.wiki.status_listing_scope %q is not supported", effective.TopData.Wiki.StatusListingScope))
|
||||
}
|
||||
for key, policy := range map[string]string{
|
||||
"topdata.wiki.stale_pages.default": effective.TopData.Wiki.StalePages.Default,
|
||||
"topdata.wiki.stale_pages.live_cleanup": effective.TopData.Wiki.StalePages.LiveCleanup,
|
||||
|
||||
@@ -278,6 +278,7 @@ topdata:
|
||||
deploy_manifest: wiki-manifest.json
|
||||
deploy_edit_summary: Custom summary
|
||||
title_prefix_min_length: 4
|
||||
status_listing_scope: namespace
|
||||
stale_pages:
|
||||
default: report
|
||||
live_cleanup: archive
|
||||
@@ -361,6 +362,9 @@ autogen:
|
||||
if got, want := effective.TopData.Wiki.TitlePrefixMinLength, 4; got != want {
|
||||
t.Fatalf("expected wiki title prefix minimum length %d, got %d", want, got)
|
||||
}
|
||||
if got, want := effective.TopData.Wiki.StatusListingScope, "namespace"; got != want {
|
||||
t.Fatalf("expected wiki status listing scope %q, got %q", want, got)
|
||||
}
|
||||
if got, want := effective.Autogen.Cache.MaxAge, "30m"; got != want {
|
||||
t.Fatalf("expected autogen cache max age %q, got %q", want, got)
|
||||
}
|
||||
@@ -866,13 +870,14 @@ func TestValidateLayoutRejectsInvalidTopDataWikiConfig(t *testing.T) {
|
||||
TopData: TopDataConfig{
|
||||
Source: "topdata",
|
||||
Wiki: TopDataWikiConfig{
|
||||
Source: "../wiki",
|
||||
Renderer: "dokuwiki",
|
||||
LinkStrategy: "rewrite_links",
|
||||
NamespacesFile: "../namespaces.yaml",
|
||||
TablesFile: "../tables.yaml",
|
||||
TemplatesDir: ".",
|
||||
ManualSectionsDir: "../manual",
|
||||
Source: "../wiki",
|
||||
Renderer: "dokuwiki",
|
||||
LinkStrategy: "rewrite_links",
|
||||
StatusListingScope: "global",
|
||||
NamespacesFile: "../namespaces.yaml",
|
||||
TablesFile: "../tables.yaml",
|
||||
TemplatesDir: ".",
|
||||
ManualSectionsDir: "../manual",
|
||||
StalePages: TopDataWikiStalePagesConfig{
|
||||
Default: "delete",
|
||||
LiveCleanup: "delete",
|
||||
@@ -890,6 +895,7 @@ func TestValidateLayoutRejectsInvalidTopDataWikiConfig(t *testing.T) {
|
||||
"topdata.wiki.source",
|
||||
"topdata.wiki.renderer",
|
||||
"topdata.wiki.link_strategy",
|
||||
"topdata.wiki.status_listing_scope",
|
||||
"topdata.wiki.namespaces_file",
|
||||
"topdata.wiki.tables_file",
|
||||
"topdata.wiki.templates_dir",
|
||||
|
||||
Reference in New Issue
Block a user