From 70bf6931195d36670857cf823a0530ecda5a9b58 Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Wed, 26 Aug 2020 21:06:09 +0200 Subject: [PATCH 1/7] wip --- application/instance.go | 12 ++++++ application/reconciler/instance.go | 3 ++ .../settings/parameters/parameters_helpers.go | 13 +++++++ application/settings/parameters/utils.go | 39 +++++++++++++++++++ go.mod | 2 + go.sum | 1 + status/status.go | 5 ++- 7 files changed, 73 insertions(+), 2 deletions(-) diff --git a/application/instance.go b/application/instance.go index 3c6e18f..93c1b4c 100644 --- a/application/instance.go +++ b/application/instance.go @@ -64,6 +64,18 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { // First we init external values and random values for name, sett := range setts { + + for _, src := range *sett.GetConfig().GetSources() { + obj := status.ObjectStatus{ + Link: "", + Name: src.Ref, + Version: "", + Kind: src.Type, + Group: "", + } + appStatus.Watched = append(appStatus.Watched, obj) + } + if len(appStatus.Settings[name].Resources.Objects) > 0 { for _, o := range appStatus.Settings[name].Resources.Objects { src := settings.Source{ diff --git a/application/reconciler/instance.go b/application/reconciler/instance.go index e342e9d..7564c51 100644 --- a/application/reconciler/instance.go +++ b/application/reconciler/instance.go @@ -82,6 +82,7 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res appStatus := r.Instance.GetApplicationStatus() oldStatus := appStatus.DeepCopy() + // TODO GET SOURCES add to watch resources in settings err := application.Init(r.Instance, r.ReconcilerBase) if err != nil { return reconcile.Result{}, err @@ -94,6 +95,7 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res cptStatus := status.ComponentStatus{ Resources: res, } + if len(appStatus.Settings) == 0 { appStatus.Settings = make(map[string]status.ComponentStatus) } @@ -104,6 +106,7 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res return ctrl.Result{}, err } + cptStatus.ComponentsReady = "Ready" appStatus.Settings[name] = cptStatus diff --git a/application/settings/parameters/parameters_helpers.go b/application/settings/parameters/parameters_helpers.go index a8bd9c3..c9fa53a 100644 --- a/application/settings/parameters/parameters_helpers.go +++ b/application/settings/parameters/parameters_helpers.go @@ -78,6 +78,19 @@ func (p *Parameters) InitTemplateValues(values map[string]interface{}) error { return nil } +func (p *Parameters) GetAllData() map[string]string { + data := make(map[string]string) + + for _, param := range *p { + if param.Type != ObjectFieldParameter && + len(param.Value) > 0 { + data[param.Key] = param.Value + } + } + + return data +} + // GetData returns the data for the secret or configmap as a key:value pairs // This function only returns data which should be either in a secret or a configmap func (p *Parameters) GetData() map[string]string { diff --git a/application/settings/parameters/utils.go b/application/settings/parameters/utils.go index a6a73cb..8853031 100644 --- a/application/settings/parameters/utils.go +++ b/application/settings/parameters/utils.go @@ -144,6 +144,22 @@ func GetDataFromResource(c client.Client, obj, owner interfaces.Object) (data ma // If object is owner we only want to get the generated data in order to not regenerate it, // other parameters are set in crds or valueFrom + if ownerRefs := obj.GetOwnerReferences(); ownerRefs != nil { + for _, ref := range ownerRefs { + if ref.Controller { + if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { + for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { + data[param] = objData[param] + } + return data, nil + } + } else { + data = objData + // controllerutil.SetOwnerReference(owner, obj, scheme) + + } + } + } if metav1.IsControlledBy(obj, owner) { if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { @@ -153,7 +169,30 @@ func GetDataFromResource(c client.Client, obj, owner interfaces.Object) (data ma } } else { data = objData + + // controllerutil.SetOwnerReference(owner, obj, scheme) + } return data, nil } + +// getOwnersReferences returns the OwnerReferences for an object as specified by the EnqueueRequestForOwner +// - if IsController is true: only take the Controller OwnerReference (if found) +// - if IsController is false: take all OwnerReferences +func GetOwnersReferences(object metav1.Object) []metav1.OwnerReference { + if object == nil { + return nil + } + + // If not filtered as Controller only, then use all the OwnerReferences + if !e.IsController { + return object.GetOwnerReferences() + } + // If filtered to a Controller, only take the Controller OwnerReference + if ownerRef := metav1.GetControllerOf(object); ownerRef != nil { + return []metav1.OwnerReference{*ownerRef} + } + // No Controller OwnerReference found + return nil +} diff --git a/go.mod b/go.mod index b72f5f1..bce1738 100644 --- a/go.mod +++ b/go.mod @@ -16,3 +16,5 @@ require ( ) replace k8s.io/client-go => k8s.io/client-go v0.18.2 + +replace k8s.libre.sh/controller-utils => ./ diff --git a/go.sum b/go.sum index e83a4c7..7e29fbc 100644 --- a/go.sum +++ b/go.sum @@ -697,6 +697,7 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7MpmSnvtrOieolJKoE= k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= +k8s.libre.sh v0.1.0 h1:TOM1qMqLdkfIvYsCAoyyPzOww/s3DYtk5PM52ZDOXyw= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/status/status.go b/status/status.go index ffb6e58..7fcc58f 100644 --- a/status/status.go +++ b/status/status.go @@ -33,7 +33,8 @@ type ApplicationStatus struct { Components map[string]ComponentStatus `json:"components,omitempty"` Settings map[string]ComponentStatus `json:"settings,omitempty"` // ComponentsReady: status of the components in the format ready/total - ComponentsReady string `json:"componentsReady,omitempty"` + ComponentsReady string `json:"componentsReady,omitempty"` + Watched Resources `json:"watched,omitempty"` } func (app *ApplicationStatus) GetResources() *Resources { @@ -51,7 +52,7 @@ func (app *ApplicationStatus) GetResources() *Resources { type ComponentStatus struct { Name string `json:"name,omitempty"` // Resources embeds a list of object statuses - Resources `json:",inline,omitempty"` + Resources `json:",inline"` // ComponentsReady: status of the components in the format ready/total ComponentsReady string `json:"componentsReady,omitempty"` } -- GitLab From eb60e66a6629ee76691a6fd358779e451344d640 Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Thu, 27 Aug 2020 16:18:16 +0200 Subject: [PATCH 2/7] WIP add logic for watching settings, add ownerRef to watched resources & watched objects in status --- application/instance.go | 54 ++++++++- application/settings/component.go | 20 ++-- .../settings/parameters/parameters_helpers.go | 43 ++++--- application/settings/parameters/utils.go | 55 +++++---- application/settings/settings.go | 5 +- binding.go | 113 ------------------ go.mod | 2 - status/zz_generated.deepcopy.go | 1 + 8 files changed, 130 insertions(+), 163 deletions(-) delete mode 100644 binding.go diff --git a/application/instance.go b/application/instance.go index 93c1b4c..d40f1a8 100644 --- a/application/instance.go +++ b/application/instance.go @@ -57,6 +57,41 @@ func GetTemplateValues(i Instance, setts map[string]settings.Component) map[stri } +func AppendIfUnique(objs []status.ObjectStatus, obj status.ObjectStatus) []status.ObjectStatus { + + if len(objs) == 0 { + objs = append(objs, obj) + } + + for _, o := range objs { + if o.Name == obj.Name && o.Kind == obj.Kind { + return objs + } + } + objs = append(objs, obj) + return objs +} + +/* func AppendSourceIfUnique(sources *Sources, source Source) *Sources { + srcs := Sources{} + + if sources != nil { + for _, ele := range *sources { + if ele == source { + return sources + } + } + }= source { + return sources + } + } + } + + srcs = append(srcs, source) + + return &srcs +} */ + func InitSettings(i Instance, r interfaces.Reconcile) error { appStatus := i.GetApplicationStatus() @@ -73,7 +108,20 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { Kind: src.Type, Group: "", } - appStatus.Watched = append(appStatus.Watched, obj) + appStatus.Watched.Objects = AppendIfUnique(appStatus.Watched.Objects, obj) + } + + for _, p := range *sett.GetConfig().GetParameters() { + if len(p.Ref) > 0 && p.Type != parameters.ObjectFieldParameter && p.RefType != parameters.ObjectFieldParameter { + obj := status.ObjectStatus{ + Link: "", + Name: p.Ref, + Version: "", + Kind: "Secret", + Group: "", + } + appStatus.Watched.Objects = AppendIfUnique(appStatus.Watched.Objects, obj) + } } if len(appStatus.Settings[name].Resources.Objects) > 0 { @@ -83,11 +131,13 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { // & TO FIX Type: strings.ToLower(o.Kind), } + // TODO append if unique *sett.GetConfig().GetSources() = append(*sett.GetConfig().GetSources(), src) } } - err := settings.Init(sett, r.GetClient(), i.GetOwner()) + // appStatus.Watched.Objects = nil + err := settings.Init(sett, r.GetClient(), i.GetOwner(), r.GetScheme()) if err != nil { return err diff --git a/application/settings/component.go b/application/settings/component.go index 837172f..94cf8c2 100644 --- a/application/settings/component.go +++ b/application/settings/component.go @@ -28,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" ) type Component interface { @@ -164,7 +165,7 @@ func GetSecretGenAnnotion(ps *parameters.Parameters) map[string]string { return annot } -func Init(s Component, c client.Client, owner interfaces.Object) error { +func Init(s Component, c client.Client, owner interfaces.Object, scheme *runtime.Scheme) error { opts := s.GetCreateOptions() if opts == nil { @@ -175,7 +176,7 @@ func Init(s Component, c client.Client, owner interfaces.Object) error { meta.SetObjectMeta(opts.CommonMeta, opts.ConfigMeta) meta.SetObjectMeta(opts.CommonMeta, opts.SecretMeta) - err := InitParametersValueFrom(s, c, owner) + err := InitParametersValueFrom(s, c, owner, scheme) if err != nil { return err @@ -193,14 +194,19 @@ func Init(s Component, c client.Client, owner interfaces.Object) error { // InitParametersValueFrom intialise the parameters with values provided in external resources in the same namespace. // All parameters values are filled from those resources and new parameters are appended. // Only Secrets and Configmaps are supported. -func InitParametersValueFrom(s Component, c client.Client, owner interfaces.Object) error { +func InitParametersValueFrom(s Component, c client.Client, owner interfaces.Object, scheme *runtime.Scheme) error { - err := s.GetParameters().InitValueFrom(c, owner) + // TO DO TO FIX, InitValueFrom and ParametersFromSources do the same thing ? + err := s.GetParameters().InitValueFrom(c, owner, scheme) if err != nil { return err } - ps, err := ParametersFromSources(s.GetSources(), c, owner) + ps, err := ParametersFromSources(s.GetSources(), c, owner, scheme) + + if err != nil { + return err + } s.GetParameters().Merge(ps) @@ -210,7 +216,7 @@ func InitParametersValueFrom(s Component, c client.Client, owner interfaces.Obje // ParametersFromSources returns the parameters from external resources that are provided in the sources. // Owner is provided to check if resources is owned in that case, only generated data defined in the annotations are fetched. // Only Secrets and Configmaps are supported. -func ParametersFromSources(srcs *Sources, c client.Client, owner interfaces.Object) (*parameters.Parameters, error) { +func ParametersFromSources(srcs *Sources, c client.Client, owner interfaces.Object, scheme *runtime.Scheme) (*parameters.Parameters, error) { var obj interfaces.Object ps := ¶meters.Parameters{} @@ -229,7 +235,7 @@ func ParametersFromSources(srcs *Sources, c client.Client, owner interfaces.Obje } - data, err := parameters.GetDataFromResource(c, obj, owner) + data, err := parameters.GetDataFromResource(c, obj, owner, scheme) if err != nil { return ps, err } diff --git a/application/settings/parameters/parameters_helpers.go b/application/settings/parameters/parameters_helpers.go index c9fa53a..a3f57c9 100644 --- a/application/settings/parameters/parameters_helpers.go +++ b/application/settings/parameters/parameters_helpers.go @@ -23,6 +23,7 @@ import ( "github.com/presslabs/controller-util/rand" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.libre.sh/controller-utils/interfaces" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -271,7 +272,7 @@ func (ps *Parameters) Merge(in *Parameters) error { // InitValueFrom intialise the parameters value from external resources // Only secrets and configmaps are supported -func (ps *Parameters) InitValueFrom(c client.Client, owner interfaces.Object) error { +func (ps *Parameters) InitValueFrom(c client.Client, owner interfaces.Object, scheme *runtime.Scheme) error { var obj interfaces.Object @@ -281,26 +282,40 @@ func (ps *Parameters) InitValueFrom(c client.Client, owner interfaces.Object) er switch ptype { case ConfigParameter: obj = &corev1.ConfigMap{} + + for ref, params := range byRef { + obj.SetName(ref) + obj.SetNamespace(owner.GetNamespace()) + + data, err := GetDataFromResource(c, obj, owner, scheme) + if err != nil { + return err + } + + err = params.MergeData(data) + if err != nil { + return err + } + } case SecretParameter: obj = &corev1.Secret{} - default: - return nil - } - for ref, params := range byRef { - obj.SetName(ref) - obj.SetNamespace(owner.GetNamespace()) + for ref, params := range byRef { + obj.SetName(ref) + obj.SetNamespace(owner.GetNamespace()) - data, err := GetDataFromResource(c, obj, owner) - if err != nil { - return err - } + data, err := GetDataFromResource(c, obj, owner, scheme) + if err != nil { + return err + } - err = params.MergeData(data) - if err != nil { - return err + err = params.MergeData(data) + if err != nil { + return err + } } } + } return nil diff --git a/application/settings/parameters/utils.go b/application/settings/parameters/utils.go index 8853031..a76ec27 100644 --- a/application/settings/parameters/utils.go +++ b/application/settings/parameters/utils.go @@ -22,10 +22,11 @@ import ( "strings" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.libre.sh/controller-utils/interfaces" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) func Marshal(i interface{}) (*Parameters, error) { @@ -115,7 +116,7 @@ func OrderByResourceRef(ps *Parameters) map[ParameterType]map[string]*Parameters // GetDataFromResource return the data as key:value pairs from external resources. // If resources are owned by the owner object, only generated resources are returned. // Only secrets and configmaps are supported. -func GetDataFromResource(c client.Client, obj, owner interfaces.Object) (data map[string]string, err error) { +func GetDataFromResource(c client.Client, obj, owner interfaces.Object, scheme *runtime.Scheme) (data map[string]string, err error) { objData := make(map[string]string) data = make(map[string]string) @@ -146,41 +147,48 @@ func GetDataFromResource(c client.Client, obj, owner interfaces.Object) (data ma // other parameters are set in crds or valueFrom if ownerRefs := obj.GetOwnerReferences(); ownerRefs != nil { for _, ref := range ownerRefs { - if ref.Controller { - if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { - for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { - data[param] = objData[param] + if ref.UID == owner.GetUID() { + if ref.Controller != nil && *ref.Controller { + if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { + for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { + data[param] = objData[param] + } } - return data, nil + } else { + data = objData } - } else { - data = objData - // controllerutil.SetOwnerReference(owner, obj, scheme) - + return data, nil } } } - if metav1.IsControlledBy(obj, owner) { - if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { - for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { - data[param] = objData[param] - } - return data, nil - } - } else { - data = objData - - // controllerutil.SetOwnerReference(owner, obj, scheme) + data = objData + controllerutil.SetOwnerReference(owner, obj, scheme) + if err := c.Update(context.Background(), obj); err != nil { + return data, err } + /* if metav1.IsControlledBy(obj, owner) { + if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { + for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { + data[param] = objData[param] + } + return data, nil + } + } else { + data = objData + + controllerutil.SetOwnerReference(owner, obj, scheme) + + } */ + return data, nil } // getOwnersReferences returns the OwnerReferences for an object as specified by the EnqueueRequestForOwner // - if IsController is true: only take the Controller OwnerReference (if found) // - if IsController is false: take all OwnerReferences -func GetOwnersReferences(object metav1.Object) []metav1.OwnerReference { +/* func GetOwnersReferences(object metav1.Object) []metav1.OwnerReference { if object == nil { return nil } @@ -196,3 +204,4 @@ func GetOwnersReferences(object metav1.Object) []metav1.OwnerReference { // No Controller OwnerReference found return nil } +*/ diff --git a/application/settings/settings.go b/application/settings/settings.go index 27ad6a1..016b9e2 100644 --- a/application/settings/settings.go +++ b/application/settings/settings.go @@ -16,6 +16,7 @@ limitations under the License. package settings import ( + "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "k8s.libre.sh/controller-utils/application/settings/parameters" @@ -167,7 +168,7 @@ func (s *Settings) SetDefaults() { // Init initialise the settings. // ObjectMeta are set from commons meta. // Parameters are initialised from external resources set in ValueFrom and random values are generated. -func (s *Settings) Init(c client.Client, owner interfaces.Object) error { +func (s *Settings) Init(c client.Client, owner interfaces.Object, scheme *runtime.Scheme) error { if s.CreateOptions == nil { s.CreateOptions = &CreateOptions{} @@ -177,7 +178,7 @@ func (s *Settings) Init(c client.Client, owner interfaces.Object) error { meta.SetObjectMeta(s.CreateOptions.CommonMeta, s.CreateOptions.ConfigMeta) meta.SetObjectMeta(s.CreateOptions.CommonMeta, s.CreateOptions.SecretMeta) - err := InitParametersValueFrom(s, c, owner) + err := InitParametersValueFrom(s, c, owner, scheme) if err != nil { return err diff --git a/binding.go b/binding.go deleted file mode 100644 index 14056a7..0000000 --- a/binding.go +++ /dev/null @@ -1,113 +0,0 @@ -/* type Mongo struct { - Hosts MongoHosts - ClientOptions ClientOptions - Oplog ClientOptions -} */ - -// type DatabaseClientConfig - -type AppBinding struct { - ClientConfig - Sources settings.Sources - Parameters *parameters.Parameters -} - -type ServiceClientConfig struct { - // Secret / Auth - // Specifies which scheme to use, for example: http, https - // If specified, then it will applied as prefix in this format: scheme:// - // If not specified, then nothing will be prefixed - Scheme string `json:"scheme" protobuf:"bytes,1,opt,name=scheme"` - - // `name` is the name of the service. - // Required - Name string `json:"name" protobuf:"bytes,2,opt,name=name"` - - // The port that will be exposed by this app. - Port int32 `json:"port" protobuf:"varint,3,opt,name=port"` - - // `path` is an optional URL path which will be sent in any request to - // this service. - // +optional - Path string `json:"path,omitempty" protobuf:"bytes,4,opt,name=path"` - - // `query` is optional encoded query string, without '?' which will be - // sent in any request to this service. - // +optional - Query string `json:"query,omitempty" protobuf:"bytes,5,opt,name=query"` -} - -type ClientConfig struct { - url - ServiceClientConfig -} - -type MongoAppClient struct { - Hosts MongoHosts - ClientOptions ClientOptions - Oplog ClientOptions -} - -type MongoHosts struct { - Hosts *parameters.Parameter `json:"hosts,omitempty" env:"MONGO_HOSTS"` - ServiceRef string `json:"endpointRef,omitempty"` - // Port int32 `json:"port,omitempty"` -} - -type ClientOptions struct { - Auth *Credential - Direct *parameters.Parameter // *bool - HeartbeatInterval *parameters.Parameter // *time.Duration - // Hosts MongoHosts - LocalThreshold *parameters.Parameter // *time.Duration - - Queries *parameters.Parameter `json:"queries,omitempty" env:"MONGO_CLIENT_QUERIES "` - Database *parameters.Parameter `json:"database,omitempty" env:"MONGO_DATABASE"` -} - -type Credential struct { - AuthMechanism *parameters.Parameter // string - AuthMechanismProperties *parameters.Parameter // map[string]string - AuthSource *parameters.Parameter // string - Username *parameters.Parameter // string - Password *parameters.Parameter // string - // PasswordSet bool -} - -// DefaultDNSSuffix is a default dns suffix for the cluster service -const DefaultDNSSuffix = "svc.cluster.local" - -func InitEndpoint(c client.Client, ctx context.Context) { - obj := &corev1.Endpoints{ - ObjectMeta: metav1.ObjectMeta{ - Name: "", - Namespace: "", - }, - } - - objectKey, _ := client.ObjectKeyFromObject(obj) - - if err := c.Get(ctx, objectKey, obj); err != nil { - // log.Error(err, "unable to fetch endpoint") - // return ctrl.Result{}, ignoreNotFound(err) - } - - hostnames := []string{} - port := obj.Subsets[0].Ports[0].Port - - for _, addr := range obj.Subsets[0].Addresses { - - hostname := strings.Join([]string{addr.Hostname, "serviceName", obj.Namespace, DefaultDNSSuffix}, ".") + - ":" + strconv.Itoa(int(port)) - - hostnames = append(hostnames, hostname) - } -} - -// hostname.subdomain.namespace.svc.cluster.local - -func getAddr() string { - // return strings.Join([]string{pod, m.Name + "-" + replset, m.Namespace, m.Spec.ClusterServiceDNSSuffix}, ".") + - // ":" + strconv.Itoa(int(m.Spec.Mongod.Net.Port)) - return "" -} diff --git a/go.mod b/go.mod index bce1738..b72f5f1 100644 --- a/go.mod +++ b/go.mod @@ -16,5 +16,3 @@ require ( ) replace k8s.io/client-go => k8s.io/client-go v0.18.2 - -replace k8s.libre.sh/controller-utils => ./ diff --git a/status/zz_generated.deepcopy.go b/status/zz_generated.deepcopy.go index b12119c..7b4460d 100644 --- a/status/zz_generated.deepcopy.go +++ b/status/zz_generated.deepcopy.go @@ -45,6 +45,7 @@ func (in *ApplicationStatus) DeepCopyInto(out *ApplicationStatus) { (*out)[key] = *val.DeepCopy() } } + in.Watched.DeepCopyInto(&out.Watched) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationStatus. -- GitLab From 0f4a0b2ca4b5bd9b6b1dd5f17f60bc589ae51241 Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Thu, 27 Aug 2020 22:40:36 +0200 Subject: [PATCH 3/7] WIP add finalizer to delete ownerref on watched resources --- application/reconciler/instance.go | 76 ++++++++++++- .../settings/parameters/parameters_helpers.go | 38 +++---- application/settings/parameters/utils.go | 102 +++++++++--------- 3 files changed, 148 insertions(+), 68 deletions(-) diff --git a/application/reconciler/instance.go b/application/reconciler/instance.go index 7564c51..634f636 100644 --- a/application/reconciler/instance.go +++ b/application/reconciler/instance.go @@ -82,12 +82,86 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res appStatus := r.Instance.GetApplicationStatus() oldStatus := appStatus.DeepCopy() - // TODO GET SOURCES add to watch resources in settings + /////////////////////////////////// + /////////// Finalizers //////////// + ////////////////////////////////// + + // name of our custom finalizer + // myFinalizerName := "apps.bound.finalizers.k8s.libre.sh" + // examine DeletionTimestamp to determine if object is under deletion + + /* if r.Instance.GetOwner().GetDeletionTimestamp().IsZero() { + // The object is not being deleted, so if it does not have our finalizer, + // then lets add the finalizer and update the object. This is equivalent + // registering our finalizer. + if !controllerutil.ContainsFinalizer(r.Instance.GetOwner(), myFinalizerName) { + controllerutil.AddFinalizer(r.Instance.GetOwner(), myFinalizerName) + } + + if err := r.GetClient().Update(context.Background(), r.Instance.GetOwner()); err != nil { + return ctrl.Result{}, err + } + } else { + // The object is being deleted + if controllerutil.ContainsFinalizer(r.Instance.GetOwner(), myFinalizerName) { + foo := r.Instance.GetOwner().GetApplicationStatus() + + var ro interfaces.Object + + for _, obj := range foo.Watched.Objects { + + if obj.Kind == "ConfigMap" { + ro = &corev1.ConfigMap{} + } else { + ro = &corev1.Secret{} + } + + ro.SetName(obj.Name) + ro.SetNamespace(r.Instance.GetOwner().GetNamespace()) + + objectKey, err := client.ObjectKeyFromObject(ro) + if err != nil { + return ctrl.Result{}, err + } + + if err := r.GetClient().Get(context.Background(), objectKey, ro); err != nil { + return ctrl.Result{}, err + } + + ownerRefs := []metav1.OwnerReference{} + + for _, ref := range ro.GetOwnerReferences() { + if ref.UID != r.Instance.GetOwner().GetUID() { + ownerRefs = append(ownerRefs, ref) + } + } + + ro.SetOwnerReferences(ownerRefs) + + if err := r.GetClient().Update(context.Background(), ro); err != nil { + return ctrl.Result{}, err + } + } + + } + + // remove our finalizer from the list and update it. + controllerutil.RemoveFinalizer(r.Instance.GetOwner(), myFinalizerName) + if err := r.GetClient().Update(context.Background(), r.Instance.GetOwner()); err != nil { + return ctrl.Result{}, err + } + // Stop reconciliation as the item is being deleted + return ctrl.Result{}, nil + } */ + err := application.Init(r.Instance, r.ReconcilerBase) if err != nil { return reconcile.Result{}, err } + ///////////////////////////////////// + ///////////////////////////////////// + // Sync Settings for name, s := range r.Instance.GetSettings() { diff --git a/application/settings/parameters/parameters_helpers.go b/application/settings/parameters/parameters_helpers.go index a3f57c9..8d2e5b7 100644 --- a/application/settings/parameters/parameters_helpers.go +++ b/application/settings/parameters/parameters_helpers.go @@ -274,21 +274,19 @@ func (ps *Parameters) Merge(in *Parameters) error { // Only secrets and configmaps are supported func (ps *Parameters) InitValueFrom(c client.Client, owner interfaces.Object, scheme *runtime.Scheme) error { - var obj interfaces.Object - sorted := OrderByResourceRef(ps) for ptype, byRef := range sorted { switch ptype { case ConfigParameter: - obj = &corev1.ConfigMap{} - + cm := &corev1.ConfigMap{} for ref, params := range byRef { - obj.SetName(ref) - obj.SetNamespace(owner.GetNamespace()) + cm.SetName(ref) + cm.SetNamespace(owner.GetNamespace()) - data, err := GetDataFromResource(c, obj, owner, scheme) + data, err := GetDataFromResource(c, cm, owner, scheme) if err != nil { + return err } @@ -298,21 +296,25 @@ func (ps *Parameters) InitValueFrom(c client.Client, owner interfaces.Object, sc } } case SecretParameter: - obj = &corev1.Secret{} - for ref, params := range byRef { - obj.SetName(ref) - obj.SetNamespace(owner.GetNamespace()) + sec := new(corev1.Secret) - data, err := GetDataFromResource(c, obj, owner, scheme) - if err != nil { - return err + for ref, params := range byRef { + if len(ref) > 0 { + sec.SetName(ref) + sec.SetNamespace(owner.GetNamespace()) + + data, err := GetDataFromResource(c, sec, owner, scheme) + if err != nil { + return err + } + + err = params.MergeData(data) + if err != nil { + return err + } } - err = params.MergeData(data) - if err != nil { - return err - } } } diff --git a/application/settings/parameters/utils.go b/application/settings/parameters/utils.go index a76ec27..2dadb16 100644 --- a/application/settings/parameters/utils.go +++ b/application/settings/parameters/utils.go @@ -118,69 +118,73 @@ func OrderByResourceRef(ps *Parameters) map[ParameterType]map[string]*Parameters // Only secrets and configmaps are supported. func GetDataFromResource(c client.Client, obj, owner interfaces.Object, scheme *runtime.Scheme) (data map[string]string, err error) { - objData := make(map[string]string) - data = make(map[string]string) + // TODO TO FIX + if obj != nil { + objData := make(map[string]string) + data = make(map[string]string) + + objectKey, err := client.ObjectKeyFromObject(obj) + if err != nil { + return data, err + } - objectKey, err := client.ObjectKeyFromObject(obj) - if err != nil { - return data, err - } + err = c.Get(context.Background(), objectKey, obj) + if err != nil { + return data, err + } - err = c.Get(context.Background(), objectKey, obj) - if err != nil { - return data, err - } + switch ro := obj.(type) { + case *corev1.Secret: + for k, v := range ro.Data { + objData[k] = string(v) + } + case *corev1.ConfigMap: + objData = ro.Data - switch ro := obj.(type) { - case *corev1.Secret: - for k, v := range ro.Data { - objData[k] = string(v) + default: + return data, errors.New("object kind should be ConfigMap or Secret") } - case *corev1.ConfigMap: - objData = ro.Data - - default: - return data, errors.New("object kind should be ConfigMap or Secret") - } - // If object is owner we only want to get the generated data in order to not regenerate it, - // other parameters are set in crds or valueFrom - if ownerRefs := obj.GetOwnerReferences(); ownerRefs != nil { - for _, ref := range ownerRefs { - if ref.UID == owner.GetUID() { - if ref.Controller != nil && *ref.Controller { - if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { - for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { - data[param] = objData[param] + // If object is owner we only want to get the generated data in order to not regenerate it, + // other parameters are set in crds or valueFrom + if ownerRefs := obj.GetOwnerReferences(); ownerRefs != nil { + for _, ref := range ownerRefs { + if ref.UID == owner.GetUID() { + if ref.Controller != nil && *ref.Controller { + if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { + for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { + data[param] = objData[param] + } } + } else { + data = objData } - } else { - data = objData + return data, nil } - return data, nil } } - } - data = objData - controllerutil.SetOwnerReference(owner, obj, scheme) - if err := c.Update(context.Background(), obj); err != nil { - return data, err - } + data = objData + controllerutil.SetOwnerReference(owner, obj, scheme) + if err := c.Update(context.Background(), obj); err != nil { + return data, err + } + + /* if metav1.IsControlledBy(obj, owner) { + if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { + for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { + data[param] = objData[param] + } + return data, nil + } + } else { + data = objData - /* if metav1.IsControlledBy(obj, owner) { - if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { - for _, param := range strings.Split(obj.GetAnnotations()["settings.k8s.libre.sh/generate"], ",") { - data[param] = objData[param] - } - return data, nil - } - } else { - data = objData + controllerutil.SetOwnerReference(owner, obj, scheme) - controllerutil.SetOwnerReference(owner, obj, scheme) + } */ - } */ + } return data, nil } -- GitLab From da4ccc1e06025a2e8b666ea9d2e3c3e7ba564d23 Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Fri, 28 Aug 2020 00:00:28 +0200 Subject: [PATCH 4/7] WIP use settings hash and mount in container --- application/reconciler/instance.go | 133 ++++++++++++----------- application/settings/component.go | 4 - application/settings/parameters/utils.go | 9 +- application/settings/settings.go | 51 +++++++-- go.mod | 2 + go.sum | 25 +++++ 6 files changed, 144 insertions(+), 80 deletions(-) diff --git a/application/reconciler/instance.go b/application/reconciler/instance.go index 634f636..019df9c 100644 --- a/application/reconciler/instance.go +++ b/application/reconciler/instance.go @@ -20,10 +20,14 @@ import ( "sort" "github.com/hashicorp/go-version" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.libre.sh/controller-utils/application" interfaces "k8s.libre.sh/controller-utils/interfaces" "k8s.libre.sh/controller-utils/status" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/reconcile" ) @@ -87,72 +91,73 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res ////////////////////////////////// // name of our custom finalizer - // myFinalizerName := "apps.bound.finalizers.k8s.libre.sh" + myFinalizerName := "apps.bound.finalizers.k8s.libre.sh" // examine DeletionTimestamp to determine if object is under deletion - /* if r.Instance.GetOwner().GetDeletionTimestamp().IsZero() { - // The object is not being deleted, so if it does not have our finalizer, - // then lets add the finalizer and update the object. This is equivalent - // registering our finalizer. - if !controllerutil.ContainsFinalizer(r.Instance.GetOwner(), myFinalizerName) { - controllerutil.AddFinalizer(r.Instance.GetOwner(), myFinalizerName) - } - - if err := r.GetClient().Update(context.Background(), r.Instance.GetOwner()); err != nil { - return ctrl.Result{}, err - } - } else { - // The object is being deleted - if controllerutil.ContainsFinalizer(r.Instance.GetOwner(), myFinalizerName) { - foo := r.Instance.GetOwner().GetApplicationStatus() - - var ro interfaces.Object - - for _, obj := range foo.Watched.Objects { - - if obj.Kind == "ConfigMap" { - ro = &corev1.ConfigMap{} - } else { - ro = &corev1.Secret{} - } - - ro.SetName(obj.Name) - ro.SetNamespace(r.Instance.GetOwner().GetNamespace()) - - objectKey, err := client.ObjectKeyFromObject(ro) - if err != nil { - return ctrl.Result{}, err - } - - if err := r.GetClient().Get(context.Background(), objectKey, ro); err != nil { - return ctrl.Result{}, err - } - - ownerRefs := []metav1.OwnerReference{} - - for _, ref := range ro.GetOwnerReferences() { - if ref.UID != r.Instance.GetOwner().GetUID() { - ownerRefs = append(ownerRefs, ref) - } - } - - ro.SetOwnerReferences(ownerRefs) - - if err := r.GetClient().Update(context.Background(), ro); err != nil { - return ctrl.Result{}, err - } - } - - } - - // remove our finalizer from the list and update it. - controllerutil.RemoveFinalizer(r.Instance.GetOwner(), myFinalizerName) - if err := r.GetClient().Update(context.Background(), r.Instance.GetOwner()); err != nil { - return ctrl.Result{}, err - } - // Stop reconciliation as the item is being deleted - return ctrl.Result{}, nil - } */ + bar := r.Instance.GetOwner() + if bar.GetDeletionTimestamp().IsZero() { + // The object is not being deleted, so if it does not have our finalizer, + // then lets add the finalizer and update the object. This is equivalent + // registering our finalizer. + if !controllerutil.ContainsFinalizer(r.Instance.GetOwner(), myFinalizerName) { + controllerutil.AddFinalizer(r.Instance.GetOwner(), myFinalizerName) + } + + if err := r.GetClient().Update(context.Background(), r.Instance.GetOwner()); err != nil { + return ctrl.Result{}, err + } + } else { + // The object is being deleted + if controllerutil.ContainsFinalizer(r.Instance.GetOwner(), myFinalizerName) { + foo := r.Instance.GetOwner().GetApplicationStatus() + + var ro interfaces.Object + + for _, obj := range foo.Watched.Objects { + + if obj.Kind == "ConfigMap" { + ro = &corev1.ConfigMap{} + } else { + ro = &corev1.Secret{} + } + + ro.SetName(obj.Name) + ro.SetNamespace(r.Instance.GetOwner().GetNamespace()) + + objectKey, err := client.ObjectKeyFromObject(ro) + if err != nil { + return ctrl.Result{}, err + } + + if err := r.GetClient().Get(context.Background(), objectKey, ro); err != nil { + return ctrl.Result{}, err + } + + ownerRefs := []metav1.OwnerReference{} + + for _, ref := range ro.GetOwnerReferences() { + if ref.UID != r.Instance.GetOwner().GetUID() { + ownerRefs = append(ownerRefs, ref) + } + } + + ro.SetOwnerReferences(ownerRefs) + + if err := r.GetClient().Update(context.Background(), ro); err != nil { + return ctrl.Result{}, err + } + } + + } + + // remove our finalizer from the list and update it. + controllerutil.RemoveFinalizer(r.Instance.GetOwner(), myFinalizerName) + if err := r.GetClient().Update(context.Background(), r.Instance.GetOwner()); err != nil { + return ctrl.Result{}, err + } + // Stop reconciliation as the item is being deleted + return ctrl.Result{}, nil + } err := application.Init(r.Instance, r.ReconcilerBase) if err != nil { diff --git a/application/settings/component.go b/application/settings/component.go index 94cf8c2..ac81c84 100644 --- a/application/settings/component.go +++ b/application/settings/component.go @@ -184,10 +184,6 @@ func Init(s Component, c client.Client, owner interfaces.Object, scheme *runtime s.GetParameters().InitRandValues() - if err != nil { - return err - } - return nil } diff --git a/application/settings/parameters/utils.go b/application/settings/parameters/utils.go index 2dadb16..a83ea5e 100644 --- a/application/settings/parameters/utils.go +++ b/application/settings/parameters/utils.go @@ -26,7 +26,6 @@ import ( "k8s.libre.sh/controller-utils/interfaces" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) func Marshal(i interface{}) (*Parameters, error) { @@ -165,10 +164,10 @@ func GetDataFromResource(c client.Client, obj, owner interfaces.Object, scheme * } data = objData - controllerutil.SetOwnerReference(owner, obj, scheme) - if err := c.Update(context.Background(), obj); err != nil { - return data, err - } + // controllerutil.SetOwnerReference(owner, obj, scheme) + // if err := c.Update(context.Background(), obj); err != nil { + // return data, err + // } /* if metav1.IsControlledBy(obj, owner) { if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { diff --git a/application/settings/settings.go b/application/settings/settings.go index 016b9e2..626f794 100644 --- a/application/settings/settings.go +++ b/application/settings/settings.go @@ -16,11 +16,13 @@ limitations under the License. package settings import ( - "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/client" + "crypto/sha1" + "fmt" + "io" + "sort" + "strings" "k8s.libre.sh/controller-utils/application/settings/parameters" - "k8s.libre.sh/controller-utils/interfaces" "k8s.libre.sh/controller-utils/meta" "k8s.libre.sh/controller-utils/objects" ) @@ -161,6 +163,20 @@ func (s *Settings) SetDefaults() { } + shaParam := ¶meters.Parameter{ + Key: s.GetMeta().GetComponent(), + Value: GetSHAfromParameters(s.GetParameters()), + MountType: parameters.MountLiteral, + } + + for _, p := range *s.GetParameters() { + if p.Key == s.GetMeta().GetComponent() { + p = shaParam + } + } + + *s.GetParameters() = append(*s.GetParameters(), shaParam) + srcs.DeepCopyInto(s.GetSources()) } @@ -168,7 +184,7 @@ func (s *Settings) SetDefaults() { // Init initialise the settings. // ObjectMeta are set from commons meta. // Parameters are initialised from external resources set in ValueFrom and random values are generated. -func (s *Settings) Init(c client.Client, owner interfaces.Object, scheme *runtime.Scheme) error { +/* func (s *Settings) Init(c client.Client, owner interfaces.Object, scheme *runtime.Scheme) error { if s.CreateOptions == nil { s.CreateOptions = &CreateOptions{} @@ -186,9 +202,30 @@ func (s *Settings) Init(c client.Client, owner interfaces.Object, scheme *runtim s.InitRandValues() - if err != nil { - return err + return nil +} +*/ + +func GetSHAfromParameters(params *parameters.Parameters) string { + values := []string{} + for _, p := range *params { + if len(p.Key) > 0 && len(p.Value) > 0 { + values = append(values, p.Key+"="+p.Value) + } } - return nil + sort.Strings(values) + + return GenerateSHA(strings.Join(values, ";")) +} + +// GenerateSHA generates SHA from string +func GenerateSHA(data string) string { + hasher := sha1.New() + _, err := io.WriteString(hasher, data) + if err != nil { + // logrus.Errorf("Unable to write data in hash writer %v", err) + } + sha := hasher.Sum(nil) + return fmt.Sprintf("%x", sha) } diff --git a/go.mod b/go.mod index b72f5f1..a8e2a78 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,8 @@ require ( github.com/onsi/ginkgo v1.14.0 github.com/onsi/gomega v1.10.1 github.com/presslabs/controller-util v0.2.4 + github.com/sirupsen/logrus v1.4.2 + github.com/stakater/Reloader v0.0.67 k8s.io/api v0.18.6 k8s.io/apimachinery v0.18.6 k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible diff --git a/go.sum b/go.sum index 7e29fbc..9a9cd36 100644 --- a/go.sum +++ b/go.sum @@ -29,7 +29,9 @@ github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdko github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= @@ -43,7 +45,10 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -103,6 +108,7 @@ github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg= @@ -168,6 +174,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191002201903-404acd9df4cc/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 h1:uHTyIjqVhYRhLbJ8nIiOJHkEZZ+5YoOsAbD3sk82NiE= github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -246,6 +253,7 @@ github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBv github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -299,6 +307,7 @@ github.com/onsi/ginkgo v1.4.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= @@ -313,6 +322,8 @@ github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/openshift/api v3.9.1-0.20190923092516-169848dd8137+incompatible/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY= +github.com/openshift/client-go v0.0.0-20190923092832-6afefc9bb372/go.mod h1:6rzn+JTr7+WYS2E1TExP4gByoABxMznR6y2SnUIkmxk= github.com/paulmach/orb v0.1.3/go.mod h1:VFlX/8C+IQ1p6FTRRKzKoOPJnvEtA5G0Veuqwbu//Vk= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -333,6 +344,8 @@ github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDf github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= +github.com/prometheus/client_golang v1.4.1 h1:FFSuS004yOQEtDdTq+TAOLP5xUq63KqAFYyOi8zA+Y8= +github.com/prometheus/client_golang v1.4.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -344,11 +357,14 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI= github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= @@ -363,6 +379,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/soheilhy/cmux v0.1.3/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -370,6 +387,7 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.0-20160722081547-f62e98d28ab7/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= @@ -381,6 +399,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stakater/Reloader v0.0.67 h1:PStmmAP3HTUhGGRAc94mmzVn0VZ45+qzUlF3FmUMpAA= +github.com/stakater/Reloader v0.0.67/go.mod h1:xg0azejtsfbLkC8oMsAvmLqr4QDsG1m7nyGNg1brj/8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= @@ -523,6 +543,7 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= @@ -604,6 +625,7 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -612,6 +634,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -625,6 +648,7 @@ gopkg.in/yaml.v2 v2.0.0/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -650,6 +674,7 @@ k8s.io/apiextensions-apiserver v0.18.2/go.mod h1:q3faSnRGmYimiocj6cHQ1I3WpLqmDgJ k8s.io/apiextensions-apiserver v0.18.6 h1:vDlk7cyFsDyfwn2rNAO2DbmUbvXy5yT5GE3rrqOzaMo= k8s.io/apiextensions-apiserver v0.18.6/go.mod h1:lv89S7fUysXjLZO7ke783xOwVTm6lKizADfvUM/SS/M= k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655/go.mod h1:nL6pwRT8NgfF8TT68DBI8uEePRt89cSvoXUVqbkWHq4= +k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8/go.mod h1:llRdnznGEAqC3DcNm6yEj472xaFVfLM7hnYofMb12tQ= k8s.io/apimachinery v0.0.0-20191214185652-442f8fb2f03a/go.mod h1:Ng1IY8TS7sC44KJxT/WUR6qFRfWwahYYYpNXyYRKOCY= k8s.io/apimachinery v0.0.0-20191216025728-0ee8b4573e3a/go.mod h1:Ng1IY8TS7sC44KJxT/WUR6qFRfWwahYYYpNXyYRKOCY= k8s.io/apimachinery v0.17.2/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -- GitLab From e0073c5e9c3f97e531c47ba18caf1a244a6a113e Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Fri, 28 Aug 2020 00:33:31 +0200 Subject: [PATCH 5/7] re-add owner ref on watched resources & fix envFrom --- application/settings/parameters/utils.go | 9 ++++--- application/settings/settings.go | 3 ++- application/settings/setttingsspec.go | 34 +++++++++++++----------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/application/settings/parameters/utils.go b/application/settings/parameters/utils.go index a83ea5e..2dadb16 100644 --- a/application/settings/parameters/utils.go +++ b/application/settings/parameters/utils.go @@ -26,6 +26,7 @@ import ( "k8s.libre.sh/controller-utils/interfaces" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) func Marshal(i interface{}) (*Parameters, error) { @@ -164,10 +165,10 @@ func GetDataFromResource(c client.Client, obj, owner interfaces.Object, scheme * } data = objData - // controllerutil.SetOwnerReference(owner, obj, scheme) - // if err := c.Update(context.Background(), obj); err != nil { - // return data, err - // } + controllerutil.SetOwnerReference(owner, obj, scheme) + if err := c.Update(context.Background(), obj); err != nil { + return data, err + } /* if metav1.IsControlledBy(obj, owner) { if len(obj.GetAnnotations()["settings.k8s.libre.sh/generate"]) > 0 { diff --git a/application/settings/settings.go b/application/settings/settings.go index 626f794..42e7300 100644 --- a/application/settings/settings.go +++ b/application/settings/settings.go @@ -137,8 +137,9 @@ func (s *Settings) SetDefaults() { } else if p.Type == parameters.SecretParameter || p.Type == "" { srcs = AppendSourceIfUnique(srcs, secretSrc) } + fmt.Println(p) // Reset valueFrom, we do not want to mount orginal resources - p.ValueFrom = parameters.ValueFrom{} + // p.ValueFrom = parameters.ValueFrom{} } } diff --git a/application/settings/setttingsspec.go b/application/settings/setttingsspec.go index bf0928e..cc278a9 100644 --- a/application/settings/setttingsspec.go +++ b/application/settings/setttingsspec.go @@ -86,25 +86,27 @@ func (c *SettingsSpec) GetEnvFrom() []corev1.EnvFromSource { envFrom := corev1.EnvFromSource{} - if c.Parameters != nil { - for _, p := range *c.Parameters { - if p.MountType == parameters.MountEnvFile && len(p.Ref) > 0 { - if p.Type == parameters.ConfigParameter { - src := Source{ - Ref: p.Ref, - Type: string(p.Type), + // TODO DO we want this ? if p.MountType == parameters.MountEnvFile && len(p.Ref) > 0 => mount as envfile ? + /* + if c.Parameters != nil { + for _, p := range *c.Parameters { + if p.MountType == parameters.MountEnvFile && len(p.Ref) > 0 { + if p.Type == parameters.ConfigParameter { + src := Source{ + Ref: p.Ref, + Type: string(p.Type), + } + c.Sources = AppendSourceIfUnique(c.Sources, src) + } else if p.Type == parameters.SecretParameter { + src := Source{ + Ref: p.Ref, + Type: string(p.Type), + } + c.Sources = AppendSourceIfUnique(c.Sources, src) } - c.Sources = AppendSourceIfUnique(c.Sources, src) - } else if p.Type == parameters.SecretParameter { - src := Source{ - Ref: p.Ref, - Type: string(p.Type), - } - c.Sources = AppendSourceIfUnique(c.Sources, src) } } - } - } + } */ if c.Sources != nil { for _, source := range *c.Sources { -- GitLab From cbab4b20954983804784e3b9e760a03951cd8d05 Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Fri, 28 Aug 2020 02:16:05 +0200 Subject: [PATCH 6/7] remove finalizer when resources is not watched anymore & fixes --- application/instance.go | 8 +- application/reconciler/instance.go | 115 ++++++++++++++++++++++++----- application/settings/settings.go | 1 - 3 files changed, 102 insertions(+), 22 deletions(-) diff --git a/application/instance.go b/application/instance.go index d40f1a8..d67425a 100644 --- a/application/instance.go +++ b/application/instance.go @@ -97,6 +97,8 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { appStatus := i.GetApplicationStatus() setts := i.GetSettings() + watched := status.Resources{} + // First we init external values and random values for name, sett := range setts { @@ -108,7 +110,7 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { Kind: src.Type, Group: "", } - appStatus.Watched.Objects = AppendIfUnique(appStatus.Watched.Objects, obj) + watched.Objects = AppendIfUnique(watched.Objects, obj) } for _, p := range *sett.GetConfig().GetParameters() { @@ -120,10 +122,12 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { Kind: "Secret", Group: "", } - appStatus.Watched.Objects = AppendIfUnique(appStatus.Watched.Objects, obj) + watched.Objects = AppendIfUnique(watched.Objects, obj) } } + appStatus.Watched = watched + if len(appStatus.Settings[name].Resources.Objects) > 0 { for _, o := range appStatus.Settings[name].Resources.Objects { src := settings.Source{ diff --git a/application/reconciler/instance.go b/application/reconciler/instance.go index 019df9c..70fd095 100644 --- a/application/reconciler/instance.go +++ b/application/reconciler/instance.go @@ -81,6 +81,34 @@ func (r *InstanceReconciler) ManageError(owner status.ObjectWithStatus) (reconci return reconcile.Result{}, nil } +func RemoverOwnerRef(c client.Client, obj interfaces.Object, owner metav1.Object) error { + + objectKey, err := client.ObjectKeyFromObject(obj) + if err != nil { + return err + } + + if err := c.Get(context.Background(), objectKey, obj); err != nil { + return err + } + + ownerRefs := []metav1.OwnerReference{} + + for _, ref := range obj.GetOwnerReferences() { + if ref.UID != owner.GetUID() { + ownerRefs = append(ownerRefs, ref) + } + } + + obj.SetOwnerReferences(ownerRefs) + + if err := c.Update(context.Background(), obj); err != nil { + return err + } + + return nil +} + func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) { appStatus := r.Instance.GetApplicationStatus() @@ -124,28 +152,10 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res ro.SetName(obj.Name) ro.SetNamespace(r.Instance.GetOwner().GetNamespace()) - objectKey, err := client.ObjectKeyFromObject(ro) - if err != nil { + if err := RemoverOwnerRef(r.GetClient(), ro, r.Instance.GetOwner()); err != nil { return ctrl.Result{}, err } - if err := r.GetClient().Get(context.Background(), objectKey, ro); err != nil { - return ctrl.Result{}, err - } - - ownerRefs := []metav1.OwnerReference{} - - for _, ref := range ro.GetOwnerReferences() { - if ref.UID != r.Instance.GetOwner().GetUID() { - ownerRefs = append(ownerRefs, ref) - } - } - - ro.SetOwnerReferences(ownerRefs) - - if err := r.GetClient().Update(context.Background(), ro); err != nil { - return ctrl.Result{}, err - } } } @@ -282,9 +292,76 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res return ctrl.Result{}, err } + diff := Difference(&oldStatus.Watched, &appStatus.Watched) + + if len(diff.Objects) > 0 { + var ro interfaces.Object + for _, obj := range diff.Objects { + if obj.Kind == "ConfigMap" { + ro = &corev1.ConfigMap{} + } else { + ro = &corev1.Secret{} + } + + ro.SetName(obj.Name) + ro.SetNamespace(r.Instance.GetOwner().GetNamespace()) + + if err := RemoverOwnerRef(r.GetClient(), ro, r.Instance.GetOwner()); err != nil { + return ctrl.Result{}, err + } + } + + } + return ctrl.Result{}, nil } +func Difference(original, desired *status.Resources) *status.Resources { + // diff := original.DeepCopy() + + diff := &status.Resources{} + diffByKey := make(map[string]status.ObjectStatus, len(original.Objects)) + desiredByKey := make(map[string]status.ObjectStatus, len(desired.Objects)) + + for _, obj := range original.Objects { + diffByKey[obj.Name] = obj + } + + for _, obj := range desired.Objects { + desiredByKey[obj.Name] = obj + } + + for item := range desiredByKey { + delete(diffByKey, item) + } + + for _, obj := range diffByKey { + diff.Objects = append(diff.Objects, obj) + } + + return diff +} + +/* func CleanUpResources(old, new *status.Resources, c client.Client, ns string) error { + diff := status.Difference(old, new) + if len(diff.Objects) > 0 { + for _, o := range diff.Objects { + unstruct := &unstructured.Unstructured{} + unstruct.SetGroupVersionKind(o.GVK()) + unstruct.SetName(o.Name) + unstruct.SetNamespace(ns) + deleteBackground := metav1.DeletePropagationBackground + opts := client.DeleteOptions{ + PropagationPolicy: &deleteBackground, + } + if err := c.Delete(context.TODO(), unstruct, &opts); err != nil { + return err + } + } + } + return nil +} */ + func SyncComponents(ctx context.Context, r interfaces.Reconcile, cpts map[string]application.ComponentMutate, owner interfaces.Object, order map[int]string) (appStatus status.ApplicationStatus, err error) { keys := []int{} diff --git a/application/settings/settings.go b/application/settings/settings.go index 42e7300..1d765aa 100644 --- a/application/settings/settings.go +++ b/application/settings/settings.go @@ -137,7 +137,6 @@ func (s *Settings) SetDefaults() { } else if p.Type == parameters.SecretParameter || p.Type == "" { srcs = AppendSourceIfUnique(srcs, secretSrc) } - fmt.Println(p) // Reset valueFrom, we do not want to mount orginal resources // p.ValueFrom = parameters.ValueFrom{} } -- GitLab From 39fbdb6f0e0b714e94aa58015b3a4d7d331a4b9b Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Fri, 28 Aug 2020 16:13:05 +0200 Subject: [PATCH 7/7] refactor --- application/instance.go | 72 +++++++------- application/reconciler/instance.go | 115 +++++++---------------- application/settings/parameters/utils.go | 21 ----- application/settings/settings.go | 7 +- application/settings/setttingsspec.go | 22 ----- go.sum | 7 ++ 6 files changed, 76 insertions(+), 168 deletions(-) diff --git a/application/instance.go b/application/instance.go index d67425a..0d59639 100644 --- a/application/instance.go +++ b/application/instance.go @@ -72,25 +72,44 @@ func AppendIfUnique(objs []status.ObjectStatus, obj status.ObjectStatus) []statu return objs } -/* func AppendSourceIfUnique(sources *Sources, source Source) *Sources { - srcs := Sources{} +func GetWatchedObjectsFromParameters(ps *parameters.Parameters) status.Resources { - if sources != nil { - for _, ele := range *sources { - if ele == source { - return sources - } - } - }= source { - return sources + watched := status.Resources{} + + for _, p := range *ps { + if len(p.Ref) > 0 && p.Type != parameters.ObjectFieldParameter && p.RefType != parameters.ObjectFieldParameter { + obj := status.ObjectStatus{ + Link: "", + Name: p.Ref, + Version: "", + Kind: "Secret", + Group: "", } + watched.Objects = AppendIfUnique(watched.Objects, obj) } } - srcs = append(srcs, source) + return watched +} + +func GetWatchedObjectsFromSources(srcs *settings.Sources) status.Resources { + + watched := status.Resources{} + + for _, src := range *srcs { + obj := status.ObjectStatus{ + Link: "", + Name: src.Ref, + Version: "", + Kind: src.Type, + Group: "", + } + + watched.Objects = AppendIfUnique(watched.Objects, obj) + } - return &srcs -} */ + return watched +} func InitSettings(i Instance, r interfaces.Reconcile) error { @@ -102,30 +121,8 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { // First we init external values and random values for name, sett := range setts { - for _, src := range *sett.GetConfig().GetSources() { - obj := status.ObjectStatus{ - Link: "", - Name: src.Ref, - Version: "", - Kind: src.Type, - Group: "", - } - watched.Objects = AppendIfUnique(watched.Objects, obj) - } - - for _, p := range *sett.GetConfig().GetParameters() { - if len(p.Ref) > 0 && p.Type != parameters.ObjectFieldParameter && p.RefType != parameters.ObjectFieldParameter { - obj := status.ObjectStatus{ - Link: "", - Name: p.Ref, - Version: "", - Kind: "Secret", - Group: "", - } - watched.Objects = AppendIfUnique(watched.Objects, obj) - } - } - + watched.Objects = append(watched.Objects, GetWatchedObjectsFromParameters(sett.GetParameters()).Objects...) + watched.Objects = append(watched.Objects, GetWatchedObjectsFromSources(sett.GetSources()).Objects...) appStatus.Watched = watched if len(appStatus.Settings[name].Resources.Objects) > 0 { @@ -140,7 +137,6 @@ func InitSettings(i Instance, r interfaces.Reconcile) error { } } - // appStatus.Watched.Objects = nil err := settings.Init(sett, r.GetClient(), i.GetOwner(), r.GetScheme()) if err != nil { diff --git a/application/reconciler/instance.go b/application/reconciler/instance.go index 70fd095..f85e343 100644 --- a/application/reconciler/instance.go +++ b/application/reconciler/instance.go @@ -45,37 +45,6 @@ func NewInstanceReconciler(r *ReconcilerBase, i application.Instance, order map[ } } -/* func (er *InstanceReconciler) ManageSuccess(instance apis.Resource) (reconcile.Result, error) { - if enforcingReconcileStatusAware, updateStatus := (instance).(apis.EnforcingReconcileStatusAware); updateStatus { - condition := status.Condition{ - Type: "ReconcileSuccess", - LastTransitionTime: metav1.Now(), - Message: astatus.SuccessfulMessage, - Reason: astatus.SuccessfulReason, - Status: corev1.ConditionTrue, - } - status := apis.EnforcingReconcileStatus{ - Conditions: status.NewConditions(condition), - LockedResourceStatuses: er.GetLockedResourceStatuses(instance), - LockedPatchStatuses: er.GetLockedPatchStatuses(instance), - } - enforcingReconcileStatusAware.SetEnforcingReconcileStatus(status) - log.V(1).Info("about to modify state for", "instance version", instance.GetResourceVersion()) - err := er.GetClient().Status().Update(context.Background(), instance) - if err != nil { - if errors.IsResourceExpired(err) { - log.Info("unable to update status for", "object version", instance.GetResourceVersion(), "resource version expired, will trigger another reconcile cycle", "") - } else { - log.Error(err, "unable to update status for", "object", instance) - } - return reconcile.Result{}, err - } - } else { - log.V(1).Info("object is not RecocileStatusAware, not setting status") - } - return reconcile.Result{}, nil -} -*/ func (r *InstanceReconciler) ManageError(owner status.ObjectWithStatus) (reconcile.Result, error) { return reconcile.Result{}, nil @@ -139,25 +108,9 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res if controllerutil.ContainsFinalizer(r.Instance.GetOwner(), myFinalizerName) { foo := r.Instance.GetOwner().GetApplicationStatus() - var ro interfaces.Object - - for _, obj := range foo.Watched.Objects { - - if obj.Kind == "ConfigMap" { - ro = &corev1.ConfigMap{} - } else { - ro = &corev1.Secret{} - } - - ro.SetName(obj.Name) - ro.SetNamespace(r.Instance.GetOwner().GetNamespace()) - - if err := RemoverOwnerRef(r.GetClient(), ro, r.Instance.GetOwner()); err != nil { - return ctrl.Result{}, err - } - + if err := CleanUpOwnerRef(foo.Watched.Objects, r.Instance.GetOwner(), r.GetClient()); err != nil { + return ctrl.Result{}, err } - } // remove our finalizer from the list and update it. @@ -295,29 +248,45 @@ func (r *InstanceReconciler) Reconcile(request reconcile.Request) (reconcile.Res diff := Difference(&oldStatus.Watched, &appStatus.Watched) if len(diff.Objects) > 0 { - var ro interfaces.Object - for _, obj := range diff.Objects { - if obj.Kind == "ConfigMap" { - ro = &corev1.ConfigMap{} - } else { - ro = &corev1.Secret{} - } + if err := CleanUpOwnerRef(diff.Objects, r.Instance.GetOwner(), r.GetClient()); err != nil { + return ctrl.Result{}, err + } + } - ro.SetName(obj.Name) - ro.SetNamespace(r.Instance.GetOwner().GetNamespace()) + return ctrl.Result{}, nil +} - if err := RemoverOwnerRef(r.GetClient(), ro, r.Instance.GetOwner()); err != nil { - return ctrl.Result{}, err - } +func CleanUpOwnerRef(osts []status.ObjectStatus, owner metav1.Object, c client.Client) error { + for _, ost := range osts { + + ro := RuntimeObjFromObjStatus(ost) + ro.SetNamespace(owner.GetNamespace()) + + if err := RemoverOwnerRef(c, ro, owner); err != nil { + return err } + } + + return nil +} +func RuntimeObjFromObjStatus(ost status.ObjectStatus) interfaces.Object { + + switch ost.Kind { + case "ConfigMap": + obj := &corev1.ConfigMap{} + obj.SetName(ost.Name) + return obj + case "Secret": + obj := &corev1.Secret{} + obj.SetName(ost.Name) + return obj } - return ctrl.Result{}, nil + return nil } func Difference(original, desired *status.Resources) *status.Resources { - // diff := original.DeepCopy() diff := &status.Resources{} diffByKey := make(map[string]status.ObjectStatus, len(original.Objects)) @@ -342,26 +311,6 @@ func Difference(original, desired *status.Resources) *status.Resources { return diff } -/* func CleanUpResources(old, new *status.Resources, c client.Client, ns string) error { - diff := status.Difference(old, new) - if len(diff.Objects) > 0 { - for _, o := range diff.Objects { - unstruct := &unstructured.Unstructured{} - unstruct.SetGroupVersionKind(o.GVK()) - unstruct.SetName(o.Name) - unstruct.SetNamespace(ns) - deleteBackground := metav1.DeletePropagationBackground - opts := client.DeleteOptions{ - PropagationPolicy: &deleteBackground, - } - if err := c.Delete(context.TODO(), unstruct, &opts); err != nil { - return err - } - } - } - return nil -} */ - func SyncComponents(ctx context.Context, r interfaces.Reconcile, cpts map[string]application.ComponentMutate, owner interfaces.Object, order map[int]string) (appStatus status.ApplicationStatus, err error) { keys := []int{} diff --git a/application/settings/parameters/utils.go b/application/settings/parameters/utils.go index 2dadb16..f72d37a 100644 --- a/application/settings/parameters/utils.go +++ b/application/settings/parameters/utils.go @@ -188,24 +188,3 @@ func GetDataFromResource(c client.Client, obj, owner interfaces.Object, scheme * return data, nil } - -// getOwnersReferences returns the OwnerReferences for an object as specified by the EnqueueRequestForOwner -// - if IsController is true: only take the Controller OwnerReference (if found) -// - if IsController is false: take all OwnerReferences -/* func GetOwnersReferences(object metav1.Object) []metav1.OwnerReference { - if object == nil { - return nil - } - - // If not filtered as Controller only, then use all the OwnerReferences - if !e.IsController { - return object.GetOwnerReferences() - } - // If filtered to a Controller, only take the Controller OwnerReference - if ownerRef := metav1.GetControllerOf(object); ownerRef != nil { - return []metav1.OwnerReference{*ownerRef} - } - // No Controller OwnerReference found - return nil -} -*/ diff --git a/application/settings/settings.go b/application/settings/settings.go index 1d765aa..03c851f 100644 --- a/application/settings/settings.go +++ b/application/settings/settings.go @@ -137,8 +137,6 @@ func (s *Settings) SetDefaults() { } else if p.Type == parameters.SecretParameter || p.Type == "" { srcs = AppendSourceIfUnique(srcs, secretSrc) } - // Reset valueFrom, we do not want to mount orginal resources - // p.ValueFrom = parameters.ValueFrom{} } } @@ -163,6 +161,8 @@ func (s *Settings) SetDefaults() { } + srcs.DeepCopyInto(s.GetSources()) + shaParam := ¶meters.Parameter{ Key: s.GetMeta().GetComponent(), Value: GetSHAfromParameters(s.GetParameters()), @@ -172,13 +172,12 @@ func (s *Settings) SetDefaults() { for _, p := range *s.GetParameters() { if p.Key == s.GetMeta().GetComponent() { p = shaParam + return } } *s.GetParameters() = append(*s.GetParameters(), shaParam) - srcs.DeepCopyInto(s.GetSources()) - } // Init initialise the settings. diff --git a/application/settings/setttingsspec.go b/application/settings/setttingsspec.go index cc278a9..ccefb7b 100644 --- a/application/settings/setttingsspec.go +++ b/application/settings/setttingsspec.go @@ -86,28 +86,6 @@ func (c *SettingsSpec) GetEnvFrom() []corev1.EnvFromSource { envFrom := corev1.EnvFromSource{} - // TODO DO we want this ? if p.MountType == parameters.MountEnvFile && len(p.Ref) > 0 => mount as envfile ? - /* - if c.Parameters != nil { - for _, p := range *c.Parameters { - if p.MountType == parameters.MountEnvFile && len(p.Ref) > 0 { - if p.Type == parameters.ConfigParameter { - src := Source{ - Ref: p.Ref, - Type: string(p.Type), - } - c.Sources = AppendSourceIfUnique(c.Sources, src) - } else if p.Type == parameters.SecretParameter { - src := Source{ - Ref: p.Ref, - Type: string(p.Type), - } - c.Sources = AppendSourceIfUnique(c.Sources, src) - } - } - } - } */ - if c.Sources != nil { for _, source := range *c.Sources { if source.Type == "configmap" { diff --git a/go.sum b/go.sum index 9a9cd36..3fd25f8 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,10 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -127,11 +129,13 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+ github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= @@ -146,6 +150,7 @@ github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsd github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.19.5 h1:Xm0Ao53uqnk9QE/LlYV5DEU09UAgpliA85QoT9LzqPw= github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= @@ -156,6 +161,7 @@ github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dp github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= @@ -277,6 +283,7 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -- GitLab