Skip to content

Commit 9aea3d8

Browse files
authored
Merge pull request #28 from matheusdefarias/adding-sigstore-cosign-adjustments-pr
A check has been created to verify if p.sigstore is different from nil
2 parents 405b05f + 848cbd7 commit 9aea3d8

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -337,31 +337,37 @@ func (p *Plugin) Configure(ctx context.Context, req *configv1.ConfigureRequest)
337337
if err := p.reloadKubeletClient(c); err != nil {
338338
return nil, err
339339
}
340+
if p.sigstore != nil {
341+
if err := configureSigstore(c, p.sigstore); err != nil {
342+
return nil, err
343+
}
344+
}
345+
// Set the config
346+
p.setConfig(c)
347+
return &configv1.ConfigureResponse{}, nil
348+
}
340349

350+
func configureSigstore(config *k8sConfig, sigstore sigstore.Sigstore) error {
341351
// Configure sigstore settings
342-
p.sigstore.ClearSkipList()
343-
if c.SkippedImages != nil {
344-
for _, imageID := range c.SkippedImages {
345-
p.sigstore.AddSkippedImage(imageID)
352+
sigstore.ClearSkipList()
353+
if config.SkippedImages != nil {
354+
for _, imageID := range config.SkippedImages {
355+
sigstore.AddSkippedImage(imageID)
346356
}
347357
}
348-
349-
p.sigstore.EnableAllowSubjectList(c.AllowedSubjectListEnabled)
350-
p.sigstore.ClearAllowedSubjects()
351-
if c.AllowedSubjects != nil {
352-
for _, subject := range c.AllowedSubjects {
353-
p.sigstore.AddAllowedSubject(subject)
358+
sigstore.EnableAllowSubjectList(config.AllowedSubjectListEnabled)
359+
sigstore.ClearAllowedSubjects()
360+
if config.AllowedSubjects != nil {
361+
for _, subject := range config.AllowedSubjects {
362+
sigstore.AddAllowedSubject(subject)
354363
}
355364
}
356-
if c.RekorURL != "" {
357-
if err := p.sigstore.SetRekorURL(c.RekorURL); err != nil {
358-
return nil, err
365+
if config.RekorURL != "" {
366+
if err := sigstore.SetRekorURL(config.RekorURL); err != nil {
367+
return err
359368
}
360369
}
361-
362-
// Set the config
363-
p.setConfig(c)
364-
return &configv1.ConfigureResponse{}, nil
370+
return nil
365371
}
366372

367373
func (p *Plugin) setConfig(config *k8sConfig) {

0 commit comments

Comments
 (0)