Skip to content

Commit 355d77c

Browse files
Merge branch 'feat/job-service-dashboard' of github.com:NishchayRajput/harbor-cli into feat/job-service-dashboard
2 parents 092f9d1 + d398093 commit 355d77c

29 files changed

Lines changed: 1206 additions & 320 deletions

.github/dependabot.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
version: 2
22
updates:
3-
- package-ecosystem: gomod
3+
- package-ecosystem: "gomod"
44
directory: "/"
55
schedule:
6-
interval: weekly
6+
interval: "weekly"
7+
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

MAINTAINERS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Maintainers
2+
3+
This file lists the current sub-project maintainers for `harbor-cli`.
4+
5+
## Current maintainers
6+
7+
- Vadim Bauer (`@Vad1mo`)
8+
- Prasanth Baskar (`@bupd`)
9+
- Patrick Eschenbach (`@qcserestipy`)
10+
- Nucleo Fusion (`@NucleoFusion`)

cmd/harbor/root/artifact/cmd.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ package artifact
1515

1616
import (
1717
"github.com/goharbor/harbor-cli/cmd/harbor/root/artifact/label"
18+
artifactscan "github.com/goharbor/harbor-cli/cmd/harbor/root/artifact/scan"
19+
artifacttags "github.com/goharbor/harbor-cli/cmd/harbor/root/artifact/tags"
1820
"github.com/spf13/cobra"
1921
)
2022

@@ -30,8 +32,8 @@ func Artifact() *cobra.Command {
3032
ListArtifactCommand(),
3133
ViewArtifactCommmand(),
3234
DeleteArtifactCommand(),
33-
ScanArtifactCommand(),
34-
ArtifactTagsCmd(),
35+
artifactscan.ScanArtifactCommand(),
36+
artifacttags.ArtifactTagsCmd(),
3537
label.LabelsArtifactCommmand(),
3638
)
3739

cmd/harbor/root/artifact/scan.go

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package artifactscan
15+
16+
import (
17+
"github.com/goharbor/harbor-cli/pkg/prompt"
18+
"github.com/goharbor/harbor-cli/pkg/utils"
19+
"github.com/spf13/cobra"
20+
)
21+
22+
func ScanArtifactCommand() *cobra.Command {
23+
cmd := &cobra.Command{
24+
Use: "scan",
25+
Short: "Scan an artifact",
26+
Long: `Scan an artifact in Harbor Repository`,
27+
Example: `harbor artifact scan start <project>/<repository>/<reference>`,
28+
}
29+
30+
cmd.AddCommand(
31+
StartScanArtifactCommand(),
32+
StopScanArtifactCommand(),
33+
// LogScanArtifactCommand(),
34+
)
35+
36+
return cmd
37+
}
38+
39+
func parseArgs(args []string) (string, string, string, error) {
40+
if len(args) > 0 {
41+
return utils.ParseProjectRepoReference(args[0])
42+
} else {
43+
projectName, err := prompt.GetProjectNameFromUser()
44+
if err != nil {
45+
return "", "", "", err
46+
}
47+
repoName := prompt.GetRepoNameFromUser(projectName)
48+
reference := prompt.GetReferenceFromUser(repoName, projectName)
49+
50+
return projectName, repoName, reference, nil
51+
}
52+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package artifactscan
15+
16+
import (
17+
"fmt"
18+
19+
"github.com/goharbor/harbor-cli/pkg/api"
20+
"github.com/spf13/cobra"
21+
)
22+
23+
func StartScanArtifactCommand() *cobra.Command {
24+
cmd := &cobra.Command{
25+
Use: "start",
26+
Short: "Start a scan of an artifact",
27+
Long: `Start a scan of an artifact in Harbor Repository`,
28+
Example: `harbor artifact scan start <project>/<repository>/<reference>`,
29+
RunE: func(cmd *cobra.Command, args []string) error {
30+
projectName, repoName, reference, err := parseArgs(args)
31+
if err != nil {
32+
return err
33+
}
34+
35+
err = api.StartScanArtifact(projectName, repoName, reference)
36+
if err != nil {
37+
return fmt.Errorf("failed to start scan of artifact: %v", err)
38+
}
39+
return nil
40+
},
41+
}
42+
return cmd
43+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package artifactscan
15+
16+
import (
17+
"fmt"
18+
19+
"github.com/goharbor/harbor-cli/pkg/api"
20+
"github.com/spf13/cobra"
21+
)
22+
23+
func StopScanArtifactCommand() *cobra.Command {
24+
cmd := &cobra.Command{
25+
Use: "stop",
26+
Short: "Stop a scan of an artifact",
27+
Long: `Stop a scan of an artifact in Harbor Repository`,
28+
Example: `harbor artifact scan stop <project>/<repository>/<reference>`,
29+
RunE: func(cmd *cobra.Command, args []string) error {
30+
projectName, repoName, reference, err := parseArgs(args)
31+
if err != nil {
32+
return err
33+
}
34+
35+
err = api.StopScanArtifact(projectName, repoName, reference)
36+
if err != nil {
37+
return fmt.Errorf("failed to stop scan of artifact: %v", err)
38+
}
39+
40+
return nil
41+
},
42+
}
43+
return cmd
44+
}

0 commit comments

Comments
 (0)