Skip to content
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
4 changes: 3 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: 2

project_name: ocm-backplane

before:
Expand Down Expand Up @@ -29,7 +31,7 @@ checksum:
name_template: "checksums.txt"

snapshot:
name_template: "{{ .Tag }}-next"
version_template: "{{ .Tag }}-next"

changelog:
sort: asc
Expand Down
5 changes: 1 addition & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ make coverage
# Security vulnerability scan
make scan

# Generate mocks
make mock-gen

# Generate code
# Generate code (including mocks)
make generate
```

Expand Down
26 changes: 4 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GO_BUILD_FLAGS_LINUX_CROSS :=-tags 'include_gcs include_oss containers_image_ope
GO_VERSION=go1.25.3+auto

GOLANGCI_LINT_VERSION=v2.5.0
GORELEASER_VERSION=v1.14.1
GORELEASER_VERSION=v2.15.3
GOVULNCHECK_VERSION=v1.1.4

TESTOPTS ?=
Expand Down Expand Up @@ -75,13 +75,13 @@ lint: getlint
$(GOPATH)/bin/golangci-lint run --timeout 5m

ensure-goreleaser:
@command -v goreleaser >/dev/null 2>&1 || go install github.com/goreleaser/goreleaser@${GORELEASER_VERSION}
@command -v goreleaser >/dev/null 2>&1 || go install github.com/goreleaser/goreleaser/v2@${GORELEASER_VERSION}
Comment thread
cblecker marked this conversation as resolved.

release: ensure-goreleaser
goreleaser release --rm-dist
goreleaser release --clean

release-with-note: ensure-goreleaser
goreleaser release --rm-dist --release-notes="$(NOTE)"
goreleaser release --clean --release-notes="$(NOTE)"

test:
env -u GOTOOLCHAIN GOTOOLCHAIN=$(GO_VERSION) go test -v $(TESTOPTS) ./...
Expand Down Expand Up @@ -110,24 +110,6 @@ clean-cross-build:
generate:
GOTOOLCHAIN=$(GO_VERSION) go generate ./...

.PHONY: mock-gen
mock-gen:
mockgen -destination=./pkg/client/mocks/ClientMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientInterface
mockgen -destination=./pkg/client/mocks/ClientWithResponsesMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientWithResponsesInterface
mockgen -destination=./pkg/utils/mocks/ClusterMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ClusterUtils
mockgen -destination=./pkg/ocm/mocks/ocmWrapperMock.go -package=mocks github.com/openshift/backplane-cli/pkg/ocm OCMInterface
mockgen -destination=./pkg/backplaneapi/mocks/clientUtilsMock.go -package=mocks github.com/openshift/backplane-cli/pkg/backplaneapi ClientUtils
mockgen -destination=./pkg/cli/session/mocks/sessionMock.go -package=mocks github.com/openshift/backplane-cli/pkg/cli/session BackplaneSessionInterface
mockgen -destination=./pkg/utils/mocks/shellCheckerMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ShellCheckerInterface
mockgen -destination=./pkg/pagerduty/mocks/clientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/pagerduty PagerDutyClient
mockgen -destination=./pkg/jira/mocks/jiraMock.go -package=mocks github.com/openshift/backplane-cli/pkg/jira IssueServiceInterface
mockgen -destination=./pkg/healthcheck/mocks/networkMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck NetworkInterface
mockgen -destination=./pkg/healthcheck/mocks/httpClientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck HTTPClient
mockgen -destination=./pkg/info/mocks/infoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info InfoService
mockgen -destination=./pkg/info/mocks/buildInfoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info BuildInfoService
mockgen -destination=./pkg/ssm/mocks/mock_ssmclient.go -package=mocks github.com/openshift/backplane-cli/cmd/ocm-backplane/cloud SSMClient
mockgen -destination=./pkg/container/mocks/containerEngineMock.go -package=mocks github.com/openshift/backplane-cli/pkg/container ContainerEngine

.PHONY: build-image
build-image:
$(CONTAINER_ENGINE) build --pull --platform linux/amd64 --build-arg GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) -t backplane-cli-builder -f ./make.Dockerfile .
Expand Down
2 changes: 2 additions & 0 deletions cmd/ocm-backplane/cloud/ssm.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ func getCurrentKubeconfig() (*rest.Config, error) {
return config, nil
}

//go:generate go tool mockgen -destination=../../../pkg/ssm/mocks/mock_ssmclient.go -package=mocks github.com/openshift/backplane-cli/cmd/ocm-backplane/cloud SSMClient

// Define SSMClient interface
type SSMClient interface {
StartSession(ctx context.Context, params *ssm.StartSessionInput, optFns ...func(*ssm.Options)) (*ssm.StartSessionOutput, error)
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo/v2 v2.28.1
github.com/onsi/gomega v1.39.1
github.com/openshift-online/ocm-api-model/clientapi v0.0.453
github.com/openshift-online/ocm-cli v1.0.10
github.com/openshift-online/ocm-sdk-go v0.1.499
github.com/openshift/backplane-api v0.0.0-20260205054653-459856398d59
Expand Down Expand Up @@ -49,6 +48,7 @@ require (
github.com/oapi-codegen/runtime v1.1.2 // indirect
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
github.com/openshift-online/ocm-api-model/clientapi v0.0.453 // indirect
github.com/openshift-online/ocm-api-model/model v0.0.453 // indirect
github.com/openshift-online/ocm-common v0.0.29 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down Expand Up @@ -164,3 +164,5 @@ require (
sigs.k8s.io/kustomize/kyaml v0.21.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.3 // indirect
)

tool go.uber.org/mock/mockgen
2 changes: 0 additions & 2 deletions make.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/i

ADD https://password.corp.redhat.com/RH-IT-Root-CA.crt /etc/pki/ca-trust/source/anchors/
RUN update-ca-trust extract

RUN go install github.com/golang/mock/mockgen@v1.6.0
1 change: 1 addition & 0 deletions pkg/backplaneapi/clientUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
logger "github.com/sirupsen/logrus"
)

//go:generate go tool mockgen -destination=mocks/clientUtilsMock.go -package=mocks github.com/openshift/backplane-cli/pkg/backplaneapi ClientUtils
type ClientUtils interface {
MakeBackplaneAPIClient(base string) (BackplaneApi.ClientWithResponsesInterface, error)
MakeBackplaneAPIClientWithAccessToken(base, accessToken string) (BackplaneApi.ClientWithResponsesInterface, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/backplaneapi/mocks/clientUtilsMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/cli/config/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
transitionStateRejected = "rejected"
)

//go:generate mockgen -destination=mocks/mock_config_api_client.go -package=mocks github.com/openshift/backplane-cli/pkg/cli/config ConfigAPIClient
//go:generate go tool mockgen -destination=mocks/mock_config_api_client.go -package=mocks github.com/openshift/backplane-cli/pkg/cli/config ConfigAPIClient

// ConfigAPIClient handles fetching configuration from backplane-api
type ConfigAPIClient interface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/session/mocks/sessionMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/cli/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/openshift/backplane-cli/pkg/ocm"
)

//go:generate go tool mockgen -destination=mocks/sessionMock.go -package=mocks github.com/openshift/backplane-cli/pkg/cli/session BackplaneSessionInterface

// BackplaneSessionInterface abstract backplane session functions
type BackplaneSessionInterface interface {
RunCommand(cmd *cobra.Command, args []string) error
Expand Down
4 changes: 4 additions & 0 deletions pkg/client/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package client

//go:generate go tool mockgen -destination=mocks/ClientMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientInterface
//go:generate go tool mockgen -destination=mocks/ClientWithResponsesMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientWithResponsesInterface
8 changes: 4 additions & 4 deletions pkg/client/mocks/ClientMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/client/mocks/ClientWithResponsesMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
pullSecretConfigDirectory string
)

//go:generate go tool mockgen -destination=mocks/containerEngineMock.go -package=mocks github.com/openshift/backplane-cli/pkg/container ContainerEngine
type ContainerEngine interface {
PullImage(imageName string) error
PutFileToMount(filename string, content []byte) error
Expand Down
2 changes: 1 addition & 1 deletion pkg/container/mocks/containerEngineMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/healthcheck/connectivity_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/spf13/cobra"
)

//go:generate go tool mockgen -destination=mocks/networkMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck NetworkInterface
//go:generate go tool mockgen -destination=mocks/httpClientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck HTTPClient

// Interfaces for dependencies
type NetworkInterface interface {
Interfaces() ([]net.Interface, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/healthcheck/mocks/httpClientMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/healthcheck/mocks/networkMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/info/buildInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package info

import "runtime/debug"

//go:generate go tool mockgen -destination=mocks/buildInfoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info BuildInfoService
type BuildInfoService interface {
// return the BuildInfo from Go build
GetBuildInfo() (info *debug.BuildInfo, ok bool)
Expand Down
1 change: 1 addition & 0 deletions pkg/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var (
UpstreamREADMETagged = fmt.Sprintf(UpstreamREADMETemplate, Version)
)

//go:generate go tool mockgen -destination=mocks/infoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info InfoService
type InfoService interface {
// get the current binary version from available sources
GetVersion() string
Expand Down
2 changes: 1 addition & 1 deletion pkg/info/mocks/buildInfoMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/info/mocks/infoMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/jira/issueService.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/andygrunwald/go-jira"
)

//go:generate go tool mockgen -destination=mocks/jiraMock.go -package=mocks github.com/openshift/backplane-cli/pkg/jira IssueServiceInterface
type IssueServiceInterface interface {
Create(issue *jira.Issue) (*jira.Issue, *jira.Response, error)
Get(issueID string, options *jira.GetQueryOptions) (*jira.Issue, *jira.Response, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/jira/mocks/jiraMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/ocm/mocks/ocmWrapperMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/ocm/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
// OCM Wrapper to abstract ocm sdk interface
// Provides a minimal interface for backplane-cli to function

//go:generate go tool mockgen -destination=mocks/ocmWrapperMock.go -package=mocks github.com/openshift/backplane-cli/pkg/ocm OCMInterface
type OCMInterface interface {
IsClusterHibernating(clusterID string) (bool, error)
GetTargetCluster(clusterKey string) (clusterID, clusterName string, err error)
Expand Down
2 changes: 2 additions & 0 deletions pkg/pagerduty/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
pdApi "github.com/PagerDuty/go-pagerduty"
)

//go:generate go tool mockgen -destination=mocks/clientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/pagerduty PagerDutyClient

// PagerDutyClient is an interface for the actual PD API
type PagerDutyClient interface {
Connect(authToken string, options ...pdApi.ClientOptions) error
Expand Down
2 changes: 1 addition & 1 deletion pkg/pagerduty/mocks/clientMock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/ssm/mocks/mock_ssmclient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/utils/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type BackplaneCluster struct {
BackplaneHost string // for e.g. https://api-backplane.apps.com
}

//go:generate go tool mockgen -destination=mocks/ClusterMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ClusterUtils
type ClusterUtils interface {
GetClusterIDAndHostFromClusterURL(clusterURL string) (string, string, error)
GetBackplaneClusterFromConfig() (BackplaneCluster, error)
Expand Down
Loading