Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix antctl mc deploy command usage #6287

Merged
merged 3 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/antctl/raw/multicluster/deploy/deploy_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ var getAPIGroupResources = getAPIGroupResourcesWrapper

func generateManifests(role string, version string) ([]string, error) {
var manifests []string
if version != "latest" && !strings.HasPrefix(version, "v") {
version = fmt.Sprintf("v%s", version)
}
switch role {
case leaderRole:
manifests = []string{
Expand Down Expand Up @@ -176,6 +179,9 @@ func deploy(cmd *cobra.Command, role string, version string, namespace string, f
for _, manifest := range manifests {
// #nosec G107
resp, err := httpGet(manifest)
if resp.StatusCode == 404 {
return fmt.Errorf("manifest %s not found", manifest)
}
if err != nil {
return err
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/antctl/raw/multicluster/deploy/deploy_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ func TestGenerateManifests(t *testing.T) {
"https://github.com/antrea-io/antrea/releases/download/v1.14.0/antrea-multicluster-member.yml",
},
},
{
name: "generate versioned leader manifests without the prefix v in the version",
role: "leader",
version: "1.14.0",
expectedManifests: []string{
"https://github.com/antrea-io/antrea/releases/download/v1.14.0/antrea-multicluster-leader.yml",
},
},
{
name: "generate versioned member manifests without the prefix v in the version",
role: "member",
version: "1.14.0",
expectedManifests: []string{
"https://github.com/antrea-io/antrea/releases/download/v1.14.0/antrea-multicluster-member.yml",
},
},
{
name: "invalid role",
role: "member1",
Expand Down
Loading