From b212b22d098662c7575e69995ac91eef1857efd2 Mon Sep 17 00:00:00 2001 From: Lion-Wei Date: Wed, 17 Oct 2018 03:53:40 +0800 Subject: [PATCH] add cluster controller (#56) --- pkg/cloud/openstack/clusteractuator.go | 22 +++++++++++++++++ pkg/controller/add_cluster.go | 34 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 pkg/cloud/openstack/clusteractuator.go create mode 100644 pkg/controller/add_cluster.go diff --git a/pkg/cloud/openstack/clusteractuator.go b/pkg/cloud/openstack/clusteractuator.go new file mode 100644 index 0000000000..6aa513bc15 --- /dev/null +++ b/pkg/cloud/openstack/clusteractuator.go @@ -0,0 +1,22 @@ +package openstack + +import ( + "github.com/golang/glog" + clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" +) + +type OpenstackClusterClient struct{} + +func NewClusterActuator() (*OpenstackClusterClient, error) { + return &OpenstackClusterClient{}, nil +} + +func (occ *OpenstackClusterClient) Reconcile(cluster *clusterv1.Cluster) error { + glog.Errorf("Not implemented yet") + return nil +} + +func (occ *OpenstackClusterClient) Delete(cluster *clusterv1.Cluster) error { + glog.Errorf("Not implemented yet") + return nil +} diff --git a/pkg/controller/add_cluster.go b/pkg/controller/add_cluster.go new file mode 100644 index 0000000000..06d276dded --- /dev/null +++ b/pkg/controller/add_cluster.go @@ -0,0 +1,34 @@ +/* +Copyright 2018 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 controller + +import ( + "sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack" + "sigs.k8s.io/cluster-api/pkg/controller/cluster" + "sigs.k8s.io/controller-runtime/pkg/manager" +) + +func init() { + // AddToManagerFuncs is a list of functions to create controllers and add them to a manager. + AddToManagerFuncs = append(AddToManagerFuncs, func(m manager.Manager) error { + clusterActuator, err := openstack.NewClusterActuator() + if err != nil { + return err + } + return cluster.AddWithActuator(m, clusterActuator) + }) +}