Skip to content

Commit

Permalink
Add IPAM provider to API
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedosin committed Dec 26, 2023
1 parent 92c7ff3 commit 69a26f3
Show file tree
Hide file tree
Showing 10 changed files with 3,472 additions and 0 deletions.
59 changes: 59 additions & 0 deletions api/v1alpha2/ipamprovider_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2023 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 v1alpha2

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

// IPAMProviderSpec defines the desired state of IPAMProvider.
type IPAMProviderSpec struct {
ProviderSpec `json:",inline"`
}

// IPAMProviderStatus defines the observed state of IPAMProvider.
type IPAMProviderStatus struct {
ProviderStatus `json:",inline"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="InstalledVersion",type="string",JSONPath=".status.installedVersion"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:storageversion

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

Spec IPAMProviderSpec `json:"spec,omitempty"`
Status IPAMProviderStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
objectTypes = append(objectTypes, &IPAMProvider{}, &IPAMProviderList{})
}
61 changes: 61 additions & 0 deletions api/v1alpha2/ipamprovider_wrapper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2023 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 v1alpha2

import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

var _ GenericProvider = &IPAMProvider{}

func (p *IPAMProvider) GetConditions() clusterv1.Conditions {
return p.Status.Conditions
}

func (p *IPAMProvider) SetConditions(conditions clusterv1.Conditions) {
p.Status.Conditions = conditions
}

func (p *IPAMProvider) GetSpec() ProviderSpec {
return p.Spec.ProviderSpec
}

func (p *IPAMProvider) SetSpec(in ProviderSpec) {
p.Spec.ProviderSpec = in
}

func (p *IPAMProvider) GetStatus() ProviderStatus {
return p.Status.ProviderStatus
}

func (p *IPAMProvider) SetStatus(in ProviderStatus) {
p.Status.ProviderStatus = in
}

func (p *IPAMProvider) GetType() string {
return "ipam"
}

func (p *IPAMProviderList) GetItems() []GenericProvider {
providers := []GenericProvider{}

for index := range p.Items {
providers = append(providers, &p.Items[index])
}

return providers
}
91 changes: 91 additions & 0 deletions api/v1alpha2/zz_generated.deepcopy.go

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

Loading

0 comments on commit 69a26f3

Please sign in to comment.