diff --git a/go.mod b/go.mod index b8d094a65..ba0e4d45e 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/nmstate/kubernetes-nmstate/api v0.0.0-20240605150941-df565dd7bf35 github.com/onsi/ginkgo/v2 v2.20.2 github.com/onsi/gomega v1.34.2 - github.com/openshift-kni/eco-goinfra v0.0.0-20241220182656-f51076771e09 // latest + github.com/openshift-kni/eco-goinfra v0.0.0-20241223124842-6085a8f8e55d // latest github.com/openshift-kni/k8sreporter v1.0.6 github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible github.com/openshift/cluster-nfd-operator v0.0.0-20240902145504-f70d1389d329 // release-4.17 diff --git a/go.sum b/go.sum index 8a96cf171..b64b33fc9 100644 --- a/go.sum +++ b/go.sum @@ -1257,8 +1257,8 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20240918194836-a0a3f896c283 h1:KGQuA0R53YMHkUVWVK5NcFKixjTXB/vaQswcwt3Pdy0= github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20240918194836-a0a3f896c283/go.mod h1:TYB+3zGmMhqOmyZ6FCbtNZSndvRDcfh16U7wgYGpe/8= -github.com/openshift-kni/eco-goinfra v0.0.0-20241220182656-f51076771e09 h1:JyZaEMYXAHwtLuSzI7/t/zgSrEy7Kk689x9/uxthx5c= -github.com/openshift-kni/eco-goinfra v0.0.0-20241220182656-f51076771e09/go.mod h1:T51OM/Mq7OogaCm7rBxdaaCrK8iXVh4E3FlEv8v90B4= +github.com/openshift-kni/eco-goinfra v0.0.0-20241223124842-6085a8f8e55d h1:sE7I27w79uhfyGzsnH8QBQ2JSEPc/sglWuaK8lY/0AI= +github.com/openshift-kni/eco-goinfra v0.0.0-20241223124842-6085a8f8e55d/go.mod h1:T51OM/Mq7OogaCm7rBxdaaCrK8iXVh4E3FlEv8v90B4= github.com/openshift-kni/k8sreporter v1.0.6 h1:aaxDzZx3s9bo1I3nopR63RGVZxcJgR94j5X87aDihYo= github.com/openshift-kni/k8sreporter v1.0.6/go.mod h1:tX6LOg0m0oXje7WNLFo8LKHC9Ix8VV0a7vUc6eyeFBQ= github.com/openshift-kni/lifecycle-agent v0.0.0-20241002223755-1e32b456449f h1:2k35EoDXvfOx/pgQKaBp2DkbBvMUBi+LuGATTH0El+U= diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/common/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/common/zz_generated.deepcopy.go index 470339848..5eb27ce23 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/common/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/common/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright 2020. @@ -67,7 +66,8 @@ func (in ValidationsStatus) DeepCopyInto(out *ValidationsStatus) { if val == nil { (*out)[key] = nil } else { - in, out := &val, &outVal + inVal := (*in)[key] + in, out := &inVal, &outVal *out = make(ValidationResults, len(*in)) copy(*out, *in) } diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/hiveextension/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/hiveextension/v1beta1/zz_generated.deepcopy.go index a0639afc7..e49df4b78 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/hiveextension/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/hiveextension/v1beta1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright 2020. @@ -205,7 +204,8 @@ func (in *AgentClusterInstallStatus) DeepCopyInto(out *AgentClusterInstallStatus if val == nil { (*out)[key] = nil } else { - in, out := &val, &outVal + inVal := (*in)[key] + in, out := &inVal, &outVal *out = make(common.ValidationResults, len(*in)) copy(*out, *in) } diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/v1beta1/zz_generated.deepcopy.go index 9454edccc..99612daae 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/assisted/api/v1beta1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright 2020. @@ -402,7 +401,8 @@ func (in *AgentStatus) DeepCopyInto(out *AgentStatus) { if val == nil { (*out)[key] = nil } else { - in, out := &val, &outVal + inVal := (*in)[key] + in, out := &inVal, &outVal *out = make(common.ValidationResults, len(*in)) copy(*out, *in) } diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_conditions.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_conditions.go index 16dd152d4..7c20133b3 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_conditions.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_conditions.go @@ -38,6 +38,7 @@ const ( RenderedTemplates ClusterInstanceConditionType = "RenderedTemplates" RenderedTemplatesValidated ClusterInstanceConditionType = "RenderedTemplatesValidated" RenderedTemplatesApplied ClusterInstanceConditionType = "RenderedTemplatesApplied" + RenderedTemplatesDeleted ClusterInstanceConditionType = "RenderedTemplatesDeleted" ClusterProvisioned ClusterInstanceConditionType = "Provisioned" ) diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_types.go index 0e86a8710..052c93032 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_types.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_types.go @@ -402,11 +402,14 @@ type ClusterInstanceSpec struct { } const ( - ManifestRenderedSuccess = "rendered" - ManifestRenderedFailure = "failed" - ManifestRenderedValidated = "validated" - ManifestSuppressed = "suppressed" - ManifestPruneFailure = "pruning-attempt-failed" + ManifestRenderedSuccess = "rendered" + ManifestRenderedFailure = "failed" + ManifestRenderedValidated = "validated" + ManifestSuppressed = "suppressed" + ManifestDeleted = "deleted" + ManifestDeletionInProgress = "deletion-in-progress" + ManifestDeletionFailure = "deletion-failed" + ManifestDeletionTimedOut = "deletion-attempt-timed-out" ) // ManifestReference contains enough information to let you locate the diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_utils.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_utils.go index a21f973e6..fd6539bef 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_utils.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/siteconfig/v1alpha1/clusterinstance_utils.go @@ -16,6 +16,13 @@ limitations under the License. package v1alpha1 +import ( + "fmt" + "strings" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + // ExtraAnnotationSearch Looks up a specific manifest Annotation for this cluster func (c *ClusterInstanceSpec) ExtraAnnotationSearch(kind string) (map[string]string, bool) { annotations, ok := c.ExtraAnnotations[kind] @@ -45,3 +52,56 @@ func (node *NodeSpec) ExtraLabelSearch(kind string, cluster *ClusterInstanceSpec } return cluster.ExtraLabelSearch(kind) } + +// MatchesIdentity checks if two ManifestReference objects are equal based on identifying fields. +// These fields are APIGroup, Kind, Name, and Namespace. +func (m *ManifestReference) MatchesIdentity(other *ManifestReference) bool { + if m == nil || other == nil { + return false + } + + // Safely compare APIGroup pointers + APIGroupMatches := m.APIGroup == nil && other.APIGroup == nil || + m.APIGroup != nil && other.APIGroup != nil && *m.APIGroup == *other.APIGroup + + // Compare identifying fields + return APIGroupMatches && + m.Kind == other.Kind && + m.Name == other.Name && + m.Namespace == other.Namespace +} + +func (m *ManifestReference) UpdateStatus(status, message string) { + if m.Status != status || m.Message != message { + m.Status = status + m.Message = message + m.LastAppliedTime = metav1.Now() + } +} + +// String generates a Kubernetes style resource path string from the ManifestReference object +func (m *ManifestReference) String() string { + apiGroup := "" + if m.APIGroup != nil && *m.APIGroup != "" { + apiGroup = fmt.Sprintf(".%s", *m.APIGroup) + } + + // Handle Namespace if present + if m.Namespace != "" { + return fmt.Sprintf("%s%s/namespaces/%s/%s", strings.ToLower(m.Kind), apiGroup, m.Namespace, m.Name) + } + + // Return without Namespace if it is empty + return fmt.Sprintf("%s%s/%s", strings.ToLower(m.Kind), apiGroup, m.Name) +} + +// IndexOfManifestByIdentity searches for a ManifestReference in the given list based on identity fields +// and returns its index. It returns -1 and a not found error if the target is not found. +func IndexOfManifestByIdentity(target *ManifestReference, manifestRefs []ManifestReference) (int, error) { + for i, ref := range manifestRefs { + if ref.MatchesIdentity(target) { + return i, nil + } + } + return -1, fmt.Errorf("ManifestReference (%s) not found", target.String()) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 7071d3379..cd19170bd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -564,7 +564,7 @@ github.com/opencontainers/runtime-spec/specs-go ## explicit; go 1.22.0 github.com/openshift-kni/cluster-group-upgrades-operator/pkg/api/clustergroupupgrades github.com/openshift-kni/cluster-group-upgrades-operator/pkg/api/clustergroupupgrades/v1alpha1 -# github.com/openshift-kni/eco-goinfra v0.0.0-20241220182656-f51076771e09 +# github.com/openshift-kni/eco-goinfra v0.0.0-20241223124842-6085a8f8e55d ## explicit; go 1.23 github.com/openshift-kni/eco-goinfra/pkg/apiservers github.com/openshift-kni/eco-goinfra/pkg/argocd