// HasClusterPermissions verifies that the current context/user is able to
// do everything required on the remote cluster.
HasClusterPermissions verifies that the current context/user is able to
do everything required on the remote cluster.
// HasClusterPermissions verifies that the current context / user is able to // do everything required on the remote cluster .
func HasClusterPermissions() error {
	ctx := viper.GetString("context")
	service := cluster.NewService()
	reviews := cluster.Client.AuthorizationV1().SelfSubjectAccessReviews()
	createReview := &authorizationapi.SelfSubjectAccessReview{
		Spec: authorizationapi.SelfSubjectAccessReviewSpec{
			ResourceAttributes: &authorizationapi.ResourceAttributes{
				Namespace: service.Namespace,
				Verb:      "create",
				Resource:  "daemonset",
			},
		},
	}
	if resp, err := reviews.Create(createReview); err != nil {
		return err
	} else if !resp.Status.Allowed {
		return fmt.Errorf(
			kubeDaemonSetError, service.Namespace, ctx, service.Namespace, ctx)
	}
	portforwardReview := &authorizationapi.SelfSubjectAccessReview{
		Spec: authorizationapi.SelfSubjectAccessReviewSpec{
			ResourceAttributes: &authorizationapi.ResourceAttributes{
				Namespace:   service.Namespace,
				Verb:        "get",
				Resource:    "pods",
				Subresource: "portforward",
			},
		},
	}
	if resp, err := reviews.Create(portforwardReview); err != nil {
		return err
	} else if !resp.Status.Allowed {
		return fmt.Errorf(
			kubePortforwardError, service.Namespace, ctx, service.Namespace, ctx)
	}
	return nil
}
func HasClusterPermissions ( ) error { ctx := viper . GetString ( " " ) service := cluster . NewService ( ) reviews := cluster . Client . AuthorizationV1 ( ) . SelfSubjectAccessReviews ( ) createReview := & authorizationapi . SelfSubjectAccessReview { Spec : authorizationapi . SelfSubjectAccessReviewSpec { ResourceAttributes : & authorizationapi . ResourceAttributes { Namespace : service . Namespace , Verb : " " , Resource : " " , } , } , } if resp , err := reviews . Create ( createReview ) ; err != nil { return err } else if ! resp . Status . Allowed { return fmt . Errorf ( kubeDaemonSetError , service . Namespace , ctx , service . Namespace , ctx ) } portforwardReview := & authorizationapi . SelfSubjectAccessReview { Spec : authorizationapi . SelfSubjectAccessReviewSpec { ResourceAttributes : & authorizationapi . ResourceAttributes { Namespace : service . Namespace , Verb : " " , Resource : " " , Subresource : " " , } , } , } if resp , err := reviews . Create ( portforwardReview ) ; err != nil { return err } else if ! resp . Status . Allowed { return fmt . Errorf ( kubePortforwardError , service . Namespace , ctx , service . Namespace , ctx ) } return nil }
HasClusterPermissions verifies that the current context/user is able to
do everything required on the remote cluster.
HasClusterPermissions verifies that the current context / user is able to do everything required on the remote cluster .