Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion api/v1/account_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type AccountSpec struct {
type AccountStatus struct {
// Conditions contains the different condition statuses for the Account object.
// +optional
Conditions []metav1.Condition `json:"conditions"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand All @@ -72,6 +72,16 @@ func (in *Account) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// GetApiTokenSecretRef returns the secret reference that contains the Cloudflare API token.
func (in *Account) GetApiTokenSecretRef() corev1.SecretReference {
return in.Spec.ApiToken.SecretRef
}

// GetInterval returns the reconcile interval defined on the account.
func (in *Account) GetInterval() metav1.Duration {
return in.Spec.Interval
}

// +kubebuilder:object:root=true

// AccountList contains a list of Account
Expand Down
97 changes: 97 additions & 0 deletions api/v2/account_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Copyright 2025 containeroo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v2

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type AccountSpecApiToken struct {
// Secret containing the API token (key must be named "apiToken")
SecretRef corev1.SecretReference `json:"secretRef"`
}

// AccountSpec defines the desired state of Account
type AccountSpec struct {
// Cloudflare API token
ApiToken AccountSpecApiToken `json:"apiToken"`
// Interval to check account status
// +kubebuilder:default="5m"
// +optional
Interval metav1.Duration `json:"interval,omitempty"`
// List of zone names that should be managed by cloudflare-operator
// Deprecated and will be removed in a future release
// +optional
// +deprecated
ManagedZones []string `json:"managedZones,omitempty"`
}

// AccountStatus defines the observed state of Account
type AccountStatus struct {
// Conditions contains the different condition statuses for the Account object.
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Namespaced
// +kubebuilder:storageversion

// Account is the Schema for the accounts API
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type == "Ready")].status`
type Account struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AccountSpec `json:"spec,omitempty"`
Status AccountStatus `json:"status,omitempty"`
}

// GetConditions returns the status conditions of the object.
func (in *Account) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// SetConditions sets the status conditions on the object.
func (in *Account) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// GetApiTokenSecretRef returns the secret reference that contains the Cloudflare API token.
func (in *Account) GetApiTokenSecretRef() corev1.SecretReference {
return in.Spec.ApiToken.SecretRef
}

// GetInterval returns the reconcile interval defined on the account.
func (in *Account) GetInterval() metav1.Duration {
return in.Spec.Interval
}

// +kubebuilder:object:root=true

// AccountList contains a list of Account
type AccountList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Account `json:"items"`
}

func init() {
SchemeBuilder.Register(&Account{}, &AccountList{})
}
19 changes: 19 additions & 0 deletions api/v2/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2025 containeroo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v2

const CloudflareOperatorFinalizer = "cloudflare-operator.io/finalizer"
31 changes: 31 additions & 0 deletions api/v2/condition_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2025 containeroo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v2

const (
// ConditionTypeReady represents the fact that the object is ready.
ConditionTypeReady string = "Ready"

// ConditionReasonReady represents the fact that the object is ready.
ConditionReasonReady string = "Ready"

// ConditionReasonNotReady represents the fact that the object is not ready.
ConditionReasonNotReady string = "NotReady"

// ConditionReasonFailed represents the fact that the object has failed.
ConditionReasonFailed string = "Failed"
)
20 changes: 20 additions & 0 deletions api/v2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright 2025 containeroo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v2 contains API Schema definitions for the cloudflare-operator.io v2 API group
// +kubebuilder:object:generate=true
// +groupName=cloudflare-operator.io
package v2
36 changes: 36 additions & 0 deletions api/v2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2025 containeroo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v2 contains API Schema definitions for the cloudflare-operator.io v2 API group
// +kubebuilder:object:generate=true
// +groupName=cloudflare-operator.io
package v2

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "cloudflare-operator.io", Version: "v2"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
145 changes: 145 additions & 0 deletions api/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading