Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

pretty print log messages IAM policy #327

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#**********************************************************************
# Builder
# Create a go runtime suitable for building and testing kfctl
ARG GOLANG_VERSION=1.12.7
FROM golang:$GOLANG_VERSION as builder

Expand All @@ -25,7 +22,8 @@ ENV PATH /go/bin:/usr/local/go/bin:/opt/google-cloud-sdk/bin:${PATH}
# use go modules
ENV GO111MODULE=on
ENV GOPATH=/go
ENV GOROOT=/usr/local/go # Workaround for https://github.com/kubernetes/gengo/issues/146
# Workaround for https://github.com/kubernetes/gengo/issues/146
ENV GOROOT=/usr/local/go

# Create kfctl folder
RUN mkdir -p ${GOPATH}/src/github.com/kubeflow/kfctl
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,11 @@ github.com/operator-framework/operator-lifecycle-manager v0.0.0-20191115003340-1
github.com/operator-framework/operator-registry v1.5.1/go.mod h1:agrQlkWOo1q8U1SAaLSS2WQ+Z9vswNT2M2HFib9iuLY=
github.com/operator-framework/operator-sdk v0.13.0 h1:AWiKOl6ZeAyQgbGVoD8fNd+eCbFuRWgr4hciaaOEBmE=
github.com/operator-framework/operator-sdk v0.13.0/go.mod h1:XRnicDD4uZCNbJbMXc0B7eyw7hjO4Xzol7FAkWHa1Nc=
github.com/otiai10/copy v1.0.1/go.mod h1:8bMCJrAqOtN/d9oyh5HR7HhLQMvcGMpGdwRDYsfOCHc=
github.com/otiai10/copy v1.0.2 h1:DDNipYy6RkIkjMwy+AWzgKiNTyj2RUI9yEMeETEpVyc=
github.com/otiai10/copy v1.0.2/go.mod h1:c7RpqBkwMom4bYTSkLSym4VSJz/XtncWRAj/J4PEIMY=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v0.0.0-20190513014714-f5a3d24e5776 h1:o59bHXu8Ejas8Kq6pjoVJQ9/neN66SM8AKh6wI42BBs=
github.com/otiai10/curr v0.0.0-20190513014714-f5a3d24e5776/go.mod h1:3HNVkVOU7vZeFXocWuvtcS0XSFLcf2XUSDHkq9t1jU4=
github.com/otiai10/mint v1.2.3/go.mod h1:YnfyPNhBvnY8bW4SGQHCs/aAFhkgySlMZbrF5U0bOVw=
github.com/otiai10/mint v1.2.4/go.mod h1:d+b7n/0R3tdyUYYylALXpWQ/kTN+QobSq/4SRGBkR3M=
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
Expand Down
7 changes: 4 additions & 3 deletions pkg/kfapp/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
kfutils "github.com/kubeflow/kfctl/v3/pkg/utils"
)

const (
Expand Down Expand Up @@ -652,17 +653,17 @@ func (aws *Aws) setAwsPluginDefaults() error {

if awsPluginSpec.ManagedCluster == nil {
awsPluginSpec.ManagedCluster = proto.Bool(awsPluginSpec.GetManagedCluster())
log.Infof("ManagedCluster set defaulting to %v", *awsPluginSpec.ManagedCluster)
log.Infof("ManagedCluster set defaulting to %v", kfutils.PrettyPrint(*awsPluginSpec.ManagedCluster))
}

if awsPluginSpec.EnablePodIamPolicy == nil {
awsPluginSpec.EnablePodIamPolicy = proto.Bool(awsPluginSpec.GetEnablePodIamPolicy())
log.Infof("EnablePodIamPolicy set defaulting to %v", *awsPluginSpec.EnablePodIamPolicy)
log.Infof("EnablePodIamPolicy set defaulting to %v", kfutils.PrettyPrint(*awsPluginSpec.EnablePodIamPolicy))
}

if awsPluginSpec.EnableNodeGroupLog == nil {
awsPluginSpec.EnableNodeGroupLog = proto.Bool(awsPluginSpec.GetEnableNodeGroupLog())
log.Infof("EnableNodeGroupLog set defaulting to %v", *awsPluginSpec.EnableNodeGroupLog)
log.Infof("EnableNodeGroupLog set defaulting to %v", kfutils.PrettyPrint(*awsPluginSpec.EnableNodeGroupLog))
}

if awsPluginSpec.Auth == nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/kfapp/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import (
restv2 "k8s.io/client-go/rest"
"k8s.io/client-go/restmapper"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
kfutils "github.com/kubeflow/kfctl/v3/pkg/utils"
)

// TODO: golint complains that we should not use all capital var name.
Expand Down Expand Up @@ -1712,8 +1713,7 @@ func (gcp *Gcp) allowAdmineditUserSA(gcpAdminSa string, gcpUserSa string) error
fmt.Sprintf("serviceAccount:%v", gcpAdminSa),
}
policy.Bindings = append(policy.Bindings, &newBinding)
log.Infof("New policy: %v", *policy)

log.Infof("New policy: %v", kfutils.PrettyPrint(*policy))
err = utils.SetServiceAccountIamPolicy(iamService, policy, gcp.kfDef.Spec.Project, gcpUserSa)
if err != nil {
return err
Expand Down Expand Up @@ -1752,7 +1752,7 @@ func (gcp *Gcp) setupWorkloadIdentity(namespace string, k8sSa2gcpSa map[string]s
if err != nil {
return err
}
log.Infof("New policy: %v", *policy)
log.Infof("New policy: %v", kfutils.PrettyPrint(*policy))
err = utils.SetServiceAccountIamPolicy(iamService, policy, gcp.kfDef.Spec.Project, gcpSa)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/iamutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"google.golang.org/api/iam/v1"
"io/ioutil"
"net/http"
kfutils "github.com/kubeflow/kfctl/v3/pkg/utils"
)

func transformSliceToInterface(slice []string) []interface{} {
Expand Down Expand Up @@ -209,7 +210,7 @@ func UpdateWorkloadIdentityBindingsPolicy(currentPolicy *iam.Policy, project str
fmt.Sprintf("serviceAccount:%v.svc.id.goog[%v/%v]", project, namespace, ksa),
}
currentPolicy.Bindings = append(currentPolicy.Bindings, &newBinding)
log.Infof("New policy: %v", *currentPolicy)
log.Infof("New policy: %v", kfutils.PrettyPrint(*currentPolicy))
return nil
}

Expand Down