Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/handlers/generic/mutation/mirrors/containerd_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func generateContainerdDefaultHostsFile(
inputs = append(inputs, input)
}

if len(inputs) == 0 {
return nil, nil
}

var b bytes.Buffer
err := containerdDefaultHostsConfigurationTemplate.Execute(&b, inputs)
if err != nil {
Expand Down
10 changes: 1 addition & 9 deletions pkg/handlers/generic/mutation/mirrors/containerd_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,7 @@ func Test_generateContainerdDefaultHostsFile(t *testing.T) {
CACert: "myregistrycert",
},
},
want: &cabpkv1.File{
Path: "/etc/containerd/certs.d/_default/hosts.toml",
Owner: "",
Permissions: "0600",
Encoding: "",
Append: false,
Content: `
`,
},
want: nil,
wantErr: nil,
},
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/handlers/generic/mutation/mirrors/inject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ var _ = Describe("Generate Global mirror patches", func() {
Operation: "add",
Path: "/spec/template/spec/kubeadmConfigSpec/files",
ValueMatcher: gomega.HaveExactElements(
gomega.HaveKeyWithValue(
"path", "/etc/containerd/certs.d/_default/hosts.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/certs.d/registry.example.com/ca.crt",
),
Expand Down Expand Up @@ -323,9 +320,6 @@ var _ = Describe("Generate Global mirror patches", func() {
Operation: "add",
Path: "/spec/template/spec/files",
ValueMatcher: gomega.HaveExactElements(
gomega.HaveKeyWithValue(
"path", "/etc/containerd/certs.d/_default/hosts.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/certs.d/registry.example.com:5050/ca.crt",
),
Expand Down
Loading