|
| 1 | +/* |
| 2 | +Copyright 2019 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package actuators |
| 18 | + |
| 19 | +import ( |
| 20 | + "fmt" |
| 21 | + |
| 22 | + "sigs.k8s.io/cluster-api-provider-docker/kind/actions" |
| 23 | + clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" |
| 24 | +) |
| 25 | + |
| 26 | +// Cluster defines a cluster actuator object |
| 27 | +type Cluster struct { |
| 28 | +} |
| 29 | + |
| 30 | +// NewClusterActuator returns a new cluster actuator object |
| 31 | +func NewClusterActuator() *Cluster { |
| 32 | + return &Cluster{} |
| 33 | +} |
| 34 | + |
| 35 | +// Reconcile setups an external load balancer for the cluster if needed |
| 36 | +func (c *Cluster) Reconcile(cluster *clusterv1.Cluster) error { |
| 37 | + elb, err := getExternalLoadBalancerNode(cluster.Name) |
| 38 | + if err != nil { |
| 39 | + fmt.Printf("%+v\n", err) |
| 40 | + return err |
| 41 | + } |
| 42 | + if elb != nil { |
| 43 | + fmt.Println("External Load Balancer already exists. Nothing to do for this cluster.") |
| 44 | + return nil |
| 45 | + } |
| 46 | + fmt.Printf("The cluster named %q has been created! Setting up some infrastructure.\n", cluster.Name) |
| 47 | + _, err = actions.SetUpLoadBalancer(cluster.Name) |
| 48 | + return err |
| 49 | +} |
| 50 | + |
| 51 | +// Delete can be used to delete a cluster |
| 52 | +func (c *Cluster) Delete(cluster *clusterv1.Cluster) error { |
| 53 | + fmt.Println("Cluster delete is not implemented.") |
| 54 | + return nil |
| 55 | +} |
0 commit comments