Skip to content

Commit cb89e6d

Browse files
crenshaw-devenneitex
authored andcommitted
feat(hydrator): commit tracing (argoproj#19441) (argoproj#23361)
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: enneitex <etienne.divet@gmail.com>
1 parent ac9fe7e commit cb89e6d

17 files changed

Lines changed: 2733 additions & 1095 deletions

File tree

assets/swagger.json

Lines changed: 60 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

commitserver/apiclient/commit.pb.go

Lines changed: 96 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

commitserver/commit/commit.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/argoproj/argo-cd/v3/commitserver/apiclient"
1313
"github.com/argoproj/argo-cd/v3/commitserver/metrics"
14+
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
1415
"github.com/argoproj/argo-cd/v3/util/git"
1516
"github.com/argoproj/argo-cd/v3/util/io"
1617
"github.com/argoproj/argo-cd/v3/util/io/files"
@@ -124,7 +125,7 @@ func (s *Service) handleCommitRequest(logCtx *log.Entry, r *apiclient.CommitHydr
124125
}
125126

126127
logCtx.Debug("Writing manifests")
127-
err = WriteForPaths(root, r.Repo.Repo, r.DrySha, r.Paths)
128+
err = WriteForPaths(root, r.Repo.Repo, r.DrySha, r.DryCommitMetadata, r.Paths)
128129
if err != nil {
129130
return "", "", fmt.Errorf("failed to write manifests: %w", err)
130131
}
@@ -211,21 +212,34 @@ func (s *Service) initGitClient(logCtx *log.Entry, r *apiclient.CommitHydratedMa
211212
}
212213

213214
type hydratorMetadataFile struct {
214-
RepoURL string `json:"repoURL"`
215-
DrySHA string `json:"drySha"`
216-
Commands []string `json:"commands"`
215+
RepoURL string `json:"repoURL,omitempty"`
216+
DrySHA string `json:"drySha,omitempty"`
217+
Commands []string `json:"commands,omitempty"`
218+
Author string `json:"author,omitempty"`
219+
Date string `json:"date,omitempty"`
220+
Message string `json:"message,omitempty"`
221+
References []v1alpha1.RevisionReference `json:"references,omitempty"`
217222
}
218223

219224
// TODO: make this configurable via ConfigMap.
220-
var manifestHydrationReadmeTemplate = `
221-
# Manifest Hydration
225+
var manifestHydrationReadmeTemplate = `# Manifest Hydration
222226
223227
To hydrate the manifests in this repository, run the following commands:
224228
225-
` + "```shell\n" + `
229+
` + "```shell" + `
226230
git clone {{ .RepoURL }}
227231
# cd into the cloned directory
228232
git checkout {{ .DrySHA }}
229233
{{ range $command := .Commands -}}
230234
{{ $command }}
231-
{{ end -}}` + "```"
235+
{{ end -}}` + "```" + `
236+
{{ if .References -}}
237+
238+
## References
239+
240+
{{ range $ref := .References -}}
241+
{{ if $ref.Commit -}}
242+
* [{{ $ref.Commit.SHA | mustRegexFind "[0-9a-f]+" | trunc 7 }}]({{ $ref.Commit.RepoURL }}): {{ $ref.Commit.Subject }} ({{ $ref.Commit.Author.Name }} <{{ $ref.Commit.Author.Email }}>)
243+
{{ end -}}
244+
{{ end -}}
245+
{{ end -}}`

commitserver/commit/commit.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ message CommitHydratedManifestsRequest {
1818
string commitMessage = 5;
1919
// Paths contains the paths to write hydrated manifests to, along with the manifests and commands to execute.
2020
repeated PathDetails paths = 6;
21+
// DryCommitMetadata contains metadata about the DRY commit, such as the author and committer.
22+
github.zerozr99.workers.dev.argoproj.argo_cd.v3.pkg.apis.application.v1alpha1.RevisionMetadata dryCommitMetadata = 7;
2123
}
2224

2325
// PathDetails holds information about hydrated manifests to be written to a particular path in the hydrated manifests

0 commit comments

Comments
 (0)