Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Log requested update template
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakknutsen committed Mar 16, 2018
1 parent 3b8af55 commit aec6537
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
17 changes: 4 additions & 13 deletions controller/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
9 changes: 9 additions & 0 deletions openshift/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
21 changes: 10 additions & 11 deletions openshift/init_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -118,26 +117,27 @@ 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,
}, "failed")
return
}
log.Info(ctx, map[string]interface{}{
"request": template,
"output": output,
"namespace": namespace,
}, "applied")
Expand All @@ -154,6 +154,5 @@ func listToTemplate(objects []map[interface{}]interface{}) string {
"objects": objects,
}

b, _ := yaml.Marshal(template)
return string(b)
return YamlString(template)
}

0 comments on commit aec6537

Please sign in to comment.