Skip to content

Commit a3a8e51

Browse files
committed
chore: rename status_conditions to conditions
1 parent 3a6ef0f commit a3a8e51

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

internal/common/status_conditions.go renamed to internal/conditions/conditions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package common
17+
package conditions
1818

1919
import (
2020
cloudflareoperatoriov1 "github.com/containeroo/cloudflare-operator/api/v1"

internal/common/status_conditions_test.go renamed to internal/conditions/conditions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package common
17+
package conditions
1818

1919
import (
2020
"errors"

internal/controller/account_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"sigs.k8s.io/controller-runtime/pkg/client"
3636

3737
cloudflareoperatoriov1 "github.com/containeroo/cloudflare-operator/api/v1"
38-
"github.com/containeroo/cloudflare-operator/internal/common"
38+
intconditions "github.com/containeroo/cloudflare-operator/internal/conditions"
3939
"github.com/containeroo/cloudflare-operator/internal/metrics"
4040
apierrors "k8s.io/apimachinery/pkg/api/errors"
4141
apierrutil "k8s.io/apimachinery/pkg/util/errors"
@@ -102,26 +102,26 @@ func (r *AccountReconciler) Reconcile(ctx context.Context, req ctrl.Request) (re
102102
func (r *AccountReconciler) reconcileAccount(ctx context.Context, account *cloudflareoperatoriov1.Account) ctrl.Result {
103103
secret := &corev1.Secret{}
104104
if err := r.Get(ctx, client.ObjectKey{Namespace: account.Spec.ApiToken.SecretRef.Namespace, Name: account.Spec.ApiToken.SecretRef.Name}, secret); err != nil {
105-
common.MarkFalse(account, err)
105+
intconditions.MarkFalse(account, err)
106106
return ctrl.Result{RequeueAfter: time.Second * 30}
107107
}
108108

109109
cfApiToken := string(secret.Data["apiToken"])
110110
if cfApiToken == "" {
111-
common.MarkFalse(account, errors.New("Secret has no key named \"apiToken\""))
111+
intconditions.MarkFalse(account, errors.New("Secret has no key named \"apiToken\""))
112112
return ctrl.Result{RequeueAfter: time.Second * 30}
113113
}
114114

115115
if r.Cf.APIToken != cfApiToken {
116116
cf, err := cloudflare.NewWithAPIToken(cfApiToken)
117117
if err != nil {
118-
common.MarkFalse(account, err)
118+
intconditions.MarkFalse(account, err)
119119
return ctrl.Result{RequeueAfter: time.Second * 30}
120120
}
121121
*r.Cf = *cf
122122
}
123123

124-
common.MarkTrue(account, "Account is ready")
124+
intconditions.MarkTrue(account, "Account is ready")
125125

126126
return ctrl.Result{RequeueAfter: account.Spec.Interval.Duration}
127127
}

internal/controller/dnsrecord_controller.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141

4242
"github.com/cloudflare/cloudflare-go"
4343
cloudflareoperatoriov1 "github.com/containeroo/cloudflare-operator/api/v1"
44-
"github.com/containeroo/cloudflare-operator/internal/common"
44+
intconditions "github.com/containeroo/cloudflare-operator/internal/conditions"
4545
"github.com/containeroo/cloudflare-operator/internal/metrics"
4646
intpredicates "github.com/containeroo/cloudflare-operator/internal/predicates"
4747
)
@@ -126,7 +126,7 @@ func (r *DNSRecordReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
126126
}
127127

128128
if len(zones.Items) == 0 {
129-
common.MarkFalse(dnsrecord, fmt.Errorf("Zone %q not found", zoneName))
129+
intconditions.MarkFalse(dnsrecord, fmt.Errorf("Zone %q not found", zoneName))
130130
return ctrl.Result{}, nil
131131
}
132132

@@ -151,12 +151,12 @@ func (r *DNSRecordReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
151151
// reconcileDNSRecord reconciles the dnsrecord
152152
func (r *DNSRecordReconciler) reconcileDNSRecord(ctx context.Context, dnsrecord *cloudflareoperatoriov1.DNSRecord, zone *cloudflareoperatoriov1.Zone) ctrl.Result {
153153
if r.Cf.APIToken == "" {
154-
common.MarkUnknown(dnsrecord, "Cloudflare account is not ready")
154+
intconditions.MarkUnknown(dnsrecord, "Cloudflare account is not ready")
155155
return ctrl.Result{RequeueAfter: time.Second * 5}
156156
}
157157

158158
if !conditions.IsTrue(zone, cloudflareoperatoriov1.ConditionTypeReady) {
159-
common.MarkUnknown(dnsrecord, "Zone is not ready")
159+
intconditions.MarkUnknown(dnsrecord, "Zone is not ready")
160160
return ctrl.Result{RequeueAfter: time.Second * 5}
161161
}
162162

@@ -165,7 +165,7 @@ func (r *DNSRecordReconciler) reconcileDNSRecord(ctx context.Context, dnsrecord
165165
var err error
166166
existingRecord, err = r.Cf.GetDNSRecord(ctx, cloudflare.ZoneIdentifier(zone.Status.ID), dnsrecord.Status.RecordID)
167167
if err != nil {
168-
common.MarkFalse(dnsrecord, err)
168+
intconditions.MarkFalse(dnsrecord, err)
169169
return ctrl.Result{}
170170
}
171171
} else {
@@ -175,7 +175,7 @@ func (r *DNSRecordReconciler) reconcileDNSRecord(ctx context.Context, dnsrecord
175175
Content: dnsrecord.Spec.Content,
176176
})
177177
if err != nil {
178-
common.MarkFalse(dnsrecord, err)
178+
intconditions.MarkFalse(dnsrecord, err)
179179
return ctrl.Result{}
180180
}
181181
if len(cfExistingRecords) > 0 {
@@ -187,14 +187,14 @@ func (r *DNSRecordReconciler) reconcileDNSRecord(ctx context.Context, dnsrecord
187187
if (dnsrecord.Spec.Type == "A" || dnsrecord.Spec.Type == "AAAA") && dnsrecord.Spec.IPRef.Name != "" {
188188
ip := &cloudflareoperatoriov1.IP{}
189189
if err := r.Get(ctx, client.ObjectKey{Name: dnsrecord.Spec.IPRef.Name}, ip); err != nil {
190-
common.MarkFalse(dnsrecord, err)
190+
intconditions.MarkFalse(dnsrecord, err)
191191
return ctrl.Result{RequeueAfter: time.Second * 30}
192192
}
193193
dnsrecord.Spec.Content = ip.Spec.Address
194194
}
195195

196196
if *dnsrecord.Spec.Proxied && dnsrecord.Spec.TTL != 1 {
197-
common.MarkFalse(dnsrecord, errors.New("TTL must be 1 when proxied"))
197+
intconditions.MarkFalse(dnsrecord, errors.New("TTL must be 1 when proxied"))
198198
return ctrl.Result{}
199199
}
200200

@@ -209,7 +209,7 @@ func (r *DNSRecordReconciler) reconcileDNSRecord(ctx context.Context, dnsrecord
209209
Data: dnsrecord.Spec.Data,
210210
})
211211
if err != nil {
212-
common.MarkFalse(dnsrecord, err)
212+
intconditions.MarkFalse(dnsrecord, err)
213213
return ctrl.Result{RequeueAfter: time.Second * 30}
214214
}
215215
dnsrecord.Status.RecordID = newDNSRecord.ID
@@ -224,12 +224,12 @@ func (r *DNSRecordReconciler) reconcileDNSRecord(ctx context.Context, dnsrecord
224224
Priority: dnsrecord.Spec.Priority,
225225
Data: dnsrecord.Spec.Data,
226226
}); err != nil {
227-
common.MarkFalse(dnsrecord, err)
227+
intconditions.MarkFalse(dnsrecord, err)
228228
return ctrl.Result{RequeueAfter: time.Second * 30}
229229
}
230230
}
231231

232-
common.MarkTrue(dnsrecord, "DNS record synced")
232+
intconditions.MarkTrue(dnsrecord, "DNS record synced")
233233

234234
return ctrl.Result{RequeueAfter: dnsrecord.Spec.Interval.Duration}
235235
}

internal/controller/ip_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"time"
3434

3535
cloudflareoperatoriov1 "github.com/containeroo/cloudflare-operator/api/v1"
36-
"github.com/containeroo/cloudflare-operator/internal/common"
36+
intconditions "github.com/containeroo/cloudflare-operator/internal/conditions"
3737
"github.com/containeroo/cloudflare-operator/internal/metrics"
3838
"github.com/fluxcd/pkg/runtime/patch"
3939
"github.com/itchyny/gojq"
@@ -111,17 +111,17 @@ func (r *IPReconciler) reconcileIP(ctx context.Context, ip *cloudflareoperatorio
111111
switch ip.Spec.Type {
112112
case "static":
113113
if err := r.handleStatic(ip); err != nil {
114-
common.MarkFalse(ip, err)
114+
intconditions.MarkFalse(ip, err)
115115
return ctrl.Result{}
116116
}
117117
case "dynamic":
118118
if err := r.handleDynamic(ctx, ip); err != nil {
119-
common.MarkFalse(ip, err)
119+
intconditions.MarkFalse(ip, err)
120120
return ctrl.Result{}
121121
}
122122
}
123123

124-
common.MarkTrue(ip, "IP is ready")
124+
intconditions.MarkTrue(ip, "IP is ready")
125125

126126
if ip.Spec.Type == "dynamic" {
127127
return ctrl.Result{RequeueAfter: ip.Spec.Interval.Duration}

internal/controller/zone_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"sigs.k8s.io/controller-runtime/pkg/client"
3636

3737
cloudflareoperatoriov1 "github.com/containeroo/cloudflare-operator/api/v1"
38-
"github.com/containeroo/cloudflare-operator/internal/common"
38+
intconditions "github.com/containeroo/cloudflare-operator/internal/conditions"
3939
"github.com/containeroo/cloudflare-operator/internal/metrics"
4040
"github.com/fluxcd/pkg/runtime/patch"
4141
)
@@ -107,26 +107,26 @@ func (r *ZoneReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
107107
// reconcileZone reconciles the zone
108108
func (r *ZoneReconciler) reconcileZone(ctx context.Context, zone *cloudflareoperatoriov1.Zone) ctrl.Result {
109109
if r.Cf.APIToken == "" {
110-
common.MarkUnknown(zone, "Cloudflare account is not ready")
110+
intconditions.MarkUnknown(zone, "Cloudflare account is not ready")
111111
return ctrl.Result{RequeueAfter: time.Second * 5}
112112
}
113113

114114
zoneID, err := r.Cf.ZoneIDByName(zone.Spec.Name)
115115
if err != nil {
116-
common.MarkFalse(zone, err)
116+
intconditions.MarkFalse(zone, err)
117117
return ctrl.Result{}
118118
}
119119

120120
zone.Status.ID = zoneID
121121

122122
if zone.Spec.Prune {
123123
if err := r.handlePrune(ctx, zone); err != nil {
124-
common.MarkFalse(zone, err)
124+
intconditions.MarkFalse(zone, err)
125125
return ctrl.Result{RequeueAfter: time.Second * 30}
126126
}
127127
}
128128

129-
common.MarkTrue(zone, "Zone is ready")
129+
intconditions.MarkTrue(zone, "Zone is ready")
130130

131131
return ctrl.Result{RequeueAfter: zone.Spec.Interval.Duration}
132132
}
@@ -143,7 +143,7 @@ func (r *ZoneReconciler) handlePrune(ctx context.Context, zone *cloudflareoperat
143143

144144
cfDnsRecords, _, err := r.Cf.ListDNSRecords(ctx, cloudflare.ZoneIdentifier(zone.Status.ID), cloudflare.ListDNSRecordsParams{})
145145
if err != nil {
146-
common.MarkFalse(zone, err)
146+
intconditions.MarkFalse(zone, err)
147147
return err
148148
}
149149

0 commit comments

Comments
 (0)