containerized-data-importer/pkg/operator/resources/cluster/rbac.go
annastopel f634cdaa17 CDI operator OLM integration:
- Generate OLM related manifests for CDI in _out/manifests/release/olm
      OLM bundle:
	- cdi CSV manifest
	- cdi crd manifest
	- cdi package manifest
     - operatorsource manifest
     - subscription manifest
     - operatorgroup manifest
- Modify cdi-operator role not to be cluster-admin but more specific
- Move all final manifests to _out/manifests directory and update travis with new manifests location
- Provide API for vendoring CDI OLM manifests generation code

Note:
  - OLM CSV update to be supported in a separate PR
  - OLM bundle integration in travis is to be supported together with CSV update
2019-05-01 13:54:28 +03:00

67 lines
1.7 KiB
Go

/*
Copyright 2018 The CDI Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
import (
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
//CreateClusterRoleBinding create cluster role bunding
func CreateClusterRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace string) *rbacv1.ClusterRoleBinding {
return &rbacv1.ClusterRoleBinding{
TypeMeta: metav1.TypeMeta{
APIVersion: "rbac.authorization.k8s.io/v1",
Kind: "ClusterRoleBinding",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"cdi.kubevirt.io": "",
},
},
RoleRef: rbacv1.RoleRef{
Kind: "ClusterRole",
Name: roleRef,
APIGroup: "rbac.authorization.k8s.io",
},
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
Name: serviceAccount,
Namespace: serviceAccountNamespace,
},
},
}
}
//CreateClusterRole create cluster role
func CreateClusterRole(name string) *rbacv1.ClusterRole {
return &rbacv1.ClusterRole{
TypeMeta: metav1.TypeMeta{
APIVersion: "rbac.authorization.k8s.io/v1",
Kind: "ClusterRole",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"cdi.kubevirt.io": "",
},
},
}
}