Skip to content

Commit

Permalink
Merge pull request #1806 from justaugustus/cip-default-dry-run
Browse files Browse the repository at this point in the history
pkg/cip: Use --no-dry-run instead of --dry-run
  • Loading branch information
k8s-ci-robot committed Nov 30, 2020
2 parents e0962dd + 7b1dd7e commit 32f6156
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
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,
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

0 comments on commit 32f6156

Please sign in to comment.