Compare commits
2 commits
7d8679840a
...
370c3c9a1d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
370c3c9a1d | ||
|
|
46c5d6b3ab |
|
|
@ -241,6 +241,8 @@ func renderDeliveryConfig(dir string, cfg config.Config) error {
|
||||||
"${FORGEJO_BASE_URL}", cfg.Git.BaseURL,
|
"${FORGEJO_BASE_URL}", cfg.Git.BaseURL,
|
||||||
"${WEBHOOK_HOSTNAME}", cfg.Delivery.WebhookHostname,
|
"${WEBHOOK_HOSTNAME}", cfg.Delivery.WebhookHostname,
|
||||||
"${WEBHOOK_PATH}", cfg.Delivery.WebhookPath,
|
"${WEBHOOK_PATH}", cfg.Delivery.WebhookPath,
|
||||||
|
"${TEKTON_CATALOG_REPO_URL}", cfg.Templates.TektonCatalogRepoURL,
|
||||||
|
"${TEKTON_CATALOG_REPO_REF}", cfg.Templates.TektonCatalogRepoRef,
|
||||||
)
|
)
|
||||||
return filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
return filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil || info.IsDir() {
|
if err != nil || info.IsDir() {
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ func TestRenderCiliumConfig(t *testing.T) {
|
||||||
func TestRenderDeliveryConfig(t *testing.T) {
|
func TestRenderDeliveryConfig(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
path := filepath.Join(dir, "webhook.yaml")
|
path := filepath.Join(dir, "webhook.yaml")
|
||||||
if err := os.WriteFile(path, []byte("host: ${WEBHOOK_HOSTNAME}\npath: ${WEBHOOK_PATH}\n"), 0644); err != nil {
|
if err := os.WriteFile(path, []byte("host: ${WEBHOOK_HOSTNAME}\npath: ${WEBHOOK_PATH}\ncatalog: ${TEKTON_CATALOG_REPO_URL}\nref: ${TEKTON_CATALOG_REPO_REF}\n"), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cfg := config.Config{Delivery: config.DeliveryConfig{WebhookHostname: "tekton.example.test", WebhookPath: "/hooks/forgejo"}}
|
cfg := config.Config{Delivery: config.DeliveryConfig{WebhookHostname: "tekton.example.test", WebhookPath: "/hooks/forgejo"}, Templates: config.TemplateConfig{TektonCatalogRepoURL: "https://catalog.example.test/tekton.git", TektonCatalogRepoRef: "release"}}
|
||||||
if err := renderDeliveryConfig(dir, cfg); err != nil {
|
if err := renderDeliveryConfig(dir, cfg); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@ func TestRenderDeliveryConfig(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if strings.Contains(string(content), "${") || !strings.Contains(string(content), "/hooks/forgejo") {
|
if strings.Contains(string(content), "${") || !strings.Contains(string(content), "/hooks/forgejo") || !strings.Contains(string(content), "https://catalog.example.test/tekton.git") || !strings.Contains(string(content), "ref: release") {
|
||||||
t.Fatalf("delivery configuration was not rendered: %s", content)
|
t.Fatalf("delivery configuration was not rendered: %s", content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,12 @@ func applyDefaults(cfg *Config) {
|
||||||
if cfg.Templates.ManifestsRepoRef == "" {
|
if cfg.Templates.ManifestsRepoRef == "" {
|
||||||
cfg.Templates.ManifestsRepoRef = "main"
|
cfg.Templates.ManifestsRepoRef = "main"
|
||||||
}
|
}
|
||||||
|
if cfg.Templates.TektonCatalogRepoURL == "" {
|
||||||
|
cfg.Templates.TektonCatalogRepoURL = "https://github.com/Pingu-Studio/tekton-pipelines.git"
|
||||||
|
}
|
||||||
|
if cfg.Templates.TektonCatalogRepoRef == "" {
|
||||||
|
cfg.Templates.TektonCatalogRepoRef = "main"
|
||||||
|
}
|
||||||
if cfg.Cilium.TrafficInterface == "" {
|
if cfg.Cilium.TrafficInterface == "" {
|
||||||
cfg.Cilium.TrafficInterface = "eth1"
|
cfg.Cilium.TrafficInterface = "eth1"
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +211,7 @@ func Validate(cfg Config) error {
|
||||||
if strings.ContainsAny(cfg.Delivery.WebhookHostname, "/:@?#") || !strings.HasPrefix(cfg.Delivery.WebhookPath, "/") || strings.ContainsAny(cfg.Delivery.WebhookPath, "?#") {
|
if strings.ContainsAny(cfg.Delivery.WebhookHostname, "/:@?#") || !strings.HasPrefix(cfg.Delivery.WebhookPath, "/") || strings.ContainsAny(cfg.Delivery.WebhookPath, "?#") {
|
||||||
return errors.New("delivery webhookHostname must be a hostname and webhookPath must be an absolute path")
|
return errors.New("delivery webhookHostname must be a hostname and webhookPath must be an absolute path")
|
||||||
}
|
}
|
||||||
if cfg.Templates.TalosRepoURL == "" || cfg.Templates.TalosRepoRef == "" || cfg.Templates.CICDRepoURL == "" || cfg.Templates.CICDRepoRef == "" || cfg.Templates.ManifestsRepoURL == "" || cfg.Templates.ManifestsRepoRef == "" {
|
if cfg.Templates.TalosRepoURL == "" || cfg.Templates.TalosRepoRef == "" || cfg.Templates.CICDRepoURL == "" || cfg.Templates.CICDRepoRef == "" || cfg.Templates.ManifestsRepoURL == "" || cfg.Templates.ManifestsRepoRef == "" || cfg.Templates.TektonCatalogRepoURL == "" || cfg.Templates.TektonCatalogRepoRef == "" {
|
||||||
return errors.New("all template repository URLs and refs are required")
|
return errors.New("all template repository URLs and refs are required")
|
||||||
}
|
}
|
||||||
if cfg.Talos.RepoDirName == "" {
|
if cfg.Talos.RepoDirName == "" {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ func TestResolveDefaultsWebhookEndpoint(t *testing.T) {
|
||||||
if cfg.Delivery.WebhookURL() != "https://tekton.example.test/" {
|
if cfg.Delivery.WebhookURL() != "https://tekton.example.test/" {
|
||||||
t.Fatalf("WebhookURL() = %q", cfg.Delivery.WebhookURL())
|
t.Fatalf("WebhookURL() = %q", cfg.Delivery.WebhookURL())
|
||||||
}
|
}
|
||||||
|
if cfg.Templates.TektonCatalogRepoURL != "https://github.com/Pingu-Studio/tekton-pipelines.git" || cfg.Templates.TektonCatalogRepoRef != "main" {
|
||||||
|
t.Fatalf("Tekton catalog defaults = %q@%q", cfg.Templates.TektonCatalogRepoURL, cfg.Templates.TektonCatalogRepoRef)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadRejectsUnknownFields(t *testing.T) {
|
func TestLoadRejectsUnknownFields(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,8 @@ type TemplateConfig struct {
|
||||||
CICDRepoRef string `yaml:"cicdRepoRef"`
|
CICDRepoRef string `yaml:"cicdRepoRef"`
|
||||||
ManifestsRepoURL string `yaml:"manifestsRepoUrl"`
|
ManifestsRepoURL string `yaml:"manifestsRepoUrl"`
|
||||||
ManifestsRepoRef string `yaml:"manifestsRepoRef"`
|
ManifestsRepoRef string `yaml:"manifestsRepoRef"`
|
||||||
|
TektonCatalogRepoURL string `yaml:"tektonCatalogRepoUrl"`
|
||||||
|
TektonCatalogRepoRef string `yaml:"tektonCatalogRepoRef"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CiliumConfig struct {
|
type CiliumConfig struct {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue