@@ -206,23 +206,45 @@ func (cmd *UpCmd) ensureNamespace() error {
206206}
207207
208208func (cmd * UpCmd ) ensureClusterRoleBinding () error {
209+ /*
210+ config := configutil.GetConfig(false)
211+
212+ accessReview := &k8sauthorizationv1.SelfSubjectAccessReview{
213+ Spec: k8sauthorizationv1.SelfSubjectAccessReviewSpec{
214+ ResourceAttributes: &k8sauthorizationv1.ResourceAttributes{
215+ Namespace: *config.DevSpace.Release.Namespace,
216+ Verb: "create",
217+ Group: "rbac.authorization.k8s.io",
218+ Resource: "roles",
219+ },
220+ },
221+ }
222+
223+ resp, permErr := cmd.kubectl.Authorization().SelfSubjectAccessReviews().Create(accessReview)
224+
225+ if permErr != nil {*/
226+
227+ if kubectl .IsMinikube () {
228+ return nil
229+ }
230+
209231 _ , err := cmd .kubectl .RbacV1beta1 ().ClusterRoleBindings ().Get (clusterRoleBindingName , metav1.GetOptions {})
210232
211233 if err != nil {
212- createRoleBinding := stdinutil .GetFromStdin (& stdinutil.GetFromStdinParams {
213- Question : "Do you want the ClusterRoleBinding '" + clusterRoleBindingName + "' to be created automatically? (yes|no)" ,
214- DefaultValue : "yes" ,
215- ValidationRegexPattern : "^(yes)|(no)$" ,
216- })
234+ clusterConfig , _ := kubectl .GetClientConfig ()
217235
218- if * createRoleBinding == "no" {
219- log .Fatal ("Please create ClusterRoleBinding '" + clusterRoleBindingName + "' manually" )
220- }
221- username := configutil .String ("" )
236+ if clusterConfig .AuthProvider != nil && clusterConfig .AuthProvider .Name == "gcp" {
237+ createRoleBinding := stdinutil .GetFromStdin (& stdinutil.GetFromStdinParams {
238+ Question : "Do you want the ClusterRoleBinding '" + clusterRoleBindingName + "' to be created automatically? (yes|no)" ,
239+ DefaultValue : "yes" ,
240+ ValidationRegexPattern : "^(yes)|(no)$" ,
241+ })
222242
223- clusterConfig , _ := kubectl .GetClientConfig ()
243+ if * createRoleBinding == "no" {
244+ log .Fatal ("Please create ClusterRoleBinding '" + clusterRoleBindingName + "' manually" )
245+ }
246+ username := configutil .String ("" )
224247
225- if clusterConfig .Username == "" {
226248 gcloudOutput , gcloudErr := exec .Command ("gcloud" , "config" , "list" , "account" , "--format" , "value(core.account)" ).Output ()
227249
228250 if gcloudErr == nil {
@@ -232,36 +254,36 @@ func (cmd *UpCmd) ensureClusterRoleBinding() error {
232254 username = & gcloudEmail
233255 }
234256 }
235- } else {
236- username = & clusterConfig .Username
237- }
238257
239- username = stdinutil .GetFromStdin (& stdinutil.GetFromStdinParams {
240- Question : "What is your cluster username? (Email address of the Google account for GKE clusters) " ,
241- DefaultValue : * username ,
242- ValidationRegexPattern : ".+" ,
243- })
258+ username = stdinutil .GetFromStdin (& stdinutil.GetFromStdinParams {
259+ Question : "What is the email address of your Google Cloud account? " ,
260+ DefaultValue : * username ,
261+ ValidationRegexPattern : ".+" ,
262+ })
244263
245- rolebinding := & k8sv1beta1.ClusterRoleBinding {
246- ObjectMeta : metav1.ObjectMeta {
247- Name : clusterRoleBindingName ,
248- },
249- Subjects : []k8sv1beta1.Subject {
250- {
251- Kind : "User" ,
252- Name : * username ,
264+ rolebinding := & k8sv1beta1.ClusterRoleBinding {
265+ ObjectMeta : metav1.ObjectMeta {
266+ Name : clusterRoleBindingName ,
253267 },
254- },
255- RoleRef : k8sv1beta1.RoleRef {
256- APIGroup : "rbac.authorization.k8s.io" ,
257- Kind : "ClusterRole" ,
258- Name : "cluster-admin" ,
259- },
260- }
268+ Subjects : []k8sv1beta1.Subject {
269+ {
270+ Kind : "User" ,
271+ Name : * username ,
272+ },
273+ },
274+ RoleRef : k8sv1beta1.RoleRef {
275+ APIGroup : "rbac.authorization.k8s.io" ,
276+ Kind : "ClusterRole" ,
277+ Name : "cluster-admin" ,
278+ },
279+ }
261280
262- _ , roleBindingErr := cmd .kubectl .RbacV1beta1 ().ClusterRoleBindings ().Create (rolebinding )
263- if roleBindingErr != nil {
264- return roleBindingErr
281+ _ , roleBindingErr := cmd .kubectl .RbacV1beta1 ().ClusterRoleBindings ().Create (rolebinding )
282+ if roleBindingErr != nil {
283+ return roleBindingErr
284+ }
285+ } else {
286+ log .Fatal ("Permissions missing: Please create the ClusterRoleBinding '" + clusterRoleBindingName + "' manually" )
265287 }
266288 }
267289 return nil
0 commit comments