Skip to content

Commit

Permalink
coredns script should exclude preview versions
Browse files Browse the repository at this point in the history
  • Loading branch information
TiberiuGC committed Jun 7, 2024
1 parent be4a37a commit a33bfab
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/addons/default/scripts/update_coredns_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,33 @@ func getLatestVersion(ctx context.Context, clusterProvider *eks.ClusterProvider,
log.Fatalf("failed calling EKS::DescribeAddonVersions: %v", err)
}

corednsVersions := output.Addons[0].AddonVersions
if len(corednsVersions) == 0 {
if len(output.Addons[0].AddonVersions) == 0 {
return ""
}
var corednsVersions []string
regexpVersion := regexp.MustCompile(`v\d+\.\d+\.\d+-eksbuild\.\d+`)
for _, info := range output.Addons[0].AddonVersions {
if regexpVersion.MatchString(*info.AddonVersion) {
corednsVersions = append(corednsVersions, *info.AddonVersion)
}
}

sort.Slice(corednsVersions, func(i, j int) bool {
vi, err := semver.Parse(trim(*corednsVersions[i].AddonVersion))
vi, err := semver.Parse(trim(corednsVersions[i]))
if err != nil {
log.Fatalf("failed to parse coredns version %s: %v", trim(*corednsVersions[i].AddonVersion), err)
log.Fatalf("failed to parse coredns version %s: %v", trim(corednsVersions[i]), err)
}
vj, err := semver.Parse(trim(*corednsVersions[j].AddonVersion))
vj, err := semver.Parse(trim(corednsVersions[j]))
if err != nil {
log.Fatalf("failed to parse coredns version %s: %v", trim(*corednsVersions[j].AddonVersion), err)
log.Fatalf("failed to parse coredns version %s: %v", trim(corednsVersions[j]), err)
}
if vi.Compare(vj) >= 0 {
return true
}
return false
})

return *corednsVersions[0].AddonVersion
return corednsVersions[0]
}

func replaceCurrentVersionIfOutdated(latestVersion string, kubernetesVersion string) {
Expand Down

0 comments on commit a33bfab

Please sign in to comment.