Skip to content

Commit

Permalink
resolving review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohit Sharma committed Oct 16, 2023
1 parent 05a400d commit 936cee1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
_output
/coverage.out
.idea/*
/coverage.out
2 changes: 1 addition & 1 deletion cmd/update-rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Run the command line as:
-o string
Path to export the updated rules to, e.g. -o /tmp/rules.yaml
-remove
Remove old rules to deprecated branch
Remove old rules of deprecated branch
-rules string
[required] URL or Path of the rules file to update rules for, e.g. --rules path/or/url/to/rules/file.yaml
-stderrthreshold value
Expand Down
22 changes: 11 additions & 11 deletions cmd/update-rules/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func parseOptions() options {
var o options
flag.StringVar(&o.branch, "branch", "", "[required] Branch to update rules for, e.g. --branch release-x.yy")
flag.StringVar(&o.rulesFile, "rules", "", "[required] URL or Path of the rules file to update rules for, e.g. --rules path/or/url/to/rules/file.yaml")
flag.BoolVar(&o.remove, "remove", false, "Remove old rules to deprecated branch")
flag.BoolVar(&o.remove, "delete", false, "Remove old rules to deprecated branch")
flag.StringVar(&o.goVersion, "go", "", "Golang version to pin for this branch, e.g. --go 1.16.1")
flag.StringVar(&o.out, "o", "", "Path to export the updated rules to, e.g. -o /tmp/rules.yaml")

Expand All @@ -58,10 +58,10 @@ func parseOptions() options {
update-rules -branch release-1.22 -go 1.17.1 -o /tmp/rules.yaml -rules /go/src/k8s.io/kubernetes/staging/publishing/rules.yaml
# Update rules to remove deprecated branch and export to /tmp/rules.yaml
update-rules -branch release-1.22 -remove true -o /tmp/rules.yaml -rules /go/src/k8s.io/kubernetes/staging/publishing/rules.yaml`
update-rules -branch release-1.22 -delete -o /tmp/rules.yaml -rules /go/src/k8s.io/kubernetes/staging/publishing/rules.yaml`

flag.Usage = func() {
fmt.Fprintf(os.Stdout, "\n Usage: update-rules --branch BRANCH --rules PATHorURL [--go VERSION | -o PATH | -remove true/false]")
fmt.Fprintf(os.Stdout, "\n Usage: update-rules --branch BRANCH --rules PATHorURL [--go VERSION | -o PATH | -delete ]")
fmt.Fprintf(os.Stdout, "\n %s\n\n", examples)
flag.PrintDefaults()
}
Expand Down Expand Up @@ -160,14 +160,14 @@ func UpdateRules(rules *config.RepositoryRules, branch, goVer string, removeRule
break
}
}
for i, br := range r.Branches {
if removeRules && br.Name == branch {
glog.Infof("Will remove rule for %s %s", branch, r.DestinationRepository)
r.Branches = append(r.Branches[:i], r.Branches[i+1:]...)
branchRuleExists = true
break
}
}
//for i, br := range r.Branches {
// if removeRules && br.Name == branch {
// glog.Infof("Will remove rule for %s %s", branch, r.DestinationRepository)
// r.Branches = append(r.Branches[:i], r.Branches[i+1:]...)
// branchRuleExists = true
// break
// }
//}
// new rules, append to destination's branches
if !branchRuleExists {
r.Branches = append(r.Branches, newBranchRule)
Expand Down

0 comments on commit 936cee1

Please sign in to comment.