Skip to content

Commit

Permalink
small fixes and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
celenechang committed Nov 3, 2023
1 parent 7c3faf7 commit 3c84995
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 40 deletions.
11 changes: 6 additions & 5 deletions apis/datadoghq/v2alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,20 @@ type RemoteConfigurationFeatureConfig struct {
Enabled *bool `json:"enabled,omitempty"`
}

// SBOMFeatureConfig contains SBOM collection global configuration.
// SBOMFeatureConfig contains SBOM (Software Bill of Materials) collection configuration.
// SBOM runs in the Agent.
type SBOMFeatureConfig struct {
// Enable this option to activate SBOM collection.
// Default: false
// +optional
Enabled *bool `json:"enabled,omitempty"`

ContainerImage *SBOMConfig `json:"containerImage,omitempty"`
Host *SBOMConfig `json:"host,omitempty"`
ContainerImage *SBOMTypeConfig `json:"containerImage,omitempty"`
Host *SBOMTypeConfig `json:"host,omitempty"`
}

// SBOMConfig contains configuration for one SBOM collection type.
type SBOMConfig struct {
// SBOMTypeConfig contains configuration for a SBOM collection type.
type SBOMTypeConfig struct {
// Enable this option to activate SBOM collection.
// Default: false
// +optional
Expand Down
42 changes: 21 additions & 21 deletions apis/datadoghq/v2alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/datadoghq/v2alpha1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/crd/bases/v1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8363,7 +8363,7 @@ spec:
description: SBOM collection configuration.
properties:
containerImage:
description: SBOMConfig contains configuration for one SBOM collection type.
description: SBOMTypeConfig contains configuration for a SBOM collection type.
properties:
analyzers:
description: Analyzers to use for SBOM collection.
Expand All @@ -8379,7 +8379,7 @@ spec:
description: 'Enable this option to activate SBOM collection. Default: false'
type: boolean
host:
description: SBOMConfig contains configuration for one SBOM collection type.
description: SBOMTypeConfig contains configuration for a SBOM collection type.
properties:
analyzers:
description: Analyzers to use for SBOM collection.
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/v1beta1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15913,7 +15913,7 @@ spec:
description: SBOM collection configuration.
properties:
containerImage:
description: SBOMConfig contains configuration for one SBOM collection type.
description: SBOMTypeConfig contains configuration for a SBOM collection type.
properties:
analyzers:
description: Analyzers to use for SBOM collection.
Expand All @@ -15929,7 +15929,7 @@ spec:
description: 'Enable this option to activate SBOM collection. Default: false'
type: boolean
host:
description: SBOMConfig contains configuration for one SBOM collection type.
description: SBOMTypeConfig contains configuration for a SBOM collection type.
properties:
analyzers:
description: Analyzers to use for SBOM collection.
Expand Down
22 changes: 14 additions & 8 deletions controllers/datadogagent/feature/sbom/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,28 @@ func (f *sbomFeature) ManageNodeAgent(managers feature.PodTemplateManagers) erro
Name: apicommon.DDSBOMEnabled,
Value: apiutils.BoolToString(&f.enabled),
})

managers.EnvVar().AddEnvVar(&corev1.EnvVar{
Name: apicommon.DDSBOMContainerImageEnabled,
Value: apiutils.BoolToString(&f.containerImageEnabled),
})
managers.EnvVar().AddEnvVar(&corev1.EnvVar{
Name: apicommon.DDSBOMContainerImageAnalyzers,
Value: strings.Join(f.containerImageAnalyzers, " "),
})
if len(f.containerImageAnalyzers) > 0 {
managers.EnvVar().AddEnvVar(&corev1.EnvVar{
Name: apicommon.DDSBOMContainerImageAnalyzers,
Value: strings.Join(f.containerImageAnalyzers, " "),
})
}

managers.EnvVar().AddEnvVar(&corev1.EnvVar{
Name: apicommon.DDSBOMHostEnabled,
Value: apiutils.BoolToString(&f.hostEnabled),
})
managers.EnvVar().AddEnvVar(&corev1.EnvVar{
Name: apicommon.DDSBOMHostAnalyzers,
Value: strings.Join(f.hostAnalyzers, " "),
})
if len(f.hostAnalyzers) > 0 {
managers.EnvVar().AddEnvVar(&corev1.EnvVar{
Name: apicommon.DDSBOMHostAnalyzers,
Value: strings.Join(f.hostAnalyzers, " "),
})
}

return nil
}
Expand Down
1 change: 0 additions & 1 deletion docs/configuration.v2alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ spec:
| features.prometheusScrape.enabled | Enable autodiscovery of pods and services exposing Prometheus metrics. Default: false |
| features.prometheusScrape.version | Version specifies the version of the OpenMetrics check. Default: 2 |
| features.remoteConfiguration.enabled | Enable this option to activate Remote Configuration. Default: true |
| features.remoteConfiguration.enabled | Enable this option to activate Remote Configuration. Default: false |
| features.sbom.containerImage.analyzers | Analyzers to use for SBOM collection. |
| features.sbom.containerImage.enabled | Enable this option to activate SBOM collection. Default: false |
| features.sbom.enabled | Enable this option to activate SBOM collection. Default: false |
Expand Down

0 comments on commit 3c84995

Please sign in to comment.