Skip to content

Commit

Permalink
chore: Use group constants for launch template naming (#6027)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Apr 12, 2024
1 parent 6439883 commit a324f58
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions pkg/providers/launchtemplate/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ import (
"sigs.k8s.io/karpenter/pkg/utils/pretty"
)

const (
launchTemplateNameFormat = "karpenter.k8s.aws/%s"
karpenterManagedTagKey = "karpenter.k8s.aws/cluster"
)
var karpenterManagedTagKey = fmt.Sprintf("%s/cluster", v1beta1.Group)

type Provider interface {
EnsureAll(context.Context, *v1beta1.EC2NodeClass, *corev1beta1.NodeClaim,
Expand Down Expand Up @@ -155,11 +152,7 @@ func (p *DefaultProvider) InvalidateCache(ctx context.Context, ltName string, lt
}

func LaunchTemplateName(options *amifamily.LaunchTemplate) string {
hash, err := hashstructure.Hash(options, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true})
if err != nil {
panic(fmt.Sprintf("hashing launch template, %s", err))
}
return fmt.Sprintf(launchTemplateNameFormat, fmt.Sprint(hash))
return fmt.Sprintf("%s/%d", v1beta1.Group, lo.Must(hashstructure.Hash(options, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true})))
}

func (p *DefaultProvider) createAMIOptions(ctx context.Context, nodeClass *v1beta1.EC2NodeClass, labels, tags map[string]string) (*amifamily.Options, error) {
Expand Down

0 comments on commit a324f58

Please sign in to comment.