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]>
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package hook
|
|
|
|
import (
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
|
|
"github.com/hanzoai/cd/gitops-engine/pkg/sync/common"
|
|
helmhook "github.com/hanzoai/cd/gitops-engine/pkg/sync/hook/helm"
|
|
resourceutil "github.com/hanzoai/cd/gitops-engine/pkg/sync/resource"
|
|
)
|
|
|
|
const (
|
|
// HookFinalizer is the finalizer added to hooks to ensure they are deleted only after the sync phase is completed.
|
|
HookFinalizer = "cd.hanzo.ai/hook-finalizer"
|
|
)
|
|
|
|
func HasHookFinalizer(obj *unstructured.Unstructured) bool {
|
|
finalizers := obj.GetFinalizers()
|
|
for _, finalizer := range finalizers {
|
|
if finalizer == HookFinalizer {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func IsHook(obj *unstructured.Unstructured) bool {
|
|
_, ok := obj.GetAnnotations()[common.AnnotationKeyHook]
|
|
if ok {
|
|
return !Skip(obj)
|
|
}
|
|
return helmhook.IsHook(obj)
|
|
}
|
|
|
|
func Skip(obj *unstructured.Unstructured) bool {
|
|
for _, hookType := range Types(obj) {
|
|
if hookType == common.HookTypeSkip {
|
|
return len(Types(obj)) == 1
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func Types(obj *unstructured.Unstructured) []common.HookType {
|
|
var types []common.HookType
|
|
for _, text := range resourceutil.GetAnnotationCSVs(obj, common.AnnotationKeyHook) {
|
|
t, ok := common.NewHookType(text)
|
|
if ok {
|
|
types = append(types, t)
|
|
}
|
|
}
|
|
// we ignore Helm hooks if we have Argo hook
|
|
if len(types) == 0 {
|
|
for _, t := range helmhook.Types(obj) {
|
|
types = append(types, t.HookType())
|
|
}
|
|
}
|
|
return types
|
|
}
|