diff --git a/controller/tenant.go b/controller/tenant.go index e81c276..ce00139 100644 --- a/controller/tenant.go +++ b/controller/tenant.go @@ -20,7 +20,6 @@ import ( "github.com/goadesign/goa" goajwt "github.com/goadesign/goa/middleware/security/jwt" uuid "github.com/satori/go.uuid" - yaml "gopkg.in/yaml.v2" ) // TenantController implements the status resource. @@ -288,8 +287,8 @@ func InitTenant(ctx context.Context, masterURL string, service tenant.Service, c "namespace": openshift.GetNamespace(request), "name": openshift.GetName(request), "kind": openshift.GetKind(request), - "request": yamlString(request), - "response": yamlString(response), + "request": openshift.YamlString(request), + "response": openshift.YamlString(response), }, "resource requested") if statusCode == http.StatusConflict { if openshift.GetKind(request) == openshift.ValKindNamespace { @@ -359,8 +358,8 @@ func InitTenant(ctx context.Context, masterURL string, service tenant.Service, c "namespace": openshift.GetNamespace(request), "name": openshift.GetName(request), "kind": openshift.GetKind(request), - "request": yamlString(request), - "response": yamlString(response), + "request": openshift.YamlString(request), + "response": openshift.YamlString(response), }, "unhandled resource response") return "", nil } @@ -442,11 +441,3 @@ func convertTenant(ctx context.Context, tenant *tenant.Tenant, namespaces []*ten } return &result } - -func yamlString(data map[interface{}]interface{}) string { - b, err := yaml.Marshal(data) - if err != nil { - return fmt.Sprintf("Could not marshal yaml %v", data) - } - return string(b) -} diff --git a/openshift/apply.go b/openshift/apply.go index e748c2e..df72f85 100644 --- a/openshift/apply.go +++ b/openshift/apply.go @@ -475,3 +475,12 @@ func (a ByKind) Less(i, j int) bool { } return iO < jO } + +// YamlString returns a Yaml object to String +func YamlString(data map[interface{}]interface{}) string { + b, err := yaml.Marshal(data) + if err != nil { + return fmt.Sprintf("Could not marshal yaml %v", data) + } + return string(b) +} diff --git a/openshift/init_tenant.go b/openshift/init_tenant.go index 077a89c..785efb9 100644 --- a/openshift/init_tenant.go +++ b/openshift/init_tenant.go @@ -7,7 +7,6 @@ import ( "github.com/fabric8-services/fabric8-tenant/tenant" "github.com/fabric8-services/fabric8-wit/log" - yaml "gopkg.in/yaml.v2" ) const ( @@ -118,19 +117,19 @@ func RawUpdateTenant(ctx context.Context, config Config, callback Callback, user for key, val := range mapped { go func(namespace string, objects []map[interface{}]interface{}, opts ApplyOptions) { defer wg.Done() - output, err := executeProccessedNamespaceCMD( - listToTemplate( - //RemoveReplicas( - Filter( - objects, - IsNotOfKind(ValKindProjectRequest), - ), - //), + template := listToTemplate( + Filter( + objects, + IsNotOfKind(ValKindProjectRequest), ), + ) + output, err := executeProccessedNamespaceCMD( + template, opts.WithNamespace(namespace), ) if err != nil { log.Error(ctx, map[string]interface{}{ + "request": template, "output": output, "namespace": namespace, "error": err, @@ -138,6 +137,7 @@ func RawUpdateTenant(ctx context.Context, config Config, callback Callback, user return } log.Info(ctx, map[string]interface{}{ + "request": template, "output": output, "namespace": namespace, }, "applied") @@ -154,6 +154,5 @@ func listToTemplate(objects []map[interface{}]interface{}) string { "objects": objects, } - b, _ := yaml.Marshal(template) - return string(b) + return YamlString(template) }