mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
go.mod still declared `module github.com/hanzoai/deploy` after the repo was renamed. A Go module path is not cosmetic — it is the resolvable location. So `go get github.com/hanzoai/cd` could not work, and anything importing this module had to spell a name that no longer exists at that address. The build log of v3.6.0 is where it surfaced: the compiler was still emitting github.com/hanzoai/deploy/cmd/cd/commands. 3541 import paths across 690 .go, 19 .proto, 4 .yaml, 3 .sh, 2 .mod, Procfile and Makefile. Plus the 62 ghcr.io/hanzoai/deploy image references, moved to ghcr.io/hanzoai/cd to match hanzo.yml's build target — a distinct string from the module path, replaced separately so neither could clobber the other. go mod tidy clean, CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./... clean. Co-authored-by: Hanzo Dev <[email protected]>
61 lines
2.1 KiB
Go
61 lines
2.1 KiB
Go
package hydrator
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
appv1 "github.com/hanzoai/cd/pkg/apis/application/v1alpha1"
|
|
"github.com/hanzoai/cd/util/git"
|
|
)
|
|
|
|
// HydratorCommitMetadata defines the struct used by both Controller and commitServer
|
|
// to define the templated commit message and the hydrated manifest
|
|
type HydratorCommitMetadata struct {
|
|
RepoURL string `json:"repoURL,omitempty"`
|
|
DrySHA string `json:"drySha,omitempty"`
|
|
Commands []string `json:"commands,omitempty"`
|
|
Author string `json:"author,omitempty"`
|
|
Date string `json:"date,omitempty"`
|
|
// Subject is the subject line of the DRY commit message, i.e. `git show --format=%s`.
|
|
Subject string `json:"subject,omitempty"`
|
|
// Body is the body of the DRY commit message, excluding the subject line, i.e. `git show --format=%b`.
|
|
// Known Argocd- trailers with valid values are removed, but all other trailers are kept.
|
|
Body string `json:"body,omitempty"`
|
|
References []appv1.RevisionReference `json:"references,omitempty"`
|
|
}
|
|
|
|
// GetCommitMetadata takes repo, drySha and commitMetadata and returns a HydratorCommitMetadata which is a
|
|
// common contract controller and commitServer
|
|
func GetCommitMetadata(repoUrl, drySha string, dryCommitMetadata *appv1.RevisionMetadata) (HydratorCommitMetadata, error) { //nolint:revive //FIXME(var-naming)
|
|
author := ""
|
|
message := ""
|
|
date := ""
|
|
var references []appv1.RevisionReference
|
|
if dryCommitMetadata != nil {
|
|
author = dryCommitMetadata.Author
|
|
message = dryCommitMetadata.Message
|
|
if dryCommitMetadata.Date != nil {
|
|
date = dryCommitMetadata.Date.Format(time.RFC3339)
|
|
}
|
|
references = dryCommitMetadata.References
|
|
}
|
|
|
|
subject, body, _ := strings.Cut(message, "\n\n")
|
|
|
|
_, bodyMinusTrailers := git.GetReferences(log.WithFields(log.Fields{"repo": repoUrl, "revision": drySha}), body)
|
|
|
|
hydratorCommitMetadata := HydratorCommitMetadata{
|
|
RepoURL: repoUrl,
|
|
DrySHA: drySha,
|
|
Author: author,
|
|
Subject: subject,
|
|
Body: bodyMinusTrailers,
|
|
Date: date,
|
|
References: references,
|
|
}
|
|
|
|
return hydratorCommitMetadata, nil
|
|
}
|