-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support yaml output for 'registry list' Signed-off-by: JianMinTang <[email protected]> * Use gofmt to format all code Signed-off-by: JianMinTang <[email protected]> * fix: Support YAML output for additional commands Signed-off-by: JianMinTang <[email protected]> * fix: Support YAML format on artiface and repo command Signed-off-by: JianMinTang <[email protected]> * fix: Implement a generic function to format output Signed-off-by: JianMinTang <[email protected]> * chore: fix the problem about golangci-lint Signed-off-by: JianMinTang <[email protected]> * AutoGenerate credential name in login (#250) * generate credential name Signed-off-by: bupd <[email protected]> * feat: add support for the password-stdin flag in login flow Signed-off-by: karanngi <[email protected]> * fix deps - fixes dependencies Signed-off-by: bupd <[email protected]> * return stdout for tests Signed-off-by: bupd <[email protected]> * update workflow Signed-off-by: bupd <[email protected]> --------- Signed-off-by: bupd <[email protected]> Signed-off-by: karanngi <[email protected]> Co-authored-by: karanngi <[email protected]> Signed-off-by: JianMinTang <[email protected]> * print test output to screen (#254) print test output to screen Signed-off-by: JianMinTang <[email protected]> * Support table format for repo view and add some comments on repo list Signed-off-by: JianMinTang <[email protected]> Add more detail on repo view Signed-off-by: JianMinTang <[email protected]> Support table format on registry view Signed-off-by: JianMinTang <[email protected]> Support table format on project view Signed-off-by: JianMinTang <[email protected]> Fixed tags list Signed-off-by: JianMinTang <[email protected]> Support table format and YAML/JSON output on artifact view Signed-off-by: JianMinTang <[email protected]> Fixed alignment problem Signed-off-by: JianMinTang <[email protected]> Fixed the code format Signed-off-by: JianMinTang <[email protected]> * AutoGenerate credential name in login (#250) * generate credential name Signed-off-by: bupd <[email protected]> * feat: add support for the password-stdin flag in login flow Signed-off-by: karanngi <[email protected]> * fix deps - fixes dependencies Signed-off-by: bupd <[email protected]> * return stdout for tests Signed-off-by: bupd <[email protected]> * update workflow Signed-off-by: bupd <[email protected]> --------- Signed-off-by: bupd <[email protected]> Signed-off-by: karanngi <[email protected]> Co-authored-by: karanngi <[email protected]> Signed-off-by: JianMinTang <[email protected]> * print test output to screen (#254) print test output to screen Signed-off-by: JianMinTang <[email protected]> * Support yaml output for 'registry list' Signed-off-by: JianMinTang <[email protected]> Use gofmt to format all code Signed-off-by: JianMinTang <[email protected]> fix: Support YAML output for additional commands Signed-off-by: JianMinTang <[email protected]> fix: Implement a generic function to format output Signed-off-by: JianMinTang <[email protected]> chore: fix the problem about golangci-lint Signed-off-by: JianMinTang <[email protected]> --------- Signed-off-by: JianMinTang <[email protected]> Signed-off-by: bupd <[email protected]> Signed-off-by: karanngi <[email protected]> Co-authored-by: Prasanth B <[email protected]> Co-authored-by: karanngi <[email protected]> Co-authored-by: Vadim Bauer <[email protected]>
- Loading branch information
1 parent
5bbf322
commit c464871
Showing
28 changed files
with
562 additions
and
178 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 was deleted.
Oops, something went wrong.
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,55 @@ | ||
package artifact | ||
|
||
import ( | ||
"github.com/goharbor/go-client/pkg/sdk/v2.0/client/artifact" | ||
"github.com/goharbor/harbor-cli/pkg/api" | ||
"github.com/goharbor/harbor-cli/pkg/prompt" | ||
"github.com/goharbor/harbor-cli/pkg/utils" | ||
"github.com/goharbor/harbor-cli/pkg/views/artifact/view" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func ViewArtifactCommmand() *cobra.Command { | ||
|
||
cmd := &cobra.Command{ | ||
Use: "view", | ||
Short: "Get information of an artifact", | ||
Long: `Get information of an artifact`, | ||
Example: `harbor artifact view <project>/<repository>/<reference>`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var err error | ||
var projectName, repoName, reference string | ||
var artifact *artifact.GetArtifactOK | ||
|
||
if len(args) > 0 { | ||
projectName, repoName, reference = utils.ParseProjectRepoReference(args[0]) | ||
} else { | ||
projectName = prompt.GetProjectNameFromUser() | ||
repoName = prompt.GetRepoNameFromUser(projectName) | ||
reference = prompt.GetReferenceFromUser(repoName, projectName) | ||
} | ||
|
||
artifact, err = api.ViewArtifact(projectName, repoName, reference) | ||
|
||
if err != nil { | ||
log.Errorf("failed to get info of an artifact: %v", err) | ||
} | ||
|
||
FormatFlag := viper.GetString("output-format") | ||
if FormatFlag != "" { | ||
err = utils.PrintFormat(artifact, FormatFlag) | ||
if err != nil { | ||
log.Error(err) | ||
return | ||
} | ||
} else { | ||
view.ViewArtifact(artifact.Payload) | ||
} | ||
|
||
}, | ||
} | ||
|
||
return cmd | ||
} |
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
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.