Skip to content

Cleanup unused etcd-init-container related Code #6972

@zhzhuang-zju

Description

@zhzhuang-zju

Task description:
We removed the InitContainer for karmada-etcd in #6637, and marked the etcd-init-image flag deprecated in #6942. It is time to clean up the unused leftover code about setting the etcd init image during the process of karmadactl init.

Solution:
Here are the leftover code blocks:

func TestEtcdInitImage(t *testing.T) {
tests := []struct {
name string
opt *CommandInitOption
expected string
}{
{
name: "ImageRegistry is set and EtcdInitImage is set to default value",
opt: &CommandInitOption{
ImageRegistry: "my-registry",
EtcdInitImage: DefaultInitImage,
},
expected: "my-registry/alpine:3.21.3",
},
{
name: "EtcdInitImage is set to a non-default value",
opt: &CommandInitOption{
EtcdInitImage: "my-etcd-init-image",
},
expected: "my-etcd-init-image",
},
{
name: "ImageRegistry is not set and EtcdInitImage is set to default value",
opt: &CommandInitOption{
EtcdInitImage: DefaultInitImage,
},
expected: DefaultInitImage,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := tt.opt.etcdInitImage()
if result != tt.expected {
t.Errorf("Unexpected result: %s, expected: %s", result, tt.expected)
}
})
}
}

// get etcd-init image
func (i *CommandInitOption) etcdInitImage() string {
if i.ImageRegistry != "" && i.EtcdInitImage == DefaultInitImage {
return i.ImageRegistry + "/alpine:3.21.3"
}
return i.EtcdInitImage
}

setIfNotEmpty(&i.EtcdInitImage, localEtcd.InitImage.GetImage())

InitImage: config.Image{
Repository: "init-image",
Tag: "latest",
},

assert.Equal(t, "init-image:latest", opt.EtcdInitImage)

Who can join or take the task:

The good first issue is intended for first-time contributors to get started on his/her contributor journey.

After a contributor has successfully completed 1-2 good first issue's,
they should be ready to move on to help wanted items, saving the remaining good first issue for other new contributors.

How to join or take the task:

Just reply on the issue with the message /assign in a separate line.

Then, the issue will be assigned to you.

How to ask for help:

If you need help or have questions, please feel free to ask on this issue.
The issue author or other members of the community will guide you through the contribution process.

Metadata

Metadata

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions