Skip to content

Commit

Permalink
chore: introduce new (identical) SubNamespace API version
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgb committed Oct 15, 2023
1 parent 1cc371d commit 05c4823
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1/subnamespace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type SubNamespaceSpec struct {
}

//+kubebuilder:object:root=true
//+kubebuilder:storageversion

// SubNamespace is the Schema for the subnamespaces API
type SubNamespace struct {
Expand Down
20 changes: 20 additions & 0 deletions api/v2alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Package v2alpha1 contains API Schema definitions for the accurate v2alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=accurate.cybozu.com
package v2alpha1

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: "accurate.cybozu.com", Version: "v2alpha1"}

// 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
)
59 changes: 59 additions & 0 deletions api/v2alpha1/subnamespace_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package v2alpha1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// SubNamespaceStatus defines the observed state of SubNamespace
// +kubebuilder:validation:Enum=ok;conflict
type SubNamespaceStatus string

const (
SubNamespaceOK = SubNamespaceStatus("ok")
SubNamespaceConflict = SubNamespaceStatus("conflict")
)

// SubNamespaceSpec defines the desired state of SubNamespace
type SubNamespaceSpec struct {
// Labels are the labels to be propagated to the sub-namespace
// +optional
Labels map[string]string `json:"labels,omitempty"`

// Annotations are the annotations to be propagated to the sub-namespace.
// +optional
Annotations map[string]string `json:"annotations,omitempty"`
}

// Keeping this version un-served for now
//+kubebuilder:unservedversion
//+kubebuilder:object:root=true

// SubNamespace is the Schema for the subnamespaces API
type SubNamespace struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec is the spec of SubNamespace.
// +optional
Spec SubNamespaceSpec `json:"spec,omitempty"`

// Status is the status of SubNamespace.
// +optional
Status SubNamespaceStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&SubNamespace{}, &SubNamespaceList{})
}
97 changes: 97 additions & 0 deletions api/v2alpha1/zz_generated.deepcopy.go

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

36 changes: 36 additions & 0 deletions charts/accurate/crds/accurate.cybozu.com_subnamespaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,39 @@ spec:
type: object
served: true
storage: true
- name: v2alpha1
schema:
openAPIV3Schema:
description: SubNamespace is the Schema for the subnamespaces API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.'
type: string
metadata:
type: object
spec:
description: Spec is the spec of SubNamespace.
properties:
annotations:
additionalProperties:
type: string
description: Annotations are the annotations to be propagated to the sub-namespace.
type: object
labels:
additionalProperties:
type: string
description: Labels are the labels to be propagated to the sub-namespace
type: object
type: object
status:
description: Status is the status of SubNamespace.
enum:
- ok
- conflict
type: string
type: object
served: false
storage: false
41 changes: 41 additions & 0 deletions config/crd/bases/accurate.cybozu.com_subnamespaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,44 @@ spec:
type: object
served: true
storage: true
- name: v2alpha1
schema:
openAPIV3Schema:
description: SubNamespace is the Schema for the subnamespaces API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.'
type: string
metadata:
type: object
spec:
description: Spec is the spec of SubNamespace.
properties:
annotations:
additionalProperties:
type: string
description: Annotations are the annotations to be propagated to the
sub-namespace.
type: object
labels:
additionalProperties:
type: string
description: Labels are the labels to be propagated to the sub-namespace
type: object
type: object
status:
description: Status is the status of SubNamespace.
enum:
- ok
- conflict
type: string
type: object
served: false
storage: false

0 comments on commit 05c4823

Please sign in to comment.