parent
8a5689617f
commit
a932544784
|
|
@ -27,15 +27,14 @@
|
|||
"internal/awsutil",
|
||||
"internal/sdk",
|
||||
"private/protocol",
|
||||
"private/protocol/ec2query",
|
||||
"private/protocol/query",
|
||||
"private/protocol/query/queryutil",
|
||||
"private/protocol/rest",
|
||||
"private/protocol/restxml",
|
||||
"private/protocol/xml",
|
||||
"private/protocol/xml/xmlutil",
|
||||
"service/ec2",
|
||||
"service/rds",
|
||||
"service/rds/rdsiface",
|
||||
"service/s3",
|
||||
"service/sts",
|
||||
]
|
||||
|
|
@ -661,6 +660,7 @@
|
|||
"pkg/util/json",
|
||||
"pkg/util/mergepatch",
|
||||
"pkg/util/net",
|
||||
"pkg/util/rand",
|
||||
"pkg/util/runtime",
|
||||
"pkg/util/sets",
|
||||
"pkg/util/strategicpatch",
|
||||
|
|
@ -848,7 +848,7 @@
|
|||
version = "v0.1.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:12730c607dac5ff500c57bd86d461556a9ec18f58e81925390bb3922d81dbe76"
|
||||
digest = "1:f0ec7eb1cd32beafc0f07edb8ff03c4974cbadf9a7ceab8383a4cee1d379d72b"
|
||||
name = "sigs.k8s.io/controller-tools"
|
||||
packages = [
|
||||
"cmd/controller-gen",
|
||||
|
|
@ -860,7 +860,7 @@
|
|||
"pkg/util",
|
||||
]
|
||||
pruneopts = "T"
|
||||
revision = "a2e6c5192e5eecd21b624847c1be289dc664178a"
|
||||
revision = "c0553d47d88e84c5e3248d4a171449bf140be05d"
|
||||
source = "https://github.com/ichekrygin/controller-tools.git"
|
||||
|
||||
[[projects]]
|
||||
|
|
@ -881,8 +881,8 @@
|
|||
"github.com/aws/aws-sdk-go-v2",
|
||||
"github.com/aws/aws-sdk-go-v2/aws",
|
||||
"github.com/aws/aws-sdk-go-v2/aws/external",
|
||||
"github.com/aws/aws-sdk-go-v2/service/ec2",
|
||||
"github.com/aws/aws-sdk-go-v2/service/rds",
|
||||
"github.com/aws/aws-sdk-go-v2/service/rds/rdsiface",
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3",
|
||||
"github.com/emicklei/go-restful",
|
||||
"github.com/go-ini/ini",
|
||||
|
|
@ -902,6 +902,7 @@
|
|||
"k8s.io/apimachinery/pkg/runtime",
|
||||
"k8s.io/apimachinery/pkg/runtime/schema",
|
||||
"k8s.io/apimachinery/pkg/types",
|
||||
"k8s.io/apimachinery/pkg/util/rand",
|
||||
"k8s.io/client-go/kubernetes",
|
||||
"k8s.io/client-go/kubernetes/fake",
|
||||
"k8s.io/client-go/kubernetes/scheme",
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ required = [
|
|||
[prune]
|
||||
go-tests = true
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/aws/aws-sdk-go-v2"
|
||||
version = "v2.0.0-preview.4"
|
||||
|
||||
# STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE.
|
||||
|
||||
[[constraint]]
|
||||
|
|
@ -34,7 +30,7 @@ required = [
|
|||
[[constraint]]
|
||||
name="sigs.k8s.io/controller-tools"
|
||||
source = "https://github.com/ichekrygin/controller-tools.git"
|
||||
revision = "a2e6c5192e5eecd21b624847c1be289dc664178a"
|
||||
revision = "c0553d47d88e84c5e3248d4a171449bf140be05d"
|
||||
|
||||
# For dependency below: Refer to issue https://github.com/golang/dep/issues/1799
|
||||
[[override]]
|
||||
|
|
|
|||
|
|
@ -17,33 +17,97 @@ limitations under the License.
|
|||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
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.
|
||||
func init() {
|
||||
SchemeBuilder.Register(&RDSInstance{}, &RDSInstanceList{})
|
||||
}
|
||||
|
||||
// RDSInstanceConditionType type for possible conditions the provider could be in.
|
||||
type RDSInstanceConditionType string
|
||||
|
||||
const (
|
||||
// Pending means that the instance create request has been received and waiting to be fulfilled
|
||||
Pending RDSInstanceConditionType = "Pending"
|
||||
// Creating means that the DB instance create request has been processed and DB Instance is being created
|
||||
Creating RDSInstanceConditionType = "Creating"
|
||||
// Deleting means that the instance is being deleted.
|
||||
Deleting RDSInstanceConditionType = "Deleting"
|
||||
// Failed means that the instance creation has failed.
|
||||
Failed RDSInstanceConditionType = "Failed"
|
||||
// Running means that the instance creation has been successful.
|
||||
Running RDSInstanceConditionType = "Running"
|
||||
)
|
||||
|
||||
type RDSDBInstanceStatus string
|
||||
|
||||
// RDSInstanceSpec defines the desired state of RDSInstance
|
||||
type RDSInstanceSpec struct {
|
||||
MasterUsername string `json:"masterUsername"`
|
||||
MasterPassword v1.SecretKeySelector `json:"masterPasswordSecretRef"`
|
||||
Engine string `json:"engine"` // "postgres"
|
||||
Class string `json:"class"` // like "db.t2.micro"
|
||||
Size int64 `json:"size"` // size in gb
|
||||
MultiAZ bool `json:"multiaz,omitempty"`
|
||||
PubliclyAccessible bool `json:"publicaccess,omitempty"`
|
||||
StorageEncrypted bool `json:"encrypted,omitempty"`
|
||||
StorageType string `json:"storagetype,omitempty"`
|
||||
Iops int64 `json:"iops,omitempty"`
|
||||
BackupRetentionPeriod int64 `json:"backupretentionperiod,omitempty"` // between 0 and 35, zero means disable
|
||||
MasterUsername string `json:"masterUsername"`
|
||||
Engine string `json:"engine"` // "postgres"
|
||||
Class string `json:"class"` // like "db.t2.micro"
|
||||
Size int64 `json:"size"` // size in gb
|
||||
SecurityGroups []string `json:"securityGroups,omitempty"` // VPC Security groups
|
||||
|
||||
ProviderRef corev1.LocalObjectReference `json:"providerRef"`
|
||||
ConnectionSecretRef corev1.LocalObjectReference `json:"connectionSecretRef"`
|
||||
}
|
||||
|
||||
// RDSInstanceStatus defines the observed state of RDSInstance
|
||||
type RDSInstanceStatus struct {
|
||||
State string `json:"state,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
ProviderID string `json:"providerID,omitempty"` // the external ID to identify this resource in the cloud provider
|
||||
State string `json:"state,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
ProviderID string `json:"providerID,omitempty"` // the external ID to identify this resource in the cloud provider
|
||||
InstanceName string `json:"instanceName,omitempty"` // the generated DB Instance name
|
||||
|
||||
// Conditions indicate state for particular aspects of a CustomResourceDefinition
|
||||
Conditions []RDSInstanceCondition
|
||||
}
|
||||
|
||||
// GetCondition returns a provider condition with the provided type if it exists.
|
||||
func (s *RDSInstanceStatus) GetCondition(conditionType RDSInstanceConditionType) *RDSInstanceCondition {
|
||||
for _, c := range s.Conditions {
|
||||
if c.Type == conditionType {
|
||||
return &c
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetCondition adds/replaces the given condition in the credentials controller status.
|
||||
func (s *RDSInstanceStatus) SetCondition(condition RDSInstanceCondition) {
|
||||
current := s.GetCondition(condition.Type)
|
||||
if current != nil && current.Status == condition.Status && current.Reason == condition.Reason {
|
||||
return
|
||||
}
|
||||
newConditions := FilterOutCondition(s.Conditions, condition.Type)
|
||||
s.Conditions = append(newConditions, condition)
|
||||
}
|
||||
|
||||
// UnsetCondition set condition status to false with the given type - if found.
|
||||
func (s *RDSInstanceStatus) UnsetCondition(conditionType RDSInstanceConditionType) {
|
||||
current := s.GetCondition(conditionType)
|
||||
if current != nil && current.Status == corev1.ConditionTrue {
|
||||
current.Status = corev1.ConditionFalse
|
||||
s.SetCondition(*current)
|
||||
}
|
||||
}
|
||||
|
||||
// UnsetAllConditions set conditions status to false on all conditions
|
||||
func (s *RDSInstanceStatus) UnsetAllConditions() {
|
||||
var newConditions []RDSInstanceCondition
|
||||
for _, c := range s.Conditions {
|
||||
c.Status = corev1.ConditionFalse
|
||||
newConditions = append(newConditions, c)
|
||||
}
|
||||
s.Conditions = newConditions
|
||||
}
|
||||
|
||||
// RemoveCondition removes the condition with the provided type from the credentials controller status.
|
||||
func (s *RDSInstanceStatus) RemoveCondition(condType RDSInstanceConditionType) {
|
||||
s.Conditions = FilterOutCondition(s.Conditions, condType)
|
||||
}
|
||||
|
||||
// +genclient
|
||||
|
|
@ -51,6 +115,7 @@ type RDSInstanceStatus struct {
|
|||
|
||||
// RDSInstance is the Schema for the instances API
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=database.aws
|
||||
type RDSInstance struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
|
@ -68,6 +133,40 @@ type RDSInstanceList struct {
|
|||
Items []RDSInstance `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&RDSInstance{}, &RDSInstanceList{})
|
||||
// RDSInstanceCondition contains details for the current condition of this pod.
|
||||
type RDSInstanceCondition struct {
|
||||
Type RDSInstanceConditionType
|
||||
Status corev1.ConditionStatus
|
||||
LastTransitionTime metav1.Time
|
||||
Reason string
|
||||
Message string
|
||||
}
|
||||
|
||||
// ProviderStatus defines the observed state of Provider
|
||||
type ProviderStatus struct {
|
||||
// Conditions indicate state for particular aspects of a CustomResourceDefinition
|
||||
Conditions []RDSInstanceCondition
|
||||
}
|
||||
|
||||
// NewCondition creates a new RDS instance condition.
|
||||
func NewCondition(condType RDSInstanceConditionType, reason, msg string) *RDSInstanceCondition {
|
||||
return &RDSInstanceCondition{
|
||||
Type: condType,
|
||||
Status: corev1.ConditionTrue,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
Reason: reason,
|
||||
Message: msg,
|
||||
}
|
||||
}
|
||||
|
||||
// FilterOutCondition returns a new slice of credentials controller conditions without conditions with the provided type.
|
||||
func FilterOutCondition(conditions []RDSInstanceCondition, condType RDSInstanceConditionType) []RDSInstanceCondition {
|
||||
var newConditions []RDSInstanceCondition
|
||||
for _, c := range conditions {
|
||||
if c.Type == condType {
|
||||
continue
|
||||
}
|
||||
newConditions = append(newConditions, c)
|
||||
}
|
||||
return newConditions
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,36 @@ 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 *ProviderStatus) DeepCopyInto(out *ProviderStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]RDSInstanceCondition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderStatus.
|
||||
func (in *ProviderStatus) DeepCopy() *ProviderStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ProviderStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RDSInstance) DeepCopyInto(out *RDSInstance) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +74,23 @@ func (in *RDSInstance) DeepCopyObject() runtime.Object {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RDSInstanceCondition) DeepCopyInto(out *RDSInstanceCondition) {
|
||||
*out = *in
|
||||
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RDSInstanceCondition.
|
||||
func (in *RDSInstanceCondition) DeepCopy() *RDSInstanceCondition {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RDSInstanceCondition)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RDSInstanceList) DeepCopyInto(out *RDSInstanceList) {
|
||||
*out = *in
|
||||
|
|
@ -87,7 +127,13 @@ func (in *RDSInstanceList) DeepCopyObject() runtime.Object {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RDSInstanceSpec) DeepCopyInto(out *RDSInstanceSpec) {
|
||||
*out = *in
|
||||
in.MasterPassword.DeepCopyInto(&out.MasterPassword)
|
||||
if in.SecurityGroups != nil {
|
||||
in, out := &in.SecurityGroups, &out.SecurityGroups
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
out.ProviderRef = in.ProviderRef
|
||||
out.ConnectionSecretRef = in.ConnectionSecretRef
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -104,6 +150,13 @@ func (in *RDSInstanceSpec) DeepCopy() *RDSInstanceSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RDSInstanceStatus) DeepCopyInto(out *RDSInstanceStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]RDSInstanceCondition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,7 @@ type ProviderSpec struct {
|
|||
Region string `json:"region"`
|
||||
|
||||
// AWS Credentials file
|
||||
SecretKey corev1.SecretKeySelector `json:"credentialsSecretRef"`
|
||||
|
||||
// AWS Credentials profile
|
||||
Profile string `json:"credentialsProfile"`
|
||||
Secret corev1.SecretKeySelector `json:"credentialsSecretRef"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
|
|
@ -44,6 +41,7 @@ type ProviderSpec struct {
|
|||
|
||||
// Provider is the Schema for the instances API
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=aws
|
||||
type Provider struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func TestStorageProvider(t *testing.T) {
|
|||
Namespace: "default",
|
||||
},
|
||||
Spec: ProviderSpec{
|
||||
SecretKey: v1.SecretKeySelector{
|
||||
Secret: v1.SecretKeySelector{
|
||||
LocalObjectReference: v1.LocalObjectReference{Name: "u-235"},
|
||||
Key: "credentials",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func (in *ProviderList) DeepCopyObject() runtime.Object {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ProviderSpec) DeepCopyInto(out *ProviderSpec) {
|
||||
*out = *in
|
||||
in.SecretKey.DeepCopyInto(&out.SecretKey)
|
||||
in.Secret.DeepCopyInto(&out.Secret)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ type CloudsqlInstanceStatus struct {
|
|||
|
||||
// CloudsqlInstance is the Schema for the instances API
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=database.gcp
|
||||
type CloudsqlInstance struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ type ProviderSpec struct {
|
|||
|
||||
// Provider is the Schema for the instances API
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=gcp
|
||||
type Provider struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
Copyright 2018 The Conductor 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 aws
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||
|
||||
awsclients "github.com/upbound/conductor/pkg/clients/aws"
|
||||
)
|
||||
|
||||
// EC2Client provides a mock implementation of the EC2API interface for unit testing purposes.
|
||||
type EC2Client struct {
|
||||
awsclients.EC2API
|
||||
MockDescribeInstances func(*ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error)
|
||||
MockDescribeSubnets func(*ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error)
|
||||
}
|
||||
|
||||
// DescribeInstances describes the given requested EC2 instances
|
||||
func (m *EC2Client) DescribeInstances(input *ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error) {
|
||||
if m.MockDescribeInstances != nil {
|
||||
return m.MockDescribeInstances(input)
|
||||
}
|
||||
return &ec2.DescribeInstancesOutput{}, nil
|
||||
}
|
||||
|
||||
// DescribeSubnets describes the given requested EC2 subnets
|
||||
func (m *EC2Client) DescribeSubnets(input *ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error) {
|
||||
if m.MockDescribeSubnets != nil {
|
||||
return m.MockDescribeSubnets(input)
|
||||
}
|
||||
return &ec2.DescribeSubnetsOutput{}, nil
|
||||
}
|
||||
Loading…
Reference in New Issue