Files
zeekayandHanzo Dev 1ab6e799c1 cd: the module is github.com/hanzoai/cd, where it is actually hosted
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]>
2026-07-28 21:16:24 -07:00

69 lines
2.0 KiB
Go

package diff
import (
"github.com/hanzoai/cd/pkg/apis/application/v1alpha1"
"github.com/hanzoai/cd/util/cd/normalizers"
"github.com/hanzoai/cd/gitops-engine/pkg/diff"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
// Normalize applies the full normalization on the lives and configs resources based
// on the provided DiffConfig.
func Normalize(lives, configs []*unstructured.Unstructured, diffConfig DiffConfig) (*NormalizationResult, error) {
result, err := preDiffNormalize(lives, configs, diffConfig)
if err != nil {
return nil, err
}
diffNormalizer, err := newDiffNormalizer(diffConfig.Ignores(), diffConfig.Overrides(), diffConfig.IgnoreNormalizerOpts())
if err != nil {
return nil, err
}
for _, live := range result.Lives {
if live != nil {
err = diffNormalizer.Normalize(live)
if err != nil {
return nil, err
}
}
}
for _, target := range result.Targets {
if target != nil {
err = diffNormalizer.Normalize(target)
if err != nil {
return nil, err
}
}
}
return result, nil
}
// newDiffNormalizer creates normalizer that uses Hanzo CD and application settings to normalize the resource prior to diffing.
func newDiffNormalizer(ignore []v1alpha1.ResourceIgnoreDifferences, overrides map[string]v1alpha1.ResourceOverride, opts normalizers.IgnoreNormalizerOpts) (diff.Normalizer, error) {
ignoreNormalizer, err := normalizers.NewIgnoreNormalizer(ignore, overrides, opts)
if err != nil {
return nil, err
}
knownTypesNorm, err := normalizers.NewKnownTypesNormalizer(overrides)
if err != nil {
return nil, err
}
return &composableNormalizer{normalizers: []diff.Normalizer{ignoreNormalizer, knownTypesNorm}}, nil
}
type composableNormalizer struct {
normalizers []diff.Normalizer
}
// Normalize performs resource normalization.
func (n *composableNormalizer) Normalize(un *unstructured.Unstructured) error {
for i := range n.normalizers {
if err := n.normalizers[i].Normalize(un); err != nil {
return err
}
}
return nil
}