Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
Adding vendored packages
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Hein <me@christopherhein.com>
  • Loading branch information
christopherhein committed Oct 4, 2018
1 parent f0170cf commit f6c9e0a
Show file tree
Hide file tree
Showing 7,381 changed files with 259,355 additions and 144,383 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
270 changes: 234 additions & 36 deletions Gopkg.lock

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions Gopkg.toml
Expand Up @@ -36,20 +36,24 @@ required = ["k8s.io/code-generator/cmd/client-gen"]

[[constraint]]
name = "k8s.io/api"
version = "kubernetes-1.10.4"
version = "kubernetes-1.11.3"

[[constraint]]
name = "k8s.io/apiextensions-apiserver"
version = "kubernetes-1.10.4"
version = "kubernetes-1.11.3"

[[constraint]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.10.4"
version = "kubernetes-1.11.3"

[[constraint]]
name = "k8s.io/client-go"
version = "7.0.0"
version = "8.0.0"

[[constraint]]
name = "k8s.io/code-generator"
version = "kubernetes-1.10.4"
version = "kubernetes-1.11.3"

[[override]]
name = "github.com/json-iterator/go"
revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682"
39 changes: 25 additions & 14 deletions pkg/operator/dynamodb/controller.go
Expand Up @@ -13,8 +13,11 @@ import (
"github.com/awslabs/aws-service-operator/pkg/config"
"github.com/awslabs/aws-service-operator/pkg/queue"
opkit "github.com/christopherhein/operator-kit"
"github.com/iancoleman/strcase"
corev1 "k8s.io/api/core/v1"
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/client-go/tools/cache"
"strings"

awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws"
awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1"
Expand Down Expand Up @@ -96,27 +99,35 @@ func QueueUpdater(config *config.Config, msg *queue.MessageBody) error {
}

if name != "" && namespace != "" {
annotations := map[string]string{
"StackID": msg.ParsedMessage["StackId"],
"StackName": msg.ParsedMessage["StackName"],
"ResourceType": msg.ParsedMessage["ResourceType"],
}
if msg.ParsedMessage["ResourceStatus"] == "ROLLBACK_COMPLETE" {
err := deleteStack(config, name, namespace, msg.ParsedMessage["StackId"])
obj, err := deleteStack(config, name, namespace, msg.ParsedMessage["StackId"])
if err != nil {
return err
}
config.Recorder.AnnotatedEventf(obj, annotations, corev1.EventTypeWarning, strcase.ToCamel(strings.ToLower(msg.ParsedMessage["ResourceStatus"])), msg.ParsedMessage["ResourceStatusReason"])
} else if msg.ParsedMessage["ResourceStatus"] == "DELETE_COMPLETE" {
err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
obj, err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
if err != nil {
return err
}

config.Recorder.AnnotatedEventf(obj, annotations, corev1.EventTypeWarning, strcase.ToCamel(strings.ToLower(msg.ParsedMessage["ResourceStatus"])), msg.ParsedMessage["ResourceStatusReason"])
err = incrementRollbackCount(config, name, namespace)
if err != nil {
return err
}
} else {
err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
obj, err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
if err != nil {
return err
}
config.Recorder.AnnotatedEventf(obj, annotations, corev1.EventTypeNormal, strcase.ToCamel(strings.ToLower(msg.ParsedMessage["ResourceStatus"])), msg.ParsedMessage["ResourceStatusReason"])
}

}

return nil
Expand All @@ -134,7 +145,7 @@ func (c *Controller) onAdd(obj interface{}) {
c.config.Logger.Infof("added dynamodb '%s' with stackID '%s'", s.Name, string(*output.StackId))
c.config.Logger.Infof("view at https://console.aws.amazon.com/cloudformation/home?#/stack/detail?stackId=%s", string(*output.StackId))

err = updateStatus(c.config, s.Name, s.Namespace, string(*output.StackId), "CREATE_IN_PROGRESS", "")
_, err = updateStatus(c.config, s.Name, s.Namespace, string(*output.StackId), "CREATE_IN_PROGRESS", "")
if err != nil {
c.config.Logger.WithError(err).Error("error updating status")
}
Expand All @@ -158,7 +169,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
c.config.Logger.Infof("updated dynamodb '%s' with params '%s'", no.Name, string(*output.StackId))
c.config.Logger.Infof("view at https://console.aws.amazon.com/cloudformation/home?#/stack/detail?stackId=%s", string(*output.StackId))

err = updateStatus(c.config, oo.Name, oo.Namespace, string(*output.StackId), "UPDATE_IN_PROGRESS", "")
_, err = updateStatus(c.config, oo.Name, oo.Namespace, string(*output.StackId), "UPDATE_IN_PROGRESS", "")
if err != nil {
c.config.Logger.WithError(err).Error("error updating status")
}
Expand Down Expand Up @@ -196,13 +207,13 @@ func incrementRollbackCount(config *config.Config, name string, namespace string
return nil
}

func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) error {
func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.DynamoDB, error) {
logger := config.Logger
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{})
if err != nil {
logger.WithError(err).Error("error getting dynamodbs")
return err
return nil, err
}

resourceCopy := resource.DeepCopy()
Expand All @@ -223,7 +234,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID
_, err = clientSet.DynamoDBs(namespace).Update(resourceCopy)
if err != nil {
logger.WithError(err).Error("error updating resource")
return err
return nil, err
}

if helpers.IsStackComplete(status, false) {
Expand All @@ -232,26 +243,26 @@ func updateStatus(config *config.Config, name string, namespace string, stackID
logger.WithError(err).Info("error syncing resources")
}
}
return nil
return resourceCopy, nil
}

func deleteStack(config *config.Config, name string, namespace string, stackID string) error {
func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.DynamoDB, error) {
logger := config.Logger
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{})
if err != nil {
logger.WithError(err).Error("error getting dynamodbs")
return err
return nil, err
}

cft := New(config, resource, "")
err = cft.DeleteStack()
if err != nil {
return err
return nil, err
}

err = cft.WaitUntilStackDeleted()
return err
return resource, err
}

func syncAdditionalResources(config *config.Config, s *awsV1alpha1.DynamoDB) (err error) {
Expand Down
39 changes: 25 additions & 14 deletions pkg/operator/ecrrepository/controller.go
Expand Up @@ -13,8 +13,11 @@ import (
"github.com/awslabs/aws-service-operator/pkg/config"
"github.com/awslabs/aws-service-operator/pkg/queue"
opkit "github.com/christopherhein/operator-kit"
"github.com/iancoleman/strcase"
corev1 "k8s.io/api/core/v1"
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/client-go/tools/cache"
"strings"

awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws"
awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1"
Expand Down Expand Up @@ -93,27 +96,35 @@ func QueueUpdater(config *config.Config, msg *queue.MessageBody) error {
}

if name != "" && namespace != "" {
annotations := map[string]string{
"StackID": msg.ParsedMessage["StackId"],
"StackName": msg.ParsedMessage["StackName"],
"ResourceType": msg.ParsedMessage["ResourceType"],
}
if msg.ParsedMessage["ResourceStatus"] == "ROLLBACK_COMPLETE" {
err := deleteStack(config, name, namespace, msg.ParsedMessage["StackId"])
obj, err := deleteStack(config, name, namespace, msg.ParsedMessage["StackId"])
if err != nil {
return err
}
config.Recorder.AnnotatedEventf(obj, annotations, corev1.EventTypeWarning, strcase.ToCamel(strings.ToLower(msg.ParsedMessage["ResourceStatus"])), msg.ParsedMessage["ResourceStatusReason"])
} else if msg.ParsedMessage["ResourceStatus"] == "DELETE_COMPLETE" {
err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
obj, err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
if err != nil {
return err
}

config.Recorder.AnnotatedEventf(obj, annotations, corev1.EventTypeWarning, strcase.ToCamel(strings.ToLower(msg.ParsedMessage["ResourceStatus"])), msg.ParsedMessage["ResourceStatusReason"])
err = incrementRollbackCount(config, name, namespace)
if err != nil {
return err
}
} else {
err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
obj, err := updateStatus(config, name, namespace, msg.ParsedMessage["StackId"], msg.ParsedMessage["ResourceStatus"], msg.ParsedMessage["ResourceStatusReason"])
if err != nil {
return err
}
config.Recorder.AnnotatedEventf(obj, annotations, corev1.EventTypeNormal, strcase.ToCamel(strings.ToLower(msg.ParsedMessage["ResourceStatus"])), msg.ParsedMessage["ResourceStatusReason"])
}

}

return nil
Expand All @@ -131,7 +142,7 @@ func (c *Controller) onAdd(obj interface{}) {
c.config.Logger.Infof("added ecrrepository '%s' with stackID '%s'", s.Name, string(*output.StackId))
c.config.Logger.Infof("view at https://console.aws.amazon.com/cloudformation/home?#/stack/detail?stackId=%s", string(*output.StackId))

err = updateStatus(c.config, s.Name, s.Namespace, string(*output.StackId), "CREATE_IN_PROGRESS", "")
_, err = updateStatus(c.config, s.Name, s.Namespace, string(*output.StackId), "CREATE_IN_PROGRESS", "")
if err != nil {
c.config.Logger.WithError(err).Error("error updating status")
}
Expand All @@ -155,7 +166,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
c.config.Logger.Infof("updated ecrrepository '%s' with params '%s'", no.Name, string(*output.StackId))
c.config.Logger.Infof("view at https://console.aws.amazon.com/cloudformation/home?#/stack/detail?stackId=%s", string(*output.StackId))

err = updateStatus(c.config, oo.Name, oo.Namespace, string(*output.StackId), "UPDATE_IN_PROGRESS", "")
_, err = updateStatus(c.config, oo.Name, oo.Namespace, string(*output.StackId), "UPDATE_IN_PROGRESS", "")
if err != nil {
c.config.Logger.WithError(err).Error("error updating status")
}
Expand Down Expand Up @@ -193,13 +204,13 @@ func incrementRollbackCount(config *config.Config, name string, namespace string
return nil
}

func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) error {
func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.ECRRepository, error) {
logger := config.Logger
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{})
if err != nil {
logger.WithError(err).Error("error getting ecrrepositories")
return err
return nil, err
}

resourceCopy := resource.DeepCopy()
Expand All @@ -222,7 +233,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID
_, err = clientSet.ECRRepositories(namespace).Update(resourceCopy)
if err != nil {
logger.WithError(err).Error("error updating resource")
return err
return nil, err
}

if helpers.IsStackComplete(status, false) {
Expand All @@ -231,26 +242,26 @@ func updateStatus(config *config.Config, name string, namespace string, stackID
logger.WithError(err).Info("error syncing resources")
}
}
return nil
return resourceCopy, nil
}

func deleteStack(config *config.Config, name string, namespace string, stackID string) error {
func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.ECRRepository, error) {
logger := config.Logger
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{})
if err != nil {
logger.WithError(err).Error("error getting ecrrepositories")
return err
return nil, err
}

cft := New(config, resource, "")
err = cft.DeleteStack()
if err != nil {
return err
return nil, err
}

err = cft.WaitUntilStackDeleted()
return err
return resource, err
}

func syncAdditionalResources(config *config.Config, s *awsV1alpha1.ECRRepository) (err error) {
Expand Down

0 comments on commit f6c9e0a

Please sign in to comment.