Skip to content

Commit

Permalink
Fix rbac e2e tests (#716)
Browse files Browse the repository at this point in the history
* Fix rbac

* Fix CA and sidecar

* Fix lint


Former-commit-id: 2ed2fe9
  • Loading branch information
andraxylia authored and ldemailly committed Sep 9, 2017
1 parent 359b59d commit 716d2ae
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/e2e/framework/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,42 @@ func (k *KubeInfo) generateRbac(src, dst string) error {
glog.Errorf("Cannot read original yaml file %s", src)
return err
}
namespace := []byte(fmt.Sprintf("namespace: %s", k.Namespace))
r := regexp.MustCompile("namespace: default")
content = r.ReplaceAllLiteral(content, namespace)

content = replacePattern(k, content, "namespace: default",
"namespace: "+k.Namespace)

content = replacePattern(k, content, "istio-pilot-admin-role-binding",
"istio-pilot-admin-role-binding-"+k.Namespace)

content = replacePattern(k, content, "istio-mixer-admin-role-binding",
"istio-mixer-admin-role-binding-"+k.Namespace)

content = replacePattern(k, content, "istio-ca-role-binding",
"istio-ca-role-binding-"+k.Namespace)

content = replacePattern(k, content, "istio-ingress-admin-role-binding",
"istio-ingress-admin-role-binding-"+k.Namespace)

content = replacePattern(k, content, "istio-egress-admin-role-binding",
"istio-egress-admin-role-binding-"+k.Namespace)

content = replacePattern(k, content, "istio-sidecar-role-binding",
"istio-sidecar-role-binding-"+k.Namespace)

err = ioutil.WriteFile(dst, content, 0600)
if err != nil {
glog.Errorf("Cannot write into generate rbac file %s", dst)
}
return err
}

func replacePattern(k *KubeInfo, content []byte, src, dest string) []byte {
r := []byte(dest)
p := regexp.MustCompile(src)
content = p.ReplaceAllLiteral(content, r)
return content
}

func (k *KubeInfo) generateIstio(src, dst string) error {
content, err := ioutil.ReadFile(src)
if err != nil {
Expand Down

0 comments on commit 716d2ae

Please sign in to comment.