Skip to content

Commit

Permalink
feat: node-collector custom namespace support (#159)
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <hen.keinan@gmail.com>
  • Loading branch information
chen-keinan authored May 16, 2023
1 parent 4173b2b commit 3b76907
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/trivy.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func main() {
}

// collect node info
ar, err := trivyk8s.ListArtifactAndNodeInfo(ctx, tolerations...)
ar, err := trivyk8s.ListArtifactAndNodeInfo(ctx, "trivy-temp", tolerations...)
if err != nil {
log.Fatal(err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/jobs/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

const (
NodeCollectorName = "node-collector"
TrivyNamespace = "trivy-temp"

// job headers
TrivyCollectorName = "trivy.collector.name"
Expand Down
6 changes: 3 additions & 3 deletions pkg/trivyk8s/trivyk8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type ArtifactsK8S interface {
// GetArtifact return kubernete scanable artifact
GetArtifact(context.Context, string, string) (*artifacts.Artifact, error)
// ListArtifactAndNodeInfo return kubernete scanable artifact and node info
ListArtifactAndNodeInfo(context.Context, ...corev1.Toleration) ([]*artifacts.Artifact, error)
ListArtifactAndNodeInfo(context.Context, string, ...corev1.Toleration) ([]*artifacts.Artifact, error)
// ListBomInfo returns kubernetes Bom (node,core components) information.
ListBomInfo(context.Context) ([]*artifacts.Artifact, error)
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func (c *client) ListArtifacts(ctx context.Context) ([]*artifacts.Artifact, erro
}

// ListArtifacts returns kubernetes scannable artifacs.
func (c *client) ListArtifactAndNodeInfo(ctx context.Context, tolerations ...corev1.Toleration) ([]*artifacts.Artifact, error) {
func (c *client) ListArtifactAndNodeInfo(ctx context.Context, namespace string, tolerations ...corev1.Toleration) ([]*artifacts.Artifact, error) {
artifactList, err := c.ListArtifacts(ctx)
if err != nil {
return nil, err
Expand All @@ -144,7 +144,7 @@ func (c *client) ListArtifactAndNodeInfo(ctx context.Context, tolerations ...cor
c.cluster,
jobs.WithTimetout(time.Minute*5),
jobs.WithJobTemplateName(jobs.NodeCollectorName),
jobs.WithJobNamespace(jobs.TrivyNamespace),
jobs.WithJobNamespace(namespace),
jobs.WithJobLabels(labels),
jobs.WithJobTolerations(tolerations),
)
Expand Down

0 comments on commit 3b76907

Please sign in to comment.