diff --git a/PROJECT b/PROJECT index 3b9636bbf..3cf7b1fa6 100644 --- a/PROJECT +++ b/PROJECT @@ -35,13 +35,4 @@ resources: kind: Management path: github.com/Mirantis/hmc/api/v1alpha1 version: v1alpha1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: hmc.mirantis.com - group: hmc.mirantis.com - kind: AWSProvider - path: github.com/Mirantis/hmc/api/v1alpha1 - version: v1alpha1 version: "3" diff --git a/api/v1alpha1/awsprovider_types.go b/api/v1alpha1/awsprovider_types.go deleted file mode 100644 index cab73c7d3..000000000 --- a/api/v1alpha1/awsprovider_types.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2024 -// -// 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 v1alpha1 - -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. - -// AWSProviderSpec defines the desired state of AWSProvider -type AWSProviderSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of AWSProvider. Edit awsprovider_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// AWSProviderStatus defines the observed state of AWSProvider -type AWSProviderStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// AWSProvider is the Schema for the awsprovider API -type AWSProvider struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec AWSProviderSpec `json:"spec,omitempty"` - Status AWSProviderStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// AWSProviderList contains a list of AWSProvider -type AWSProviderList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSProvider `json:"items"` -} - -func init() { - SchemeBuilder.Register(&AWSProvider{}, &AWSProviderList{}) -} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 4f25349f2..7f6c6c00b 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -25,95 +25,6 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSProvider) DeepCopyInto(out *AWSProvider) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSProvider. -func (in *AWSProvider) DeepCopy() *AWSProvider { - if in == nil { - return nil - } - out := new(AWSProvider) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSProvider) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSProviderList) DeepCopyInto(out *AWSProviderList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]AWSProvider, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSProviderList. -func (in *AWSProviderList) DeepCopy() *AWSProviderList { - if in == nil { - return nil - } - out := new(AWSProviderList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSProviderList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSProviderSpec) DeepCopyInto(out *AWSProviderSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSProviderSpec. -func (in *AWSProviderSpec) DeepCopy() *AWSProviderSpec { - if in == nil { - return nil - } - out := new(AWSProviderSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSProviderStatus) DeepCopyInto(out *AWSProviderStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSProviderStatus. -func (in *AWSProviderStatus) DeepCopy() *AWSProviderStatus { - if in == nil { - return nil - } - out := new(AWSProviderStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Component) DeepCopyInto(out *Component) { *out = *in diff --git a/cmd/main.go b/cmd/main.go index de691db76..1f902b5c4 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -172,13 +172,6 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "Management") os.Exit(1) } - if err = (&controller.AWSProviderReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "AWSProvider") - os.Exit(1) - } if err = mgr.Add(&controller.Poller{ Client: mgr.GetClient(), Config: mgr.GetConfig(), diff --git a/internal/controller/provideraws_controller.go b/internal/controller/provideraws_controller.go deleted file mode 100644 index bb678aea6..000000000 --- a/internal/controller/provideraws_controller.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2024 -// -// 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 controller - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - hmcmirantiscomv1alpha1 "github.com/Mirantis/hmc/api/v1alpha1" -) - -// AWSProviderReconciler reconciles a AWSProvider object -type AWSProviderReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the AWSProvider object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.17.3/pkg/reconcile -func (r *AWSProviderReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *AWSProviderReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&hmcmirantiscomv1alpha1.AWSProvider{}). - Complete(r) -} diff --git a/internal/controller/provideraws_controller_test.go b/internal/controller/provideraws_controller_test.go deleted file mode 100644 index 06ca19ce3..000000000 --- a/internal/controller/provideraws_controller_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2024 -// -// 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 controller - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - hmcmirantiscomv1alpha1 "github.com/Mirantis/hmc/api/v1alpha1" -) - -var _ = Describe("AWSProvider Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - awsprovider := &hmcmirantiscomv1alpha1.AWSProvider{} - - BeforeEach(func() { - By("creating the custom resource for the Kind AWSProvider") - err := k8sClient.Get(ctx, typeNamespacedName, awsprovider) - if err != nil && errors.IsNotFound(err) { - resource := &hmcmirantiscomv1alpha1.AWSProvider{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &hmcmirantiscomv1alpha1.AWSProvider{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance AWSProvider") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &AWSProviderReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/templates/hmc/templates/crds/hmc.mirantis.com_awsproviders.yaml b/templates/hmc/templates/crds/hmc.mirantis.com_awsproviders.yaml deleted file mode 100644 index 0c0256858..000000000 --- a/templates/hmc/templates/crds/hmc.mirantis.com_awsproviders.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.14.0 - name: awsproviders.hmc.mirantis.com -spec: - group: hmc.mirantis.com - names: - kind: AWSProvider - listKind: AWSProviderList - plural: awsproviders - singular: awsprovider - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: AWSProvider is the Schema for the awsprovider 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.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - 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.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: AWSProviderSpec defines the desired state of AWSProvider - properties: - foo: - description: Foo is an example field of AWSProvider. Edit awsprovider_types.go - to remove/update - type: string - type: object - status: - description: AWSProviderStatus defines the observed state of AWSProvider - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/templates/hmc/templates/rbac/roles.yaml b/templates/hmc/templates/rbac/roles.yaml index 7cad5c226..a498dfb9d 100644 --- a/templates/hmc/templates/rbac/roles.yaml +++ b/templates/hmc/templates/rbac/roles.yaml @@ -17,32 +17,6 @@ rules: - patch - update - watch -- apiGroups: - - hmc.mirantis.com - resources: - - awsproviders - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - hmc.mirantis.com - resources: - - awsproviders/finalizers - verbs: - - update -- apiGroups: - - hmc.mirantis.com - resources: - - awsproviders/status - verbs: - - get - - patch - - update - apiGroups: - hmc.mirantis.com resources: