-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install: Add a hidden --base-version flag
The --version flag doesn't always maps to a Cilium version. For example, Cilium CI jobs use commit SHAs as image tags. This flag allows you to explicitly provide the "base" Cilium version being installed so that the install command can configure Cilium accordingly. Signed-off-by: Michi Mutsuzaki <[email protected]>
- Loading branch information
1 parent
01bed3a
commit 8ed8abb
Showing
5 changed files
with
89 additions
and
7 deletions.
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
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,61 @@ | ||
// Copyright 2020-2021 Authors of Cilium | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package install | ||
|
||
import ( | ||
"io" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/blang/semver/v4" | ||
) | ||
|
||
func TestK8sInstaller_getCiliumVersion(t *testing.T) { | ||
type fields struct{ params Parameters } | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want semver.Version | ||
}{ | ||
{ | ||
name: "default", | ||
fields: fields{Parameters{Writer: io.Discard}}, | ||
want: semver.Version{Major: 1, Minor: 10, Patch: 0}, | ||
}, | ||
{ | ||
name: "version", | ||
fields: fields{Parameters{Writer: io.Discard, Version: "v1.10.3"}}, | ||
want: semver.Version{Major: 1, Minor: 10, Patch: 3}, | ||
}, | ||
{ | ||
name: "base-version", | ||
fields: fields{Parameters{Writer: io.Discard, Version: "random-version-string", BaseVersion: "v1.9.8"}}, | ||
want: semver.Version{Major: 1, Minor: 9, Patch: 8}, | ||
}, | ||
{ | ||
name: "random-version-without-base-version", | ||
fields: fields{Parameters{Writer: io.Discard, Version: "random-version-string"}}, | ||
want: semver.Version{Major: 1, Minor: 10, Patch: 0}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
k := &K8sInstaller{params: tt.fields.params} | ||
if got := k.getCiliumVersion(); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("getCiliumVersion() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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