Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate ClusterSlice API, clients, informers #2745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ ${OPENAPI_PKG}/openapi-gen \
--output-package k8s.io/ingress-gce/pkg/apis/svcneg/v1beta1 \
--go-header-file ${SCRIPT_ROOT}/boilerplate.go.txt

echo "Performing code generation for ClusterSlice CRD"
${CODEGEN_PKG}/generate-groups.sh \
"deepcopy,client,informer,lister" \
k8s.io/ingress-gce/pkg/clusterslice/client k8s.io/ingress-gce/pkg/apis \
"clusterslice:v1" \
--go-header-file ${SCRIPT_ROOT}/boilerplate.go.txt

echo "Generating openapi for ClusterSlice v1"
${OPENAPI_PKG}/openapi-gen \
--output-file-base zz_generated.openapi \
--input-dirs k8s.io/ingress-gce/pkg/apis/clusterslice/v1 \
--output-package k8s.io/ingress-gce/pkg/apis/clusterslice/v1 \
--go-header-file ${SCRIPT_ROOT}/boilerplate.go.txt

echo "Performing code generation for ServiceAttachment CRD"
${CODEGEN_PKG}/generate-groups.sh \
"deepcopy,client,informer,lister" \
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/clusterslice/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Kubernetes Authors.
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 clusterslice

import "k8s.io/ingress-gce/pkg/flags"

var (
GroupName = flags.F.ClusterSliceAPIGroup
)
16 changes: 16 additions & 0 deletions pkg/apis/clusterslice/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Copyright 2024 The Kubernetes Authors.
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.
*/
// +k8s:deepcopy-gen=package
// Package v1beta1 is the v1beta1 version of the API.
// +groupName=flags.F.ClusterSliceAPIGroup
package v1
50 changes: 50 additions & 0 deletions pkg/apis/clusterslice/v1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2020 The Kubernetes Authors.
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 v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/ingress-gce/pkg/apis/clusterslice"
)

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: clusterslice.GroupName, Version: "v1"}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ClusterSlice{},
&ClusterSliceList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
64 changes: 64 additions & 0 deletions pkg/apis/clusterslice/v1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2024 The Kubernetes Authors.
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 v1

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

// ClusterSlice is the Schema for the ClusterSlice resource in the Multi-Project cluster.
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
//
// +k8s:openapi-gen=true
type ClusterSlice struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClusterSliceSpec `json:"spec,omitempty"`
Status ClusterSliceStatus `json:"status,omitempty"`
}

// ClusterSliceSpec is the spec for a resource
// +k8s:openapi-gen=true
type ClusterSliceSpec struct {
// The ID of the project where the cluster slice is to be created.
ProjectID string `json:"projectID,omitempty"`
// The project number where the cluster slice is to be created.
ProjectNumber int64 `json:"projectNumber,omitempty"`
// The network configuration for the cluster slice.
NetworkConfig *NetworkConfig `json:"networkConfig,omitempty"`
}

// NetworkConfig specifies the network configuration for the cluster slice.
type NetworkConfig struct {
// The network where the cluster slice is to be created.
Network string `json:"network,omitempty"`
// The default subnetwork where the cluster slice is to be created.
DefaultSubnetwork string `json:"defaultSubnetwork,omitempty"`
}

// ClusterSliceStatus is the status for a ClusterSlice resource
type ClusterSliceStatus struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterSliceList is a list of ClusterSlice resources
type ClusterSliceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []ClusterSlice `json:"items"`
}
140 changes: 140 additions & 0 deletions pkg/apis/clusterslice/v1/zz_generated.deepcopy.go

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

Loading