diff --git a/Dockerfile.apiserver b/Dockerfile.apiserver index f6bb923e8..8cfa72d28 100644 --- a/Dockerfile.apiserver +++ b/Dockerfile.apiserver @@ -25,13 +25,14 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ARG VERSION ARG BUILD_TIMESTAMP ARG COMMIT_HASH +ARG BUILD_OPTS ENV CGO_ENABLED=1 RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=.,target=/build,ro \ - xx-go build -ldflags="-s -w -extldflags -static \ + xx-go build ${BUILD_OPTS} -ldflags="-s -w -extldflags -static \ -X 'github.com/openclarity/vmclarity/core/version.Version=${VERSION}' \ -X 'github.com/openclarity/vmclarity/core/version.CommitHash=${COMMIT_HASH}' \ -X 'github.com/openclarity/vmclarity/core/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \ @@ -41,6 +42,10 @@ RUN xx-verify /bin/vmclarity-apiserver FROM alpine:3.19@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b +RUN apk add --update --no-cache \ + ca-certificates \ + libc6-compat + COPY --from=builder ["/bin/vmclarity-apiserver", "/bin/vmclarity-apiserver"] ENTRYPOINT ["/bin/vmclarity-apiserver"] diff --git a/Dockerfile.cli b/Dockerfile.cli index b5db32cb5..5bae87766 100644 --- a/Dockerfile.cli +++ b/Dockerfile.cli @@ -26,13 +26,14 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ARG VERSION ARG BUILD_TIMESTAMP ARG COMMIT_HASH +ARG BUILD_OPTS -ENV CGO_ENABLED=0 +ENV CGO_ENABLED=1 RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=.,target=/build,ro \ - xx-go build -ldflags="-s -w -extldflags -static \ + xx-go build ${BUILD_OPTS} -ldflags="-s -w -extldflags -static \ -X 'github.com/openclarity/vmclarity/core/version.Version=${VERSION}' \ -X 'github.com/openclarity/vmclarity/core/version.CommitHash=${COMMIT_HASH}' \ -X 'github.com/openclarity/vmclarity/core/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \ @@ -44,7 +45,8 @@ RUN apk upgrade --quiet --no-cache RUN apk add --update --no-cache \ util-linux \ - ca-certificates + ca-certificates \ + libc6-compat COPY --from=builder /bin/vmclarity-cli /bin/vmclarity-cli diff --git a/Dockerfile.cr-discovery-server b/Dockerfile.cr-discovery-server index ea71091fd..fd51b89d6 100644 --- a/Dockerfile.cr-discovery-server +++ b/Dockerfile.cr-discovery-server @@ -25,13 +25,14 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ARG VERSION ARG BUILD_TIMESTAMP ARG COMMIT_HASH +ARG BUILD_OPTS -ENV CGO_ENABLED=0 +ENV CGO_ENABLED=1 RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=.,target=/build,ro \ - xx-go build -ldflags="-s -w -extldflags -static \ + xx-go build ${BUILD_OPTS} -ldflags="-s -w -extldflags -static \ -X 'github.com/openclarity/vmclarity/core/version.Version=${VERSION}' \ -X 'github.com/openclarity/vmclarity/core/version.CommitHash=${COMMIT_HASH}' \ -X 'github.com/openclarity/vmclarity/core/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \ @@ -43,4 +44,8 @@ FROM alpine:3.19@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761 COPY --from=builder ["/bin/vmclarity-cr-discovery-server", "/bin/vmclarity-cr-discovery-server"] +RUN apk add --update --no-cache \ + ca-certificates \ + libc6-compat + ENTRYPOINT ["/bin/vmclarity-cr-discovery-server"] diff --git a/Dockerfile.orchestrator b/Dockerfile.orchestrator index dc5400a00..d4772da88 100644 --- a/Dockerfile.orchestrator +++ b/Dockerfile.orchestrator @@ -25,13 +25,14 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ARG VERSION ARG BUILD_TIMESTAMP ARG COMMIT_HASH +ARG BUILD_OPTS ENV CGO_ENABLED=1 RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=.,target=/build,ro \ - xx-go build -ldflags="-s -w -extldflags -static \ + xx-go build ${BUILD_OPTS} -ldflags="-s -w -extldflags -static \ -X 'github.com/openclarity/vmclarity/core/version.Version=${VERSION}' \ -X 'github.com/openclarity/vmclarity/core/version.CommitHash=${COMMIT_HASH}' \ -X 'github.com/openclarity/vmclarity/core/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \ @@ -43,4 +44,8 @@ FROM alpine:3.19@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761 COPY --from=builder ["/bin/vmclarity-orchestrator", "/bin/vmclarity-orchestrator"] +RUN apk add --update --no-cache \ + ca-certificates \ + libc6-compat + ENTRYPOINT ["/bin/vmclarity-orchestrator"] diff --git a/Dockerfile.uibackend b/Dockerfile.uibackend index 7552fcfd1..e1b717f77 100644 --- a/Dockerfile.uibackend +++ b/Dockerfile.uibackend @@ -25,13 +25,14 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ARG VERSION ARG BUILD_TIMESTAMP ARG COMMIT_HASH +ARG BUILD_OPTS -ENV CGO_ENABLED=0 +ENV CGO_ENABLED=1 RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=.,target=/build,ro \ - xx-go build -ldflags="-s -w -extldflags -static \ + xx-go build ${BUILD_OPTS} -ldflags="-s -w -extldflags -static \ -X 'github.com/openclarity/vmclarity/core/version.Version=${VERSION}' \ -X 'github.com/openclarity/vmclarity/core/version.CommitHash=${COMMIT_HASH}' \ -X 'github.com/openclarity/vmclarity/core/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \ @@ -43,6 +44,10 @@ FROM alpine:3.19@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761 COPY --from=builder ["/bin/vmclarity-ui-backend", "/bin/vmclarity-ui-backend"] +RUN apk add --update --no-cache \ + ca-certificates \ + libc6-compat + ENTRYPOINT ["/bin/vmclarity-ui-backend"] CMD ["--help"] diff --git a/Makefile b/Makefile index 5df0f6a3a..cfdbd327f 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ DOCKER_REGISTRY ?= ghcr.io/openclarity DOCKER_TAG ?= $(VERSION) VMCLARITY_TOOLS_BASE ?= GO_VERSION ?= $(shell cat $(ROOT_DIR)/.go-version) +GO_BUILD_TAGS ?= #### ## Runtime variables @@ -56,25 +57,30 @@ build: ui build-all-go ## Build all components .PHONY: build-all-go build-all-go: bin/vmclarity-apiserver bin/vmclarity-cli bin/vmclarity-orchestrator bin/vmclarity-ui-backend bin/vmclarity-cr-discovery-server ## Build all go components +BUILD_OPTS = -race +ifneq ($(GO_BUILD_TAGS),) +BUILD_OPTS += -tags $(GO_BUILD_TAGS) +endif + LDFLAGS = -s -w LDFLAGS += -X 'github.com/openclarity/vmclarity/core/version.Version=$(VERSION)' LDFLAGS += -X 'github.com/openclarity/vmclarity/core/version.CommitHash=$(COMMIT_HASH)' LDFLAGS += -X 'github.com/openclarity/vmclarity/core/version.BuildTimestamp=$(BUILD_TIMESTAMP)' bin/vmclarity-orchestrator: $(shell find api provider orchestrator utils core) | $(BIN_DIR) - cd orchestrator && go build -race -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go + cd orchestrator && go build $(BUILD_OPTS) -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go bin/vmclarity-apiserver: $(shell find api api/server) | $(BIN_DIR) - cd api/server && go build -race -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go + cd api/server && go build $(BUILD_OPTS) -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go bin/vmclarity-cli: $(shell find api cli utils core) | $(BIN_DIR) - cd cli && go build -race -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go + cd cli && go build $(BUILD_OPTS) -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go bin/vmclarity-ui-backend: $(shell find api uibackend/server) | $(BIN_DIR) - cd uibackend/server && go build -race -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go + cd uibackend/server && go build $(BUILD_OPTS) -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go bin/vmclarity-cr-discovery-server: $(shell find api containerruntimediscovery/server utils core) | $(BIN_DIR) - cd containerruntimediscovery/server && go build -race -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go + cd containerruntimediscovery/server && go build $(BUILD_OPTS) -ldflags="$(LDFLAGS)" -o $(ROOT_DIR)/$@ cmd/main.go .PHONY: clean clean: clean-ui clean-go ## Clean all build artifacts @@ -215,6 +221,7 @@ BAKE_ENV += DOCKER_TAG=$(DOCKER_TAG) BAKE_ENV += VERSION=$(VERSION) BAKE_ENV += BUILD_TIMESTAMP=$(BUILD_TIMESTAMP) BAKE_ENV += COMMIT_HASH=$(COMMIT_HASH) +BAKE_ENV += BUILD_OPTS="$(BUILD_OPTS)" BAKE_OPTS = ifneq ($(strip $(VMCLARITY_TOOLS_BASE)),) diff --git a/docker-bake.hcl b/docker-bake.hcl index 70da4723d..141f3c29c 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -10,6 +10,7 @@ variable "VERSION" {default = null} variable "BUILD_TIMESTAMP" {default = null} variable "COMMIT_HASH" {default = null} variable "VMCLARITY_TOOLS_BASE" {default = null} +variable "BUILD_OPTS" {default = null} function "get_tag" { params = [name] @@ -40,6 +41,7 @@ target "_common_args_for_go" { VERSION = "${VERSION}" BUILD_TIMESTAMP = "${BUILD_TIMESTAMP}" COMMIT_HASH = "${COMMIT_HASH}" + BUILD_OPTS = "${BUILD_OPTS}" } } diff --git a/orchestrator/orchestrator.go b/orchestrator/orchestrator.go index 8f60a6342..f330fb255 100644 --- a/orchestrator/orchestrator.go +++ b/orchestrator/orchestrator.go @@ -23,7 +23,6 @@ import ( "github.com/Portshift/go-utils/healthz" apiclient "github.com/openclarity/vmclarity/api/client" - apitypes "github.com/openclarity/vmclarity/api/types" "github.com/openclarity/vmclarity/core/log" discovery "github.com/openclarity/vmclarity/orchestrator/discoverer" assetscanprocessor "github.com/openclarity/vmclarity/orchestrator/processor/assetscan" @@ -33,12 +32,6 @@ import ( scanconfigwatcher "github.com/openclarity/vmclarity/orchestrator/watcher/scanconfig" scanestimationwatcher "github.com/openclarity/vmclarity/orchestrator/watcher/scanestimation" "github.com/openclarity/vmclarity/provider" - "github.com/openclarity/vmclarity/provider/aws" - "github.com/openclarity/vmclarity/provider/azure" - "github.com/openclarity/vmclarity/provider/docker" - "github.com/openclarity/vmclarity/provider/external" - "github.com/openclarity/vmclarity/provider/gcp" - "github.com/openclarity/vmclarity/provider/kubernetes" ) type Orchestrator struct { @@ -126,24 +119,3 @@ func (o *Orchestrator) Stop(ctx context.Context) { o.cancelFunc() } } - -// nolint:wrapcheck -// NewProvider returns an initialized provider.Provider based on the kind apitypes.CloudProvider. -func NewProvider(ctx context.Context, kind apitypes.CloudProvider) (provider.Provider, error) { - switch kind { - case apitypes.Azure: - return azure.New(ctx) - case apitypes.Docker: - return docker.New(ctx) - case apitypes.AWS: - return aws.New(ctx) - case apitypes.GCP: - return gcp.New(ctx) - case apitypes.External: - return external.New(ctx) - case apitypes.Kubernetes: - return kubernetes.New(ctx) - default: - return nil, fmt.Errorf("unsupported provider: %s", kind) - } -} diff --git a/orchestrator/provider.go b/orchestrator/provider.go new file mode 100644 index 000000000..fd2e91cb7 --- /dev/null +++ b/orchestrator/provider.go @@ -0,0 +1,53 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !providerv2 + +package orchestrator + +import ( + "context" + "fmt" + + apitypes "github.com/openclarity/vmclarity/api/types" + "github.com/openclarity/vmclarity/provider" + "github.com/openclarity/vmclarity/provider/aws" + "github.com/openclarity/vmclarity/provider/azure" + "github.com/openclarity/vmclarity/provider/docker" + "github.com/openclarity/vmclarity/provider/external" + "github.com/openclarity/vmclarity/provider/gcp" + "github.com/openclarity/vmclarity/provider/kubernetes" +) + +// nolint:wrapcheck +// NewProvider returns an initialized provider.Provider based on the kind apitypes.CloudProvider. +func NewProvider(ctx context.Context, kind apitypes.CloudProvider) (provider.Provider, error) { + switch kind { + case apitypes.Azure: + return azure.New(ctx) + case apitypes.Docker: + return docker.New(ctx) + case apitypes.AWS: + return aws.New(ctx) + case apitypes.GCP: + return gcp.New(ctx) + case apitypes.External: + return external.New(ctx) + case apitypes.Kubernetes: + return kubernetes.New(ctx) + default: + return nil, fmt.Errorf("unsupported provider: %s", kind) + } +} diff --git a/orchestrator/providerv2.go b/orchestrator/providerv2.go new file mode 100644 index 000000000..b12ce1009 --- /dev/null +++ b/orchestrator/providerv2.go @@ -0,0 +1,53 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build providerv2 + +package orchestrator + +import ( + "context" + "fmt" + + apitypes "github.com/openclarity/vmclarity/api/types" + provider2 "github.com/openclarity/vmclarity/provider" + "github.com/openclarity/vmclarity/provider/docker" + "github.com/openclarity/vmclarity/provider/external" + "github.com/openclarity/vmclarity/provider/kubernetes" + "github.com/openclarity/vmclarity/provider/v2/aws" + "github.com/openclarity/vmclarity/provider/v2/azure" + "github.com/openclarity/vmclarity/provider/v2/gcp" +) + +// nolint:wrapcheck +// NewProvider returns an initialized provider.Provider based on the kind apitypes.CloudProvider. +func NewProvider(ctx context.Context, kind apitypes.CloudProvider) (provider2.Provider, error) { + switch kind { + case apitypes.Azure: + return azure.New(ctx) + case apitypes.Docker: + return docker.New(ctx) + case apitypes.AWS: + return aws.New(ctx) + case apitypes.GCP: + return gcp.New(ctx) + case apitypes.External: + return external.New(ctx) + case apitypes.Kubernetes: + return kubernetes.New(ctx) + default: + return nil, fmt.Errorf("unsupported provider: %s", kind) + } +} diff --git a/provider/v2/aws/discoverer/discoverer.go b/provider/v2/aws/discoverer/discoverer.go new file mode 100644 index 000000000..03706bb43 --- /dev/null +++ b/provider/v2/aws/discoverer/discoverer.go @@ -0,0 +1,31 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package discoverer + +import ( + "context" + + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Discoverer = &Discoverer{} + +type Discoverer struct{} + +func (d *Discoverer) DiscoverAssets(ctx context.Context) provider.AssetDiscoverer { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/aws/estimator/estimator.go b/provider/v2/aws/estimator/estimator.go new file mode 100644 index 000000000..5b79b9844 --- /dev/null +++ b/provider/v2/aws/estimator/estimator.go @@ -0,0 +1,32 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package estimator + +import ( + "context" + + apitypes "github.com/openclarity/vmclarity/api/types" + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Estimator = &Estimator{} + +type Estimator struct{} + +func (e *Estimator) Estimate(ctx context.Context, stats apitypes.AssetScanStats, asset *apitypes.Asset, template *apitypes.AssetScanTemplate) (*apitypes.Estimation, error) { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/aws/provider.go b/provider/v2/aws/provider.go new file mode 100644 index 000000000..e7f1ad18e --- /dev/null +++ b/provider/v2/aws/provider.go @@ -0,0 +1,47 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aws + +import ( + "context" + + apitypes "github.com/openclarity/vmclarity/api/types" + "github.com/openclarity/vmclarity/provider" + "github.com/openclarity/vmclarity/provider/v2/aws/discoverer" + "github.com/openclarity/vmclarity/provider/v2/aws/estimator" + "github.com/openclarity/vmclarity/provider/v2/aws/scanner" +) + +var _ provider.Provider = &Provider{} + +type Provider struct { + *discoverer.Discoverer + *scanner.Scanner + *estimator.Estimator +} + +func (p *Provider) Kind() apitypes.CloudProvider { + // TODO implement me + panic("implement me") +} + +func New(_ context.Context) (provider.Provider, error) { + return &Provider{ + Discoverer: &discoverer.Discoverer{}, + Scanner: &scanner.Scanner{}, + Estimator: &estimator.Estimator{}, + }, nil +} diff --git a/provider/v2/aws/scanner/scanner.go b/provider/v2/aws/scanner/scanner.go new file mode 100644 index 000000000..9a6064884 --- /dev/null +++ b/provider/v2/aws/scanner/scanner.go @@ -0,0 +1,36 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package scanner + +import ( + "context" + + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Scanner = &Scanner{} + +type Scanner struct{} + +func (s *Scanner) RunAssetScan(ctx context.Context, t *provider.ScanJobConfig) error { + // TODO implement me + panic("implement me") +} + +func (s *Scanner) RemoveAssetScan(ctx context.Context, t *provider.ScanJobConfig) error { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/azure/discoverer/discoverer.go b/provider/v2/azure/discoverer/discoverer.go new file mode 100644 index 000000000..03706bb43 --- /dev/null +++ b/provider/v2/azure/discoverer/discoverer.go @@ -0,0 +1,31 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package discoverer + +import ( + "context" + + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Discoverer = &Discoverer{} + +type Discoverer struct{} + +func (d *Discoverer) DiscoverAssets(ctx context.Context) provider.AssetDiscoverer { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/azure/estimator/estimator.go b/provider/v2/azure/estimator/estimator.go new file mode 100644 index 000000000..5b79b9844 --- /dev/null +++ b/provider/v2/azure/estimator/estimator.go @@ -0,0 +1,32 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package estimator + +import ( + "context" + + apitypes "github.com/openclarity/vmclarity/api/types" + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Estimator = &Estimator{} + +type Estimator struct{} + +func (e *Estimator) Estimate(ctx context.Context, stats apitypes.AssetScanStats, asset *apitypes.Asset, template *apitypes.AssetScanTemplate) (*apitypes.Estimation, error) { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/azure/provider.go b/provider/v2/azure/provider.go new file mode 100644 index 000000000..f09cc0b3d --- /dev/null +++ b/provider/v2/azure/provider.go @@ -0,0 +1,47 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package azure + +import ( + "context" + + apitypes "github.com/openclarity/vmclarity/api/types" + "github.com/openclarity/vmclarity/provider" + "github.com/openclarity/vmclarity/provider/v2/aws/discoverer" + "github.com/openclarity/vmclarity/provider/v2/aws/estimator" + "github.com/openclarity/vmclarity/provider/v2/aws/scanner" +) + +var _ provider.Provider = &Provider{} + +type Provider struct { + *discoverer.Discoverer + *scanner.Scanner + *estimator.Estimator +} + +func (p *Provider) Kind() apitypes.CloudProvider { + // TODO implement me + panic("implement me") +} + +func New(_ context.Context) (*Provider, error) { + return &Provider{ + Discoverer: &discoverer.Discoverer{}, + Scanner: &scanner.Scanner{}, + Estimator: &estimator.Estimator{}, + }, nil +} diff --git a/provider/v2/azure/scanner/scanner.go b/provider/v2/azure/scanner/scanner.go new file mode 100644 index 000000000..9a6064884 --- /dev/null +++ b/provider/v2/azure/scanner/scanner.go @@ -0,0 +1,36 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package scanner + +import ( + "context" + + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Scanner = &Scanner{} + +type Scanner struct{} + +func (s *Scanner) RunAssetScan(ctx context.Context, t *provider.ScanJobConfig) error { + // TODO implement me + panic("implement me") +} + +func (s *Scanner) RemoveAssetScan(ctx context.Context, t *provider.ScanJobConfig) error { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/gcp/discoverer/discoverer.go b/provider/v2/gcp/discoverer/discoverer.go new file mode 100644 index 000000000..03706bb43 --- /dev/null +++ b/provider/v2/gcp/discoverer/discoverer.go @@ -0,0 +1,31 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package discoverer + +import ( + "context" + + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Discoverer = &Discoverer{} + +type Discoverer struct{} + +func (d *Discoverer) DiscoverAssets(ctx context.Context) provider.AssetDiscoverer { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/gcp/estimator/estimator.go b/provider/v2/gcp/estimator/estimator.go new file mode 100644 index 000000000..5b79b9844 --- /dev/null +++ b/provider/v2/gcp/estimator/estimator.go @@ -0,0 +1,32 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package estimator + +import ( + "context" + + apitypes "github.com/openclarity/vmclarity/api/types" + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Estimator = &Estimator{} + +type Estimator struct{} + +func (e *Estimator) Estimate(ctx context.Context, stats apitypes.AssetScanStats, asset *apitypes.Asset, template *apitypes.AssetScanTemplate) (*apitypes.Estimation, error) { + // TODO implement me + panic("implement me") +} diff --git a/provider/v2/gcp/provider.go b/provider/v2/gcp/provider.go new file mode 100644 index 000000000..304470ba6 --- /dev/null +++ b/provider/v2/gcp/provider.go @@ -0,0 +1,47 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gcp + +import ( + "context" + + apitypes "github.com/openclarity/vmclarity/api/types" + "github.com/openclarity/vmclarity/provider" + "github.com/openclarity/vmclarity/provider/v2/aws/discoverer" + "github.com/openclarity/vmclarity/provider/v2/aws/estimator" + "github.com/openclarity/vmclarity/provider/v2/aws/scanner" +) + +var _ provider.Provider = &Provider{} + +type Provider struct { + *discoverer.Discoverer + *scanner.Scanner + *estimator.Estimator +} + +func (p *Provider) Kind() apitypes.CloudProvider { + // TODO implement me + panic("implement me") +} + +func New(_ context.Context) (*Provider, error) { + return &Provider{ + Discoverer: &discoverer.Discoverer{}, + Scanner: &scanner.Scanner{}, + Estimator: &estimator.Estimator{}, + }, nil +} diff --git a/provider/v2/gcp/scanner/scanner.go b/provider/v2/gcp/scanner/scanner.go new file mode 100644 index 000000000..9a6064884 --- /dev/null +++ b/provider/v2/gcp/scanner/scanner.go @@ -0,0 +1,36 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package scanner + +import ( + "context" + + "github.com/openclarity/vmclarity/provider" +) + +var _ provider.Scanner = &Scanner{} + +type Scanner struct{} + +func (s *Scanner) RunAssetScan(ctx context.Context, t *provider.ScanJobConfig) error { + // TODO implement me + panic("implement me") +} + +func (s *Scanner) RemoveAssetScan(ctx context.Context, t *provider.ScanJobConfig) error { + // TODO implement me + panic("implement me") +}