Skip to content

Commit 6ad027c

Browse files
authored
use go template for gitea registry (#345)
Signed-off-by: Manabu McCloskey <[email protected]>
1 parent 3772620 commit 6ad027c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

pkg/kind/cluster.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ type IProvider interface {
4646
}
4747

4848
type TemplateConfig struct {
49+
util.CorePackageTemplateConfig
4950
KubernetesVersion string
5051
ExtraPortsMapping []PortMapping
51-
IngressProtocol string
52-
Port string
5352
}
5453

5554
//go:embed resources/*
@@ -89,10 +88,9 @@ func (c *Cluster) getConfig() ([]byte, error) {
8988

9089
var retBuff []byte
9190
if retBuff, err = util.ApplyTemplate(rawConfigTempl, TemplateConfig{
92-
KubernetesVersion: c.kubeVersion,
93-
ExtraPortsMapping: portMappingPairs,
94-
IngressProtocol: c.cfg.Protocol,
95-
Port: c.cfg.Port,
91+
CorePackageTemplateConfig: c.cfg,
92+
KubernetesVersion: c.kubeVersion,
93+
ExtraPortsMapping: portMappingPairs,
9694
}); err != nil {
9795
return []byte{}, err
9896
}

pkg/kind/cluster_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
func TestGetConfig(t *testing.T) {
2020
cluster, err := NewCluster("testcase", "v1.26.3", "", "", "", util.CorePackageTemplateConfig{
21+
Host: "cnoe.localtest.me",
2122
Port: "8443",
2223
})
2324
if err != nil {
@@ -57,6 +58,7 @@ containerdConfigPatches:
5758
func TestExtraPortMappings(t *testing.T) {
5859

5960
cluster, err := NewCluster("testcase", "v1.26.3", "", "", "22:32222", util.CorePackageTemplateConfig{
61+
Host: "cnoe.localtest.me",
6062
Port: "8443",
6163
})
6264
if err != nil {

pkg/kind/resources/kind.yaml.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ nodes:
1111
kubeletExtraArgs:
1212
node-labels: "ingress-ready=true"
1313
extraPortMappings:
14-
- containerPort: {{ if (eq .IngressProtocol "http") -}} 80 {{- else -}} 443 {{- end }}
14+
- containerPort: {{ if (eq .Protocol "http") -}} 80 {{- else -}} 443 {{- end }}
1515
hostPort: {{ .Port }}
1616
protocol: TCP
1717
{{ range .ExtraPortsMapping -}}
@@ -21,7 +21,7 @@ nodes:
2121
{{ end }}
2222
containerdConfigPatches:
2323
- |-
24-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gitea.cnoe.localtest.me:8443"]
25-
endpoint = ["https://gitea.cnoe.localtest.me"]
26-
[plugins."io.containerd.grpc.v1.cri".registry.configs."gitea.cnoe.localtest.me".tls]
24+
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gitea.{{ .Host }}:{{ .Port }}"]
25+
endpoint = ["https://gitea.{{ .Host }}"]
26+
[plugins."io.containerd.grpc.v1.cri".registry.configs."gitea.{{ .Host }}".tls]
2727
insecure_skip_verify = true

0 commit comments

Comments
 (0)