Skip to content

Commit

Permalink
Helm: RBAC generation fixes (#1461) (#1467)
Browse files Browse the repository at this point in the history
* internal/pkg/scaffold/helm/role.go: return on role generation error

* internal/pkg/scaffold/helm/role.go: handle OCP k8s versions

* hack/tests/e2e-helm.sh: fail on failed RBAC generation

* CHANGELOG.md: added lines for fixes from #1456 and #1461
  • Loading branch information
joelanford committed May 21, 2019
1 parent cffb948 commit 5284ed3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

### Bug Fixes

- Fixes a regression that causes Helm RBAC generation to contain an empty custom ruleset when the chart's default manifest contains only namespaced resources. ([#1456](https://github.com/operator-framework/operator-sdk/pull/1456))
- Fixes an issue that causes Helm RBAC generation to fail when creating new operators with a Kubernetes context configured to connect to an OpenShift cluster. ([#1461](https://github.com/operator-framework/operator-sdk/pull/1461))

## v0.8.0

### Added
Expand Down
7 changes: 6 additions & 1 deletion hack/tests/e2e-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ fi

# create and build the operator
pushd "$GOTMP"
operator-sdk new nginx-operator --api-version=helm.example.com/v1alpha1 --kind=Nginx --type=helm
log=$(operator-sdk new nginx-operator --api-version=helm.example.com/v1alpha1 --kind=Nginx --type=helm 2>&1)
echo $log
if echo $log | grep -q "failed to generate RBAC rules"; then
echo FAIL expected successful generation of RBAC rules
exit 1
fi

pushd nginx-operator
sed -i 's|\(FROM quay.io/operator-framework/helm-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/scaffold/helm/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func CreateRoleScaffold(cfg *rest.Config, chart *chart.Chart) (*scaffold.Role, e
if err != nil {
log.Warnf("Using default RBAC rules: failed to generate RBAC rules: %s", err)
roleScaffold.SkipDefaultRules = false
return roleScaffold, nil
}

// Use a ClusterRole if cluster scoped resources are listed in the chart
Expand Down Expand Up @@ -183,12 +184,13 @@ func getServerVersionAndResources(cfg *rest.Config) (*version.Info, []*metav1.AP
}

func getDefaultManifests(c *chart.Chart, kubeVersion *version.Info) ([]tiller.Manifest, error) {
v := strings.TrimSuffix(fmt.Sprintf("%s.%s", kubeVersion.Major, kubeVersion.Minor), "+")
renderOpts := renderutil.Options{
ReleaseOptions: chartutil.ReleaseOptions{
IsInstall: true,
IsUpgrade: false,
},
KubeVersion: fmt.Sprintf("%s.%s", kubeVersion.Major, kubeVersion.Minor),
KubeVersion: v,
}

renderedTemplates, err := renderutil.Render(c, &chart.Config{}, renderOpts)
Expand Down

0 comments on commit 5284ed3

Please sign in to comment.