Skip to content

Commit

Permalink
changed artifact tags list cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Althaf66 authored Dec 8, 2024
1 parent 2191907 commit c2ea66b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cmd/harbor/root/artifact/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func ScanArtifactCommand() *cobra.Command {
Use: "scan",
Short: "Scan an artifact",
Long: `Scan an artifact in Harbor Repository`,
Example: `harbor artifact scan start <project>/<repository>/<reference>`,
Example: `harbor artifact scan start <project>/<repository>@<reference>`,
}

cmd.AddCommand(
Expand All @@ -30,7 +30,7 @@ func StartScanArtifactCommand() *cobra.Command {
Use: "start",
Short: "Start a scan of an artifact",
Long: `Start a scan of an artifact in Harbor Repository`,
Example: `harbor artifact scan start <project>/<repository>/<reference>`,
Example: `harbor artifact scan start <project>/<repository>@<reference>`,
Run: func(cmd *cobra.Command, args []string) {
var err error

Expand All @@ -56,7 +56,7 @@ func StopScanArtifactCommand() *cobra.Command {
Use: "stop",
Short: "Stop a scan of an artifact",
Long: `Stop a scan of an artifact in Harbor Repository`,
Example: `harbor artifact scan stop <project>/<repository>/<reference>`,
Example: `harbor artifact scan stop <project>/<repository>@<reference>`,
Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
6 changes: 0 additions & 6 deletions pkg/api/artifact_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func DeleteArtifact(projectName, repoName, reference string) error {
Reference: reference,
})
if err != nil {
log.Errorf("Failed to delete artifact: %v", err)
return err
}

Expand All @@ -44,7 +43,6 @@ func ViewArtifact(projectName, repoName, reference string) (*artifact.GetArtifac
})

if err != nil {
log.Errorf("Failed to get artifact info: %v", err)
return response, err
}

Expand Down Expand Up @@ -90,7 +88,6 @@ func StartScanArtifact(projectName, repoName, reference string) error {
Reference: reference,
})
if err != nil {
log.Errorf("Failed to start scan: %v", err)
return err
}

Expand All @@ -111,7 +108,6 @@ func StopScanArtifact(projectName, repoName, reference string) error {
Reference: reference,
})
if err != nil {
log.Errorf("Failed to stop scan: %v", err)
return err
}

Expand All @@ -133,7 +129,6 @@ func DeleteTag(projectName, repoName, reference, tag string) error {
TagName: tag,
})
if err != nil {
log.Errorf("Failed to delete tag: %v", err)
return err
}

Expand Down Expand Up @@ -182,7 +177,6 @@ func CreateTag(projectName, repoName, reference, tagName string) error {
},
})
if err != nil {
log.Errorf("Failed to create tag: %v", err)
return err
}
log.Infof("Tag created successfully: %s/%s@%s:%s", projectName, repoName, reference, tagName)
Expand Down
10 changes: 6 additions & 4 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ func ParseProjectRepo(projectRepo string) (string, string) {
}

func ParseProjectRepoReference(projectRepoReference string) (string, string, string) {
split := strings.Split(projectRepoReference, "/")
if len(split) != 3 {
log.Fatalf("invalid project/repository/reference format: %s", projectRepoReference)
projectname := strings.Split(projectRepoReference, "/")
reponame := strings.Split(projectname[1], "@")
referencename := strings.Split(projectname[1], "@")
if len(projectname) != 2 && len(reponame) != 2 && len(referencename) != 2 {
log.Fatalf("invalid project/repository@reference format: %s", projectRepoReference)
}
return split[0], split[1], split[2]
return projectname[0], reponame[0], referencename[1]
}

func SanitizeServerAddress(server string) string {
Expand Down

0 comments on commit c2ea66b

Please sign in to comment.