diff --git a/cmd/rad/cmd/root.go b/cmd/rad/cmd/root.go index b96a2dcfc0a..228088a5712 100644 --- a/cmd/rad/cmd/root.go +++ b/cmd/rad/cmd/root.go @@ -70,6 +70,7 @@ import ( "github.com/radius-project/radius/pkg/cli/cmd/run" "github.com/radius-project/radius/pkg/cli/cmd/uninstall" uninstall_kubernetes "github.com/radius-project/radius/pkg/cli/cmd/uninstall/kubernetes" + version "github.com/radius-project/radius/pkg/cli/cmd/version" workspace_create "github.com/radius-project/radius/pkg/cli/cmd/workspace/create" workspace_delete "github.com/radius-project/radius/pkg/cli/cmd/workspace/delete" workspace_list "github.com/radius-project/radius/pkg/cli/cmd/workspace/list" @@ -371,6 +372,9 @@ func initSubCommands() { uninstallKubernetesCmd, _ := uninstall_kubernetes.NewCommand(framework) uninstallCmd.AddCommand(uninstallKubernetesCmd) + + versionCmd, _ := version.NewCommand(framework) + RootCmd.AddCommand(versionCmd) } // The dance we do with config is kinda complex. We want commands to be able to retrieve a config (*viper.Viper) diff --git a/cmd/rad/cmd/version.go b/cmd/rad/cmd/version.go deleted file mode 100644 index 8ec87a53db5..00000000000 --- a/cmd/rad/cmd/version.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -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 cmd - -import ( - "io" - - "github.com/radius-project/radius/pkg/cli/bicep" - "github.com/radius-project/radius/pkg/cli/output" - "github.com/radius-project/radius/pkg/version" - "github.com/spf13/cobra" -) - -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Prints the versions of the rad cli", - RunE: func(cmd *cobra.Command, args []string) error { - cli, err := cmd.Flags().GetBool("cli") - if err != nil { - return err - } - - if !cli { - outFormat, _ := cmd.Flags().GetString("output") - writeVersionString(outFormat, cmd.OutOrStdout()) - } else { - output.LogInfo("%s", version.Version()) - } - return nil - }, -} - -func writeVersionString(format string, w io.Writer) { - var displayVersion = struct { - Release string `json:"release"` - Version string `json:"version"` - Bicep string `json:"bicep"` - Commit string `json:"commit"` - }{ - version.Release(), - version.Version(), - bicep.Version(), - version.Commit(), - } - _ = output.Write(format, displayVersion, w, output.FormatterOptions{Columns: []output.Column{ - { - Heading: "RELEASE", - JSONPath: "{ .Release }", - }, - { - Heading: "VERSION", - JSONPath: "{ .Version }", - }, - { - Heading: "BICEP", - JSONPath: "{ .Bicep }", - }, - { - Heading: "COMMIT", - JSONPath: "{ .Commit }", - }, - }}) -} - -func init() { - RootCmd.AddCommand(versionCmd) - versionCmd.Flags().Bool("cli", false, "Use this flag to only show the rad CLI version") -} diff --git a/pkg/cli/cmd/version/version.go b/pkg/cli/cmd/version/version.go new file mode 100644 index 00000000000..0a7595c16ee --- /dev/null +++ b/pkg/cli/cmd/version/version.go @@ -0,0 +1,193 @@ +package version + +import ( + "context" + + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/version" + "github.com/spf13/cobra" +) + +type CLIVersionInfo struct { + Release string `json:"release"` + Version string `json:"version"` + Bicep string `json:"bicep"` + Commit string `json:"commit"` +} + +type ControlPlaneVersionInfo struct { + Version string `json:"version"` + Status string `json:"status"` +} + +// getCliVersionInfo returns the CLI version information +func getCliVersionInfo() CLIVersionInfo { + return CLIVersionInfo{ + Release: version.Release(), + Version: version.Version(), + Bicep: bicep.Version(), + Commit: version.Commit(), + } +} + +// getControlPlaneVersionInfo retrieves the Control Plane version information +func (r *Runner) getControlPlaneVersionInfo() ControlPlaneVersionInfo { + cpInfo := ControlPlaneVersionInfo{ + Version: "Not installed", + Status: "Not connected", + } + + state, err := r.Helm.CheckRadiusInstall(r.KubeContext) + if err != nil { + // Keep the default "Not connected" status + return cpInfo + } + + // Connection successful, update status + cpInfo.Status = "Not installed" + + if state.RadiusInstalled { + cpInfo.Status = "Installed" + cpInfo.Version = state.RadiusVersion + } + + return cpInfo +} + +// Update the NewCommand function +func NewCommand(factory framework.Factory) (*cobra.Command, framework.Runner) { + runner := NewRunner(factory) + + cmd := &cobra.Command{ + Use: "version", + Short: "Prints the versions of the rad CLI and the Radius Control Plane", + Long: `Display version information for the rad CLI installed on your machine and the Radius Control Plane running on your cluster. +By default this shows all available version information.`, + Example: `# Show all version information +rad version + +# Show only the CLI version +rad version --cli`, + RunE: framework.RunCommand(runner), + } + + cmd.Flags().Bool("cli", false, "Use this flag to only show the rad CLI version") + return cmd, runner +} + +// Runner is the Runner implementation for the version command +type Runner struct { + Helm helm.Interface + Output output.Interface + KubeContext string + Format string + CLIOnly bool +} + +// NewRunner creates a new Runner instance +func NewRunner(factory framework.Factory) *Runner { + return &Runner{ + Output: factory.GetOutput(), + Helm: factory.GetHelmInterface(), + } +} + +// Validate validates the command arguments +func (r *Runner) Validate(cmd *cobra.Command, args []string) error { + format, err := cmd.Flags().GetString("output") + if err != nil { + return err + } + if format == "" { + format = "table" + } + r.Format = format + + cliOnly, err := cmd.Flags().GetBool("cli") + if err != nil { + return err + } + r.CLIOnly = cliOnly + + return nil +} + +// Run executes the version command +func (r *Runner) Run(ctx context.Context) error { + if r.CLIOnly { + return r.writeCliVersionOnly(r.Format) + } + + return r.writeVersionInfo(r.Format) +} + +// writeCliVersionOnly displays only CLI version information +func (r *Runner) writeCliVersionOnly(format string) error { + // No header when only showing CLI info + return r.Output.WriteFormatted(format, getCliVersionInfo(), getCliVersionFormatterOptions()) +} + +// writeVersionInfo displays both CLI and Control Plane version information +func (r *Runner) writeVersionInfo(format string) error { + // Display CLI version information + cliVersion := getCliVersionInfo() + + // Only show headers for human-readable formats + if format != "json" && format != "yaml" { + r.Output.LogInfo("CLI Version Information:") + } + + err := r.Output.WriteFormatted(format, cliVersion, getCliVersionFormatterOptions()) + if err != nil { + return err + } + + // Get control plane info (handles errors internally) + cpInfo := r.getControlPlaneVersionInfo() + + // Only show headers for human-readable formats + if format != "json" && format != "yaml" { + r.Output.LogInfo("\nControl Plane Information:") + } + + return r.Output.WriteFormatted(format, cpInfo, getControlPlaneFormatterOptions()) +} + +// getCliVersionFormatterOptions returns formatter options for CLI version information +func getCliVersionFormatterOptions() output.FormatterOptions { + return output.FormatterOptions{Columns: []output.Column{ + { + Heading: "RELEASE", + JSONPath: "{ .Release }", + }, + { + Heading: "VERSION", + JSONPath: "{ .Version }", + }, + { + Heading: "BICEP", + JSONPath: "{ .Bicep }", + }, + { + Heading: "COMMIT", + JSONPath: "{ .Commit }", + }, + }} +} + +// getControlPlaneFormatterOptions returns formatter options for Control Plane version information +func getControlPlaneFormatterOptions() output.FormatterOptions { + return output.FormatterOptions{Columns: []output.Column{ + { + Heading: "STATUS", + JSONPath: "{ .Status }", + }, + { + Heading: "VERSION", + JSONPath: "{ .Version }", + }, + }} +} diff --git a/pkg/cli/cmd/version/version_test.go b/pkg/cli/cmd/version/version_test.go new file mode 100644 index 00000000000..89b656b2b57 --- /dev/null +++ b/pkg/cli/cmd/version/version_test.go @@ -0,0 +1,421 @@ +package version + +import ( + "context" + "fmt" + "testing" + + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/version" + "github.com/spf13/cobra" + "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" +) + +// TestNewCommand tests that the command is created correctly with the right flags and configuration +func TestNewCommand(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockFactory := framework.NewMockFactory(ctrl) + mockHelmInterface := helm.NewMockInterface(ctrl) + mockOutput := &output.MockOutput{} + + mockFactory.EXPECT().GetHelmInterface().Return(mockHelmInterface) + mockFactory.EXPECT().GetOutput().Return(mockOutput) + + cmd, runner := NewCommand(mockFactory) + + // Verify command metadata + require.Equal(t, "version", cmd.Use) + require.Equal(t, "Prints the versions of the rad CLI and the Radius Control Plane", cmd.Short) + + // Verify flags + cliOnly, err := cmd.Flags().GetBool("cli") + require.NoError(t, err) + require.False(t, cliOnly) + + // Verify runner was created properly + versionRunner, ok := runner.(*Runner) + require.True(t, ok) + require.Equal(t, mockHelmInterface, versionRunner.Helm) + require.Equal(t, mockOutput, versionRunner.Output) +} + +// TestValidate tests the Validate function behavior +func TestValidate(t *testing.T) { + testCases := []struct { + name string + outputFlag string + cliFlag string + expectedFormat string + expectedCLIOnly bool + }{ + { + name: "Default values", + outputFlag: "", + cliFlag: "false", + expectedFormat: "table", + expectedCLIOnly: false, + }, + { + name: "JSON output and CLI only", + outputFlag: "json", + cliFlag: "true", + expectedFormat: "json", + expectedCLIOnly: true, + }, + { + name: "YAML output", + outputFlag: "yaml", + cliFlag: "false", + expectedFormat: "yaml", + expectedCLIOnly: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockHelmInterface := helm.NewMockInterface(ctrl) + mockOutput := &output.MockOutput{} + + runner := &Runner{ + Helm: mockHelmInterface, + Output: mockOutput, + } + + cmd := &cobra.Command{} + cmd.Flags().Bool("cli", false, "") + cmd.Flags().String("output", "", "") + + if tc.outputFlag != "" { + err := cmd.Flags().Set("output", tc.outputFlag) + require.NoError(t, err) + } + + err := cmd.Flags().Set("cli", tc.cliFlag) + require.NoError(t, err) + + err = runner.Validate(cmd, []string{}) + require.NoError(t, err) + require.Equal(t, tc.expectedFormat, runner.Format) + require.Equal(t, tc.expectedCLIOnly, runner.CLIOnly) + }) + } +} + +// TestWriteCliVersionOnly tests the writeCliVersionOnly method +func TestWriteCliVersionOnly(t *testing.T) { + testCases := []struct { + name string + format string + expectedInfo CLIVersionInfo + }{ + { + name: "Table format", + format: "table", + expectedInfo: CLIVersionInfo{ + Release: version.Release(), + Version: version.Version(), + Bicep: bicep.Version(), + Commit: version.Commit(), + }, + }, + { + name: "JSON format", + format: "json", + expectedInfo: CLIVersionInfo{ + Release: version.Release(), + Version: version.Version(), + Bicep: bicep.Version(), + Commit: version.Commit(), + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockOutput := output.NewMockInterface(ctrl) + runner := &Runner{ + Output: mockOutput, + } + + mockOutput.EXPECT().WriteFormatted( + tc.format, + gomock.Any(), + gomock.Any(), + ).Do(func(format string, data any, options output.FormatterOptions) error { + actualData, ok := data.(CLIVersionInfo) + require.True(t, ok) + require.Equal(t, tc.expectedInfo.Release, actualData.Release) + require.Equal(t, tc.expectedInfo.Version, actualData.Version) + require.Equal(t, tc.expectedInfo.Bicep, actualData.Bicep) + require.Equal(t, tc.expectedInfo.Commit, actualData.Commit) + return nil + }).Return(nil) + + err := runner.writeCliVersionOnly(tc.format) + require.NoError(t, err) + }) + } +} + +// TestWriteVersionInfo tests the writeVersionInfo method with different scenarios +func TestWriteVersionInfo(t *testing.T) { + testCases := []struct { + name string + format string + installState helm.InstallState + helmError error + expectedStatus string + expectedVersion string + showHeaders bool + }{ + { + name: "Radius installed - table format", + format: "table", + installState: helm.InstallState{ + RadiusInstalled: true, + RadiusVersion: "v0.45.0", + }, + helmError: nil, + expectedStatus: "Installed", + expectedVersion: "v0.45.0", + showHeaders: true, + }, + { + name: "Radius not installed - table format", + format: "table", + installState: helm.InstallState{ + RadiusInstalled: false, + }, + helmError: nil, + expectedStatus: "Not installed", + expectedVersion: "Not installed", + showHeaders: true, + }, + { + name: "Connection error - table format", + format: "table", + installState: helm.InstallState{}, + helmError: fmt.Errorf("connection failed"), + expectedStatus: "Not connected", + expectedVersion: "Not installed", + showHeaders: true, + }, + { + name: "Radius installed - JSON format", + format: "json", + installState: helm.InstallState{ + RadiusInstalled: true, + RadiusVersion: "v0.45.0", + }, + helmError: nil, + expectedStatus: "Installed", + expectedVersion: "v0.45.0", + showHeaders: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockHelmInterface := helm.NewMockInterface(ctrl) + mockOutput := output.NewMockInterface(ctrl) + + runner := &Runner{ + Helm: mockHelmInterface, + Output: mockOutput, + Format: tc.format, + } + + mockHelmInterface.EXPECT().CheckRadiusInstall("").Return(tc.installState, tc.helmError) + + // Only expect headers for formats that show them + if tc.showHeaders { + mockOutput.EXPECT().LogInfo("CLI Version Information:") + } + + mockOutput.EXPECT().WriteFormatted(tc.format, gomock.Any(), gomock.Any()).Return(nil) + + if tc.showHeaders { + mockOutput.EXPECT().LogInfo("\nControl Plane Information:") + } + + mockOutput.EXPECT().WriteFormatted(tc.format, gomock.Any(), gomock.Any()).Do( + func(format string, data any, options output.FormatterOptions) error { + controlPlane, ok := data.(ControlPlaneVersionInfo) + require.True(t, ok) + require.Equal(t, tc.expectedStatus, controlPlane.Status) + require.Equal(t, tc.expectedVersion, controlPlane.Version) + return nil + }).Return(nil) + + err := runner.writeVersionInfo(tc.format) + require.NoError(t, err) + }) + } +} + +// TestRun tests the Run method with various flags +func TestRun(t *testing.T) { + testCases := []struct { + name string + cliOnly bool + format string + expectCLIOnly bool + }{ + { + name: "CLI and Control Plane versions - table format", + cliOnly: false, + format: "table", + expectCLIOnly: false, + }, + { + name: "CLI version only - table format", + cliOnly: true, + format: "table", + expectCLIOnly: true, + }, + { + name: "CLI and Control Plane versions - JSON format", + cliOnly: false, + format: "json", + expectCLIOnly: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockHelmInterface := helm.NewMockInterface(ctrl) + mockOutput := output.NewMockInterface(ctrl) + + runner := &Runner{ + Helm: mockHelmInterface, + Output: mockOutput, + CLIOnly: tc.cliOnly, + Format: tc.format, + } + + if tc.expectCLIOnly { + mockOutput.EXPECT().WriteFormatted(tc.format, gomock.Any(), gomock.Any()).Return(nil) + } else { + // Setup expected calls for full version info + if tc.format != "json" && tc.format != "yaml" { + mockOutput.EXPECT().LogInfo("CLI Version Information:") + } + mockOutput.EXPECT().WriteFormatted(tc.format, gomock.Any(), gomock.Any()).Return(nil) + + mockHelmInterface.EXPECT().CheckRadiusInstall("").Return(helm.InstallState{ + RadiusInstalled: true, + RadiusVersion: "v0.45.0", + }, nil) + + if tc.format != "json" && tc.format != "yaml" { + mockOutput.EXPECT().LogInfo("\nControl Plane Information:") + } + mockOutput.EXPECT().WriteFormatted(tc.format, gomock.Any(), gomock.Any()).Return(nil) + } + + err := runner.Run(context.Background()) + require.NoError(t, err) + }) + } +} + +// TestGetControlPlaneVersionInfo tests the getControlPlaneVersionInfo method +func TestGetControlPlaneVersionInfo(t *testing.T) { + testCases := []struct { + name string + installState helm.InstallState + helmError error + expectedStatus string + expectedVersion string + }{ + { + name: "Radius installed", + installState: helm.InstallState{ + RadiusInstalled: true, + RadiusVersion: "v0.45.0", + }, + helmError: nil, + expectedStatus: "Installed", + expectedVersion: "v0.45.0", + }, + { + name: "Radius not installed", + installState: helm.InstallState{ + RadiusInstalled: false, + }, + helmError: nil, + expectedStatus: "Not installed", + expectedVersion: "Not installed", + }, + { + name: "Connection error", + installState: helm.InstallState{}, + helmError: fmt.Errorf("connection failed"), + expectedStatus: "Not connected", + expectedVersion: "Not installed", + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockHelmInterface := helm.NewMockInterface(ctrl) + + runner := &Runner{ + Helm: mockHelmInterface, + } + + mockHelmInterface.EXPECT().CheckRadiusInstall("").Return(tc.installState, tc.helmError) + + cpInfo := runner.getControlPlaneVersionInfo() + + require.Equal(t, tc.expectedStatus, cpInfo.Status) + require.Equal(t, tc.expectedVersion, cpInfo.Version) + }) + } +} + +// TestGetControlPlaneFormatterOptions tests the formatter options for control plane info +func TestGetControlPlaneFormatterOptions(t *testing.T) { + expectedColumns := []struct { + heading string + jsonPath string + }{ + { + heading: "STATUS", + jsonPath: "{ .Status }", + }, + { + heading: "VERSION", + jsonPath: "{ .Version }", + }, + } + + options := getControlPlaneFormatterOptions() + require.Equal(t, len(expectedColumns), len(options.Columns)) + + for i, expected := range expectedColumns { + require.Equal(t, expected.heading, options.Columns[i].Heading) + require.Equal(t, expected.jsonPath, options.Columns[i].JSONPath) + } +} diff --git a/pkg/cli/framework/framework.go b/pkg/cli/framework/framework.go index c8fe2729e57..36e2931c06d 100644 --- a/pkg/cli/framework/framework.go +++ b/pkg/cli/framework/framework.go @@ -34,6 +34,8 @@ import ( "github.com/spf13/cobra" ) +//go:generate mockgen -typed -destination=./mock_factory.go -package=framework -self_package github.com/radius-project/radius/pkg/cli/framework github.com/radius-project/radius/pkg/cli/framework Factory + // Factory interface handles resources for interfacing with corerp and configs type Factory interface { GetBicep() bicep.Interface diff --git a/pkg/cli/framework/mock_factory.go b/pkg/cli/framework/mock_factory.go new file mode 100644 index 00000000000..c74d341ace1 --- /dev/null +++ b/pkg/cli/framework/mock_factory.go @@ -0,0 +1,583 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/radius-project/radius/pkg/cli/framework (interfaces: Factory) +// +// Generated by this command: +// +// mockgen -typed -destination=./mock_factory.go -package=framework -self_package github.com/radius-project/radius/pkg/cli/framework github.com/radius-project/radius/pkg/cli/framework Factory +// + +// Package framework is a generated GoMock package. +package framework + +import ( + reflect "reflect" + + aws "github.com/radius-project/radius/pkg/cli/aws" + azure "github.com/radius-project/radius/pkg/cli/azure" + bicep "github.com/radius-project/radius/pkg/cli/bicep" + namespace "github.com/radius-project/radius/pkg/cli/cmd/env/namespace" + connections "github.com/radius-project/radius/pkg/cli/connections" + deploy "github.com/radius-project/radius/pkg/cli/deploy" + helm "github.com/radius-project/radius/pkg/cli/helm" + kubernetes "github.com/radius-project/radius/pkg/cli/kubernetes" + logstream "github.com/radius-project/radius/pkg/cli/kubernetes/logstream" + portforward "github.com/radius-project/radius/pkg/cli/kubernetes/portforward" + output "github.com/radius-project/radius/pkg/cli/output" + prompt "github.com/radius-project/radius/pkg/cli/prompt" + gomock "go.uber.org/mock/gomock" +) + +// MockFactory is a mock of Factory interface. +type MockFactory struct { + ctrl *gomock.Controller + recorder *MockFactoryMockRecorder +} + +// MockFactoryMockRecorder is the mock recorder for MockFactory. +type MockFactoryMockRecorder struct { + mock *MockFactory +} + +// NewMockFactory creates a new mock instance. +func NewMockFactory(ctrl *gomock.Controller) *MockFactory { + mock := &MockFactory{ctrl: ctrl} + mock.recorder = &MockFactoryMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFactory) EXPECT() *MockFactoryMockRecorder { + return m.recorder +} + +// GetAWSClient mocks base method. +func (m *MockFactory) GetAWSClient() aws.Client { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAWSClient") + ret0, _ := ret[0].(aws.Client) + return ret0 +} + +// GetAWSClient indicates an expected call of GetAWSClient. +func (mr *MockFactoryMockRecorder) GetAWSClient() *MockFactoryGetAWSClientCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAWSClient", reflect.TypeOf((*MockFactory)(nil).GetAWSClient)) + return &MockFactoryGetAWSClientCall{Call: call} +} + +// MockFactoryGetAWSClientCall wrap *gomock.Call +type MockFactoryGetAWSClientCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetAWSClientCall) Return(arg0 aws.Client) *MockFactoryGetAWSClientCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetAWSClientCall) Do(f func() aws.Client) *MockFactoryGetAWSClientCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetAWSClientCall) DoAndReturn(f func() aws.Client) *MockFactoryGetAWSClientCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetAzureClient mocks base method. +func (m *MockFactory) GetAzureClient() azure.Client { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAzureClient") + ret0, _ := ret[0].(azure.Client) + return ret0 +} + +// GetAzureClient indicates an expected call of GetAzureClient. +func (mr *MockFactoryMockRecorder) GetAzureClient() *MockFactoryGetAzureClientCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAzureClient", reflect.TypeOf((*MockFactory)(nil).GetAzureClient)) + return &MockFactoryGetAzureClientCall{Call: call} +} + +// MockFactoryGetAzureClientCall wrap *gomock.Call +type MockFactoryGetAzureClientCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetAzureClientCall) Return(arg0 azure.Client) *MockFactoryGetAzureClientCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetAzureClientCall) Do(f func() azure.Client) *MockFactoryGetAzureClientCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetAzureClientCall) DoAndReturn(f func() azure.Client) *MockFactoryGetAzureClientCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetBicep mocks base method. +func (m *MockFactory) GetBicep() bicep.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBicep") + ret0, _ := ret[0].(bicep.Interface) + return ret0 +} + +// GetBicep indicates an expected call of GetBicep. +func (mr *MockFactoryMockRecorder) GetBicep() *MockFactoryGetBicepCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBicep", reflect.TypeOf((*MockFactory)(nil).GetBicep)) + return &MockFactoryGetBicepCall{Call: call} +} + +// MockFactoryGetBicepCall wrap *gomock.Call +type MockFactoryGetBicepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetBicepCall) Return(arg0 bicep.Interface) *MockFactoryGetBicepCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetBicepCall) Do(f func() bicep.Interface) *MockFactoryGetBicepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetBicepCall) DoAndReturn(f func() bicep.Interface) *MockFactoryGetBicepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetConfigFileInterface mocks base method. +func (m *MockFactory) GetConfigFileInterface() ConfigFileInterface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConfigFileInterface") + ret0, _ := ret[0].(ConfigFileInterface) + return ret0 +} + +// GetConfigFileInterface indicates an expected call of GetConfigFileInterface. +func (mr *MockFactoryMockRecorder) GetConfigFileInterface() *MockFactoryGetConfigFileInterfaceCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConfigFileInterface", reflect.TypeOf((*MockFactory)(nil).GetConfigFileInterface)) + return &MockFactoryGetConfigFileInterfaceCall{Call: call} +} + +// MockFactoryGetConfigFileInterfaceCall wrap *gomock.Call +type MockFactoryGetConfigFileInterfaceCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetConfigFileInterfaceCall) Return(arg0 ConfigFileInterface) *MockFactoryGetConfigFileInterfaceCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetConfigFileInterfaceCall) Do(f func() ConfigFileInterface) *MockFactoryGetConfigFileInterfaceCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetConfigFileInterfaceCall) DoAndReturn(f func() ConfigFileInterface) *MockFactoryGetConfigFileInterfaceCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetConfigHolder mocks base method. +func (m *MockFactory) GetConfigHolder() *ConfigHolder { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConfigHolder") + ret0, _ := ret[0].(*ConfigHolder) + return ret0 +} + +// GetConfigHolder indicates an expected call of GetConfigHolder. +func (mr *MockFactoryMockRecorder) GetConfigHolder() *MockFactoryGetConfigHolderCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConfigHolder", reflect.TypeOf((*MockFactory)(nil).GetConfigHolder)) + return &MockFactoryGetConfigHolderCall{Call: call} +} + +// MockFactoryGetConfigHolderCall wrap *gomock.Call +type MockFactoryGetConfigHolderCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetConfigHolderCall) Return(arg0 *ConfigHolder) *MockFactoryGetConfigHolderCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetConfigHolderCall) Do(f func() *ConfigHolder) *MockFactoryGetConfigHolderCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetConfigHolderCall) DoAndReturn(f func() *ConfigHolder) *MockFactoryGetConfigHolderCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetConnectionFactory mocks base method. +func (m *MockFactory) GetConnectionFactory() connections.Factory { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConnectionFactory") + ret0, _ := ret[0].(connections.Factory) + return ret0 +} + +// GetConnectionFactory indicates an expected call of GetConnectionFactory. +func (mr *MockFactoryMockRecorder) GetConnectionFactory() *MockFactoryGetConnectionFactoryCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConnectionFactory", reflect.TypeOf((*MockFactory)(nil).GetConnectionFactory)) + return &MockFactoryGetConnectionFactoryCall{Call: call} +} + +// MockFactoryGetConnectionFactoryCall wrap *gomock.Call +type MockFactoryGetConnectionFactoryCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetConnectionFactoryCall) Return(arg0 connections.Factory) *MockFactoryGetConnectionFactoryCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetConnectionFactoryCall) Do(f func() connections.Factory) *MockFactoryGetConnectionFactoryCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetConnectionFactoryCall) DoAndReturn(f func() connections.Factory) *MockFactoryGetConnectionFactoryCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetDeploy mocks base method. +func (m *MockFactory) GetDeploy() deploy.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDeploy") + ret0, _ := ret[0].(deploy.Interface) + return ret0 +} + +// GetDeploy indicates an expected call of GetDeploy. +func (mr *MockFactoryMockRecorder) GetDeploy() *MockFactoryGetDeployCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeploy", reflect.TypeOf((*MockFactory)(nil).GetDeploy)) + return &MockFactoryGetDeployCall{Call: call} +} + +// MockFactoryGetDeployCall wrap *gomock.Call +type MockFactoryGetDeployCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetDeployCall) Return(arg0 deploy.Interface) *MockFactoryGetDeployCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetDeployCall) Do(f func() deploy.Interface) *MockFactoryGetDeployCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetDeployCall) DoAndReturn(f func() deploy.Interface) *MockFactoryGetDeployCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetHelmInterface mocks base method. +func (m *MockFactory) GetHelmInterface() helm.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetHelmInterface") + ret0, _ := ret[0].(helm.Interface) + return ret0 +} + +// GetHelmInterface indicates an expected call of GetHelmInterface. +func (mr *MockFactoryMockRecorder) GetHelmInterface() *MockFactoryGetHelmInterfaceCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHelmInterface", reflect.TypeOf((*MockFactory)(nil).GetHelmInterface)) + return &MockFactoryGetHelmInterfaceCall{Call: call} +} + +// MockFactoryGetHelmInterfaceCall wrap *gomock.Call +type MockFactoryGetHelmInterfaceCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetHelmInterfaceCall) Return(arg0 helm.Interface) *MockFactoryGetHelmInterfaceCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetHelmInterfaceCall) Do(f func() helm.Interface) *MockFactoryGetHelmInterfaceCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetHelmInterfaceCall) DoAndReturn(f func() helm.Interface) *MockFactoryGetHelmInterfaceCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetKubernetesInterface mocks base method. +func (m *MockFactory) GetKubernetesInterface() kubernetes.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetKubernetesInterface") + ret0, _ := ret[0].(kubernetes.Interface) + return ret0 +} + +// GetKubernetesInterface indicates an expected call of GetKubernetesInterface. +func (mr *MockFactoryMockRecorder) GetKubernetesInterface() *MockFactoryGetKubernetesInterfaceCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetKubernetesInterface", reflect.TypeOf((*MockFactory)(nil).GetKubernetesInterface)) + return &MockFactoryGetKubernetesInterfaceCall{Call: call} +} + +// MockFactoryGetKubernetesInterfaceCall wrap *gomock.Call +type MockFactoryGetKubernetesInterfaceCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetKubernetesInterfaceCall) Return(arg0 kubernetes.Interface) *MockFactoryGetKubernetesInterfaceCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetKubernetesInterfaceCall) Do(f func() kubernetes.Interface) *MockFactoryGetKubernetesInterfaceCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetKubernetesInterfaceCall) DoAndReturn(f func() kubernetes.Interface) *MockFactoryGetKubernetesInterfaceCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetLogstream mocks base method. +func (m *MockFactory) GetLogstream() logstream.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLogstream") + ret0, _ := ret[0].(logstream.Interface) + return ret0 +} + +// GetLogstream indicates an expected call of GetLogstream. +func (mr *MockFactoryMockRecorder) GetLogstream() *MockFactoryGetLogstreamCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogstream", reflect.TypeOf((*MockFactory)(nil).GetLogstream)) + return &MockFactoryGetLogstreamCall{Call: call} +} + +// MockFactoryGetLogstreamCall wrap *gomock.Call +type MockFactoryGetLogstreamCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetLogstreamCall) Return(arg0 logstream.Interface) *MockFactoryGetLogstreamCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetLogstreamCall) Do(f func() logstream.Interface) *MockFactoryGetLogstreamCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetLogstreamCall) DoAndReturn(f func() logstream.Interface) *MockFactoryGetLogstreamCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetNamespaceInterface mocks base method. +func (m *MockFactory) GetNamespaceInterface() namespace.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNamespaceInterface") + ret0, _ := ret[0].(namespace.Interface) + return ret0 +} + +// GetNamespaceInterface indicates an expected call of GetNamespaceInterface. +func (mr *MockFactoryMockRecorder) GetNamespaceInterface() *MockFactoryGetNamespaceInterfaceCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNamespaceInterface", reflect.TypeOf((*MockFactory)(nil).GetNamespaceInterface)) + return &MockFactoryGetNamespaceInterfaceCall{Call: call} +} + +// MockFactoryGetNamespaceInterfaceCall wrap *gomock.Call +type MockFactoryGetNamespaceInterfaceCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetNamespaceInterfaceCall) Return(arg0 namespace.Interface) *MockFactoryGetNamespaceInterfaceCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetNamespaceInterfaceCall) Do(f func() namespace.Interface) *MockFactoryGetNamespaceInterfaceCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetNamespaceInterfaceCall) DoAndReturn(f func() namespace.Interface) *MockFactoryGetNamespaceInterfaceCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetOutput mocks base method. +func (m *MockFactory) GetOutput() output.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOutput") + ret0, _ := ret[0].(output.Interface) + return ret0 +} + +// GetOutput indicates an expected call of GetOutput. +func (mr *MockFactoryMockRecorder) GetOutput() *MockFactoryGetOutputCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOutput", reflect.TypeOf((*MockFactory)(nil).GetOutput)) + return &MockFactoryGetOutputCall{Call: call} +} + +// MockFactoryGetOutputCall wrap *gomock.Call +type MockFactoryGetOutputCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetOutputCall) Return(arg0 output.Interface) *MockFactoryGetOutputCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetOutputCall) Do(f func() output.Interface) *MockFactoryGetOutputCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetOutputCall) DoAndReturn(f func() output.Interface) *MockFactoryGetOutputCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetPortforward mocks base method. +func (m *MockFactory) GetPortforward() portforward.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPortforward") + ret0, _ := ret[0].(portforward.Interface) + return ret0 +} + +// GetPortforward indicates an expected call of GetPortforward. +func (mr *MockFactoryMockRecorder) GetPortforward() *MockFactoryGetPortforwardCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPortforward", reflect.TypeOf((*MockFactory)(nil).GetPortforward)) + return &MockFactoryGetPortforwardCall{Call: call} +} + +// MockFactoryGetPortforwardCall wrap *gomock.Call +type MockFactoryGetPortforwardCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetPortforwardCall) Return(arg0 portforward.Interface) *MockFactoryGetPortforwardCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetPortforwardCall) Do(f func() portforward.Interface) *MockFactoryGetPortforwardCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetPortforwardCall) DoAndReturn(f func() portforward.Interface) *MockFactoryGetPortforwardCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetPrompter mocks base method. +func (m *MockFactory) GetPrompter() prompt.Interface { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPrompter") + ret0, _ := ret[0].(prompt.Interface) + return ret0 +} + +// GetPrompter indicates an expected call of GetPrompter. +func (mr *MockFactoryMockRecorder) GetPrompter() *MockFactoryGetPrompterCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPrompter", reflect.TypeOf((*MockFactory)(nil).GetPrompter)) + return &MockFactoryGetPrompterCall{Call: call} +} + +// MockFactoryGetPrompterCall wrap *gomock.Call +type MockFactoryGetPrompterCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFactoryGetPrompterCall) Return(arg0 prompt.Interface) *MockFactoryGetPrompterCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFactoryGetPrompterCall) Do(f func() prompt.Interface) *MockFactoryGetPrompterCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFactoryGetPrompterCall) DoAndReturn(f func() prompt.Interface) *MockFactoryGetPrompterCall { + c.Call = c.Call.DoAndReturn(f) + return c +} diff --git a/pkg/cli/output/mock_writer.go b/pkg/cli/output/mock_writer.go index 8f40097fa48..cc92139b6ba 100644 --- a/pkg/cli/output/mock_writer.go +++ b/pkg/cli/output/mock_writer.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/radius-project/radius/pkg/cli/output (interfaces: Interface) +// +// Generated by this command: +// +// mockgen -typed -destination=./mock_writer.go -package=output -self_package github.com/radius-project/radius/pkg/cli/output github.com/radius-project/radius/pkg/cli/output Interface +// // Package output is a generated GoMock package. package output @@ -33,16 +38,160 @@ func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { return m.recorder } -// Write mocks base method. -func (m *MockInterface) Write(arg0 string, arg1 any, arg2 FormatterOptions) error { +// BeginStep mocks base method. +func (m *MockInterface) BeginStep(arg0 string, arg1 ...any) Step { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Write", arg0, arg1, arg2) + varargs := []any{arg0} + for _, a := range arg1 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "BeginStep", varargs...) + ret0, _ := ret[0].(Step) + return ret0 +} + +// BeginStep indicates an expected call of BeginStep. +func (mr *MockInterfaceMockRecorder) BeginStep(arg0 any, arg1 ...any) *MockInterfaceBeginStepCall { + mr.mock.ctrl.T.Helper() + varargs := append([]any{arg0}, arg1...) + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BeginStep", reflect.TypeOf((*MockInterface)(nil).BeginStep), varargs...) + return &MockInterfaceBeginStepCall{Call: call} +} + +// MockInterfaceBeginStepCall wrap *gomock.Call +type MockInterfaceBeginStepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceBeginStepCall) Return(arg0 Step) *MockInterfaceBeginStepCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceBeginStepCall) Do(f func(string, ...any) Step) *MockInterfaceBeginStepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceBeginStepCall) DoAndReturn(f func(string, ...any) Step) *MockInterfaceBeginStepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// CompleteStep mocks base method. +func (m *MockInterface) CompleteStep(arg0 Step) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "CompleteStep", arg0) +} + +// CompleteStep indicates an expected call of CompleteStep. +func (mr *MockInterfaceMockRecorder) CompleteStep(arg0 any) *MockInterfaceCompleteStepCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompleteStep", reflect.TypeOf((*MockInterface)(nil).CompleteStep), arg0) + return &MockInterfaceCompleteStepCall{Call: call} +} + +// MockInterfaceCompleteStepCall wrap *gomock.Call +type MockInterfaceCompleteStepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceCompleteStepCall) Return() *MockInterfaceCompleteStepCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceCompleteStepCall) Do(f func(Step)) *MockInterfaceCompleteStepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceCompleteStepCall) DoAndReturn(f func(Step)) *MockInterfaceCompleteStepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// LogInfo mocks base method. +func (m *MockInterface) LogInfo(arg0 string, arg1 ...any) { + m.ctrl.T.Helper() + varargs := []any{arg0} + for _, a := range arg1 { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "LogInfo", varargs...) +} + +// LogInfo indicates an expected call of LogInfo. +func (mr *MockInterfaceMockRecorder) LogInfo(arg0 any, arg1 ...any) *MockInterfaceLogInfoCall { + mr.mock.ctrl.T.Helper() + varargs := append([]any{arg0}, arg1...) + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogInfo", reflect.TypeOf((*MockInterface)(nil).LogInfo), varargs...) + return &MockInterfaceLogInfoCall{Call: call} +} + +// MockInterfaceLogInfoCall wrap *gomock.Call +type MockInterfaceLogInfoCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceLogInfoCall) Return() *MockInterfaceLogInfoCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceLogInfoCall) Do(f func(string, ...any)) *MockInterfaceLogInfoCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceLogInfoCall) DoAndReturn(f func(string, ...any)) *MockInterfaceLogInfoCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// WriteFormatted mocks base method. +func (m *MockInterface) WriteFormatted(arg0 string, arg1 any, arg2 FormatterOptions) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteFormatted", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } -// Write indicates an expected call of Write. -func (mr *MockInterfaceMockRecorder) Write(arg0, arg1, arg2 any) *gomock.Call { +// WriteFormatted indicates an expected call of WriteFormatted. +func (mr *MockInterfaceMockRecorder) WriteFormatted(arg0, arg1, arg2 any) *MockInterfaceWriteFormattedCall { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockInterface)(nil).Write), arg0, arg1, arg2) + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteFormatted", reflect.TypeOf((*MockInterface)(nil).WriteFormatted), arg0, arg1, arg2) + return &MockInterfaceWriteFormattedCall{Call: call} +} + +// MockInterfaceWriteFormattedCall wrap *gomock.Call +type MockInterfaceWriteFormattedCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockInterfaceWriteFormattedCall) Return(arg0 error) *MockInterfaceWriteFormattedCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockInterfaceWriteFormattedCall) Do(f func(string, any, FormatterOptions) error) *MockInterfaceWriteFormattedCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockInterfaceWriteFormattedCall) DoAndReturn(f func(string, any, FormatterOptions) error) *MockInterfaceWriteFormattedCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/pkg/cli/output/writer.go b/pkg/cli/output/writer.go index d11973e769c..2fff33ae17e 100644 --- a/pkg/cli/output/writer.go +++ b/pkg/cli/output/writer.go @@ -21,6 +21,8 @@ import ( "io" ) +//go:generate mockgen -typed -destination=./mock_writer.go -package=output -self_package github.com/radius-project/radius/pkg/cli/output github.com/radius-project/radius/pkg/cli/output Interface + // Interface is a mockable interface for writing cli output type Interface interface { // LogInfo logs a message that is displayed to the user by default.