Add gvk to rest of api type
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
@@ -25,8 +25,9 @@ import (
|
|||||||
// notificationv1.Alert
|
// notificationv1.Alert
|
||||||
|
|
||||||
var alertType = apiType{
|
var alertType = apiType{
|
||||||
kind: notificationv1.AlertKind,
|
kind: notificationv1.AlertKind,
|
||||||
humanKind: "alert",
|
humanKind: "alert",
|
||||||
|
groupVersion: notificationv1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type alertAdapter struct {
|
type alertAdapter struct {
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ import (
|
|||||||
// notificationv1.Provider
|
// notificationv1.Provider
|
||||||
|
|
||||||
var alertProviderType = apiType{
|
var alertProviderType = apiType{
|
||||||
kind: notificationv1.ProviderKind,
|
kind: notificationv1.ProviderKind,
|
||||||
humanKind: "alert provider",
|
humanKind: "alert provider",
|
||||||
|
groupVersion: notificationv1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type alertProviderAdapter struct {
|
type alertProviderAdapter struct {
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ import (
|
|||||||
// helmv2.HelmRelease
|
// helmv2.HelmRelease
|
||||||
|
|
||||||
var helmReleaseType = apiType{
|
var helmReleaseType = apiType{
|
||||||
kind: helmv2.HelmReleaseKind,
|
kind: helmv2.HelmReleaseKind,
|
||||||
humanKind: "helmreleases",
|
humanKind: "helmrelease",
|
||||||
|
groupVersion: helmv2.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type helmReleaseAdapter struct {
|
type helmReleaseAdapter struct {
|
||||||
|
|||||||
@@ -30,8 +30,9 @@ import (
|
|||||||
// imagev1.ImageRepository
|
// imagev1.ImageRepository
|
||||||
|
|
||||||
var imageRepositoryType = apiType{
|
var imageRepositoryType = apiType{
|
||||||
kind: imagev1.ImageRepositoryKind,
|
kind: imagev1.ImageRepositoryKind,
|
||||||
humanKind: "image repository",
|
humanKind: "image repository",
|
||||||
|
groupVersion: imagev1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type imageRepositoryAdapter struct {
|
type imageRepositoryAdapter struct {
|
||||||
@@ -63,8 +64,9 @@ func (a imageRepositoryListAdapter) len() int {
|
|||||||
// imagev1.ImagePolicy
|
// imagev1.ImagePolicy
|
||||||
|
|
||||||
var imagePolicyType = apiType{
|
var imagePolicyType = apiType{
|
||||||
kind: imagev1.ImagePolicyKind,
|
kind: imagev1.ImagePolicyKind,
|
||||||
humanKind: "image policy",
|
humanKind: "image policy",
|
||||||
|
groupVersion: imagev1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type imagePolicyAdapter struct {
|
type imagePolicyAdapter struct {
|
||||||
@@ -92,8 +94,9 @@ func (a imagePolicyListAdapter) len() int {
|
|||||||
// autov1.ImageUpdateAutomation
|
// autov1.ImageUpdateAutomation
|
||||||
|
|
||||||
var imageUpdateAutomationType = apiType{
|
var imageUpdateAutomationType = apiType{
|
||||||
kind: autov1.ImageUpdateAutomationKind,
|
kind: autov1.ImageUpdateAutomationKind,
|
||||||
humanKind: "image update automation",
|
humanKind: "image update automation",
|
||||||
|
groupVersion: autov1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type imageUpdateAutomationAdapter struct {
|
type imageUpdateAutomationAdapter struct {
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ import (
|
|||||||
// kustomizev1.Kustomization
|
// kustomizev1.Kustomization
|
||||||
|
|
||||||
var kustomizationType = apiType{
|
var kustomizationType = apiType{
|
||||||
kind: kustomizev1.KustomizationKind,
|
kind: kustomizev1.KustomizationKind,
|
||||||
humanKind: "kustomizations",
|
humanKind: "kustomization",
|
||||||
|
groupVersion: kustomizev1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type kustomizationAdapter struct {
|
type kustomizationAdapter struct {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import (
|
|||||||
// implementation can pick whichever it wants to use.
|
// implementation can pick whichever it wants to use.
|
||||||
type apiType struct {
|
type apiType struct {
|
||||||
kind, humanKind string
|
kind, humanKind string
|
||||||
|
groupVersion schema.GroupVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// adapter is an interface for a wrapper or alias from which we can
|
// adapter is an interface for a wrapper or alias from which we can
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ import (
|
|||||||
// notificationv1.Receiver
|
// notificationv1.Receiver
|
||||||
|
|
||||||
var receiverType = apiType{
|
var receiverType = apiType{
|
||||||
kind: notificationv1.ReceiverKind,
|
kind: notificationv1.ReceiverKind,
|
||||||
humanKind: "receiver",
|
humanKind: "receiver",
|
||||||
|
groupVersion: notificationv1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type receiverAdapter struct {
|
type receiverAdapter struct {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/client-go/util/retry"
|
"k8s.io/client-go/util/retry"
|
||||||
@@ -95,7 +96,8 @@ func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating %s %s in %s namespace", reconcile.kind, name, *kubeconfigArgs.Namespace)
|
logger.Actionf("annotating %s %s in %s namespace", reconcile.kind, name, *kubeconfigArgs.Namespace)
|
||||||
if err := requestReconciliation(ctx, kubeClient, namespacedName, reconcile.object); err != nil {
|
if err := requestReconciliation(ctx, kubeClient, namespacedName,
|
||||||
|
reconcile.groupVersion.WithKind(reconcile.kind)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("%s annotated", reconcile.kind)
|
logger.Successf("%s annotated", reconcile.kind)
|
||||||
@@ -142,21 +144,25 @@ func reconciliationHandled(ctx context.Context, kubeClient client.Client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func requestReconciliation(ctx context.Context, kubeClient client.Client,
|
func requestReconciliation(ctx context.Context, kubeClient client.Client,
|
||||||
namespacedName types.NamespacedName, obj reconcilable) error {
|
namespacedName types.NamespacedName, gvk schema.GroupVersionKind) error {
|
||||||
return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) {
|
return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) {
|
||||||
if err := kubeClient.Get(ctx, namespacedName, obj.asClientObject()); err != nil {
|
object := &metav1.PartialObjectMetadata{}
|
||||||
|
object.SetGroupVersionKind(gvk)
|
||||||
|
object.SetName(namespacedName.Name)
|
||||||
|
object.SetNamespace(namespacedName.Namespace)
|
||||||
|
if err := kubeClient.Get(ctx, namespacedName, object); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
patch := client.MergeFrom(obj.deepCopyClientObject())
|
patch := client.MergeFrom(object.DeepCopy())
|
||||||
if ann := obj.GetAnnotations(); ann == nil {
|
if ann := object.GetAnnotations(); ann == nil {
|
||||||
obj.SetAnnotations(map[string]string{
|
object.SetAnnotations(map[string]string{
|
||||||
meta.ReconcileRequestAnnotation: time.Now().Format(time.RFC3339Nano),
|
meta.ReconcileRequestAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ann[meta.ReconcileRequestAnnotation] = time.Now().Format(time.RFC3339Nano)
|
ann[meta.ReconcileRequestAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
obj.SetAnnotations(ann)
|
object.SetAnnotations(ann)
|
||||||
}
|
}
|
||||||
return kubeClient.Patch(ctx, obj.asClientObject(), patch)
|
return kubeClient.Patch(ctx, object, patch)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ func (reconcile reconcileWithSourceCommand) run(cmd *cobra.Command, args []strin
|
|||||||
|
|
||||||
lastHandledReconcileAt := reconcile.object.lastHandledReconcileRequest()
|
lastHandledReconcileAt := reconcile.object.lastHandledReconcileRequest()
|
||||||
logger.Actionf("annotating %s %s in %s namespace", reconcile.kind, name, *kubeconfigArgs.Namespace)
|
logger.Actionf("annotating %s %s in %s namespace", reconcile.kind, name, *kubeconfigArgs.Namespace)
|
||||||
if err := requestReconciliation(ctx, kubeClient, namespacedName, reconcile.object); err != nil {
|
if err := requestReconciliation(ctx, kubeClient, namespacedName,
|
||||||
|
reconcile.groupVersion.WithKind(reconcile.kind)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("%s annotated", reconcile.kind)
|
logger.Successf("%s annotated", reconcile.kind)
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ import (
|
|||||||
// sourcev1.Bucket
|
// sourcev1.Bucket
|
||||||
|
|
||||||
var bucketType = apiType{
|
var bucketType = apiType{
|
||||||
kind: sourcev1.BucketKind,
|
kind: sourcev1.BucketKind,
|
||||||
humanKind: "source bucket",
|
humanKind: "source bucket",
|
||||||
|
groupVersion: sourcev1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type bucketAdapter struct {
|
type bucketAdapter struct {
|
||||||
@@ -62,8 +63,9 @@ func (a bucketListAdapter) len() int {
|
|||||||
// sourcev1.HelmChart
|
// sourcev1.HelmChart
|
||||||
|
|
||||||
var helmChartType = apiType{
|
var helmChartType = apiType{
|
||||||
kind: sourcev1.HelmChartKind,
|
kind: sourcev1.HelmChartKind,
|
||||||
humanKind: "source chart",
|
humanKind: "source chart",
|
||||||
|
groupVersion: sourcev1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type helmChartAdapter struct {
|
type helmChartAdapter struct {
|
||||||
@@ -95,8 +97,9 @@ func (a helmChartListAdapter) len() int {
|
|||||||
// sourcev1.GitRepository
|
// sourcev1.GitRepository
|
||||||
|
|
||||||
var gitRepositoryType = apiType{
|
var gitRepositoryType = apiType{
|
||||||
kind: sourcev1.GitRepositoryKind,
|
kind: sourcev1.GitRepositoryKind,
|
||||||
humanKind: "source git",
|
humanKind: "source git",
|
||||||
|
groupVersion: sourcev1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type gitRepositoryAdapter struct {
|
type gitRepositoryAdapter struct {
|
||||||
@@ -128,8 +131,9 @@ func (a gitRepositoryListAdapter) len() int {
|
|||||||
// sourcev1.HelmRepository
|
// sourcev1.HelmRepository
|
||||||
|
|
||||||
var helmRepositoryType = apiType{
|
var helmRepositoryType = apiType{
|
||||||
kind: sourcev1.HelmRepositoryKind,
|
kind: sourcev1.HelmRepositoryKind,
|
||||||
humanKind: "source helm",
|
humanKind: "source helm",
|
||||||
|
groupVersion: sourcev1.GroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
type helmRepositoryAdapter struct {
|
type helmRepositoryAdapter struct {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
► deleting helmreleases thrfg in {{ .ns }} namespace
|
► deleting helmrelease thrfg in {{ .ns }} namespace
|
||||||
✔ helmreleases deleted
|
✔ helmrelease deleted
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
► resuming helmreleases thrfg in {{ .ns }} namespace
|
► resuming helmrelease thrfg in {{ .ns }} namespace
|
||||||
✔ helmreleases resumed
|
✔ helmrelease resumed
|
||||||
◎ waiting for HelmRelease reconciliation
|
◎ waiting for HelmRelease reconciliation
|
||||||
✔ HelmRelease reconciliation completed
|
✔ HelmRelease reconciliation completed
|
||||||
✔ applied revision 6.0.0
|
✔ applied revision 6.0.0
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
► suspending helmreleases thrfg in {{ .ns }} namespace
|
► suspending helmrelease thrfg in {{ .ns }} namespace
|
||||||
✔ helmreleases suspended
|
✔ helmrelease suspended
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
► deleting kustomizations tkfg in {{ .ns }} namespace
|
► deleting kustomization tkfg in {{ .ns }} namespace
|
||||||
✔ kustomizations deleted
|
✔ kustomization deleted
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
► resuming kustomizations tkfg in {{ .ns }} namespace
|
► resuming kustomization tkfg in {{ .ns }} namespace
|
||||||
✔ kustomizations resumed
|
✔ kustomization resumed
|
||||||
◎ waiting for Kustomization reconciliation
|
◎ waiting for Kustomization reconciliation
|
||||||
✔ Kustomization reconciliation completed
|
✔ Kustomization reconciliation completed
|
||||||
✔ applied revision 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951
|
✔ applied revision 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
► suspending kustomizations tkfg in {{ .ns }} namespace
|
► suspending kustomization tkfg in {{ .ns }} namespace
|
||||||
✔ kustomizations suspended
|
✔ kustomization suspended
|
||||||
|
|||||||
Reference in New Issue
Block a user