Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/cip: Use --no-dry-run instead of --dry-run #1806

Merged
merged 1 commit into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/cip/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var (

type RootOptions struct {
LogLevel string
DryRun bool
Version bool
}

Expand Down
17 changes: 9 additions & 8 deletions pkg/cip/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type RunOptions struct {
Threads int
MaxImageSize int
SeverityThreshold int
DryRun bool
NoDryRun bool
JSONLogSummary bool
ParseOnly bool
MinimalSnapshot bool
Expand Down Expand Up @@ -142,7 +142,7 @@ func RunPromoteCmd(opts *RunOptions) error {
sc, err = reg.MakeSyncContext(
mfests,
opts.Threads,
opts.DryRun,
opts.NoDryRun,
opts.UseServiceAcct,
)
if err != nil {
Expand All @@ -159,8 +159,9 @@ func RunPromoteCmd(opts *RunOptions) error {
sc, err = reg.MakeSyncContext(
mfests,
opts.Threads,
opts.DryRun,
opts.UseServiceAcct)
opts.NoDryRun,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure what does that function expects, but if it takes dryRun, shouldn’t we also invert it here?

For example, if takes dryRun and it is dryRun, noDryRun would be set to false, so this function would run as noDryRun instead of dryRun.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opts.UseServiceAcct,
)
if err != nil {
logrus.Fatal(err)
}
Expand Down Expand Up @@ -211,7 +212,7 @@ So a 'fixable' vulnerability may not necessarily be immediately actionable. For
example, even though a fixed version of the binary is available, it doesn't
necessarily mean that a new version of the image layer is available.`,
)
} else if opts.DryRun {
} else if !opts.NoDryRun {
logrus.Info("********** START (DRY RUN) **********")
} else {
logrus.Info("********** START **********")
Expand Down Expand Up @@ -250,7 +251,7 @@ necessarily mean that a new version of the image layer is available.`,
sc, err = reg.MakeSyncContext(
mfests,
opts.Threads,
opts.DryRun,
opts.NoDryRun,
opts.UseServiceAcct,
)
if err != nil {
Expand Down Expand Up @@ -303,7 +304,7 @@ necessarily mean that a new version of the image layer is available.`,
}

// Check the pull request
if opts.DryRun {
if !opts.NoDryRun {
err = sc.RunChecks([]reg.PreCheck{})
if err != nil {
return errors.Wrap(err, "running prechecks before promotion")
Expand Down Expand Up @@ -364,7 +365,7 @@ necessarily mean that a new version of the image layer is available.`,
// nolint: gocritic
if opts.SeverityThreshold >= 0 {
logrus.Info("********** FINISHED (VULN CHECK) **********")
} else if opts.DryRun {
} else if !opts.NoDryRun {
logrus.Info("********** FINISHED (DRY RUN) **********")
} else {
logrus.Info("********** FINISHED **********")
Expand Down
18 changes: 9 additions & 9 deletions pkg/cip/dockerregistry/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func GetSrcRegistry(rcs []RegistryContext) (*RegistryContext, error) {
func MakeSyncContext(
mfests []Manifest,
threads int,
dryRun, useSvcAcc bool,
noDryRun, useSvcAcc bool,
) (SyncContext, error) {
sc := SyncContext{
Threads: threads,
DryRun: dryRun,
NoDryRun: noDryRun,
UseServiceAccount: useSvcAcc,
Inv: make(MasterInventory),
InvIgnore: []ImageName{},
Expand Down Expand Up @@ -1959,7 +1959,7 @@ func MKPopulateRequestsForPromotionEdges(
return
}

if sc.DryRun {
if !sc.NoDryRun {
logrus.Info("---------- BEGIN PROMOTION (DRY RUN) ----------")
} else {
logrus.Info("---------- BEGIN PROMOTION ----------")
Expand Down Expand Up @@ -2220,7 +2220,7 @@ func (sc *SyncContext) Promote(

captured := make(CapturedRequests)

if sc.DryRun {
if !sc.NoDryRun {
processRequestDryRun := MkRequestCapturer(&captured)
processRequest = processRequestDryRun
} else {
Expand All @@ -2233,7 +2233,7 @@ func (sc *SyncContext) Promote(

err := sc.ExecRequests(populateRequests, processRequest)

if sc.DryRun {
if !sc.NoDryRun {
sc.PrintCapturedRequests(&captured)
}

Expand Down Expand Up @@ -2405,7 +2405,7 @@ func (sc *SyncContext) GarbageCollect(

captured := make(CapturedRequests)

if sc.DryRun {
if !sc.NoDryRun {
processRequestDryRun := MkRequestCapturer(&captured)
processRequest = processRequestDryRun
} else {
Expand All @@ -2421,7 +2421,7 @@ func (sc *SyncContext) GarbageCollect(
logrus.Info(err)
}

if sc.DryRun {
if !sc.NoDryRun {
sc.PrintCapturedRequests(&captured)
}
}
Expand Down Expand Up @@ -2529,7 +2529,7 @@ func (sc *SyncContext) ClearRepository(

captured := make(CapturedRequests)

if sc.DryRun {
if !sc.NoDryRun {
processRequestDryRun := MkRequestCapturer(&captured)
processRequest = processRequestDryRun
} else {
Expand Down Expand Up @@ -2566,7 +2566,7 @@ func (sc *SyncContext) ClearRepository(
logrus.Info(err)
}

if sc.DryRun {
if !sc.NoDryRun {
sc.PrintCapturedRequests(&captured)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cip/dockerregistry/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type CollectedLogs struct {
// SyncContext is the main data structure for performing the promotion.
type SyncContext struct {
Threads int
DryRun bool
NoDryRun bool
UseServiceAccount bool
Inv MasterInventory
InvIgnore []ImageName
Expand Down