Add support for incremental stamping#175
Conversation
skylib/kustomize/kustomize.bzl
Outdated
| variables = "--variable=NAMESPACE={namespace}".format( | ||
| namespace = namespace, | ||
| ) | ||
| variables += " --variable=GIT_REVISION=\"$(git rev-parse HEAD)\"" |
There was a problem hiding this comment.
We should not do stamping of stamps in .show and .apply commands.
- The git command will not work because the current directory is not the source directory.
- We will be breaking the idempotency properties of
.showandapplycommands, which is no backward compatible behavior change.
| dryRun = flag.Bool("dry_run", false, "Do not create PRs, just print what would be done") | ||
| stamp = flag.Bool("stamp", false, "Stamp results of gitops targets with volatile information") |
There was a problem hiding this comment.
| dryRun = flag.Bool("dry_run", false, "Do not create PRs, just print what would be done") | |
| stamp = flag.Bool("stamp", false, "Stamp results of gitops targets with volatile information") | |
| stamp = flag.Bool("stamp", false, "Stamp results of gitops targets with volatile information") | |
| dryRun = flag.Bool("dry_run", false, "Do not create PRs, just print what would be done") |
Historically we kept dryRun as a last argument definition.
gitops/git/git.go
Outdated
| } | ||
|
|
||
| // split by newline and ignore empty strings | ||
| func SplitFunc(c rune) bool { |
There was a problem hiding this comment.
This function doesn't seem to belong to the public interface of git module. Please make it private or inline.
gitops/git/git.go
Outdated
| if err != nil { | ||
| log.Fatalf("ERROR: %s", err) | ||
| } | ||
| return strings.FieldsFunc(files, SplitFunc) |
There was a problem hiding this comment.
I'd prefer the use of the Scanner. While it will be more verbose it will be more obvious what empty lines re not returned.
var files []string
sc := bufio.NewScanner(strings.NewReader(s))
for sc.Scan() {
files = append(files, sc.Text())
}
return lines
gitops/git/git.go
Outdated
| } | ||
|
|
||
| // RemoveDiff removes the changes made to a specific file in the repository | ||
| func (r *Repo) RemoveDiff(fileName string) { |
There was a problem hiding this comment.
| func (r *Repo) RemoveDiff(fileName string) { | |
| func (r *Repo) RestoreFile(fileName string) { |
Align with the terminology used by Git. For example:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/index.ts
gitops/prer/create_gitops_prs.go
Outdated
| return qr | ||
| } | ||
|
|
||
| func getContext(workdir *git.Repo, branchName string) map[string]interface{} { |
There was a problem hiding this comment.
| func getContext(workdir *git.Repo, branchName string) map[string]interface{} { | |
| func getGitStatusDict(workdir *git.Repo, branchName string) map[string]interface{} { |
getContext is too generic.
gitops/prer/create_gitops_prs.go
Outdated
|
|
||
| ctx := getContext(workdir, branchName) | ||
|
|
||
| stampedTemplate := fasttemplate.ExecuteString(string(template), "{{", "}}", ctx) |
There was a problem hiding this comment.
fasttemplate.Execute function writes directly into file.
| stampedTemplate := fasttemplate.ExecuteString(string(template), "{{", "}}", ctx) | |
| outf, err = os.OpenFile(fullPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, perm) | |
| if err != nil { | |
| log.Fatalf("Unable to create output file %s: %v", output, err) | |
| } | |
| defer outf.Close() | |
| _, err = fasttemplate.Execute(string(template), "{{", "}}", ctx) |
Description
Modify the
create_gitops_prutility to optionally implement the following algorithm:service.yamlfile is an output of theservice.gitopstargetservice.gitops>service.yamlservice.yamldigest >service.yaml.digestservice.yaml.digestare the same as those committed into gitservice.yaml.digestfileservice.yamlservice.yaml.digestandservice.yamlRelated Issue
Motivation and Context
The existing GitOps PR process creates a new GitOps PR when a ConfigMap object that exposes a volatile file changes even if the deployment artifact doesn't change.
How Has This Been Tested?
Types of changes
Checklist: