Files
zeekayandHanzo Dev dead2da249 cd: the configuration speaks CD_ and KV_
The fork was already ours everywhere that matters — our image, our IAM (dex
is not deployed), hanzo kv behind what the env still called REDIS. Only the
vocabulary was upstream's: ARGOCD_* across the Go, the manifests, the docs
and the plugin contract, and mkdocs still titled 'Argo CD' pointing at
argoproj/argo-cd.

ARGOCD_ -> CD_ and REDIS_ -> KV_ across 345 files, plus the 8 e2e/cmp
fixtures that assert the plugin env contract — those had to move with the
binary, which now emits CD_APP_NAME where they expected ARGOCD_APP_NAME.

Left alone deliberately, because renaming them would be wrong:
- util/helm/testdata/redis/ and gitops-engine/.../statefulset*.yaml are
  fixtures for a THIRD-PARTY chart named redis, not our config
- util/kustomize/testdata/ likewise
- generated.proto regenerates from types.go, which is already clean

go build ./... exit 0.

LOCKSTEP: the live StatefulSet sets 47 ARGOCD_* names the binary no longer
reads. universe 4a5375735 carries the matching manifest change; they deploy
together or the controller falls back to defaults.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-28 15:55:46 -07:00

126 lines
4.6 KiB
Go

package v1alpha1
import (
"errors"
"fmt"
)
type SourceIntegrity struct {
// Git - policies for git source verification
Git *SourceIntegrityGit `json:"git" protobuf:"bytes,1,name=git"` // A mandatory field until there are alternatives
}
type SourceIntegrityGit struct {
Policies []*SourceIntegrityGitPolicy `json:"policies" protobuf:"bytes,1,name=policies"`
}
type SourceIntegrityGitPolicy struct {
// List of repository criteria restricting repositories the policy will apply to
Repos []SourceIntegrityGitPolicyRepo `json:"repos" protobuf:"bytes,1,name=repos"`
// Verify GPG commit/tag signatures
GPG *SourceIntegrityGitPolicyGPG `json:"gpg" protobuf:"bytes,2,name=gpg"` // A mandatory field until there are alternatives
}
type SourceIntegrityGitPolicyRepo struct {
// URL specifier, glob.
URL string `json:"url" protobuf:"bytes,1,name=url"`
}
type SourceIntegrityGitPolicyGPGMode string
var (
// SourceIntegrityGitPolicyGPGModeNone performs no verification at all. This is useful for troubleshooting.
SourceIntegrityGitPolicyGPGModeNone SourceIntegrityGitPolicyGPGMode = "none"
// SourceIntegrityGitPolicyGPGModeHead verifies the current target revision, an annotated tag, or a commit.
SourceIntegrityGitPolicyGPGModeHead SourceIntegrityGitPolicyGPGMode = "head"
// SourceIntegrityGitPolicyGPGModeStrict verifies all ancestry of target revision all the way to git init or seal commits.
// If pointing to an annotated tag, it verifies both the tag signature and the commit history.
SourceIntegrityGitPolicyGPGModeStrict SourceIntegrityGitPolicyGPGMode = "strict"
)
// SourceIntegrityGitPolicyGPG verifies that the commit(s) are both correctly signed by a key in the repo-server keyring,
// and that they are signed by one of the key listed in Keys.
//
// This policy can be deactivated through the CD_GPG_ENABLED environment variable.
//
// Note the listing of problematic commits/signatures reported when "strict" mode validation fails may not be complete.
// This means that a user that has addressed all problems reported by source integrity check can run into
// further problematic signatures on a subsequent attempt. That happens namely when history contains seal commits signed
// with gpg keys that are in the keyring, but not listed in Keys.
type SourceIntegrityGitPolicyGPG struct {
Mode SourceIntegrityGitPolicyGPGMode `json:"mode" protobuf:"bytes,1,name=mode"`
// List of key IDs to trust. The keys need to be in the repository server keyring.
Keys []string `json:"keys" protobuf:"bytes,3,name=keys"`
}
// CacheKey computes a unique string key to be used for caching.
// The key's value will change if any of the fields in SourceIntegrity change.
func (s *SourceIntegrity) CacheKey() string {
return s.String()
}
// SourceIntegrityCheckResult represents a conclusion of the SourceIntegrity evaluation.
// Each check performed on a source(es), holds a check item representing all checks performed.
type SourceIntegrityCheckResult struct {
// Checks holds a list of checks performed, with their eventual problems. If a check is not specified here,
// it means it was not performed.
Checks []SourceIntegrityCheckResultItem `protobuf:"bytes,1,opt,name=checks"`
}
type SourceIntegrityCheckResultItem struct {
// Name of the check that is human-understandable pointing out to the kind of verification performed.
Name string `protobuf:"bytes,1,name=name"`
// Problems is a list of messages explaining why the check failed. Empty list means the check has succeeded.
Problems []string `protobuf:"bytes,2,name=problems"`
}
func (r *SourceIntegrityCheckResult) PassedChecks() (names []string) {
names = []string{}
for _, item := range r.Checks {
if len(item.Problems) == 0 {
names = append(names, item.Name)
}
}
return names
}
func (r *SourceIntegrityCheckResult) AsError() error {
if r == nil {
return nil
}
var errs []error
for _, check := range r.Checks {
for _, p := range check.Problems {
errs = append(errs, fmt.Errorf("%s: %s", check.Name, p))
}
}
if len(errs) > 0 {
return errors.Join(errs...)
}
return nil
}
// IsValid reports if some of the performed checks had any problem
func (r *SourceIntegrityCheckResult) IsValid() bool {
for _, item := range r.Checks {
if len(item.Problems) > 0 {
return false
}
}
return true
}
// InjectSourceName updates the names of the checks with a new prefix. This is to distinguish results reported when
// checking multiple sources.
func (r *SourceIntegrityCheckResult) InjectSourceName(sourceName string) {
if r == nil {
return
}
for chi, check := range r.Checks {
for pi, problem := range check.Problems {
r.Checks[chi].Problems[pi] = fmt.Sprintf("%s: %s", sourceName, problem)
}
}
}