Skip to content

Instantly share code, notes, and snippets.

@feloy
Created June 17, 2018 14:52
Show Gist options
  • Save feloy/8734a6336c22428cf23161dd97dd55af to your computer and use it in GitHub Desktop.
Save feloy/8734a6336c22428cf23161dd97dd55af to your computer and use it in GitHub Desktop.
func (o *k8s) canICreateDeployments() (bool, error) {
ssar := &authorizationv1.SelfSubjectAccessReview{
Spec: authorizationv1.SelfSubjectAccessReviewSpec{
ResourceAttributes: &authorizationv1.ResourceAttributes{
Verb: "create",
Resource: "deployments",
},
},
}
ssar, err := o.clientset.AuthorizationV1().SelfSubjectAccessReviews().Create(ssar)
if err != nil {
return false, err
}
return ssar.Status.Allowed, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment