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 1 commit
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
9 changes: 9 additions & 0 deletions pkg/antctl/raw/multicluster/deploy/deploy_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package deploy
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -91,6 +92,9 @@ func createResources(cmd *cobra.Command, apiGroupResources []*restmapper.APIGrou

obj, gvk, err := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme).Decode(rawObj.Raw, nil, nil)
if err != nil {
if string(content) == "Not Found" {
roopeshsn marked this conversation as resolved.
Show resolved Hide resolved
return errors.New("specified version tag is not found")
roopeshsn marked this conversation as resolved.
Show resolved Hide resolved
}
return err
}
unstructuredMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj)
Expand Down Expand Up @@ -169,6 +173,11 @@ func deploy(cmd *cobra.Command, role string, version string, namespace string, f
return err
}
} else {
if version != "latest" {
if !strings.HasPrefix(version, "v") {
version = fmt.Sprintf("v%s", version)
}
}
roopeshsn marked this conversation as resolved.
Show resolved Hide resolved
manifests, err := generateManifests(role, version)
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