diff --git a/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go b/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go index 17cf0c73ab..5612ad7071 100644 --- a/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go +++ b/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go @@ -17,22 +17,58 @@ limitations under the License. package v1alpha1 import ( + corev1 "k8s.io/api/core/v1" 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. -// AWSMachineProviderConfigSpec defines the desired state of AWSMachineProviderConfig -type AWSMachineProviderConfigSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file +// AWSMachineProviderStatus is the type that will be embedded in a Machine.Status.ProviderStatus field. +// It containsk AWS-specific status information. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type AWSMachineProviderStatus struct { + metav1.TypeMeta + + // InstanceID is the instance ID of the machine created in AWS + InstanceID *string + + // InstanceState is the state of the AWS instance for this machine + InstanceState *string + + // Conditions is a set of conditions associated with the Machine to indicate + // errors or other status + Conditions []AWSMachineProviderCondition } -// AWSMachineProviderConfigStatus defines the observed state of AWSMachineProviderConfig -type AWSMachineProviderConfigStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file +// AWSMachineProviderConditionType is a valid value for AWSMachineProviderCondition.Type +type AWSMachineProviderConditionType string + +// Valid conditions for an AWS machine instance +const ( + // MachineCreation indicates whether the machine has been created or not. If not, + // it should include a reason and message for the failure. + MachineCreation AWSMachineProviderConditionType = "MachineCreation" +) + +// AWSMachineProviderCondition is a condition in a AWSMachineProviderStatus +type AWSMachineProviderCondition struct { + // Type is the type of the condition. + Type AWSMachineProviderConditionType + // Status is the status of the condition. + Status corev1.ConditionStatus + // LastProbeTime is the last time we probed the condition. + // +optional + LastProbeTime metav1.Time + // LastTransitionTime is the last time the condition transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time + // Reason is a unique, one-word, CamelCase reason for the condition's last transition. + // +optional + Reason string + // Message is a human-readable message indicating details about last transition. + // +optional + Message string } // +genclient @@ -44,8 +80,94 @@ type AWSMachineProviderConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSMachineProviderConfigSpec `json:"spec,omitempty"` - Status AWSMachineProviderConfigStatus `json:"status,omitempty"` + // AMI is the reference to the AMI from which to create the machine instance. + AMI AWSResourceReference + + // InstanceType is the type of instance to create. Example: m4.xlarge + InstanceType string + + // Tags is the set of tags to add to apply to an instance, in addition to the ones + // added by default by the actuator. These tags are additive. The actuator will ensure + // these tags are present, but will not remove any other tags that may exist on the + // instance. + Tags []TagSpecification + + // IAMInstanceProfile is a reference to an IAM role to assign to the instance + IAMInstanceProfile *AWSResourceReference + + // UserDataSecret contains a local reference to a secret that contains the + // UserData to apply to the instance + UserDataSecret *corev1.LocalObjectReference + + // CredentialsSecret is a reference to the secret with AWS credentials. Otherwise, defaults to permissions + // provided by attached IAM role where the actuator is running. + CredentialsSecret *corev1.LocalObjectReference + + // KeyName is the name of the KeyPair to use for SSH + KeyName *string + + // DeviceIndex is the index of the device on the instance for the network interface attachment. + // Defaults to 0. + DeviceIndex int64 + + // PublicIP specifies whether the instance should get a public IP. If not present, + // it should use the default of its subnet. + PublicIP *bool + + // SecurityGroups is an array of references to security groups that should be applied to the + // instance. + SecurityGroups []AWSResourceReference + + // Subnet is a reference to the subnet to use for this instance + Subnet AWSResourceReference + + // Placement specifies where to create the instance in AWS + Placement Placement + + // LoadBalancerIDs is the IDs of the load balancers to which the new instance + // should be added once it is created. + LoadBalancerIDs []AWSResourceReference +} + +// AWSResourceReference is a reference to a specific AWS resource by ID, ARN, or filters. +// Only one of ID, ARN or Filters may be specified. Specifying more than one will result in +// a validation error. +type AWSResourceReference struct { + // ID of resource + ID *string + + // ARN of resource + ARN *string + + // Filters is a set of filters used to identify a resource + Filters []Filter +} + +// Placement indicates where to create the instance in AWS +type Placement struct { + // Region is the region to use to create the instance + Region string + + // AvailabilityZone is the availability zone of the instance + AvailabilityZone string +} + +// Filter is a filter used to identify an AWS resource +type Filter struct { + // Name of the filter. Filter names are case-sensitive. + Name string + + // Values includes one or more filter values. Filter values are case-sensitive. + Values []string +} + +// TagSpecification is the name/value pair for a tag +type TagSpecification struct { + // Name of the tag + Name string + + // Value of the tag + Value string } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -58,5 +180,5 @@ type AWSMachineProviderConfigList struct { } func init() { - SchemeBuilder.Register(&AWSMachineProviderConfig{}, &AWSMachineProviderConfigList{}) + SchemeBuilder.Register(&AWSMachineProviderConfig{}, &AWSMachineProviderConfigList{}, AWSMachineProviderStatus{}) } diff --git a/pkg/apis/awsproviderconfig/v1alpha1/register.go b/pkg/apis/awsproviderconfig/v1alpha1/register.go index 77ecd486c9..3d87b9efb2 100644 --- a/pkg/apis/awsproviderconfig/v1alpha1/register.go +++ b/pkg/apis/awsproviderconfig/v1alpha1/register.go @@ -25,8 +25,13 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/runtime/serializer" + clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" + "fmt" + "bytes" ) var ( @@ -36,3 +41,85 @@ var ( // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} ) + +// AWSProviderConfigCodec is a runtime codec for the provider configuration +// +k8s:deepcopy-gen=false +type AWSProviderConfigCodec struct { + encoder runtime.Encoder + decoder runtime.Decoder +} + +// NewScheme creates a new Scheme +func NewScheme() (*runtime.Scheme, error) { + return SchemeBuilder.Build() +} + +// NewCodec creates a serializer/deserializer for the provider configuration +func NewCodec() (*AWSProviderConfigCodec, error) { + scheme, err := NewScheme() + if err != nil { + return nil, err + } + codecFactory := serializer.NewCodecFactory(scheme) + encoder, err := newEncoder(&codecFactory) + if err != nil { + return nil, err + } + codec := AWSProviderConfigCodec{ + encoder: encoder, + decoder: codecFactory.UniversalDecoder(SchemeGroupVersion), + } + return &codec, nil +} + +// DecodeFromProviderConfig deserialises an object from the provider config +func (codec *AWSProviderConfigCodec) DecodeFromProviderConfig(providerConfig clusterv1.ProviderConfig, out runtime.Object) error { + if providerConfig.Value != nil { + _, _, err := codec.decoder.Decode(providerConfig.Value.Raw, nil, out) + if err != nil { + return fmt.Errorf("decoding failure: %v", err) + } + } + return nil +} + +// EncodeToProviderConfig serialises an object to the provider config +func (codec *AWSProviderConfigCodec) EncodeToProviderConfig(in runtime.Object) (*clusterv1.ProviderConfig, error) { + var buf bytes.Buffer + if err := codec.encoder.Encode(in, &buf); err != nil { + return nil, fmt.Errorf("encoding failed: %v", err) + } + return &clusterv1.ProviderConfig{ + Value: &runtime.RawExtension{Raw: buf.Bytes()}, + }, nil +} + +// EncodeProviderStatus serialises the provider status +func (codec *AWSProviderConfigCodec) EncodeProviderStatus(in runtime.Object) (*runtime.RawExtension, error) { + var buf bytes.Buffer + if err := codec.encoder.Encode(in, &buf); err != nil { + return nil, fmt.Errorf("encoding failed: %v", err) + } + + return &runtime.RawExtension{Raw: buf.Bytes()}, nil +} + +// DecodeProviderStatus serialises the provider status +func (codec *AWSProviderConfigCodec) DecodeProviderStatus(providerStatus *runtime.RawExtension, out runtime.Object) error { + if providerStatus != nil { + _, _, err := codec.decoder.Decode(providerStatus.Raw, nil, out) + if err != nil { + return fmt.Errorf("decoding failure: %v", err) + } + } + return nil +} + +func newEncoder(codecFactory *serializer.CodecFactory) (runtime.Encoder, error) { + serializerInfos := codecFactory.SupportedMediaTypes() + if len(serializerInfos) == 0 { + return nil, fmt.Errorf("unable to find any serlializers") + } + encoder := codecFactory.EncoderForVersion(serializerInfos[0].Serializer, SchemeGroupVersion) + return encoder, nil +} \ No newline at end of file diff --git a/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go index 2727b707eb..d949a9c9f0 100644 --- a/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go @@ -20,16 +20,80 @@ limitations under the License. package v1alpha1 import ( + v1 "k8s.io/api/core/v1" 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 *AWSMachineProviderCondition) DeepCopyInto(out *AWSMachineProviderCondition) { + *out = *in + in.LastProbeTime.DeepCopyInto(&out.LastProbeTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderCondition. +func (in *AWSMachineProviderCondition) DeepCopy() *AWSMachineProviderCondition { + if in == nil { + return nil + } + out := new(AWSMachineProviderCondition) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AWSMachineProviderConfig) DeepCopyInto(out *AWSMachineProviderConfig) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status + in.AMI.DeepCopyInto(&out.AMI) + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make([]TagSpecification, len(*in)) + copy(*out, *in) + } + if in.IAMInstanceProfile != nil { + in, out := &in.IAMInstanceProfile, &out.IAMInstanceProfile + *out = new(AWSResourceReference) + (*in).DeepCopyInto(*out) + } + if in.UserDataSecret != nil { + in, out := &in.UserDataSecret, &out.UserDataSecret + *out = new(v1.LocalObjectReference) + **out = **in + } + if in.CredentialsSecret != nil { + in, out := &in.CredentialsSecret, &out.CredentialsSecret + *out = new(v1.LocalObjectReference) + **out = **in + } + if in.KeyName != nil { + in, out := &in.KeyName, &out.KeyName + *out = new(string) + **out = **in + } + if in.PublicIP != nil { + in, out := &in.PublicIP, &out.PublicIP + *out = new(bool) + **out = **in + } + if in.SecurityGroups != nil { + in, out := &in.SecurityGroups, &out.SecurityGroups + *out = make([]AWSResourceReference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.Subnet.DeepCopyInto(&out.Subnet) + out.Placement = in.Placement + if in.LoadBalancerIDs != nil { + in, out := &in.LoadBalancerIDs, &out.LoadBalancerIDs + *out = make([]AWSResourceReference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -85,33 +149,129 @@ func (in *AWSMachineProviderConfigList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSMachineProviderConfigSpec) DeepCopyInto(out *AWSMachineProviderConfigSpec) { +func (in *AWSMachineProviderStatus) DeepCopyInto(out *AWSMachineProviderStatus) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.InstanceID != nil { + in, out := &in.InstanceID, &out.InstanceID + *out = new(string) + **out = **in + } + if in.InstanceState != nil { + in, out := &in.InstanceState, &out.InstanceState + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]AWSMachineProviderCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderStatus. +func (in *AWSMachineProviderStatus) DeepCopy() *AWSMachineProviderStatus { + if in == nil { + return nil + } + out := new(AWSMachineProviderStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSMachineProviderStatus) 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 *AWSResourceReference) DeepCopyInto(out *AWSResourceReference) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.ARN != nil { + in, out := &in.ARN, &out.ARN + *out = new(string) + **out = **in + } + if in.Filters != nil { + in, out := &in.Filters, &out.Filters + *out = make([]Filter, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSResourceReference. +func (in *AWSResourceReference) DeepCopy() *AWSResourceReference { + if in == nil { + return nil + } + out := new(AWSResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Filter) DeepCopyInto(out *Filter) { + *out = *in + if in.Values != nil { + in, out := &in.Values, &out.Values + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Filter. +func (in *Filter) DeepCopy() *Filter { + if in == nil { + return nil + } + out := new(Filter) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Placement) DeepCopyInto(out *Placement) { *out = *in return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderConfigSpec. -func (in *AWSMachineProviderConfigSpec) DeepCopy() *AWSMachineProviderConfigSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Placement. +func (in *Placement) DeepCopy() *Placement { if in == nil { return nil } - out := new(AWSMachineProviderConfigSpec) + out := new(Placement) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSMachineProviderConfigStatus) DeepCopyInto(out *AWSMachineProviderConfigStatus) { +func (in *TagSpecification) DeepCopyInto(out *TagSpecification) { *out = *in return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderConfigStatus. -func (in *AWSMachineProviderConfigStatus) DeepCopy() *AWSMachineProviderConfigStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagSpecification. +func (in *TagSpecification) DeepCopy() *TagSpecification { if in == nil { return nil } - out := new(AWSMachineProviderConfigStatus) + out := new(TagSpecification) in.DeepCopyInto(out) return out } diff --git a/pkg/cloud/aws/client/mock/client_generated.go b/pkg/cloud/aws/client/mock/client_generated.go index a4524810cb..d7925e87fe 100644 --- a/pkg/cloud/aws/client/mock/client_generated.go +++ b/pkg/cloud/aws/client/mock/client_generated.go @@ -1,139 +1,119 @@ -// Code generated by MockGen. DO NOT EDIT. +// Automatically generated by MockGen. DO NOT EDIT! // Source: ./client.go -// Package mock is a generated GoMock package. package mock import ( ec2 "github.com/aws/aws-sdk-go/service/ec2" elb "github.com/aws/aws-sdk-go/service/elb" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockClient is a mock of Client interface +// Mock of Client interface type MockClient struct { ctrl *gomock.Controller - recorder *MockClientMockRecorder + recorder *_MockClientRecorder } -// MockClientMockRecorder is the mock recorder for MockClient -type MockClientMockRecorder struct { +// Recorder for MockClient (not exported) +type _MockClientRecorder struct { mock *MockClient } -// NewMockClient creates a new mock instance func NewMockClient(ctrl *gomock.Controller) *MockClient { mock := &MockClient{ctrl: ctrl} - mock.recorder = &MockClientMockRecorder{mock} + mock.recorder = &_MockClientRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockClient) EXPECT() *MockClientMockRecorder { - return m.recorder +func (_m *MockClient) EXPECT() *_MockClientRecorder { + return _m.recorder } -// DescribeImages mocks base method -func (m *MockClient) DescribeImages(arg0 *ec2.DescribeImagesInput) (*ec2.DescribeImagesOutput, error) { - ret := m.ctrl.Call(m, "DescribeImages", arg0) +func (_m *MockClient) DescribeImages(_param0 *ec2.DescribeImagesInput) (*ec2.DescribeImagesOutput, error) { + ret := _m.ctrl.Call(_m, "DescribeImages", _param0) ret0, _ := ret[0].(*ec2.DescribeImagesOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeImages indicates an expected call of DescribeImages -func (mr *MockClientMockRecorder) DescribeImages(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeImages", reflect.TypeOf((*MockClient)(nil).DescribeImages), arg0) +func (_mr *_MockClientRecorder) DescribeImages(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "DescribeImages", arg0) } -// DescribeVpcs mocks base method -func (m *MockClient) DescribeVpcs(arg0 *ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error) { - ret := m.ctrl.Call(m, "DescribeVpcs", arg0) +func (_m *MockClient) DescribeVpcs(_param0 *ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error) { + ret := _m.ctrl.Call(_m, "DescribeVpcs", _param0) ret0, _ := ret[0].(*ec2.DescribeVpcsOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeVpcs indicates an expected call of DescribeVpcs -func (mr *MockClientMockRecorder) DescribeVpcs(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeVpcs", reflect.TypeOf((*MockClient)(nil).DescribeVpcs), arg0) +func (_mr *_MockClientRecorder) DescribeVpcs(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "DescribeVpcs", arg0) } -// DescribeSubnets mocks base method -func (m *MockClient) DescribeSubnets(arg0 *ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error) { - ret := m.ctrl.Call(m, "DescribeSubnets", arg0) +func (_m *MockClient) DescribeSubnets(_param0 *ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error) { + ret := _m.ctrl.Call(_m, "DescribeSubnets", _param0) ret0, _ := ret[0].(*ec2.DescribeSubnetsOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeSubnets indicates an expected call of DescribeSubnets -func (mr *MockClientMockRecorder) DescribeSubnets(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeSubnets", reflect.TypeOf((*MockClient)(nil).DescribeSubnets), arg0) +func (_mr *_MockClientRecorder) DescribeSubnets(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "DescribeSubnets", arg0) } -// DescribeSecurityGroups mocks base method -func (m *MockClient) DescribeSecurityGroups(arg0 *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error) { - ret := m.ctrl.Call(m, "DescribeSecurityGroups", arg0) +func (_m *MockClient) DescribeSecurityGroups(_param0 *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error) { + ret := _m.ctrl.Call(_m, "DescribeSecurityGroups", _param0) ret0, _ := ret[0].(*ec2.DescribeSecurityGroupsOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeSecurityGroups indicates an expected call of DescribeSecurityGroups -func (mr *MockClientMockRecorder) DescribeSecurityGroups(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeSecurityGroups", reflect.TypeOf((*MockClient)(nil).DescribeSecurityGroups), arg0) +func (_mr *_MockClientRecorder) DescribeSecurityGroups(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "DescribeSecurityGroups", arg0) } -// RunInstances mocks base method -func (m *MockClient) RunInstances(arg0 *ec2.RunInstancesInput) (*ec2.Reservation, error) { - ret := m.ctrl.Call(m, "RunInstances", arg0) +func (_m *MockClient) RunInstances(_param0 *ec2.RunInstancesInput) (*ec2.Reservation, error) { + ret := _m.ctrl.Call(_m, "RunInstances", _param0) ret0, _ := ret[0].(*ec2.Reservation) ret1, _ := ret[1].(error) return ret0, ret1 } -// RunInstances indicates an expected call of RunInstances -func (mr *MockClientMockRecorder) RunInstances(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunInstances", reflect.TypeOf((*MockClient)(nil).RunInstances), arg0) +func (_mr *_MockClientRecorder) RunInstances(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "RunInstances", arg0) } -// DescribeInstances mocks base method -func (m *MockClient) DescribeInstances(arg0 *ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error) { - ret := m.ctrl.Call(m, "DescribeInstances", arg0) +func (_m *MockClient) DescribeInstances(_param0 *ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error) { + ret := _m.ctrl.Call(_m, "DescribeInstances", _param0) ret0, _ := ret[0].(*ec2.DescribeInstancesOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeInstances indicates an expected call of DescribeInstances -func (mr *MockClientMockRecorder) DescribeInstances(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeInstances", reflect.TypeOf((*MockClient)(nil).DescribeInstances), arg0) +func (_mr *_MockClientRecorder) DescribeInstances(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "DescribeInstances", arg0) } -// TerminateInstances mocks base method -func (m *MockClient) TerminateInstances(arg0 *ec2.TerminateInstancesInput) (*ec2.TerminateInstancesOutput, error) { - ret := m.ctrl.Call(m, "TerminateInstances", arg0) +func (_m *MockClient) TerminateInstances(_param0 *ec2.TerminateInstancesInput) (*ec2.TerminateInstancesOutput, error) { + ret := _m.ctrl.Call(_m, "TerminateInstances", _param0) ret0, _ := ret[0].(*ec2.TerminateInstancesOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// TerminateInstances indicates an expected call of TerminateInstances -func (mr *MockClientMockRecorder) TerminateInstances(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TerminateInstances", reflect.TypeOf((*MockClient)(nil).TerminateInstances), arg0) +func (_mr *_MockClientRecorder) TerminateInstances(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "TerminateInstances", arg0) } -// RegisterInstancesWithLoadBalancer mocks base method -func (m *MockClient) RegisterInstancesWithLoadBalancer(arg0 *elb.RegisterInstancesWithLoadBalancerInput) (*elb.RegisterInstancesWithLoadBalancerOutput, error) { - ret := m.ctrl.Call(m, "RegisterInstancesWithLoadBalancer", arg0) +func (_m *MockClient) RegisterInstancesWithLoadBalancer(_param0 *elb.RegisterInstancesWithLoadBalancerInput) (*elb.RegisterInstancesWithLoadBalancerOutput, error) { + ret := _m.ctrl.Call(_m, "RegisterInstancesWithLoadBalancer", _param0) ret0, _ := ret[0].(*elb.RegisterInstancesWithLoadBalancerOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// RegisterInstancesWithLoadBalancer indicates an expected call of RegisterInstancesWithLoadBalancer -func (mr *MockClientMockRecorder) RegisterInstancesWithLoadBalancer(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInstancesWithLoadBalancer", reflect.TypeOf((*MockClient)(nil).RegisterInstancesWithLoadBalancer), arg0) +func (_mr *_MockClientRecorder) RegisterInstancesWithLoadBalancer(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "RegisterInstancesWithLoadBalancer", arg0) } diff --git a/pkg/cloud/aws/providerconfig/doc.go b/pkg/cloud/aws/providerconfig/doc.go deleted file mode 100644 index cf3ca4fa76..0000000000 --- a/pkg/cloud/aws/providerconfig/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/aws/providerconfig -// +k8s:openapi-gen=true -// +k8s:defaulter-gen=TypeMeta - -package providerconfig diff --git a/pkg/cloud/aws/providerconfig/register.go b/pkg/cloud/aws/providerconfig/register.go deleted file mode 100644 index 3227420d1a..0000000000 --- a/pkg/cloud/aws/providerconfig/register.go +++ /dev/null @@ -1,63 +0,0 @@ -// 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 providerconfig - -import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -var ( - // SchemeBuilder with scheme builder - SchemeBuilder runtime.SchemeBuilder - // AddToScheme is method for adding objects to the scheme - AddToScheme = SchemeBuilder.AddToScheme - localSchemeBuilder = &SchemeBuilder -) - -func init() { - localSchemeBuilder.Register(addKnownTypes) -} - -// GroupName is group name of the cluster kinds -const GroupName = "aws.cluster.k8s.io" - -// SchemeGroupVersion is scheme group version of the cluster kinds -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} - -// Kind returns group kind for a given kind/object -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Resource returns group resource for a given resource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSMachineProviderConfig{}, - ) - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSClusterProviderConfig{}, - ) - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSMachineProviderStatus{}, - ) - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSClusterProviderStatus{}, - ) - return nil -} diff --git a/pkg/cloud/aws/providerconfig/types.go b/pkg/cloud/aws/providerconfig/types.go deleted file mode 100644 index a1d910faa2..0000000000 --- a/pkg/cloud/aws/providerconfig/types.go +++ /dev/null @@ -1,174 +0,0 @@ -// 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 providerconfig - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// AWSMachineProviderConfig is the type that will be embedded in a Machine.Spec.ProviderConfig field -// for an AWS instance. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AWSMachineProviderConfig struct { - metav1.TypeMeta - - // AMI is the reference to the AMI from which to create the machine instance. - AMI AWSResourceReference - - // InstanceType is the type of instance to create. Example: m4.xlarge - InstanceType string - - // Tags is the set of tags to add to apply to an instance, in addition to the ones - // added by default by the actuator. These tags are additive. The actuator will ensure - // these tags are present, but will not remove any other tags that may exist on the - // instance. - Tags []TagSpecification - - // IAMInstanceProfile is a reference to an IAM role to assign to the instance - IAMInstanceProfile *AWSResourceReference - - // UserDataSecret contains a local reference to a secret that contains the - // UserData to apply to the instance - UserDataSecret *corev1.LocalObjectReference - - // CredentialsSecret is a reference to the secret with AWS credentials. Otherwise, defaults to permissions - // provided by attached IAM role where the actuator is running. - CredentialsSecret *corev1.LocalObjectReference - - // KeyName is the name of the KeyPair to use for SSH - KeyName *string - - // DeviceIndex is the index of the device on the instance for the network interface attachment. - // Defaults to 0. - DeviceIndex int64 - - // PublicIP specifies whether the instance should get a public IP. If not present, - // it should use the default of its subnet. - PublicIP *bool - - // SecurityGroups is an array of references to security groups that should be applied to the - // instance. - SecurityGroups []AWSResourceReference - - // Subnet is a reference to the subnet to use for this instance - Subnet AWSResourceReference - - // Placement specifies where to create the instance in AWS - Placement Placement - - // LoadBalancerIDs is the IDs of the load balancers to which the new instance - // should be added once it is created. - LoadBalancerIDs []AWSResourceReference -} - -// AWSResourceReference is a reference to a specific AWS resource by ID, ARN, or filters. -// Only one of ID, ARN or Filters may be specified. Specifying more than one will result in -// a validation error. -type AWSResourceReference struct { - // ID of resource - ID *string - - // ARN of resource - ARN *string - - // Filters is a set of filters used to identify a resource - Filters []Filter -} - -// Placement indicates where to create the instance in AWS -type Placement struct { - // Region is the region to use to create the instance - Region string - - // AvailabilityZone is the availability zone of the instance - AvailabilityZone string -} - -// Filter is a filter used to identify an AWS resource -type Filter struct { - // Name of the filter. Filter names are case-sensitive. - Name string - - // Values includes one or more filter values. Filter values are case-sensitive. - Values []string -} - -// TagSpecification is the name/value pair for a tag -type TagSpecification struct { - // Name of the tag - Name string - - // Value of the tag - Value string -} - -// AWSClusterProviderConfig is aws speific configuration -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AWSClusterProviderConfig struct { - metav1.TypeMeta -} - -// AWSMachineProviderStatus is the type that will be embedded in a Machine.Status.ProviderStatus field. -// It containsk AWS-specific status information. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AWSMachineProviderStatus struct { - metav1.TypeMeta - - // InstanceID is the instance ID of the machine created in AWS - InstanceID *string - - // InstanceState is the state of the AWS instance for this machine - InstanceState *string - - // Conditions is a set of conditions associated with the Machine to indicate - // errors or other status - Conditions []AWSMachineProviderCondition -} - -// AWSMachineProviderConditionType is a valid value for AWSMachineProviderCondition.Type -type AWSMachineProviderConditionType string - -// Valid conditions for an AWS machine instance -const ( - // MachineCreation indicates whether the machine has been created or not. If not, - // it should include a reason and message for the failure. - MachineCreation AWSMachineProviderConditionType = "MachineCreation" -) - -// AWSMachineProviderCondition is a condition in a AWSMachineProviderStatus -type AWSMachineProviderCondition struct { - // Type is the type of the condition. - Type AWSMachineProviderConditionType - // Status is the status of the condition. - Status corev1.ConditionStatus - // LastProbeTime is the last time we probed the condition. - // +optional - LastProbeTime metav1.Time - // LastTransitionTime is the last time the condition transitioned from one status to another. - // +optional - LastTransitionTime metav1.Time - // Reason is a unique, one-word, CamelCase reason for the condition's last transition. - // +optional - Reason string - // Message is a human-readable message indicating details about last transition. - // +optional - Message string -} - -// AWSClusterProviderStatus is AWS specific status -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AWSClusterProviderStatus struct { - metav1.TypeMeta -} diff --git a/pkg/cloud/aws/providerconfig/v1alpha1/doc.go b/pkg/cloud/aws/providerconfig/v1alpha1/doc.go deleted file mode 100644 index e49e252d7d..0000000000 --- a/pkg/cloud/aws/providerconfig/v1alpha1/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/aws/providerconfig -// +k8s:openapi-gen=true -// +k8s:defaulter-gen=TypeMeta - -package v1alpha1 diff --git a/pkg/cloud/aws/providerconfig/v1alpha1/register.go b/pkg/cloud/aws/providerconfig/v1alpha1/register.go deleted file mode 100644 index e2439e4fa4..0000000000 --- a/pkg/cloud/aws/providerconfig/v1alpha1/register.go +++ /dev/null @@ -1,159 +0,0 @@ -// 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 v1alpha1 - -import ( - "bytes" - "fmt" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/runtime/serializer" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - - "sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/aws/providerconfig" -) - -// AWSProviderConfigCodec carries AWS provider configuration encoder/decoder -// +k8s:deepcopy-gen=false -type AWSProviderConfigCodec struct { - encoder runtime.Encoder - decoder runtime.Decoder -} - -// GroupName is group name of the cluster kinds -const GroupName = "aws.cluster.k8s.io" - -// SchemeGroupVersion is scheme group version of the cluster kinds -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} - -var ( - // SchemeBuilder with scheme builder - SchemeBuilder runtime.SchemeBuilder - localSchemeBuilder = &SchemeBuilder - // AddToScheme is method for adding objects to the scheme - AddToScheme = localSchemeBuilder.AddToScheme -) - -var ( - // Scheme with new scheme - Scheme, _ = NewScheme() - // Codecs for creating a server config - Codecs = serializer.NewCodecFactory(Scheme) - // Encoder for encoding cluster objects - Encoder, _ = newEncoder(&Codecs) -) - -func init() { - localSchemeBuilder.Register(addKnownTypes) -} - -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSMachineProviderConfig{}, - ) - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSClusterProviderConfig{}, - ) - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSMachineProviderStatus{}, - ) - scheme.AddKnownTypes(SchemeGroupVersion, - &AWSClusterProviderStatus{}, - ) - return nil -} - -// NewScheme builds new scheme -func NewScheme() (*runtime.Scheme, error) { - scheme := runtime.NewScheme() - if err := AddToScheme(scheme); err != nil { - return nil, err - } - if err := providerconfig.AddToScheme(scheme); err != nil { - return nil, err - } - addKnownTypes(scheme) - return scheme, nil -} - -// NewCodec builds new coder and encoder -func NewCodec() (*AWSProviderConfigCodec, error) { - scheme, err := NewScheme() - if err != nil { - return nil, err - } - codecFactory := serializer.NewCodecFactory(scheme) - encoder, err := newEncoder(&codecFactory) - if err != nil { - return nil, err - } - codec := AWSProviderConfigCodec{ - encoder: encoder, - decoder: codecFactory.UniversalDecoder(SchemeGroupVersion), - } - return &codec, nil -} - -// DecodeFromProviderConfig decodes provider config into accessible object -func (codec *AWSProviderConfigCodec) DecodeFromProviderConfig(providerConfig clusterv1.ProviderConfig, out runtime.Object) error { - if providerConfig.Value != nil { - _, _, err := codec.decoder.Decode(providerConfig.Value.Raw, nil, out) - if err != nil { - return fmt.Errorf("decoding failure: %v", err) - } - } - return nil -} - -// EncodeToProviderConfig encodes provider config into raw bytes -func (codec *AWSProviderConfigCodec) EncodeToProviderConfig(in runtime.Object) (*clusterv1.ProviderConfig, error) { - var buf bytes.Buffer - if err := codec.encoder.Encode(in, &buf); err != nil { - return nil, fmt.Errorf("encoding failed: %v", err) - } - return &clusterv1.ProviderConfig{ - Value: &runtime.RawExtension{Raw: buf.Bytes()}, - }, nil -} - -// EncodeProviderStatus decodes provider status into accessible object -func (codec *AWSProviderConfigCodec) EncodeProviderStatus(in runtime.Object) (*runtime.RawExtension, error) { - var buf bytes.Buffer - if err := codec.encoder.Encode(in, &buf); err != nil { - return nil, fmt.Errorf("encoding failed: %v", err) - } - - return &runtime.RawExtension{Raw: buf.Bytes()}, nil -} - -// DecodeProviderStatus encodes status into raw bytes -func (codec *AWSProviderConfigCodec) DecodeProviderStatus(providerStatus *runtime.RawExtension, out runtime.Object) error { - if providerStatus != nil { - _, _, err := codec.decoder.Decode(providerStatus.Raw, nil, out) - if err != nil { - return fmt.Errorf("decoding failure: %v", err) - } - } - return nil -} - -func newEncoder(codecFactory *serializer.CodecFactory) (runtime.Encoder, error) { - serializerInfos := codecFactory.SupportedMediaTypes() - if len(serializerInfos) == 0 { - return nil, fmt.Errorf("unable to find any serlializers") - } - encoder := codecFactory.EncoderForVersion(serializerInfos[0].Serializer, SchemeGroupVersion) - return encoder, nil -} diff --git a/pkg/cloud/aws/providerconfig/v1alpha1/types.go b/pkg/cloud/aws/providerconfig/v1alpha1/types.go deleted file mode 100644 index 5e5ba72c15..0000000000 --- a/pkg/cloud/aws/providerconfig/v1alpha1/types.go +++ /dev/null @@ -1,214 +0,0 @@ -/* -Copyright 2017 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 v1alpha1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// AWSMachineProviderConfig is the type that will be embedded in a Machine.Spec.ProviderConfig field -// for an AWS instance. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AWSMachineProviderConfig struct { - metav1.TypeMeta `json:",inline"` - - // AMI is the reference to the AMI from which to create the machine instance. - AMI AWSResourceReference `json:"ami"` - - // InstanceType is the type of instance to create. Example: m4.xlarge - InstanceType string `json:"instanceType"` - - // Tags is the set of tags to add to apply to an instance, in addition to the ones - // added by default by the actuator. These tags are additive. The actuator will ensure - // these tags are present, but will not remove any other tags that may exist on the - // instance. - Tags []TagSpecification `json:"tags"` - - // IAMInstanceProfile is a reference to an IAM role to assign to the instance - IAMInstanceProfile *AWSResourceReference `json:"iamInstanceProfile"` - - // UserDataSecret contains a local reference to a secret that contains the - // UserData to apply to the instance - UserDataSecret *corev1.LocalObjectReference `json:"userDataSecret"` - - // CredentialsSecret is a reference to the secret with AWS credentials. Otherwise, defaults to permissions - // provided by attached IAM role where the actuator is running. - CredentialsSecret *corev1.LocalObjectReference `json:"credentialsSecret"` - - // KeyName is the name of the KeyPair to use for SSH - KeyName *string `json:"keyName"` - - // DeviceIndex is the index of the device on the instance for the network interface attachment. - // Defaults to 0. - DeviceIndex int64 `json:"deviceIndex"` - - // PublicIP specifies whether the instance should get a public IP. If not present, - // it should use the default of its subnet. - PublicIP *bool `json:"publicIp"` - - // SecurityGroups is an array of references to security groups that should be applied to the - // instance. - SecurityGroups []AWSResourceReference `json:"securityGroups"` - - // Subnet is a reference to the subnet to use for this instance - Subnet AWSResourceReference `json:"subnet"` - - // Placement specifies where to create the instance in AWS - Placement Placement `json:"placement"` - - // LoadBalancerIDs is the IDs of the load balancers to which the new instance - // should be added once it is created. - LoadBalancerIDs []AWSResourceReference `json:"loadBalancerIds"` -} - -// AWSResourceReference is a reference to a specific AWS resource by ID, ARN, or filters -type AWSResourceReference struct { - // ID of resource - ID *string `json:"id"` - - // ARN of resource - ARN *string `json:"arn"` - - // Filters is a set of filters used to identify a resource - Filters []Filter `json:"filters"` -} - -// Placement indicates where to create the instance in AWS -type Placement struct { - // Region is the region to use to create the instance - Region string `json:"region"` - - // AvailabilityZone is the availability zone of the instance - AvailabilityZone string `json:"availabilityZone"` -} - -// Filter is a filter used to identify an AWS resource -type Filter struct { - // Name of the filter - Name string `json:"name"` - - // Values includes one or more filter values - Values []string `json:"values"` -} - -// TagSpecification is the name/value pair for a tag -type TagSpecification struct { - // Name of the tag - Name string `json:"name"` - - // Value of the tag - Value string `json:"value"` -} - -// AWSClusterProviderStatus is AWS specific status -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AWSClusterProviderStatus struct { - metav1.TypeMeta `json:",inline"` -} - -// Annotation constants -const ( - // ClusterNameLabel is the label that a machineset must have to identify the - // cluster to which it belongs. - ClusterNameLabel = "sigs.k8s.io/cluster-api-cluster" - MachineRoleLabel = "sigs.k8s.io/cluster-api-machine-role" - MachineTypeLabel = "sigs.k8s.io/cluster-api-machine-type" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// AWSClusterProviderConfig is the AWS specific cluster specification stored in the ProviderConfig of an AWS cluster.k8s.io.Cluster. -type AWSClusterProviderConfig struct { - // +optional - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - - // KeyPairName is the name of the AWS key pair to use for SSH access to EC2 - // instances in this cluster - KeyPairName string `json:"keyPairName"` - - // Region specifies the AWS region where the cluster will be created - Region string `json:"region"` - - // VPCName specifies the name of the VPC to associate with the cluster. - // If a value is specified, a VPC will be created with that name if it - // does not already exist in the cloud provider. If it does exist, the - // existing VPC will be used. - // If no name is specified, a VPC name will be generated using the - // cluster name and created in the cloud provider. - // +optional - VPCName string `json:"vpcName,omitempty"` -} - -// AWSMachineProviderStatus is the type that will be embedded in a Machine.Status.ProviderStatus field. -// It containsk AWS-specific status information. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AWSMachineProviderStatus struct { - metav1.TypeMeta `json:",inline"` - - // InstanceID is the instance ID of the machine created in AWS - InstanceID *string `json:"instanceId"` - - // InstanceState is the state of the AWS instance for this machine - InstanceState *string `json:"instanceState"` - - // Conditions is a set of conditions associated with the Machine to indicate - // errors or other status - Conditions []AWSMachineProviderCondition `json:"conditions"` -} - -// AWSMachineProviderConditionType is a valid value for AWSMachineProviderCondition.Type -type AWSMachineProviderConditionType string - -// Valid conditions for an AWS machine instance -const ( - // MachineCreation indicates whether the machine has been created or not. If not, - // it should include a reason and message for the failure. - MachineCreation AWSMachineProviderConditionType = "MachineCreation" -) - -// AWSMachineProviderCondition is a condition in a AWSMachineProviderStatus -type AWSMachineProviderCondition struct { - // Type is the type of the condition. - Type AWSMachineProviderConditionType `json:"type"` - // Status is the status of the condition. - Status corev1.ConditionStatus `json:"status"` - // LastProbeTime is the last time we probed the condition. - // +optional - LastProbeTime metav1.Time `json:"lastProbeTime"` - // LastTransitionTime is the last time the condition transitioned from one status to another. - // +optional - LastTransitionTime metav1.Time `json:"lastTransitionTime"` - // Reason is a unique, one-word, CamelCase reason for the condition's last transition. - // +optional - Reason string `json:"reason"` - // Message is a human-readable message indicating details about last transition. - // +optional - Message string `json:"message"` -} - -// NodeType is the type of the Node -type NodeType string - -const ( - // NodeTypeMaster is a node that is a master in the cluster - NodeTypeMaster NodeType = "Master" - // NodeTypeCompute is a node that is a compute node in the cluster - NodeTypeCompute NodeType = "Compute" -) diff --git a/pkg/cloud/aws/providerconfig/v1alpha1/zz_generated.deepcopy.go b/pkg/cloud/aws/providerconfig/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index c3f584119d..0000000000 --- a/pkg/cloud/aws/providerconfig/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,291 +0,0 @@ -// +build !ignore_autogenerated - -// 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. -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1 "k8s.io/api/core/v1" - 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 *AWSClusterProviderConfig) DeepCopyInto(out *AWSClusterProviderConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterProviderConfig. -func (in *AWSClusterProviderConfig) DeepCopy() *AWSClusterProviderConfig { - if in == nil { - return nil - } - out := new(AWSClusterProviderConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSClusterProviderConfig) 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 *AWSClusterProviderStatus) DeepCopyInto(out *AWSClusterProviderStatus) { - *out = *in - out.TypeMeta = in.TypeMeta - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterProviderStatus. -func (in *AWSClusterProviderStatus) DeepCopy() *AWSClusterProviderStatus { - if in == nil { - return nil - } - out := new(AWSClusterProviderStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSClusterProviderStatus) 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 *AWSMachineProviderCondition) DeepCopyInto(out *AWSMachineProviderCondition) { - *out = *in - in.LastProbeTime.DeepCopyInto(&out.LastProbeTime) - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderCondition. -func (in *AWSMachineProviderCondition) DeepCopy() *AWSMachineProviderCondition { - if in == nil { - return nil - } - out := new(AWSMachineProviderCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSMachineProviderConfig) DeepCopyInto(out *AWSMachineProviderConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - in.AMI.DeepCopyInto(&out.AMI) - if in.Tags != nil { - in, out := &in.Tags, &out.Tags - *out = make([]TagSpecification, len(*in)) - copy(*out, *in) - } - if in.IAMInstanceProfile != nil { - in, out := &in.IAMInstanceProfile, &out.IAMInstanceProfile - *out = new(AWSResourceReference) - (*in).DeepCopyInto(*out) - } - if in.UserDataSecret != nil { - in, out := &in.UserDataSecret, &out.UserDataSecret - *out = new(v1.LocalObjectReference) - **out = **in - } - if in.CredentialsSecret != nil { - in, out := &in.CredentialsSecret, &out.CredentialsSecret - *out = new(v1.LocalObjectReference) - **out = **in - } - if in.KeyName != nil { - in, out := &in.KeyName, &out.KeyName - *out = new(string) - **out = **in - } - if in.PublicIP != nil { - in, out := &in.PublicIP, &out.PublicIP - *out = new(bool) - **out = **in - } - if in.SecurityGroups != nil { - in, out := &in.SecurityGroups, &out.SecurityGroups - *out = make([]AWSResourceReference, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - in.Subnet.DeepCopyInto(&out.Subnet) - out.Placement = in.Placement - if in.LoadBalancerIDs != nil { - in, out := &in.LoadBalancerIDs, &out.LoadBalancerIDs - *out = make([]AWSResourceReference, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderConfig. -func (in *AWSMachineProviderConfig) DeepCopy() *AWSMachineProviderConfig { - if in == nil { - return nil - } - out := new(AWSMachineProviderConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSMachineProviderConfig) 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 *AWSMachineProviderStatus) DeepCopyInto(out *AWSMachineProviderStatus) { - *out = *in - out.TypeMeta = in.TypeMeta - if in.InstanceID != nil { - in, out := &in.InstanceID, &out.InstanceID - *out = new(string) - **out = **in - } - if in.InstanceState != nil { - in, out := &in.InstanceState, &out.InstanceState - *out = new(string) - **out = **in - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]AWSMachineProviderCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderStatus. -func (in *AWSMachineProviderStatus) DeepCopy() *AWSMachineProviderStatus { - if in == nil { - return nil - } - out := new(AWSMachineProviderStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSMachineProviderStatus) 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 *AWSResourceReference) DeepCopyInto(out *AWSResourceReference) { - *out = *in - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } - if in.ARN != nil { - in, out := &in.ARN, &out.ARN - *out = new(string) - **out = **in - } - if in.Filters != nil { - in, out := &in.Filters, &out.Filters - *out = make([]Filter, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSResourceReference. -func (in *AWSResourceReference) DeepCopy() *AWSResourceReference { - if in == nil { - return nil - } - out := new(AWSResourceReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Filter) DeepCopyInto(out *Filter) { - *out = *in - if in.Values != nil { - in, out := &in.Values, &out.Values - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Filter. -func (in *Filter) DeepCopy() *Filter { - if in == nil { - return nil - } - out := new(Filter) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Placement) DeepCopyInto(out *Placement) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Placement. -func (in *Placement) DeepCopy() *Placement { - if in == nil { - return nil - } - out := new(Placement) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TagSpecification) DeepCopyInto(out *TagSpecification) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagSpecification. -func (in *TagSpecification) DeepCopy() *TagSpecification { - if in == nil { - return nil - } - out := new(TagSpecification) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/cloud/aws/providerconfig/zz_generated.deepcopy.go b/pkg/cloud/aws/providerconfig/zz_generated.deepcopy.go deleted file mode 100644 index dd10c81d02..0000000000 --- a/pkg/cloud/aws/providerconfig/zz_generated.deepcopy.go +++ /dev/null @@ -1,290 +0,0 @@ -// +build !ignore_autogenerated - -// 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. -// Code generated by deepcopy-gen. DO NOT EDIT. - -package providerconfig - -import ( - v1 "k8s.io/api/core/v1" - 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 *AWSClusterProviderConfig) DeepCopyInto(out *AWSClusterProviderConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterProviderConfig. -func (in *AWSClusterProviderConfig) DeepCopy() *AWSClusterProviderConfig { - if in == nil { - return nil - } - out := new(AWSClusterProviderConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSClusterProviderConfig) 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 *AWSClusterProviderStatus) DeepCopyInto(out *AWSClusterProviderStatus) { - *out = *in - out.TypeMeta = in.TypeMeta - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterProviderStatus. -func (in *AWSClusterProviderStatus) DeepCopy() *AWSClusterProviderStatus { - if in == nil { - return nil - } - out := new(AWSClusterProviderStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSClusterProviderStatus) 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 *AWSMachineProviderCondition) DeepCopyInto(out *AWSMachineProviderCondition) { - *out = *in - in.LastProbeTime.DeepCopyInto(&out.LastProbeTime) - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderCondition. -func (in *AWSMachineProviderCondition) DeepCopy() *AWSMachineProviderCondition { - if in == nil { - return nil - } - out := new(AWSMachineProviderCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AWSMachineProviderConfig) DeepCopyInto(out *AWSMachineProviderConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - in.AMI.DeepCopyInto(&out.AMI) - if in.Tags != nil { - in, out := &in.Tags, &out.Tags - *out = make([]TagSpecification, len(*in)) - copy(*out, *in) - } - if in.IAMInstanceProfile != nil { - in, out := &in.IAMInstanceProfile, &out.IAMInstanceProfile - *out = new(AWSResourceReference) - (*in).DeepCopyInto(*out) - } - if in.UserDataSecret != nil { - in, out := &in.UserDataSecret, &out.UserDataSecret - *out = new(v1.LocalObjectReference) - **out = **in - } - if in.CredentialsSecret != nil { - in, out := &in.CredentialsSecret, &out.CredentialsSecret - *out = new(v1.LocalObjectReference) - **out = **in - } - if in.KeyName != nil { - in, out := &in.KeyName, &out.KeyName - *out = new(string) - **out = **in - } - if in.PublicIP != nil { - in, out := &in.PublicIP, &out.PublicIP - *out = new(bool) - **out = **in - } - if in.SecurityGroups != nil { - in, out := &in.SecurityGroups, &out.SecurityGroups - *out = make([]AWSResourceReference, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - in.Subnet.DeepCopyInto(&out.Subnet) - out.Placement = in.Placement - if in.LoadBalancerIDs != nil { - in, out := &in.LoadBalancerIDs, &out.LoadBalancerIDs - *out = make([]AWSResourceReference, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderConfig. -func (in *AWSMachineProviderConfig) DeepCopy() *AWSMachineProviderConfig { - if in == nil { - return nil - } - out := new(AWSMachineProviderConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSMachineProviderConfig) 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 *AWSMachineProviderStatus) DeepCopyInto(out *AWSMachineProviderStatus) { - *out = *in - out.TypeMeta = in.TypeMeta - if in.InstanceID != nil { - in, out := &in.InstanceID, &out.InstanceID - *out = new(string) - **out = **in - } - if in.InstanceState != nil { - in, out := &in.InstanceState, &out.InstanceState - *out = new(string) - **out = **in - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]AWSMachineProviderCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineProviderStatus. -func (in *AWSMachineProviderStatus) DeepCopy() *AWSMachineProviderStatus { - if in == nil { - return nil - } - out := new(AWSMachineProviderStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AWSMachineProviderStatus) 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 *AWSResourceReference) DeepCopyInto(out *AWSResourceReference) { - *out = *in - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } - if in.ARN != nil { - in, out := &in.ARN, &out.ARN - *out = new(string) - **out = **in - } - if in.Filters != nil { - in, out := &in.Filters, &out.Filters - *out = make([]Filter, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSResourceReference. -func (in *AWSResourceReference) DeepCopy() *AWSResourceReference { - if in == nil { - return nil - } - out := new(AWSResourceReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Filter) DeepCopyInto(out *Filter) { - *out = *in - if in.Values != nil { - in, out := &in.Values, &out.Values - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Filter. -func (in *Filter) DeepCopy() *Filter { - if in == nil { - return nil - } - out := new(Filter) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Placement) DeepCopyInto(out *Placement) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Placement. -func (in *Placement) DeepCopy() *Placement { - if in == nil { - return nil - } - out := new(Placement) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TagSpecification) DeepCopyInto(out *TagSpecification) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagSpecification. -func (in *TagSpecification) DeepCopy() *TagSpecification { - if in == nil { - return nil - } - out := new(TagSpecification) - in.DeepCopyInto(out) - return out -}