Skip to content

Commit

Permalink
Fix antctl mc deploy command usage (#6287)
Browse files Browse the repository at this point in the history
This patch ensures that v is optional in version tag and improved error
message if specified version tag is not found.

Signed-off-by: Roopesh Saravanan <[email protected]>
  • Loading branch information
roopeshsn authored May 11, 2024
1 parent 7753d7f commit 4ec2bdd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit 4ec2bdd

Please sign in to comment.