Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update image analyzer dependency #416

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions cmd/controller/state/imagescan/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ func (s *Scanner) ScanImage(ctx context.Context, params ScanImageParams) (rerr e

switch containerRuntime {
case "docker":
if mode == "" {
mode = imagescanconfig.ModeDaemon
}
if mode == imagescanconfig.ModeDaemon {
switch mode {
case imagescanconfig.ModeDaemon, "":
vols.volumes = append(vols.volumes, corev1.Volume{
Name: "docker-sock",
VolumeSource: corev1.VolumeSource{
Expand All @@ -115,10 +113,8 @@ func (s *Scanner) ScanImage(ctx context.Context, params ScanImageParams) (rerr e
})
}
case "containerd":
if mode == "" {
mode = imagescanconfig.ModeHostFS
}
if mode == imagescanconfig.ModeHostFS {
switch mode {
case imagescanconfig.ModeHostFS, "":
vols.volumes = append(vols.volumes, corev1.Volume{
Name: "containerd-content",
VolumeSource: corev1.VolumeSource{
Expand All @@ -133,7 +129,7 @@ func (s *Scanner) ScanImage(ctx context.Context, params ScanImageParams) (rerr e
ReadOnly: true,
MountPath: imagescanconfig.ContainerdContentDir,
})
} else if mode == imagescanconfig.ModeDaemon {
case imagescanconfig.ModeDaemon:
vols.volumes = append(vols.volumes, corev1.Volume{
Name: "containerd-sock",
VolumeSource: corev1.VolumeSource{
Expand All @@ -149,6 +145,7 @@ func (s *Scanner) ScanImage(ctx context.Context, params ScanImageParams) (rerr e
MountPath: "/run/containerd/containerd.sock",
})
}

if s.cfg.PrivateRegistryPullSecret != "" {
vols.volumes = append(vols.volumes, corev1.Volume{
Name: "pull-secret",
Expand Down Expand Up @@ -293,7 +290,7 @@ func (s *Scanner) ScanImage(ctx context.Context, params ScanImageParams) (rerr e
_, err := jobs.Get(ctx, jobSpec.Name, metav1.GetOptions{})
if err == nil {
if err := s.waitForCompletion(ctx, jobs, jobName); err != nil {
return fmt.Errorf("job already exist, wait for completion: %w", err)
return fmt.Errorf("job already exists, waiting for completion: %w", err)
}
return nil
}
Expand All @@ -311,9 +308,9 @@ func (s *Scanner) ScanImage(ctx context.Context, params ScanImageParams) (rerr e
jobPod, _ := s.getJobPod(ctx, jobName)
if jobPod != nil {
conds := getPodConditionsString(jobPod.Status.Conditions)
return fmt.Errorf("wait for completion, pod_conditions=%s: %w", conds, err)
return fmt.Errorf("waiting for completion, pod_conditions=%s: %w", conds, err)
}
return fmt.Errorf("wait for completion: %w", err)
return fmt.Errorf("waiting for completion: %w", err)
}
}
return nil
Expand Down Expand Up @@ -412,7 +409,6 @@ func scanJobSpec(
vol volumesAndMounts,
tolerations []corev1.Toleration,
) *batchv1.Job {

podLabels := map[string]string{}
if cfg.CloudProvider == "aks" {
podLabels["azure.workload.identity/use"] = "true"
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.2
require (
github.com/ClickHouse/clickhouse-go/v2 v2.30.0
github.com/aquasecurity/trivy v0.57.1
github.com/castai/image-analyzer v0.6.2
github.com/castai/image-analyzer v0.7.0
github.com/cenkalti/backoff/v4 v4.3.0
github.com/cespare/xxhash/v2 v2.3.0
github.com/cilium/cilium v1.17.0-pre.2
Expand Down Expand Up @@ -320,7 +320,7 @@ require (
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f // indirect
github.com/knqyf263/go-deb-version v0.0.0-20230223133812-3ed183d23422 // indirect
github.com/knqyf263/go-deb-version v0.0.0-20241115132648-6f4aee6ccd23 // indirect
github.com/knqyf263/go-rpmdb v0.1.1 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXe
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/bytecodealliance/wasmtime-go/v3 v3.0.2 h1:3uZCA/BLTIu+DqCfguByNMJa2HVHpXvjfy0Dy7g6fuA=
github.com/bytecodealliance/wasmtime-go/v3 v3.0.2/go.mod h1:RnUjnIXxEJcL6BgCvNyzCCRzZcxCgsZCi+RNlvYor5Q=
github.com/castai/image-analyzer v0.6.2 h1:uhy6spu6elWKeAyazoSdXvLRn+/oLx2+h28suTStTPk=
github.com/castai/image-analyzer v0.6.2/go.mod h1:wx491C4r9II40KNrpMyfjvRWYlQ7SX5tYAS6Ayi7E6w=
github.com/castai/image-analyzer v0.7.0 h1:7bgZaAU9Xws0PveBCMSbzMKAQh6Adh707eFP4sz4TvE=
github.com/castai/image-analyzer v0.7.0/go.mod h1:v0tmj4tRXUS7wSioXrCCfzA+m+5DG+vquF0VLrlsnQo=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -914,8 +914,8 @@ github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y7
github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f h1:GvCU5GXhHq+7LeOzx/haG7HSIZokl3/0GkoUFzsRJjg=
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f/go.mod h1:q59u9px8b7UTj0nIjEjvmTWekazka6xIt6Uogz5Dm+8=
github.com/knqyf263/go-deb-version v0.0.0-20230223133812-3ed183d23422 h1:PPPlUUqPP6fLudIK4n0l0VU4KT2cQGnheW9x8pNiCHI=
github.com/knqyf263/go-deb-version v0.0.0-20230223133812-3ed183d23422/go.mod h1:ijAmSS4jErO6+KRzcK6ixsm3Vt96hMhJ+W+x+VmbrQA=
github.com/knqyf263/go-deb-version v0.0.0-20241115132648-6f4aee6ccd23 h1:dWzdsqjh1p2gNtRKqNwuBvKqMNwnLOPLzVZT1n6DK7s=
github.com/knqyf263/go-deb-version v0.0.0-20241115132648-6f4aee6ccd23/go.mod h1:lUaIXCWzf7BRKTY5iEcrYy1TfgbYLYVIS/B2vPkJzOc=
github.com/knqyf263/go-rpm-version v0.0.0-20220614171824-631e686d1075 h1:aC6MEAs3PE3lWD7lqrJfDxHd6hcced9R4JTZu85cJwU=
github.com/knqyf263/go-rpm-version v0.0.0-20220614171824-631e686d1075/go.mod h1:i4sF0l1fFnY1aiw08QQSwVAFxHEm311Me3WsU/X7nL0=
github.com/knqyf263/go-rpmdb v0.1.1 h1:oh68mTCvp1XzxdU7EfafcWzzfstUZAEa3MW0IJye584=
Expand Down