Skip to content

Commit

Permalink
OCM-7264 | fix: Ensured that name is optional when creating a Kubelet…
Browse files Browse the repository at this point in the history
…Config
  • Loading branch information
robpblake committed May 14, 2024
1 parent 643efc6 commit 95238e9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/ocm/kubeletconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ func (c *Client) DeleteKubeletConfig(ctx context.Context, clusterID string) erro

func toOCMKubeletConfig(args KubeletConfigArgs) (*cmv1.KubeletConfig, error) {
builder := &cmv1.KubeletConfigBuilder{}
kubeletConfig, err := builder.PodPidsLimit(args.PodPidsLimit).Name(args.Name).Build()
builder.PodPidsLimit(args.PodPidsLimit)
if args.Name != "" {
builder.Name(args.Name)
}

kubeletConfig, err := builder.Build()
if err != nil {
return nil, err
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/ocm/kubeletconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,29 @@ var _ = Describe("KubeletConfig", Ordered, func() {
"The KubeletConfig with name 'notExisting' does not exist on cluster '%s'", clusterId)))
})
})

Context("toOcmConfig", func() {
It("Sets the name if it has been supplied", func() {
kubeletConfig, err := toOCMKubeletConfig(KubeletConfigArgs{
Name: "testing",
PodPidsLimit: 10000,
})

Expect(err).NotTo(HaveOccurred())
Expect(kubeletConfig.Name()).To(Equal("testing"))
Expect(kubeletConfig.PodPidsLimit()).To(Equal(10000))
})

It("Does not set the name if it has not been supplied", func() {
kubeletConfig, err := toOCMKubeletConfig(KubeletConfigArgs{
PodPidsLimit: 10000,
})

Expect(err).NotTo(HaveOccurred())
Expect(kubeletConfig.Name()).To(BeEmpty())
Expect(kubeletConfig.PodPidsLimit()).To(Equal(10000))
})
})
})

func createKubeletConfig() (string, error) {
Expand Down

0 comments on commit 95238e9

Please sign in to comment.