Skip to content

Commit

Permalink
Use upstream of application-api directly
Browse files Browse the repository at this point in the history
We used to copy/vendor application-api to go around dependency
alignment issues. Now that has been resolved upstream and we can use the
upstream dependency directly.
This greatly simplifies the build and consumption of ec-cli as a
dependency.

reference: EC-241
  • Loading branch information
zregvart committed Nov 7, 2023
1 parent 1c4fc15 commit ed0d853
Show file tree
Hide file tree
Showing 34 changed files with 32 additions and 1,158 deletions.
20 changes: 0 additions & 20 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,6 @@ updates:
all:
patterns:
- "*"
- package-ecosystem: "gomod"
directory: "/application/"
schedule:
interval: weekly
time: '15:00'
timezone: Etc/UTC
groups:
all:
patterns:
- "*"
- package-ecosystem: "gomod"
directory: "/application/generator"
schedule:
interval: weekly
time: '15:00'
timezone: Etc/UTC
groups:
all:
patterns:
- "*"
- package-ecosystem: "npm"
directory: "/"
schedule:
Expand Down
20 changes: 7 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ help: ## Display this help

##@ Building

generate: $(wildcard application/*/doc.go)
ifndef NO_GENERATE
@cd $(dir $<)
@go generate
endif

.PHONY: $(ALL_SUPPORTED_OS_ARCH)
$(ALL_SUPPORTED_OS_ARCH): generate ## Build binaries for specific platform/architecture, e.g. make dist/ec_linux_amd64
$(ALL_SUPPORTED_OS_ARCH): ## Build binaries for specific platform/architecture, e.g. make dist/ec_linux_amd64
@GOOS=$(word 2,$(subst _, ,$(notdir $@))); \
GOARCH=$(word 3,$(subst _, ,$(notdir $@))); \
GOOS=$${GOOS} GOARCH=$${GOARCH} CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/enterprise-contract/ec-cli/internal/version.Version=$(VERSION)" -o dist/ec_$${GOOS}_$${GOARCH}; \
Expand All @@ -65,7 +59,7 @@ BUILD_IMG_ARCH:=$(shell podman version -f {{.Server.OsArch}} | awk -F/ '{print $
build-for-test: dist/ec_$(BUILD_IMG_ARCH)

.PHONY: reference-docs
reference-docs: generate ## Generate reference documentation input YAML files
reference-docs: ## Generate reference documentation input YAML files
@mkdir -p dist
@rm -rf dist/cli-reference
# Make sure docs for experimental commands are generated.
Expand All @@ -78,7 +72,7 @@ clean: ## Delete build output
##@ Testing

.PHONY: test
test: generate ## Run all unit tests
test: ## Run all unit tests
@echo "Unit tests:"
@go test -race -covermode=atomic -coverprofile=coverage-unit.out -timeout 500ms -tags=unit ./...
@echo "Integration tests:"
Expand All @@ -92,7 +86,7 @@ ACCEPTANCE_TIMEOUT:=20m
.ONESHELL:
.SHELLFLAGS=-e -c
.PHONY: acceptance
acceptance: generate ## Run all acceptance tests
acceptance: ## Run all acceptance tests
@ACCEPTANCE_WORKDIR="$$(mktemp -d)"
@function cleanup() {
cp "$${ACCEPTANCE_WORKDIR}"/features/__snapshots__/* "$(ROOT_DIR)"/features/__snapshots__/
Expand All @@ -102,7 +96,7 @@ acceptance: generate ## Run all acceptance tests
@cp -R . "$${ACCEPTANCE_WORKDIR}"
@cd "$${ACCEPTANCE_WORKDIR}"
@go run acceptance/coverage/coverage.go .
@$(MAKE) build -e NO_GENERATE=1
@$(MAKE) build
@export COVERAGE_FILEPATH="$${ACCEPTANCE_WORKDIR}"
@export COVERAGE_FILENAME="-acceptance"
@cd acceptance && go test -timeout $(ACCEPTANCE_TIMEOUT) ./...
Expand Down Expand Up @@ -135,7 +129,7 @@ ci: test lint-fix acceptance ## Run the usual required CI tasks
LICENSE_IGNORE=-ignore 'dist/cli-reference/*.yaml' -ignore 'acceptance/examples/*.yaml' -ignore 'configs/*/*.yaml' -ignore 'node_modules/**' -ignore 'hack/**/charts/**'
LINT_TO_GITHUB_ANNOTATIONS='map(map(.)[])[][] as $$d | $$d.posn | split(":") as $$posn | "::warning file=\($$posn[0]),line=\($$posn[1]),col=\($$posn[2])::\($$d.message)"'
.PHONY: lint
lint: generate tekton-lint go-mod-lint ## Run linter
lint: tekton-lint go-mod-lint ## Run linter
# addlicense doesn't give us a nice explanation so we prefix it with one
@go run -modfile tools/go.mod github.com/google/addlicense -c '$(COPY)' -y '' -s -check $(LICENSE_IGNORE) . | sed 's/^/Missing license header in: /g'
# piping to sed above looses the exit code, luckily addlicense is fast so we invoke it for the second time to exit 1 in case of issues
Expand All @@ -144,7 +138,7 @@ lint: generate tekton-lint go-mod-lint ## Run linter
@(cd acceptance && go run -modfile ../tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --path-prefix acceptance --sort-results $(if $(GITHUB_ACTIONS), --out-format=github-actions --timeout=10m0s))

.PHONY: lint-fix
lint-fix: generate ## Fix linting issues automagically
lint-fix: ## Fix linting issues automagically
@go run -modfile tools/go.mod github.com/google/addlicense -c '$(COPY)' -y '' -s $(LICENSE_IGNORE) .
@go run -modfile tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --fix
@(cd acceptance && go run -modfile ../tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --path-prefix acceptance --fix)
Expand Down
5 changes: 2 additions & 3 deletions acceptance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/cucumber/godog v0.13.0
github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7
github.com/doiit/picocolors v1.0.1
github.com/enterprise-contract/ec-cli/application v0.0.0-00010101000000-000000000000
github.com/enterprise-contract/enterprise-contract-controller/api v0.0.0-20230725143429-4731fc7d3b41
github.com/evanphx/json-patch/v5 v5.7.0
github.com/gkampitakis/go-snaps v0.4.11 // we need custom snapshot directory & file support from https://github.com/gkampitakis/go-snaps/pull/60
Expand Down Expand Up @@ -43,6 +42,8 @@ require (
sigs.k8s.io/yaml v1.4.0
)

require github.com/redhat-appstudio/application-api v0.0.0-20231026192857-89515ad2504f

require (
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect
Expand Down Expand Up @@ -247,5 +248,3 @@ require (
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
)

replace github.com/enterprise-contract/ec-cli/application => ../application/
2 changes: 2 additions & 0 deletions acceptance/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,8 @@ github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf
github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ=
github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0 h1:sadMIsgmHpEOGbUs6VtHBXRR1OHevnj7hLx9ZcdNGW4=
github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c=
github.com/redhat-appstudio/application-api v0.0.0-20231026192857-89515ad2504f h1:PoKf7gCV/g5blkzVlODkqeynmfIACcR7NqWF8eqnuec=
github.com/redhat-appstudio/application-api v0.0.0-20231026192857-89515ad2504f/go.mod h1:YvckuKHe82eWloGk0/BpSw4YYG2owrGZAanztbOj3pQ=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down
4 changes: 2 additions & 2 deletions acceptance/kubernetes/kind/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
// `--tls-verify=false` here.

func (k *kindCluster) buildCliImage(ctx context.Context) error {
cmd := exec.CommandContext(ctx, "make", "push-image", fmt.Sprintf("IMAGE_REPO=localhost:%d/ec-cli", k.registryPort), "PODMAN_OPTS=--tls-verify=false", "-e", "NO_GENERATE=1") /* #nosec */
cmd := exec.CommandContext(ctx, "make", "push-image", fmt.Sprintf("IMAGE_REPO=localhost:%d/ec-cli", k.registryPort), "PODMAN_OPTS=--tls-verify=false") /* #nosec */

if out, err := cmd.CombinedOutput(); err != nil {
fmt.Printf("[ERROR] Unable to build and push the CLI image, %q returned an error: %v\nCommand output:\n", cmd, err)
Expand Down Expand Up @@ -130,7 +130,7 @@ func (k *kindCluster) buildTaskBundleImage(ctx context.Context) error {

for version, tasks := range taskBundles {
tasksPath := strings.Join(tasks, ",")
cmd := exec.CommandContext(ctx, "make", "task-bundle", fmt.Sprintf("TASK_REPO=localhost:%d/ec-task-bundle", k.registryPort), fmt.Sprintf("TASKS=%s", tasksPath), fmt.Sprintf("TASK_TAG=%s", version), "-e", "NO_GENERATE=1") /* #nosec */
cmd := exec.CommandContext(ctx, "make", "task-bundle", fmt.Sprintf("TASK_REPO=localhost:%d/ec-task-bundle", k.registryPort), fmt.Sprintf("TASKS=%s", tasksPath), fmt.Sprintf("TASK_TAG=%s", version)) /* #nosec */
if out, err := cmd.CombinedOutput(); err != nil {
fmt.Printf("[ERROR] Unable to build and push the Task bundle image, %q returned an error: %v\nCommand output:\n", cmd, err)
fmt.Print(string(out))
Expand Down
2 changes: 1 addition & 1 deletion acceptance/kubernetes/kind/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"time"

ecc "github.com/enterprise-contract/enterprise-contract-controller/api/v1alpha1"
app "github.com/redhat-appstudio/application-api/api/v1alpha1"
"github.com/tektoncd/cli/pkg/formatted"
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
tekton "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1"
Expand All @@ -39,7 +40,6 @@ import (
"github.com/enterprise-contract/ec-cli/acceptance/kubernetes/types"
"github.com/enterprise-contract/ec-cli/acceptance/kustomize"
"github.com/enterprise-contract/ec-cli/acceptance/testenv"
app "github.com/enterprise-contract/ec-cli/application/v1alpha1"
)

// createPolicyObject creates the EnterpriseContractPolicy object with the given
Expand Down
23 changes: 0 additions & 23 deletions application/application.go

This file was deleted.

15 changes: 0 additions & 15 deletions application/generator/boilerplate.go.txt

This file was deleted.

33 changes: 0 additions & 33 deletions application/generator/borrow.sh

This file was deleted.

22 changes: 0 additions & 22 deletions application/generator/dependencies.go

This file was deleted.

40 changes: 0 additions & 40 deletions application/generator/go.mod

This file was deleted.

Loading

0 comments on commit ed0d853

Please sign in to comment.