@@ -129,7 +129,6 @@ func StopRecommendCronJob() {
129
129
130
130
// RecommendPolicyMain generates recommended policies from policy-template GH
131
131
func RecommendPolicyMain () {
132
- var policy []types.KnoxSystemPolicy
133
132
134
133
if ! isLatest () {
135
134
if _ , err := DownloadAndUnzipRelease (); err != nil {
@@ -162,26 +161,23 @@ func RecommendPolicyMain() {
162
161
163
162
for _ , ns := range NsNotFilter {
164
163
if d .Namespace != ns {
165
- policy = generateHardenPolicy (d .Name , d .Namespace , d .Spec .Template .Labels )
166
- policies = append (policies , policy ... )
164
+ policies = append (policies , generateHardenPolicy (d .Name , d .Namespace , d .Spec .Template .Labels )... )
167
165
}
168
166
}
169
167
}
170
168
171
169
for _ , r := range replicaSets .Items {
172
170
for _ , ns := range NsNotFilter {
173
171
if r .Namespace != ns && len (r .ObjectMeta .OwnerReferences ) == 0 {
174
- policy = generateHardenPolicy (r .Name , r .Namespace , r .Spec .Template .Labels )
175
- policies = append (policies , policy ... )
172
+ policies = append (policies , generateHardenPolicy (r .Name , r .Namespace , r .Spec .Template .Labels )... )
176
173
}
177
174
}
178
175
}
179
176
180
- for _ , r := range statefulSets .Items {
177
+ for _ , s := range statefulSets .Items {
181
178
for _ , ns := range NsNotFilter {
182
- if r .Namespace != ns {
183
- policy = generateHardenPolicy (r .Name , r .Namespace , r .Spec .Template .Labels )
184
- policies = append (policies , policy ... )
179
+ if s .Namespace != ns {
180
+ policies = append (policies , generateHardenPolicy (s .Name , s .Namespace , s .Spec .Template .Labels )... )
185
181
}
186
182
}
187
183
}
0 commit comments