Skip to content

Commit

Permalink
use go template for gitea registry (#345)
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu McCloskey <[email protected]>
  • Loading branch information
nabuskey authored Jul 30, 2024
1 parent 3772620 commit 6ad027c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 4 additions & 6 deletions pkg/kind/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ type IProvider interface {
}

type TemplateConfig struct {
util.CorePackageTemplateConfig
KubernetesVersion string
ExtraPortsMapping []PortMapping
IngressProtocol string
Port string
}

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

var retBuff []byte
if retBuff, err = util.ApplyTemplate(rawConfigTempl, TemplateConfig{
KubernetesVersion: c.kubeVersion,
ExtraPortsMapping: portMappingPairs,
IngressProtocol: c.cfg.Protocol,
Port: c.cfg.Port,
CorePackageTemplateConfig: c.cfg,
KubernetesVersion: c.kubeVersion,
ExtraPortsMapping: portMappingPairs,
}); err != nil {
return []byte{}, err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/kind/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

func TestGetConfig(t *testing.T) {
cluster, err := NewCluster("testcase", "v1.26.3", "", "", "", util.CorePackageTemplateConfig{
Host: "cnoe.localtest.me",
Port: "8443",
})
if err != nil {
Expand Down Expand Up @@ -57,6 +58,7 @@ containerdConfigPatches:
func TestExtraPortMappings(t *testing.T) {

cluster, err := NewCluster("testcase", "v1.26.3", "", "", "22:32222", util.CorePackageTemplateConfig{
Host: "cnoe.localtest.me",
Port: "8443",
})
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kind/resources/kind.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nodes:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: {{ if (eq .IngressProtocol "http") -}} 80 {{- else -}} 443 {{- end }}
- containerPort: {{ if (eq .Protocol "http") -}} 80 {{- else -}} 443 {{- end }}
hostPort: {{ .Port }}
protocol: TCP
{{ range .ExtraPortsMapping -}}
Expand All @@ -21,7 +21,7 @@ nodes:
{{ end }}
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gitea.cnoe.localtest.me:8443"]
endpoint = ["https://gitea.cnoe.localtest.me"]
[plugins."io.containerd.grpc.v1.cri".registry.configs."gitea.cnoe.localtest.me".tls]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gitea.{{ .Host }}:{{ .Port }}"]
endpoint = ["https://gitea.{{ .Host }}"]
[plugins."io.containerd.grpc.v1.cri".registry.configs."gitea.{{ .Host }}".tls]
insecure_skip_verify = true

0 comments on commit 6ad027c

Please sign in to comment.