Skip to content

Commit

Permalink
Remove unnecessary args from tink annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mitalipaygude committed Feb 15, 2024
1 parent d42b907 commit fa06540
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/api/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ func (c *Cluster) ClearTinkerbellIPAnnotation() {
}

// HasTinkerbellIPAnnotation returns the tinkerbell IP value if the annotation exists.
func (c *Cluster) HasTinkerbellIPAnnotation() (string, bool) {
func (c *Cluster) HasTinkerbellIPAnnotation() string {
if tinkerbellIP, ok := c.Annotations[tinkerbellIPAnnotation]; ok {
return tinkerbellIP, true
return tinkerbellIP
}
return "", false
return ""
}

// RegistryAuth returns whether registry requires authentication or not.
Expand Down
7 changes: 3 additions & 4 deletions pkg/api/v1alpha1/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1624,14 +1624,13 @@ func TestClusterClearTinkerbellIPAnnotation(t *testing.T) {
},
}
c.AddTinkerbellIPAnnotation("1.1.1.1")
val, ok := c.HasTinkerbellIPAnnotation()
val := c.HasTinkerbellIPAnnotation()

g.Expect(ok).To(BeTrue())
g.Expect(val).To(ContainSubstring("1.1.1.1"))

c.ClearTinkerbellIPAnnotation()
_, ok = c.Annotations[tinkerbellIPAnnotation]
g.Expect(ok).To(BeFalse())
val = c.Annotations[tinkerbellIPAnnotation]
g.Expect(val).To(BeEmpty())
}

func TestGitOpsEquals(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/providers/tinkerbell/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (p *Provider) BootstrapClusterOpts(_ *cluster.Spec) ([]bootstrapper.Bootstr
func (p *Provider) PreCAPIInstallOnBootstrap(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error {
logger.V(4).Info("Installing Tinkerbell stack on bootstrap cluster")

// We add this annotation to pass the admin machine URL to the controller for cluster creation.
logger.V(4).Info("Adding annotation for tinkerbell ip on bootstrap cluster")
clusterSpec.Cluster.AddTinkerbellIPAnnotation(p.tinkerbellIP)
versionsBundle := clusterSpec.RootVersionsBundle()
Expand Down
4 changes: 2 additions & 2 deletions pkg/providers/tinkerbell/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (tb *TemplateBuilder) GenerateCAPISpecControlPlane(clusterSpec *cluster.Spe
}
var OSImageURL string

if tinkerbellIP, ok := clusterSpec.Cluster.HasTinkerbellIPAnnotation(); ok {
if tinkerbellIP := clusterSpec.Cluster.HasTinkerbellIPAnnotation(); tinkerbellIP != "" {
tb.tinkerbellIP = tinkerbellIP
}

Expand Down Expand Up @@ -127,7 +127,7 @@ func (tb *TemplateBuilder) GenerateCAPISpecWorkers(clusterSpec *cluster.Spec, wo
bundle := clusterSpec.RootVersionsBundle()
OSImageURL := clusterSpec.TinkerbellDatacenter.Spec.OSImageURL

if tinkerbellIP, ok := clusterSpec.Cluster.HasTinkerbellIPAnnotation(); ok {
if tinkerbellIP := clusterSpec.Cluster.HasTinkerbellIPAnnotation(); tinkerbellIP != "" {
tb.tinkerbellIP = tinkerbellIP
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/workflows/management/create_install_eksa.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (s *installEksaComponentsOnBootstrapTask) Checkpoint() *task.CompletedTask
type installEksaComponentsOnWorkloadTask struct{}

func (s *installEksaComponentsOnWorkloadTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task {
// Removes the tinkerbell IP annotation added to the spec for controller based cluster creation. This
// helps use the right admin machine URL for hegel URLS.
if commandContext.ClusterSpec.Cluster.Spec.DatacenterRef.Kind == v1alpha1.TinkerbellDatacenterKind {
logger.Info("Removing Tinkerbell IP annotation")
commandContext.ClusterSpec.Cluster.ClearTinkerbellIPAnnotation()
Expand Down

0 comments on commit fa06540

Please sign in to comment.