Skip to content

Commit a844bf3

Browse files
committed
rename command to move
Signed-off-by: Dentrax <furkan.turkal@chainguard.dev>
1 parent 3eeddb4 commit a844bf3

File tree

4 files changed

+28
-34
lines changed

4 files changed

+28
-34
lines changed
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
## wolfictl advisory stream
1+
## wolfictl advisory move
22

3-
Start version streaming for a package by moving its advisories into a new package.
3+
Move a package's advisories into a new package.
44

5-
***Aliases**: stream*
5+
***Aliases**: mv*
66

77
### Usage
88

99
```
10-
wolfictl advisory stream <package-name> <version-streamed-package-name>
10+
wolfictl advisory move <old-package-name> <new-package-name>
1111
```
1212

1313
### Synopsis
1414

15-
Start version streaming for a package by moving its advisories into a new package.
15+
Move a package's advisories into a new package.
1616

1717
This command will move most advisories for the given package into a new package. And rename the
1818
package to the new package name. (i.e., from foo.advisories.yaml to foo-X.Y.advisories.yaml) If the
1919
target file already exists, the command will try to merge the advisories. To ensure the advisories
2020
are up-to-date, the command will start a scan for the new package.
2121

22+
This command is also useful to start version streaming for an existing package that has not been
23+
version streamed before. Especially that requires manual intervention to move the advisories.
24+
2225
The command will move the latest event for each advisory, and will update the timestamp
2326
of the event to now. The command will not copy events of type "detection", "fixed",
2427
"analysis_not_planned", or "fix_not_planned".
@@ -28,7 +31,7 @@ of the event to now. The command will not copy events of type "detection", "fixe
2831

2932
```
3033
-d, --dir string directory containing the advisories to copy (default ".")
31-
-h, --help help for stream
34+
-h, --help help for move
3235
```
3336

3437
### Options inherited from parent commands
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1-
.TH "WOLFICTL\-ADVISORY\-STREAM" "1" "" "Auto generated by spf13/cobra" ""
1+
.TH "WOLFICTL\-ADVISORY\-MOVE" "1" "" "Auto generated by spf13/cobra" ""
22
.nh
33
.ad l
44

55

66
.SH NAME
77
.PP
8-
wolfictl\-advisory\-stream \- Start version streaming for a package by moving its advisories into a new package.
8+
wolfictl\-advisory\-move \- Move a package's advisories into a new package.
99

1010

1111
.SH SYNOPSIS
1212
.PP
13-
\fBwolfictl advisory stream <package-name> <version-streamed-package-name>\fP
13+
\fBwolfictl advisory move <old-package-name> <new-package-name>\fP
1414

1515

1616
.SH DESCRIPTION
1717
.PP
18-
Start version streaming for a package by moving its advisories into a new package.
18+
Move a package's advisories into a new package.
1919

2020
.PP
2121
This command will move most advisories for the given package into a new package. And rename the
2222
package to the new package name. (i.e., from foo.advisories.yaml to foo\-X.Y.advisories.yaml) If the
2323
target file already exists, the command will try to merge the advisories. To ensure the advisories
2424
are up\-to\-date, the command will start a scan for the new package.
2525

26+
.PP
27+
This command is also useful to start version streaming for an existing package that has not been
28+
version streamed before. Especially that requires manual intervention to move the advisories.
29+
2630
.PP
2731
The command will move the latest event for each advisory, and will update the timestamp
2832
of the event to now. The command will not copy events of type "detection", "fixed",
@@ -36,7 +40,7 @@ of the event to now. The command will not copy events of type "detection", "fixe
3640

3741
.PP
3842
\fB\-h\fP, \fB\-\-help\fP[=false]
39-
help for stream
43+
help for move
4044

4145

4246
.SH OPTIONS INHERITED FROM PARENT COMMANDS

pkg/cli/advisory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func cmdAdvisory() *cobra.Command {
4848
cmdAdvisorySecDB(),
4949
cmdAdvisoryUpdate(),
5050
cmdAdvisoryValidate(),
51-
cmdAdvisoryStream(),
51+
cmdAdvisoryMove(),
5252
)
5353

5454
return cmd
Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@ package cli
22

33
import (
44
"fmt"
5-
"regexp"
65
"strings"
76

87
"github.com/spf13/cobra"
98
v2 "github.com/wolfi-dev/wolfictl/pkg/configs/advisory/v2"
109
rwos "github.com/wolfi-dev/wolfictl/pkg/configs/rwfs/os"
1110
)
1211

13-
func cmdAdvisoryStream() *cobra.Command {
12+
func cmdAdvisoryMove() *cobra.Command {
1413
var dir string
1514
cmd := &cobra.Command{
16-
Use: "stream <package-name> <version-streamed-package-name>",
17-
Aliases: []string{"stream"},
18-
Short: "Start version streaming for a package by moving its advisories into a new package.",
19-
Long: `Start version streaming for a package by moving its advisories into a new package.
15+
Use: "move <old-package-name> <new-package-name>",
16+
Aliases: []string{"mv"},
17+
Short: "Move a package's advisories into a new package.",
18+
Long: `Move a package's advisories into a new package.
2019
2120
This command will move most advisories for the given package into a new package. And rename the
2221
package to the new package name. (i.e., from foo.advisories.yaml to foo-X.Y.advisories.yaml) If the
2322
target file already exists, the command will try to merge the advisories. To ensure the advisories
2423
are up-to-date, the command will start a scan for the new package.
2524
25+
This command is also useful to start version streaming for an existing package that has not been
26+
version streamed before. Especially that requires manual intervention to move the advisories.
27+
2628
The command will move the latest event for each advisory, and will update the timestamp
2729
of the event to now. The command will not copy events of type "detection", "fixed",
2830
"analysis_not_planned", or "fix_not_planned".
@@ -36,10 +38,6 @@ of the event to now. The command will not copy events of type "detection", "fixe
3638
have = strings.TrimSuffix(have, ".advisories.yaml")
3739
want = strings.TrimSuffix(want, ".advisories.yaml")
3840

39-
if err := checkPackageHasVersionStreamSuffix(want); err != nil {
40-
return err
41-
}
42-
4341
advisoryFsys := rwos.DirFS(dir)
4442
advisoryCfgs, err := v2.NewIndex(ctx, advisoryFsys)
4543
if err != nil {
@@ -71,8 +69,7 @@ of the event to now. The command will not copy events of type "detection", "fixe
7169
havePath := have + ".advisories.yaml"
7270
wantPath := want + ".advisories.yaml"
7371

74-
// If automation already created the new advisory file before manual version streaming,
75-
// respect the existing file and merge the advisories to it.
72+
// If the new file already exists, merge the old advisories to it and re-create.
7673
if shouldMergeExistings {
7774
newDoc := newEntry.Configuration()
7875

@@ -102,16 +99,6 @@ of the event to now. The command will not copy events of type "detection", "fixe
10299
return cmd
103100
}
104101

105-
// checkPackageHasVersionStreamSuffix ensures the package name has the "-X" or "-X.Y" suffix.
106-
// X and Y are positive integers.
107-
func checkPackageHasVersionStreamSuffix(pkg string) error {
108-
re := regexp.MustCompile(`-\d+(\.\d+)?$`)
109-
if re.MatchString(pkg) {
110-
return nil
111-
}
112-
return fmt.Errorf("new package name %q does not have the version stream suffix", pkg)
113-
}
114-
115102
// mergeExistingAdvisories merges the current advisories with the existing advisories.
116103
func mergeExistingAdvisories(current, existing v2.Advisories) v2.Advisories {
117104
res := make(v2.Advisories, 0, len(current)+len(existing))

0 commit comments

Comments
 (0)