@@ -52,18 +52,22 @@ func NewSASecuritySpec(ns, sa string) *SASecuritySpec {
5252 }
5353}
5454
55+ // IsDefaultServiceAccount returns whether the service account is default
5556func (s * SASecuritySpec ) IsDefaultServiceAccount () bool {
5657 return s .ServiceAccount == "default"
5758}
5859
60+ // AddContainerSecuritySpec adds container security spec object to the associated service account
5961func (s * SASecuritySpec ) AddContainerSecuritySpec (css ContainerSecuritySpec ) {
6062 s .ContainerSecuritySpecList = append (s .ContainerSecuritySpecList , css )
6163}
6264
65+ // AddPodSecuritySpec adds pod security spec object to the associated service account
6366func (s * SASecuritySpec ) AddPodSecuritySpec (pss PodSecuritySpec ) {
6467 s .PodSecuritySpecList = append (s .PodSecuritySpecList , pss )
6568}
6669
70+ // GeneratePSPName generates psp name
6771func (s * SASecuritySpec ) GeneratePSPName () string {
6872 if s .PSPName == "" {
6973 s .PSPName = fmt .Sprintf ("psp-for-%s-%s" , s .Namespace , s .ServiceAccount )
@@ -72,6 +76,7 @@ func (s *SASecuritySpec) GeneratePSPName() string {
7276 return s .PSPName
7377}
7478
79+ // GenerateComment generate comments for the psp grants (no psp will be created for default service account)
7580func (s * SASecuritySpec ) GenerateComment () string {
7681 decision := "will be"
7782
@@ -101,6 +106,7 @@ func (s *SASecuritySpec) GetWorkloadImages() []string {
101106 return workLoadImageList
102107}
103108
109+ // GenerateRole creates a role object contains the privilege to use the psp
104110func (s * SASecuritySpec ) GenerateRole () * v1rbac.Role {
105111 roleName := fmt .Sprintf ("use-psp-by-%s:%s" , s .Namespace , s .ServiceAccount )
106112
@@ -124,6 +130,7 @@ func (s *SASecuritySpec) GenerateRole() *v1rbac.Role {
124130 }
125131}
126132
133+ // GenerateRoleBinding creates a rolebinding for the service account to use the psp
127134func (s * SASecuritySpec ) GenerateRoleBinding () * v1rbac.RoleBinding {
128135 roleBindingName := fmt .Sprintf ("use-psp-by-%s:%s-binding" , s .Namespace , s .ServiceAccount )
129136 roleName := fmt .Sprintf ("use-psp-by-%s:%s" , s .Namespace , s .ServiceAccount )
0 commit comments