Skip to content

Commit

Permalink
Improve register example UX, Moved from argument to version flag. (#222)
Browse files Browse the repository at this point in the history
* fix flytesnacks register version

Signed-off-by: Yuvraj <[email protected]>
  • Loading branch information
yindia authored Nov 30, 2021
1 parent 8d2b83b commit b09e206
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion flytectl/cmd/config/subcommand/register/files_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package register

var (
DefaultFilesConfig = &FilesConfig{
Version: "v1",
Version: "",
ContinueOnError: false,
}
)
Expand Down
10 changes: 3 additions & 7 deletions flytectl/cmd/register/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const (
Registers all latest flytesnacks example
::
bin/flytectl register examples -d development -p flytesnacks
bin/flytectl register examples -d development -p flytesnacks
Registers specific release of flytesnacks example
::
bin/flytectl register examples -d development -p flytesnacks v0.2.176
bin/flytectl register examples -d development -p flytesnacks --version v0.2.176
Note: register command automatically override the version with release version
Usage
Expand All @@ -37,15 +37,11 @@ var (

func registerExamplesFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) error {
var examples []github.ReleaseAsset
var release string

// Deprecated checks for --k8Service
deprecatedCheck(ctx, &rconfig.DefaultFilesConfig.K8sServiceAccount, rconfig.DefaultFilesConfig.K8ServiceAccount)

if len(args) == 1 {
release = args[0]
}
examples, tag, err := getAllFlytesnacksExample(githubOrg, flytesnacksRepository, release)
examples, tag, err := getAllFlytesnacksExample(githubOrg, flytesnacksRepository, rconfig.DefaultFilesConfig.Version)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions flytectl/cmd/register/register_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,15 @@ func filterExampleFromRelease(releases github.RepositoryRelease) []github.Releas
return assets
}

func getAllFlytesnacksExample(org, repository, release string) ([]github.ReleaseAsset, string, error) {
func getAllFlytesnacksExample(org, repository, version string) ([]github.ReleaseAsset, string, error) {
c := github.NewClient(nil)
opt := &github.ListOptions{Page: 1, PerPage: 1}
if len(release) > 0 {
releases, _, err := c.Repositories.GetReleaseByTag(context.Background(), org, repository, release)
if len(version) > 0 {
releases, _, err := c.Repositories.GetReleaseByTag(context.Background(), org, repository, version)
if err != nil {
return nil, "", err
}
return filterExampleFromRelease(*releases), release, nil
return filterExampleFromRelease(*releases), version, nil
}
releases, _, err := c.Repositories.ListReleases(context.Background(), org, repository, opt)
if err != nil {
Expand Down

0 comments on commit b09e206

Please sign in to comment.