Skip to content

Commit 8696fb8

Browse files
committed
adds more comments
Signed-off-by: kaizhe <[email protected]>
1 parent d9c63e6 commit 8696fb8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

advisor/types/pspgrant.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,22 @@ func NewSASecuritySpec(ns, sa string) *SASecuritySpec {
5252
}
5353
}
5454

55+
// IsDefaultServiceAccount returns whether the service account is default
5556
func (s *SASecuritySpec) IsDefaultServiceAccount() bool {
5657
return s.ServiceAccount == "default"
5758
}
5859

60+
// AddContainerSecuritySpec adds container security spec object to the associated service account
5961
func (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
6366
func (s *SASecuritySpec) AddPodSecuritySpec(pss PodSecuritySpec) {
6467
s.PodSecuritySpecList = append(s.PodSecuritySpecList, pss)
6568
}
6669

70+
// GeneratePSPName generates psp name
6771
func (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)
7580
func (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
104110
func (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
127134
func (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

Comments
 (0)