-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): Add kubernetes version to coredns version mapping (#939)
Added script and makefile target to update coredns version mapping. `make coredns.sync` will fetch the list of releases from upstream release branches and create a mapping of k8s versions to coredns versions.
- Loading branch information
1 parent
adf8a6a
commit 4751e3c
Showing
8 changed files
with
556 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2024 Nutanix. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package versions | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestReturnsCorrectCoreDNSVersionForValidKubernetesVersion(t *testing.T) { | ||
version, found := GetCoreDNSVersion("v1.27") | ||
assert.True(t, found) | ||
assert.Equal(t, "v1.10.1", version) | ||
} | ||
|
||
func TestReturnsCorrectCoreDNSVersionForValidKubernetesVersionWithoutVPrefix(t *testing.T) { | ||
version, found := GetCoreDNSVersion("1.27") | ||
assert.True(t, found) | ||
assert.Equal(t, "v1.10.1", version) | ||
} | ||
|
||
func TestReturnsFalseForInvalidKubernetesVersion(t *testing.T) { | ||
version, found := GetCoreDNSVersion("v2.99") | ||
assert.False(t, found) | ||
assert.Equal(t, "", version) | ||
} | ||
|
||
func TestReturnsFalseForMalformedKubernetesVersion(t *testing.T) { | ||
version, found := GetCoreDNSVersion("invalid-version") | ||
assert.False(t, found) | ||
assert.Equal(t, "", version) | ||
} | ||
|
||
func TestReturnsCorrectMappingForGetKubernetesToCoreDNSVersionMap(t *testing.T) { | ||
mapping := GetKubernetesToCoreDNSVersionMap() | ||
expected := map[string]string{ | ||
"v1.22": "v1.8.4", | ||
"v1.23": "v1.8.6", | ||
"v1.24": "v1.8.6", | ||
"v1.25": "v1.9.3", | ||
"v1.26": "v1.9.3", | ||
"v1.27": "v1.10.1", | ||
"v1.28": "v1.10.1", | ||
"v1.29": "v1.11.1", | ||
"v1.30": "v1.11.3", | ||
"v1.31": "v1.11.3", | ||
} | ||
assert.Equal(t, expected, mapping) | ||
} |
Oops, something went wrong.