Skip to content

Commit

Permalink
machineconfgiuration: sync types
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Kopels committed Nov 21, 2024
1 parent 983ef91 commit 3bdcf1c
Show file tree
Hide file tree
Showing 134 changed files with 55,851 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/sync/configs/machineconfiguration-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: machineconfiguration
sync: true
repo_link: "https://github.com/openshift/api/"
branch: master
remote_api_directory: operator/v1
local_api_directory: schemes/machineconfiguration/mctypes
...
87 changes: 87 additions & 0 deletions pkg/machineconfiguration/machineconfiguration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package machineconfiguration

import (
"context"
"github.com/golang/glog"
"github.com/openshift-kni/eco-goinfra/pkg/clients"
machineconfigurationv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
runtimeClient "sigs.k8s.io/controller-runtime/pkg/client"
)

// APIGroup represents metallb api group.
const (
APIGroup = "operator.openshift.io"
APIVersion = "v1"
)

// MCBuilder provides struct for a MachineConfiguration object.
type MCBuilder struct {
Definition *machineconfigurationv1.MachineConfiguration
Object *machineconfigurationv1.MachineConfiguration
apiClient runtimeClient.Client
}

// NewMachineConfigurationBuilder creates a new instance of machineconfiguration.
func NewMachineConfigurationBuilder(apiClient *clients.Settings, name string) *MCBuilder {

Check failure on line 27 in pkg/machineconfiguration/machineconfiguration.go

View workflow job for this annotation

GitHub Actions / lint

block should not start with a whitespace (wsl)

err := apiClient.AttachScheme(machineconfigurationv1.AddToScheme)
if err != nil {
glog.V(100).Infof("Failed to add metallb scheme to client schemes")

return nil
}

return &MCBuilder{
apiClient: apiClient,
Definition: &machineconfigurationv1.MachineConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
},
}
}

// Get retrieves existing machineconfiguration from cluster if found.
func (builder *MCBuilder) Get() (*machineconfigurationv1.MachineConfiguration, error) {
glog.V(100).Infof("Pulling existing machineSet name")

machineConfig := &machineconfigurationv1.MachineConfiguration{}
err := builder.apiClient.Get(context.TODO(),
runtimeClient.ObjectKey{Name: builder.Definition.Name}, machineConfig)

return machineConfig, err
}

// Pull pulls existing machineconfiguration from cluster.
func Pull(apiClient *clients.Settings, name string) (b *MCBuilder, err error) {
glog.V(100).Infof("Pulling existing machineSet name %s ", name)

err = apiClient.AttachScheme(machineconfigurationv1.AddToScheme)
if err != nil {
glog.V(100).Infof("Failed to add machineconfiguration scheme to client schemes")

return nil, err
}

builder := MCBuilder{
apiClient: apiClient,
Definition: &machineconfigurationv1.MachineConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
},
}

builder.Definition = builder.Object

return &MCBuilder{}, nil
}

// GetMachineConfigurationGVR returns bgppeer's GroupVersionResource which could be used for Clean function.
func GetMachineConfigurationGVR() schema.GroupVersionResource {
return schema.GroupVersionResource{
Group: APIGroup, Version: APIVersion, Resource: "machinesets",
}
}
3 changes: 3 additions & 0 deletions pkg/schemes/machineconfiguration/mctypes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: test
test:
make -C ../../tests test GINKGO_EXTRA_ARGS=--focus="operator.openshift.io/v1"
7 changes: 7 additions & 0 deletions pkg/schemes/machineconfiguration/mctypes/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +k8s:deepcopy-gen=package,register
// +k8s:defaulter-gen=TypeMeta
// +k8s:openapi-gen=true

// +kubebuilder:validation:Optional
// +groupName=operator.openshift.io
package mctypes
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
feature-gate.release.openshift.io/: "true"
name: clustercsidrivers.operator.openshift.io
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
metadata:
properties:
name:
enum:
- ebs.csi.aws.com
- efs.csi.aws.com
- disk.csi.azure.com
- file.csi.azure.com
- filestore.csi.storage.gke.io
- pd.csi.storage.gke.io
- cinder.csi.openstack.org
- csi.vsphere.vmware.com
- manila.csi.openstack.org
- csi.ovirt.org
- csi.kubevirt.io
- csi.sharedresource.openshift.io
- diskplugin.csi.alibabacloud.com
- vpc.block.csi.ibm.io
- powervs.csi.ibm.com
- secrets-store.csi.k8s.io
- smb.csi.k8s.io
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
feature-gate.release.openshift.io/: "true"
name: dnses.operator.openshift.io
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
upstreamResolvers:
default: {}
properties:
upstreams:
items:
anyOf:
- not:
required:
- address
- port
properties:
type:
enum:
- ""
- SystemResolvConf
- optional:
- port
properties:
type:
enum:
- Network
required:
- address
properties:
address:
anyOf:
- format: ipv4
- format: ipv6
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
feature-gate.release.openshift.io/: "true"
name: ingresscontrollers.operator.openshift.io
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
logging:
properties:
access:
properties:
destination:
properties:
syslog:
oneOf:
- properties:
address:
format: ipv4
- properties:
address:
format: ipv6
tuningOptions:
anyOf:
- properties:
maxConnections:
enum:
- -1
- 0
- properties:
maxConnections:
format: int32
maximum: 2000000
minimum: 2000
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.availableReplicas
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
feature-gate.release.openshift.io/: "true"
name: insightsoperators.operator.openshift.io
spec:
versions:
- name: v1
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.availableReplicas
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
feature-gate.release.openshift.io/: "true"
name: kubeapiservers.operator.openshift.io
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
managementState:
pattern: ^(Managed|Force)$
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
feature-gate.release.openshift.io/: "true"
name: kubecontrollermanagers.operator.openshift.io
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
managementState:
pattern: ^(Managed|Force)$
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
feature-gate.release.openshift.io/: "true"
name: kubeschedulers.operator.openshift.io
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
managementState:
pattern: ^(Managed|Force)$
82 changes: 82 additions & 0 deletions pkg/schemes/machineconfiguration/mctypes/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package mctypes

import (
configv1 "github.com/openshift/api/config/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

var (
GroupName = "operator.openshift.io"
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, configv1.Install)
// Install is a function which adds this version to a scheme
Install = schemeBuilder.AddToScheme

// SchemeGroupVersion generated code relies on this name
// Deprecated
SchemeGroupVersion = GroupVersion
// AddToScheme exists solely to keep the old generators creating valid code
// DEPRECATED
AddToScheme = schemeBuilder.AddToScheme
)

// Resource generated code relies on this being here, but it logically belongs to the group
// DEPRECATED
func Resource(resource string) schema.GroupResource {
return schema.GroupResource{Group: GroupName, Resource: resource}
}

func addKnownTypes(scheme *runtime.Scheme) error {
metav1.AddToGroupVersion(scheme, GroupVersion)

scheme.AddKnownTypes(GroupVersion,
&Authentication{},
&AuthenticationList{},
&DNS{},
&DNSList{},
&CloudCredential{},
&CloudCredentialList{},
&ClusterCSIDriver{},
&ClusterCSIDriverList{},
&Console{},
&ConsoleList{},
&CSISnapshotController{},
&CSISnapshotControllerList{},
&Etcd{},
&EtcdList{},
&KubeAPIServer{},
&KubeAPIServerList{},
&KubeControllerManager{},
&KubeControllerManagerList{},
&KubeScheduler{},
&KubeSchedulerList{},
&KubeStorageVersionMigrator{},
&KubeStorageVersionMigratorList{},
&MachineConfiguration{},
&MachineConfigurationList{},
&Network{},
&NetworkList{},
&OpenShiftAPIServer{},
&OpenShiftAPIServerList{},
&OpenShiftControllerManager{},
&OpenShiftControllerManagerList{},
&OLM{},
&OLMList{},
&ServiceCA{},
&ServiceCAList{},
&ServiceCatalogAPIServer{},
&ServiceCatalogAPIServerList{},
&ServiceCatalogControllerManager{},
&ServiceCatalogControllerManagerList{},
&IngressController{},
&IngressControllerList{},
&InsightsOperator{},
&InsightsOperatorList{},
&Storage{},
&StorageList{},
)

return nil
}
Loading

0 comments on commit 3bdcf1c

Please sign in to comment.