From e528a89a731b8e49443d3db1d1db3cea107ef59f Mon Sep 17 00:00:00 2001
From: Sidney Shiba <sidney.shiba@ericsson.com>
Date: Wed, 21 Oct 2020 13:40:57 -0500
Subject: [PATCH] BootConfiguration struct for Bootstrap Container

Adding BootConfiguration structure in preparation for the implementation
of Bootstrap Container / Ephemeral Cluster through "phase/executor".

Change-Id: I0239e9c975784703dd6abacbb17b5e15744f3924
---
 pkg/api/v1alpha1/README.md                  | 25 +++++++++
 pkg/api/v1alpha1/bootconfiguration_types.go | 48 +++++++++++++++++
 pkg/api/v1alpha1/groupversion_info.go       |  1 +
 pkg/api/v1alpha1/zz_generated.deepcopy.go   | 57 +++++++++++++++++++++
 4 files changed, 131 insertions(+)
 create mode 100644 pkg/api/v1alpha1/README.md
 create mode 100644 pkg/api/v1alpha1/bootconfiguration_types.go

diff --git a/pkg/api/v1alpha1/README.md b/pkg/api/v1alpha1/README.md
new file mode 100644
index 000000000..67dc929a5
--- /dev/null
+++ b/pkg/api/v1alpha1/README.md
@@ -0,0 +1,25 @@
+# Generating *zz_generated.deepcopy.go* in api/v1alpha1
+
+This directory contains the data types needed by *airshipctl phase run* command.
+
+When you add a new data structure in this directory you will need to generate the file *zz_generated.deepcopy.go*.
+To generate this file you will need the tool *controller-gen" executable.
+
+If you don't have *controller-gen* in your machine, clone the following repository and compile it.
+
+```bash
+git clone https://github.com/kubernetes-sigs/controller-tools.git
+cd controller-tools/cmd/controller-gen
+go build -o controller-gen
+```
+
+Now you can generate the *zz_generated.deepcopy.go* using *controller-gen* as follow:
+
+```bash
+/path/to/controller-gen object paths=/path/to/airshipctl/pkg/api/v1alpha1/
+```
+
+At this point you should have a newly generated *zz_generated.deepcopy.go*.
+Just check if your data structure has been added to this file and you are good to go.
+
+>TODO: Add this task in the Makefile
diff --git a/pkg/api/v1alpha1/bootconfiguration_types.go b/pkg/api/v1alpha1/bootconfiguration_types.go
new file mode 100644
index 000000000..77b0e7fd9
--- /dev/null
+++ b/pkg/api/v1alpha1/bootconfiguration_types.go
@@ -0,0 +1,48 @@
+/*
+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"
+)
+
+// EphemeralCluster structure contains the data for the ephemeral cluster
+type EphemeralCluster struct {
+	BootstrapCommand string `json:"bootstrapCommand,omitempty"`
+	ConfigFilename   string `json:"configFilename,omitempty"`
+}
+
+// BootstrapContainer structure contains the data for the bootstrap container
+type BootstrapContainer struct {
+	ContainerRuntime string `json:"containerRuntime,omitempty"`
+	Image            string `json:"image,omitempty"`
+	Volume           string `json:"volume,omitempty"`
+	Kubeconfig       string `json:"kubeconfig,omitempty"`
+}
+
+// BootConfiguration structure is inherited from apimachinery TypeMeta and ObjectMeta and is a top level
+// configuration structure for the bootstrap container
+type BootConfiguration struct {
+	metav1.TypeMeta   `json:",inline"`
+	metav1.ObjectMeta `json:"metadata,omitempty"`
+
+	BootstrapContainer BootstrapContainer `json:"bootstrapContainer"`
+	EphemeralCluster   EphemeralCluster   `json:"ephemeralCluster"`
+}
+
+// DefaultBootConfiguration can be used to safely unmarshal BootConfiguration object without nil pointers
+func DefaultBootConfiguration() *BootConfiguration {
+	return &BootConfiguration{}
+}
diff --git a/pkg/api/v1alpha1/groupversion_info.go b/pkg/api/v1alpha1/groupversion_info.go
index d796560ed..42db8f838 100644
--- a/pkg/api/v1alpha1/groupversion_info.go
+++ b/pkg/api/v1alpha1/groupversion_info.go
@@ -51,6 +51,7 @@ func init() {
 		&ClusterMap{},
 		&ReplacementTransformer{},
 		&Templater{},
+		&BootConfiguration{},
 	)
 	_ = AddToScheme(Scheme) //nolint:errcheck
 }
diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go
index ce2250d4f..4214e388c 100644
--- a/pkg/api/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go
@@ -56,6 +56,48 @@ func (in *ApplyWaitOptions) DeepCopy() *ApplyWaitOptions {
 	return out
 }
 
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *BootConfiguration) DeepCopyInto(out *BootConfiguration) {
+	*out = *in
+	out.TypeMeta = in.TypeMeta
+	in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
+	out.BootstrapContainer = in.BootstrapContainer
+	out.EphemeralCluster = in.EphemeralCluster
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootConfiguration.
+func (in *BootConfiguration) DeepCopy() *BootConfiguration {
+	if in == nil {
+		return nil
+	}
+	out := new(BootConfiguration)
+	in.DeepCopyInto(out)
+	return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *BootConfiguration) 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 *BootstrapContainer) DeepCopyInto(out *BootstrapContainer) {
+	*out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootstrapContainer.
+func (in *BootstrapContainer) DeepCopy() *BootstrapContainer {
+	if in == nil {
+		return nil
+	}
+	out := new(BootstrapContainer)
+	in.DeepCopyInto(out)
+	return out
+}
+
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *Builder) DeepCopyInto(out *Builder) {
 	*out = *in
@@ -194,6 +236,21 @@ func (in *Container) DeepCopy() *Container {
 	return out
 }
 
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *EphemeralCluster) DeepCopyInto(out *EphemeralCluster) {
+	*out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EphemeralCluster.
+func (in *EphemeralCluster) DeepCopy() *EphemeralCluster {
+	if in == nil {
+		return nil
+	}
+	out := new(EphemeralCluster)
+	in.DeepCopyInto(out)
+	return out
+}
+
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *ImageConfiguration) DeepCopyInto(out *ImageConfiguration) {
 	*out = *in