Skip to content

Commit 749931e

Browse files
committed
non-reconciliable & readiness of static objects
Signed-off-by: Sunny <darkowlzz@protonmail.com>
1 parent a337a7e commit 749931e

15 files changed

+53
-140
lines changed

cmd/flux/get_alert.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strings"
2323

2424
"github.com/spf13/cobra"
25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/runtime"
2627

2728
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
@@ -76,7 +77,7 @@ func init() {
7677

7778
func (s alertListAdapter) summariseItem(i int, includeNamespace bool, includeKind bool) []string {
7879
item := s.Items[i]
79-
status, msg := statusAndMessage(item.Status.Conditions)
80+
status, msg := string(metav1.ConditionTrue), "Alert is Ready"
8081
return append(nameColumns(&item, includeNamespace, includeKind), strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg)
8182
}
8283

cmd/flux/get_alertprovider.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121

2222
"github.com/spf13/cobra"
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
"k8s.io/apimachinery/pkg/runtime"
2425

2526
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
@@ -74,7 +75,7 @@ func init() {
7475

7576
func (s alertProviderListAdapter) summariseItem(i int, includeNamespace bool, includeKind bool) []string {
7677
item := s.Items[i]
77-
status, msg := statusAndMessage(item.Status.Conditions)
78+
status, msg := string(metav1.ConditionTrue), "Provider is Ready"
7879
return append(nameColumns(&item, includeNamespace, includeKind), status, msg)
7980
}
8081

cmd/flux/get_source_helm.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strings"
2323

2424
"github.com/spf13/cobra"
25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/runtime"
2627

2728
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
@@ -81,7 +82,12 @@ func (a *helmRepositoryListAdapter) summariseItem(i int, includeNamespace bool,
8182
if item.GetArtifact() != nil {
8283
revision = item.GetArtifact().Revision
8384
}
84-
status, msg := statusAndMessage(item.Status.Conditions)
85+
var status, msg string
86+
if item.Spec.Type == sourcev1.HelmRepositoryTypeOCI {
87+
status, msg = string(metav1.ConditionTrue), "Helm repository is Ready"
88+
} else {
89+
status, msg = statusAndMessage(item.Status.Conditions)
90+
}
8591
revision = utils.TruncateHex(revision)
8692
msg = utils.TruncateHex(msg)
8793
return append(nameColumns(&item, includeNamespace, includeKind),

cmd/flux/reconcile.go

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type reconcilable interface {
6161
GetAnnotations() map[string]string
6262
SetAnnotations(map[string]string)
6363

64+
hasReconciler() bool // does the object's current configuration has a reconciler to reconcile it?
6465
lastHandledReconcileRequest() string // what was the last handled reconcile request?
6566
successMessage() string // what do you want to tell people when successfully reconciled?
6667
}
@@ -101,6 +102,11 @@ func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error {
101102
return err
102103
}
103104

105+
if reconcile.object.hasReconciler() {
106+
logger.Successf("reconciliation not supported by the object")
107+
return nil
108+
}
109+
104110
if reconcile.object.isSuspended() {
105111
return fmt.Errorf("resource is suspended")
106112
}

cmd/flux/reconcile_alert.go

-44
This file was deleted.

cmd/flux/reconcile_alertprovider.go

-93
This file was deleted.

cmd/flux/reconcile_helmrelease.go

+4
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName
8181
Namespace: ns,
8282
}
8383
}
84+
85+
func (obj helmReleaseAdapter) hasReconciler() bool {
86+
return true
87+
}

cmd/flux/reconcile_image_repository.go

+4
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ func (obj imageRepositoryAdapter) lastHandledReconcileRequest() string {
4848
func (obj imageRepositoryAdapter) successMessage() string {
4949
return fmt.Sprintf("scan fetched %d tags", obj.Status.LastScanResult.TagCount)
5050
}
51+
52+
func (obj imageRepositoryAdapter) hasReconciler() bool {
53+
return true
54+
}

cmd/flux/reconcile_image_updateauto.go

+4
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ func (obj imageUpdateAutomationAdapter) successMessage() string {
6060
}
6161
return "automation not yet run"
6262
}
63+
64+
func (obj imageUpdateAutomationAdapter) hasReconciler() bool {
65+
return true
66+
}

cmd/flux/reconcile_kustomization.go

+4
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@ func (obj kustomizationAdapter) getSource() (reconcileSource, types.NamespacedNa
8888
Namespace: obj.Spec.SourceRef.Namespace,
8989
}
9090
}
91+
92+
func (obj kustomizationAdapter) hasReconciler() bool {
93+
return true
94+
}

cmd/flux/reconcile_source_bucket.go

+4
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ func (obj bucketAdapter) lastHandledReconcileRequest() string {
4848
func (obj bucketAdapter) successMessage() string {
4949
return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision)
5050
}
51+
52+
func (obj bucketAdapter) hasReconciler() bool {
53+
return true
54+
}

cmd/flux/reconcile_source_chart.go

+4
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,7 @@ func (obj helmChartAdapter) getSource() (reconcileSource, types.NamespacedName)
8484
Namespace: obj.Namespace,
8585
}
8686
}
87+
88+
func (obj helmChartAdapter) hasReconciler() bool {
89+
return true
90+
}

cmd/flux/reconcile_source_git.go

+4
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ func (obj gitRepositoryAdapter) lastHandledReconcileRequest() string {
4848
func (obj gitRepositoryAdapter) successMessage() string {
4949
return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision)
5050
}
51+
52+
func (obj gitRepositoryAdapter) hasReconciler() bool {
53+
return true
54+
}

cmd/flux/reconcile_source_helm.go

+4
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ func (obj helmRepositoryAdapter) successMessage() string {
6060
}
6161
return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision)
6262
}
63+
64+
func (obj helmRepositoryAdapter) hasReconciler() bool {
65+
return obj.Spec.Type == sourcev1.HelmRepositoryTypeOCI
66+
}

cmd/flux/reconcile_source_oci.go

+4
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ func (obj ociRepositoryAdapter) lastHandledReconcileRequest() string {
4848
func (obj ociRepositoryAdapter) successMessage() string {
4949
return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision)
5050
}
51+
52+
func (obj ociRepositoryAdapter) hasReconciler() bool {
53+
return true
54+
}

0 commit comments

Comments
 (0)