diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 02864b85..7106f4cc 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,3 +1,5 @@ +version: 2 + project_name: ocm-backplane before: @@ -29,7 +31,7 @@ checksum: name_template: "checksums.txt" snapshot: - name_template: "{{ .Tag }}-next" + version_template: "{{ .Tag }}-next" changelog: sort: asc diff --git a/CLAUDE.md b/CLAUDE.md index 24ae7ee1..c82fef57 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,10 +42,7 @@ make coverage # Security vulnerability scan make scan -# Generate mocks -make mock-gen - -# Generate code +# Generate code (including mocks) make generate ``` diff --git a/Makefile b/Makefile index a77d0858..9ac3b8c7 100644 --- a/Makefile +++ b/Makefile @@ -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 ?= @@ -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} 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) ./... @@ -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 . diff --git a/cmd/ocm-backplane/cloud/ssm.go b/cmd/ocm-backplane/cloud/ssm.go index 29552adc..91797f24 100644 --- a/cmd/ocm-backplane/cloud/ssm.go +++ b/cmd/ocm-backplane/cloud/ssm.go @@ -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) diff --git a/go.mod b/go.mod index 83c391b2..52a875d4 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -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 diff --git a/make.Dockerfile b/make.Dockerfile index 5b0d9b66..41ec170f 100644 --- a/make.Dockerfile +++ b/make.Dockerfile @@ -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 diff --git a/pkg/backplaneapi/clientUtils.go b/pkg/backplaneapi/clientUtils.go index a498e5f3..b260daad 100644 --- a/pkg/backplaneapi/clientUtils.go +++ b/pkg/backplaneapi/clientUtils.go @@ -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) diff --git a/pkg/backplaneapi/mocks/clientUtilsMock.go b/pkg/backplaneapi/mocks/clientUtilsMock.go index 0a498579..06738201 100644 --- a/pkg/backplaneapi/mocks/clientUtilsMock.go +++ b/pkg/backplaneapi/mocks/clientUtilsMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/backplaneapi/mocks/clientUtilsMock.go -package=mocks github.com/openshift/backplane-cli/pkg/backplaneapi ClientUtils +// mockgen -destination=mocks/clientUtilsMock.go -package=mocks github.com/openshift/backplane-cli/pkg/backplaneapi ClientUtils // // Package mocks is a generated GoMock package. diff --git a/pkg/cli/config/api_client.go b/pkg/cli/config/api_client.go index 87279bda..2032831c 100644 --- a/pkg/cli/config/api_client.go +++ b/pkg/cli/config/api_client.go @@ -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 { diff --git a/pkg/cli/session/mocks/sessionMock.go b/pkg/cli/session/mocks/sessionMock.go index e40b9f7a..4c190d18 100644 --- a/pkg/cli/session/mocks/sessionMock.go +++ b/pkg/cli/session/mocks/sessionMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/cli/session/mocks/sessionMock.go -package=mocks github.com/openshift/backplane-cli/pkg/cli/session BackplaneSessionInterface +// mockgen -destination=mocks/sessionMock.go -package=mocks github.com/openshift/backplane-cli/pkg/cli/session BackplaneSessionInterface // // Package mocks is a generated GoMock package. diff --git a/pkg/cli/session/session.go b/pkg/cli/session/session.go index f19b8130..b7873bd7 100644 --- a/pkg/cli/session/session.go +++ b/pkg/cli/session/session.go @@ -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 diff --git a/pkg/client/generate.go b/pkg/client/generate.go new file mode 100644 index 00000000..d46456f2 --- /dev/null +++ b/pkg/client/generate.go @@ -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 diff --git a/pkg/client/mocks/ClientMock.go b/pkg/client/mocks/ClientMock.go index c407f991..6b341a33 100644 --- a/pkg/client/mocks/ClientMock.go +++ b/pkg/client/mocks/ClientMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/client/mocks/ClientMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientInterface +// mockgen -destination=mocks/ClientMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientInterface // // Package mocks is a generated GoMock package. @@ -44,7 +44,7 @@ func (m *MockClientInterface) EXPECT() *MockClientInterfaceMockRecorder { } // CreateJob mocks base method. -func (m *MockClientInterface) CreateJob(ctx context.Context, clusterId string, body Openapi.CreateJob, reqEditors ...Openapi.RequestEditorFn) (*http.Response, error) { +func (m *MockClientInterface) CreateJob(ctx context.Context, clusterId string, body Openapi.CreateJobJSONRequestBody, reqEditors ...Openapi.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() varargs := []any{ctx, clusterId, body} for _, a := range reqEditors { @@ -104,7 +104,7 @@ func (mr *MockClientInterfaceMockRecorder) CreateRemediation(ctx, clusterId, par } // CreateReport mocks base method. -func (m *MockClientInterface) CreateReport(ctx context.Context, clusterId string, body Openapi.CreateReport, reqEditors ...Openapi.RequestEditorFn) (*http.Response, error) { +func (m *MockClientInterface) CreateReport(ctx context.Context, clusterId string, body Openapi.CreateReportJSONRequestBody, reqEditors ...Openapi.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() varargs := []any{ctx, clusterId, body} for _, a := range reqEditors { @@ -144,7 +144,7 @@ func (mr *MockClientInterfaceMockRecorder) CreateReportWithBody(ctx, clusterId, } // CreateTestScriptRun mocks base method. -func (m *MockClientInterface) CreateTestScriptRun(ctx context.Context, clusterId string, body Openapi.CreateTestJob, reqEditors ...Openapi.RequestEditorFn) (*http.Response, error) { +func (m *MockClientInterface) CreateTestScriptRun(ctx context.Context, clusterId string, body Openapi.CreateTestScriptRunJSONRequestBody, reqEditors ...Openapi.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() varargs := []any{ctx, clusterId, body} for _, a := range reqEditors { diff --git a/pkg/client/mocks/ClientWithResponsesMock.go b/pkg/client/mocks/ClientWithResponsesMock.go index 102121fe..f577be67 100644 --- a/pkg/client/mocks/ClientWithResponsesMock.go +++ b/pkg/client/mocks/ClientWithResponsesMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/client/mocks/ClientWithResponsesMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientWithResponsesInterface +// mockgen -destination=mocks/ClientWithResponsesMock.go -package=mocks github.com/openshift/backplane-api/pkg/client ClientWithResponsesInterface // // Package mocks is a generated GoMock package. @@ -63,7 +63,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CreateJobWithBodyWithRes } // CreateJobWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) CreateJobWithResponse(ctx context.Context, clusterId string, body Openapi.CreateJob, reqEditors ...Openapi.RequestEditorFn) (*Openapi.CreateJobResponse, error) { +func (m *MockClientWithResponsesInterface) CreateJobWithResponse(ctx context.Context, clusterId string, body Openapi.CreateJobJSONRequestBody, reqEditors ...Openapi.RequestEditorFn) (*Openapi.CreateJobResponse, error) { m.ctrl.T.Helper() varargs := []any{ctx, clusterId, body} for _, a := range reqEditors { @@ -123,7 +123,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CreateReportWithBodyWith } // CreateReportWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) CreateReportWithResponse(ctx context.Context, clusterId string, body Openapi.CreateReport, reqEditors ...Openapi.RequestEditorFn) (*Openapi.CreateReportResponse, error) { +func (m *MockClientWithResponsesInterface) CreateReportWithResponse(ctx context.Context, clusterId string, body Openapi.CreateReportJSONRequestBody, reqEditors ...Openapi.RequestEditorFn) (*Openapi.CreateReportResponse, error) { m.ctrl.T.Helper() varargs := []any{ctx, clusterId, body} for _, a := range reqEditors { @@ -163,7 +163,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CreateTestScriptRunWithB } // CreateTestScriptRunWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) CreateTestScriptRunWithResponse(ctx context.Context, clusterId string, body Openapi.CreateTestJob, reqEditors ...Openapi.RequestEditorFn) (*Openapi.CreateTestScriptRunResponse, error) { +func (m *MockClientWithResponsesInterface) CreateTestScriptRunWithResponse(ctx context.Context, clusterId string, body Openapi.CreateTestScriptRunJSONRequestBody, reqEditors ...Openapi.RequestEditorFn) (*Openapi.CreateTestScriptRunResponse, error) { m.ctrl.T.Helper() varargs := []any{ctx, clusterId, body} for _, a := range reqEditors { diff --git a/pkg/container/container.go b/pkg/container/container.go index 88e010da..5586b5ce 100644 --- a/pkg/container/container.go +++ b/pkg/container/container.go @@ -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 diff --git a/pkg/container/mocks/containerEngineMock.go b/pkg/container/mocks/containerEngineMock.go index 9e48a5ba..f8dbb63c 100644 --- a/pkg/container/mocks/containerEngineMock.go +++ b/pkg/container/mocks/containerEngineMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/container/mocks/containerEngineMock.go -package=mocks github.com/openshift/backplane-cli/pkg/container ContainerEngine +// mockgen -destination=mocks/containerEngineMock.go -package=mocks github.com/openshift/backplane-cli/pkg/container ContainerEngine // // Package mocks is a generated GoMock package. diff --git a/pkg/healthcheck/connectivity_checks.go b/pkg/healthcheck/connectivity_checks.go index dd59eadb..757cf557 100644 --- a/pkg/healthcheck/connectivity_checks.go +++ b/pkg/healthcheck/connectivity_checks.go @@ -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) diff --git a/pkg/healthcheck/mocks/httpClientMock.go b/pkg/healthcheck/mocks/httpClientMock.go index 8f0abe08..07c9dab5 100644 --- a/pkg/healthcheck/mocks/httpClientMock.go +++ b/pkg/healthcheck/mocks/httpClientMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/healthcheck/mocks/httpClientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck HTTPClient +// mockgen -destination=mocks/httpClientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck HTTPClient // // Package mocks is a generated GoMock package. diff --git a/pkg/healthcheck/mocks/networkMock.go b/pkg/healthcheck/mocks/networkMock.go index 29dc30bb..4da42c04 100644 --- a/pkg/healthcheck/mocks/networkMock.go +++ b/pkg/healthcheck/mocks/networkMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/healthcheck/mocks/networkMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck NetworkInterface +// mockgen -destination=mocks/networkMock.go -package=mocks github.com/openshift/backplane-cli/pkg/healthcheck NetworkInterface // // Package mocks is a generated GoMock package. diff --git a/pkg/info/buildInfo.go b/pkg/info/buildInfo.go index c1a8089c..2add925d 100644 --- a/pkg/info/buildInfo.go +++ b/pkg/info/buildInfo.go @@ -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) diff --git a/pkg/info/info.go b/pkg/info/info.go index a75b4a95..a4e88f27 100644 --- a/pkg/info/info.go +++ b/pkg/info/info.go @@ -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 diff --git a/pkg/info/mocks/buildInfoMock.go b/pkg/info/mocks/buildInfoMock.go index 63b67485..37d04377 100644 --- a/pkg/info/mocks/buildInfoMock.go +++ b/pkg/info/mocks/buildInfoMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/info/mocks/buildInfoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info BuildInfoService +// mockgen -destination=mocks/buildInfoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info BuildInfoService // // Package mocks is a generated GoMock package. diff --git a/pkg/info/mocks/infoMock.go b/pkg/info/mocks/infoMock.go index 24711427..222a0999 100644 --- a/pkg/info/mocks/infoMock.go +++ b/pkg/info/mocks/infoMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/info/mocks/infoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info InfoService +// mockgen -destination=mocks/infoMock.go -package=mocks github.com/openshift/backplane-cli/pkg/info InfoService // // Package mocks is a generated GoMock package. diff --git a/pkg/jira/issueService.go b/pkg/jira/issueService.go index e96e3269..1f2c425f 100644 --- a/pkg/jira/issueService.go +++ b/pkg/jira/issueService.go @@ -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) diff --git a/pkg/jira/mocks/jiraMock.go b/pkg/jira/mocks/jiraMock.go index de137c97..530058aa 100644 --- a/pkg/jira/mocks/jiraMock.go +++ b/pkg/jira/mocks/jiraMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/jira/mocks/jiraMock.go -package=mocks github.com/openshift/backplane-cli/pkg/jira IssueServiceInterface +// mockgen -destination=mocks/jiraMock.go -package=mocks github.com/openshift/backplane-cli/pkg/jira IssueServiceInterface // // Package mocks is a generated GoMock package. diff --git a/pkg/ocm/mocks/ocmWrapperMock.go b/pkg/ocm/mocks/ocmWrapperMock.go index 31d998d1..2cc757cb 100644 --- a/pkg/ocm/mocks/ocmWrapperMock.go +++ b/pkg/ocm/mocks/ocmWrapperMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/ocm/mocks/ocmWrapperMock.go -package=mocks github.com/openshift/backplane-cli/pkg/ocm OCMInterface +// mockgen -destination=mocks/ocmWrapperMock.go -package=mocks github.com/openshift/backplane-cli/pkg/ocm OCMInterface // // Package mocks is a generated GoMock package. @@ -12,9 +12,9 @@ package mocks import ( reflect "reflect" - v1 "github.com/openshift-online/ocm-api-model/clientapi/accesstransparency/v1" - v10 "github.com/openshift-online/ocm-api-model/clientapi/clustersmgmt/v1" sdk "github.com/openshift-online/ocm-sdk-go" + v1 "github.com/openshift-online/ocm-sdk-go/accesstransparency/v1" + v10 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1" gomock "go.uber.org/mock/gomock" ) diff --git a/pkg/ocm/ocm.go b/pkg/ocm/ocm.go index ac6daa9b..27300b02 100644 --- a/pkg/ocm/ocm.go +++ b/pkg/ocm/ocm.go @@ -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) diff --git a/pkg/pagerduty/client.go b/pkg/pagerduty/client.go index c4a82614..69d13833 100644 --- a/pkg/pagerduty/client.go +++ b/pkg/pagerduty/client.go @@ -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 diff --git a/pkg/pagerduty/mocks/clientMock.go b/pkg/pagerduty/mocks/clientMock.go index c37bcd26..cfae9b3d 100644 --- a/pkg/pagerduty/mocks/clientMock.go +++ b/pkg/pagerduty/mocks/clientMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/pagerduty/mocks/clientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/pagerduty PagerDutyClient +// mockgen -destination=mocks/clientMock.go -package=mocks github.com/openshift/backplane-cli/pkg/pagerduty PagerDutyClient // // Package mocks is a generated GoMock package. diff --git a/pkg/ssm/mocks/mock_ssmclient.go b/pkg/ssm/mocks/mock_ssmclient.go index e2afb023..d7d7578b 100644 --- a/pkg/ssm/mocks/mock_ssmclient.go +++ b/pkg/ssm/mocks/mock_ssmclient.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/ssm/mocks/mock_ssmclient.go -package=mocks github.com/openshift/backplane-cli/cmd/ocm-backplane/cloud SSMClient +// mockgen -destination=../../../pkg/ssm/mocks/mock_ssmclient.go -package=mocks github.com/openshift/backplane-cli/cmd/ocm-backplane/cloud SSMClient // // Package mocks is a generated GoMock package. diff --git a/pkg/utils/cluster.go b/pkg/utils/cluster.go index f5327146..dfe30e77 100644 --- a/pkg/utils/cluster.go +++ b/pkg/utils/cluster.go @@ -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) diff --git a/pkg/utils/mocks/ClusterMock.go b/pkg/utils/mocks/ClusterMock.go index 8724a6bf..2c958ff1 100644 --- a/pkg/utils/mocks/ClusterMock.go +++ b/pkg/utils/mocks/ClusterMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/utils/mocks/ClusterMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ClusterUtils +// mockgen -destination=mocks/ClusterMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ClusterUtils // // Package mocks is a generated GoMock package. diff --git a/pkg/utils/mocks/shellCheckerMock.go b/pkg/utils/mocks/shellCheckerMock.go index 5deaed4b..c64e15d4 100644 --- a/pkg/utils/mocks/shellCheckerMock.go +++ b/pkg/utils/mocks/shellCheckerMock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination=./pkg/utils/mocks/shellCheckerMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ShellCheckerInterface +// mockgen -destination=mocks/shellCheckerMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ShellCheckerInterface // // Package mocks is a generated GoMock package. diff --git a/pkg/utils/shell.go b/pkg/utils/shell.go index 7c6fc351..ba53dc8b 100644 --- a/pkg/utils/shell.go +++ b/pkg/utils/shell.go @@ -4,6 +4,7 @@ import "os" var ShellChecker ShellCheckerInterface = DefaultShellChecker{} +//go:generate go tool mockgen -destination=mocks/shellCheckerMock.go -package=mocks github.com/openshift/backplane-cli/pkg/utils ShellCheckerInterface type ShellCheckerInterface interface { IsValidShell(shellPath string) bool }