From 30b5c0484390cdf0b26c9ebedd9d94c5692e25ac Mon Sep 17 00:00:00 2001 From: Bradley Jones Date: Thu, 25 Jul 2024 17:13:50 +0100 Subject: [PATCH] chore: set the version by ldflag Signed-off-by: Bradley Jones --- .goreleaser.yml | 2 ++ pkg/adapter/adapter.go | 46 ++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index c6d8e6e..cb60d28 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -15,6 +15,8 @@ builds: goos: - linux - darwin + ldflags: + - -X github.com/anchore/harbor-scanner-adapter/pkg/adapter.AdapterVersion={{.Version}} checksum: name_template: 'checksums.txt' snapshot: diff --git a/pkg/adapter/adapter.go b/pkg/adapter/adapter.go index 32209ad..2a5f9ed 100644 --- a/pkg/adapter/adapter.go +++ b/pkg/adapter/adapter.go @@ -12,34 +12,36 @@ const ( HarborMetadataVulnDBUpdateKey = "harbor.scanner-adapter/vulnerability-database-updated-at" HarborMetadataScannerTypeKey = "harbor.scanner-adapter/scanner-type" AdapterType = "os-package-vulnerability" // #nosec G101 - AdapterVersion = "1.3.2" AdapterVendor = "Anchore Inc." AdapterName = "Anchore" ) -var AdapterMetadata = harbor.ScannerAdapterMetadata{ - Scanner: harbor.Scanner{ - Name: AdapterName, - Version: AdapterVersion, - Vendor: AdapterVendor, - }, - Capabilities: []harbor.Capability{ - { - ConsumesMIMETypes: []string{ - DockerImageMimeType, - OciImageMimeType, - }, - ProducesMIMETypes: []string{ - HarborVulnReportv1MimeType, - RawVulnReportMimeType, +var ( + AdapterVersion = "dev" + AdapterMetadata = harbor.ScannerAdapterMetadata{ + Scanner: harbor.Scanner{ + Name: AdapterName, + Version: AdapterVersion, + Vendor: AdapterVendor, + }, + Capabilities: []harbor.Capability{ + { + ConsumesMIMETypes: []string{ + DockerImageMimeType, + OciImageMimeType, + }, + ProducesMIMETypes: []string{ + HarborVulnReportv1MimeType, + RawVulnReportMimeType, + }, }, }, - }, - Properties: map[string]string{ - HarborMetadataVulnDBUpdateKey: "", // This gets updated in response to requests from Harbor - HarborMetadataScannerTypeKey: AdapterType, - }, -} + Properties: map[string]string{ + HarborMetadataVulnDBUpdateKey: "", // This gets updated in response to requests from Harbor + HarborMetadataScannerTypeKey: AdapterType, + }, + } +) // ScannerAdapter defines methods for scanning container images. type ScannerAdapter interface {