### MockClient: Install and Upgrade Charts (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.0/mock_tab=versions Provides Go code examples for the MockClient's InstallChart and UpgradeChart methods. These mocks simulate the installation or upgrade of a Helm chart and return a release object or an error. They require a context and a ChartSpec. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) ``` ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call ``` -------------------------------- ### Install Go Helm Client Library Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/index This command installs the go-helm-client library using the `go get` command. Ensure you have Go installed and configured correctly. ```bash go get github.com/mittwald/go-helm-client ``` -------------------------------- ### MockClient: Install and Upgrade Chart (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.10/mock_tab=versions Provides mock implementations for installing and upgrading Helm charts. These functions simulate the behavior of the Helm client's install and upgrade operations, returning mock release information or errors. ```go type MockClient struct { ctrl *gomock.Controller recorder *MockClientMockRecorder } type MockClientMockRecorder struct { } func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallChart", reflect.TypeOf((*MockClient)(nil).InstallChart), ctx, spec) } func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpgradeChart", reflect.TypeOf((*MockClient)(nil).UpgradeChart), ctx, spec) } ``` -------------------------------- ### MockClient Method: InstallChart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.3/mock Mocks the InstallChart method, allowing tests to simulate the installation of Helm charts and verify the installation process. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, ...) (*release.Release, error) ``` -------------------------------- ### MockClient: Install, Upgrade, and List Releases (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.7.0/mock_tab=versions This snippet demonstrates mocking three core Helm operations: installing a chart, upgrading a chart, and listing releases based on their state. It uses `context.Context` for install/upgrade and accepts a state mask for listing. This is crucial for testing Helm deployment pipelines. ```go import ( "context" "github.com/helm/helm/pkg/action" "helm.sh/helm/v3/pkg/release" "github.com/mittwald/go-helm-client" ) type MockClient struct { // ... other fields } func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { // Implementation details return nil, nil } func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { // Implementation details return nil, nil } func (m *MockClient) ListReleasesByStateMask(arg0 action.ListStates) ([]*release.Release, error) { // Implementation details return nil, nil } ``` -------------------------------- ### MockClient: Get Providers and Settings (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.9.3/mock_tab=versions Demonstrates mocking GetProviders and GetSettings from the MockClient. These mocks are useful for testing components that interact with Helm's provider information and environment settings in a controlled manner, ensuring predictable behavior during tests. ```go func (m *MockClient) GetProviders() getter.Providers { ret := m.ctrl.Call(m, "GetProviders") ret0, _ := ret[0].(getter.Providers) return ret0 } func (mr *MockClientMockRecorder) GetProviders() *gomock.Call { return mr.recorder.On("GetProviders") } func (m *MockClient) GetSettings() *cli.EnvSettings { ret := m.ctrl.Call(m, "GetSettings") ret0, _ := ret[0].(*cli.EnvSettings) return ret0 } func (mr *MockClientMockRecorder) GetSettings() *gomock.Call { return mr.recorder.On("GetSettings") } ``` -------------------------------- ### MockClient: Install and Upgrade Helm Charts (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.9.3/mock_tab=versions Demonstrates how to mock the InstallChart and UpgradeChart functions of the MockClient. These mocks are useful for testing logic that depends on Helm chart installations or upgrades without performing actual Helm operations. They take context and chart specifications as input. ```go type MockClient struct { ctrl *gomock.Controller recorder *MockClientMockRecorder } type MockClientMockRecorder struct { recorder record.Recorder } func NewMockClient(ctrl gomock.Controller) *MockClient { mock := &MockClient{ctrl: ctrl} mock.recorder = &MockClientMockRecorder{recorder: ctrl.RecordDirTO} return mock } func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { ret := m.ctrl.Call(m, "InstallChart", ctx, spec) ret0, _ := ret[0].(*release.Release) ret1, _ := ret[1].(error) return ret0, ret1 } func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call { return mr.recorder.On("InstallChart", ctx, spec) } func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { ret := m.ctrl.Call(m, "UpgradeChart", ctx, spec) ret0, _ := ret[0].(*release.Release) ret1, _ := ret[1].(error) return ret0, ret1 } func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call { return mr.recorder.On("UpgradeChart", ctx, spec) } ``` -------------------------------- ### Go MockClient Install, List, and Upgrade Chart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.4.1/mock_tab=versions This Go snippet showcases mock functions for installing, listing deployed releases, and upgrading Helm charts. It utilizes 'context', 'action', and 'release' packages from Helm. ```go package main import ( "context" "github.com/golang/mock/gomock" "github.com/helm/helm-go/pkg/action" "github.com/helm/helm-go/pkg/release" "github.com/mittwald/go-helm-client" ) type MockClient struct { ctrl *gomock.Controller } func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { // Implementation omitted for brevity return nil, nil } func (m *MockClient) ListReleasesByStateMask(arg0 action.ListStates) ([]*release.Release, error) { // Implementation omitted for brevity return nil, nil } func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { // Implementation omitted for brevity return nil, nil } type MockClientMockRecorder struct { ctrl *gomock.Controller } func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call { // Implementation omitted for brevity return nil } func (mr *MockClientMockRecorder) ListReleasesByStateMask(arg0 interface{}) *gomock.Call { // Implementation omitted for brevity return nil } func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call { // Implementation omitted for brevity return nil } ``` -------------------------------- ### MockClient: Install, Upgrade, and List Releases (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.8.5/mock_tab=versions This set of methods on the MockClient facilitates the management of Helm releases. It includes functions for installing new charts, upgrading existing ones, and listing releases based on their state. ```Go package main import ( "context" "github.com/mittwald/go-helm-client" "github.com/mittwald/go-helm-client/pkg/action" "github.com/mittwald/go-helm-client/pkg/helmclient" "github.com/mittwald/go-helm-client/pkg/release" ) func main() { // Mock client setup would typically involve gomock var mockClient *helmclient.MockClient ctx := context.Background() schartSpec := &helmclient.ChartSpec{} // Install Chart released, err := mockClient.InstallChart(ctx, schartSpec) _ = released if err != nil { // Handle error } // Upgrade Chart upgraded, err := mockClient.UpgradeChart(ctx, schartSpec) _ = upgraded if err != nil { // Handle error } // List Releases by State states := action.ListStates{} releases, err := mockClient.ListReleasesByStateMask(states) _ = releases if err != nil { // Handle error } } ``` -------------------------------- ### MockClient: Install, Upgrade, and List Helm Releases (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.16/mock_tab=versions Demonstrates how to use the mock client to install, upgrade, and list Helm releases. It utilizes `context.Context` and `helmclient.ChartSpec` as inputs and returns release information or errors. This is useful for testing Helm client interactions. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) func (m *MockClient) ListReleasesByStateMask(arg0 action.ListStates) ([]*release.Release, error) ``` -------------------------------- ### Mock Helm Client - InstallChart Method - GoMock Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.7/mock This Go code demonstrates mocking the InstallChart function for the Helm client. It allows tests to simulate the installation of a Helm chart with specified context, chart specifications, and options. The mock returns a release object or an error, enabling verification of chart installation logic. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, ...) (*release.Release, error) func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts any) *gomock.Call ``` -------------------------------- ### MockClient: Install Chart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.2/mock Mocks the InstallChart method for a MockClient. This method installs a Helm chart. It requires a context, a ChartSpec defining the chart to install, and optional generic Helm options. It returns a pointer to a release.Release object representing the installed release and an error. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) { // Mock implementation return nil, nil } ``` -------------------------------- ### Go MockClient InstallChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.3/mock Mocks the InstallChart method of the MockClient, enabling the installation of a Helm chart. It takes a context, chart specification, and generic options, returning the installed release or an error. This is crucial for testing chart installation processes. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) InstallChart mocks base method. ``` -------------------------------- ### Install or Upgrade Helm Chart with Custom Values (Go) Source: https://context7.com/context7/pkg_go_dev_github_com_mittwald_go-helm-client/llms.txt This Go example shows how to install a new Helm chart or upgrade an existing release using the go-helm-client. It allows specifying custom values via a YAML string, enabling fine-grained control over the deployment. The snippet includes options for waiting for completion, setting timeouts, and managing namespaces. ```Go package main import ( "context" "log" "time" helmclient "github.com/mittwald/go-helm-client" ) func main() { client, err := helmclient.New(&helmclient.Options{ Namespace: "production", }) if err != nil { log.Fatalf("Failed to create client: %v", err) } chartSpec := &helmclient.ChartSpec{ ReleaseName: "my-nginx", ChartName: "bitnami/nginx", Namespace: "production", Version: "13.2.0", Wait: true, Timeout: 5 * time.Minute, ValuesYaml: ` replicaCount: 3 service: type: LoadBalancer port: 80 resources: limits: cpu: 500m memory: 512Mi requests: cpu: 250m memory: 256Mi `, CreateNamespace: true, DependencyUpdate: true, Atomic: true, CleanupOnFail: true, } ctx := context.Background() release, err := client.InstallOrUpgradeChart(ctx, chartSpec, nil) if err != nil { log.Fatalf("Failed to install/upgrade chart: %v", err) } log.Printf("Successfully deployed release: %s (version: %d, status: %s)", release.Name, release.Version, release.Info.Status) } ``` -------------------------------- ### Mock Helm Client InstallChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/mock Mocks the InstallChart method for installing a new Helm chart. This allows tests to verify installation logic without actually performing a chart installation. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, ...) (*release.Release, error) { // Implementation omitted for brevity } ``` -------------------------------- ### Mock Helm Client: Install Chart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.9.4/mock Mocks the InstallChart method for installing a Helm chart. Allows tests to simulate chart installations and verify expected outcomes without executing actual Helm commands. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { // Implementation omitted for brevity } ``` -------------------------------- ### Install Helm Chart from URL (Go) Source: https://context7.com/context7/pkg_go_dev_github_com_mittwald_go-helm-client/llms.txt This Go code snippet shows how to install a Helm chart directly from a remote URL without needing to add it as a repository first. The go-helm-client library handles fetching and installing the chart specified by the URL, with options for configuration and timeouts. ```Go package main import ( "context" "log" "time" helmclient "github.com/mittwald/go-helm-client" ) func main() { client, err := helmclient.New(&helmclient.Options{ Namespace: "default", }) if err != nil { log.Fatalf("Failed to create client: %v", err) } chartSpec := &helmclient.ChartSpec{ ReleaseName: "remote-app", ChartName: "https://example.com/charts/myapp-1.0.0.tgz", Namespace: "default", Wait: true, Timeout: 5 * time.Minute, } release, err := client.InstallOrUpgradeChart(context.Background(), chartSpec, nil) if err != nil { log.Fatalf("Failed to install from URL: %v", err) } log.Printf("Successfully installed chart from URL: %s", release.Name) } ``` -------------------------------- ### MockClientMockRecorder: InstallChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/mock InstallChart is a mock method to indicate an expected call for installing a Helm chart. It requires a context, chart specification, and options. ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts any) *gomock.Call ``` -------------------------------- ### Recorder for InstallChart - Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.5/mock Records an expected call to the InstallChart method. It allows specifying the 'ctx', 'spec', and 'opts' arguments, returning a gomock.Call object for mock setup. ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts interface{}) *gomock.Call ``` -------------------------------- ### MockClient InstallChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.5/mock The InstallChart method on MockClient installs a Helm chart based on the provided chart specification and generic Helm options. It requires a context, chart spec, and options, returning the installed release and an error. This function mocks the base method. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) ``` -------------------------------- ### MockClient: InstallChart Functionality Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.4/mock This method mocks the InstallChart functionality, used for simulating the installation of a Helm chart during testing. It requires a context, a ChartSpec, and optional Helm options. It returns the installed release object or an error. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) InstallChart mocks base method. ``` ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts interface{}) *gomock.Call InstallChart indicates an expected call of InstallChart. ``` -------------------------------- ### MockClient: Install, Upgrade, List, and Get Releases in Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.15/mock_tab=versions Provides mock implementations for installing, upgrading, listing, and retrieving Helm releases. These functions are crucial for testing Helm client interactions without actual cluster communication. They accept context and chart specifications as input and return release information or errors. ```Go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) func (m *MockClient) ListReleasesByStateMask(arg0 action.ListStates) ([]*release.Release, error) func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call func (mr *MockClientMockRecorder) ListReleasesByStateMask(arg0 interface{}) *gomock.Call ``` -------------------------------- ### MockClient: Mock InstallChart Method (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.9.0/mock This method mocks the InstallChart function, simulating the installation of a Helm chart. It takes a context and a ChartSpec, returning the deployed release and an error. Essential for testing chart installation workflows. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { // ... implementation details ... } ``` -------------------------------- ### Mock Helm Client: Install Chart in Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.6/mock This method mocks the InstallChart function for installing a Helm chart. Tests can use this to verify that chart installation was attempted with the correct specifications. It takes a context, chart spec, and options, returning the deployed release or an error. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, ... *release.Release, error) { // ... implementation details ... } ``` -------------------------------- ### MockClient: InstallChart Mock - Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.1/mock Mocks the InstallChart method for installing a Helm chart. It accepts a context, chart specification, and options, returning the installed release and an error. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts ...interface{}) (*release.Release, error) { // Mock implementation return nil, nil } ``` -------------------------------- ### Install Helm Chart from Local Archive (Go) Source: https://context7.com/context7/pkg_go_dev_github_com_mittwald_go-helm-client/llms.txt This Go code demonstrates how to install a Helm chart directly from a local .tgz archive file using the go-helm-client library. It specifies the local path to the chart archive and allows for custom values and namespace configuration during installation. ```Go package main import ( "context" "log" "time" helmclient "github.com/mittwald/go-helm-client" ) func main() { client, err := helmclient.New(&helmclient.Options{ Namespace: "default", }) if err != nil { log.Fatalf("Failed to create client: %v", err) } chartSpec := &helmclient.ChartSpec{ ReleaseName: "local-app", ChartName: "./path/to/mychart-1.0.0.tgz", Namespace: "default", Wait: true, Timeout: 3 * time.Minute, ValuesYaml: `replicas: 2`, } release, err := client.InstallOrUpgradeChart(context.Background(), chartSpec, nil) if err != nil { log.Fatalf("Failed to install from local archive: %v", err) } log.Printf("Successfully installed local chart: %s", release.Name) } ``` -------------------------------- ### MockClient Install, Upgrade, and ListReleases in Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.10.0/mock_tab=versions Documents mock functions for installing, upgrading, and listing Helm releases. These mocks are essential for testing Helm deployment and management workflows. ```go type MockClient + func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) + func (m *MockClient) ListReleasesByStateMask(arg0 action.ListStates) ([]*release.Release, error) + func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) type MockClientMockRecorder + func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call + func (mr *MockClientMockRecorder) ListReleasesByStateMask(arg0 interface{}) *gomock.Call + func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call ``` -------------------------------- ### MockClient InstallChart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.1/mock Mocks the InstallChart method of the helmclient.Client interface. It takes a context, chart specification, and generic options, returning a release object and an error. This mock is for simulating chart installations during testing. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) { return nil, nil } ``` -------------------------------- ### Mock Helm Client: Get Chart and Run Tests (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.4/mock_tab=versions Provides examples for mocking `GetChart` and `RunChartTests` functions. `GetChart` allows mocking the retrieval of chart details, while `RunChartTests` mocks the execution of chart tests, both useful for unit testing Helm interactions. ```go package main import ( "github.com/golang/mock/gomock" "github.com/mittwald/go-helm-client" "github.com/mittwald/go-helm-client/pkg/action" "github.com/mittwald/go-helm-client/pkg/chart" "github.com/mittwald/go-helm-client/pkg/helmclient" ) func main() { ctrl := gomock.NewController(nil) defer ctrl.Finish() mockClient := helmclient.NewMockClient(ctrl) // Example: Mocking GetChart chart := &chart.Chart{} chartPathOptions := &action.ChartPathOptions{} mockClient.EXPECT().GetChart("my-chart", chartPathOptions).Return(chart, "/path/to/chart", nil) // Example: Mocking RunChartTests mockClient.EXPECT().RunChartTests("my-release-name").Return(true, nil) // In a real test, you would then call your code that uses mockClient } ``` -------------------------------- ### Chart Installation and Upgrades Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/index_tab=doc APIs for installing and upgrading Helm charts with specified configurations. ```APIDOC ## POST /api/charts/install-upgrade ### Description Installs or upgrades a Helm chart based on the provided specification and options. ### Method POST ### Endpoint /api/charts/install-upgrade ### Parameters #### Request Body - **spec** (ChartSpec) - Required - The specification for the chart to install or upgrade. - **opts** (GenericHelmOptions) - Optional - Generic Helm options, including post-renderer and rollback configuration. ### Request Example ```json { "spec": { "chart": "mychart", "version": "1.0.0", "namespace": "default", "values": "a: 1\nb: 2" }, "opts": {} } ``` ### Response #### Success Response (200) - **release** (release.Release) - The release object representing the installed or upgraded chart. #### Response Example ```json { "name": "mychart-1-0-0", "namespace": "default", "version": 1, "status": "deployed" } ``` ``` ```APIDOC ## POST /api/charts/install ### Description Installs a Helm chart with the provided specification and options. ### Method POST ### Endpoint /api/charts/install ### Parameters #### Request Body - **spec** (ChartSpec) - Required - The specification for the chart to install. - **opts** (GenericHelmOptions) - Optional - Generic Helm options, including post-renderer and rollback configuration. ### Request Example ```json { "spec": { "chart": "mychart", "version": "1.0.0", "namespace": "default" }, "opts": {} } ``` ### Response #### Success Response (200) - **release** (release.Release) - The release object representing the installed chart. #### Response Example ```json { "name": "mychart-1-0-0", "namespace": "default", "version": 1, "status": "deployed" } ``` ``` ```APIDOC ## POST /api/charts/upgrade ### Description Upgrades an existing Helm chart with the provided specification and options. ### Method POST ### Endpoint /api/charts/upgrade ### Parameters #### Request Body - **spec** (ChartSpec) - Required - The specification for the chart to upgrade. - **opts** (GenericHelmOptions) - Optional - Generic Helm options, including post-renderer and rollback configuration. ### Request Example ```json { "spec": { "chart": "mychart", "version": "1.1.0", "namespace": "default" }, "opts": {} } ``` ### Response #### Success Response (200) - **release** (release.Release) - The release object representing the upgraded chart. #### Response Example ```json { "name": "mychart-1-1-0", "namespace": "default", "version": 2, "status": "deployed" } ``` ``` -------------------------------- ### Install Helm Chart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/index Installs a Helm chart based on the provided `ChartSpec` and options. This function handles the creation of a new release. ```go release, err := c.InstallChart(ctx context.Context, spec *ChartSpec, opts *GenericHelmOptions) (*release.Release, error) ``` -------------------------------- ### Mock Helm Client Mock Recorder: Install Chart in Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.5/mock This mock recorder is used to define expectations for the InstallChart method. It captures the context, chart specification, and any additional options passed to the mocked installation call. ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts interface{}) *gomock.Call { // Mock recorder implementation provided by GoMock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock.ctrl.T, reflect.TypeOf((*MockClient)(nil)).Elem(), "InstallChart", reflect.TypeOf((*context.Context)(nil)).Elem(), reflect.TypeOf((*helmclient.ChartSpec)(nil)).Elem()) } ``` -------------------------------- ### MockClient: InstallChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.1/mock Mocks the InstallChart method for installing a new Helm chart. It takes a context, chart specification, and optional Helm options. It returns the installed release object or an error. This is crucial for testing chart installation workflows. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) { // Mock implementation } ``` -------------------------------- ### MockClient: Install and Upgrade Charts in Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.18/mock_tab=versions Provides methods to install and upgrade Helm charts using a MockClient. These functions take a context and a chart specification as input and return the release information or an error. They are part of the go-helm-client library. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) ``` -------------------------------- ### Mock InstallChart Method - Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.5/mock Mocks the InstallChart method for installing a Helm chart. It takes a context, chart specification, and options, returning the deployed release or an error. This allows for testing chart installation workflows. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, ...) (*release.Release, error) ``` -------------------------------- ### MockClient: Install or Upgrade Chart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.2/mock Mocks the InstallOrUpgradeChart method for a MockClient. This method installs a chart if it's not already installed, or upgrades it if it exists. It takes a context, a ChartSpec, and optional Helm options. It returns the resulting release information or an error. ```go func (m *MockClient) InstallOrUpgradeChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) { // Mock implementation return nil, nil } ``` -------------------------------- ### MockClient: InstallChart Method (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/mock Mocks the InstallChart method for installing a Helm chart. It takes a context, chart specification, and generic options, returning the deployed release and an error. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) { // Implementation details for mocking } ``` -------------------------------- ### Go MockClient Mock Recorder Functions Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.14/mock This snippet shows various mock functions for the MockClientMockRecorder in Go. These functions allow for the simulation of expected calls to a Helm client, facilitating testing scenarios. They cover operations like getting release values, settings, installing, upgrading, uninstalling charts, and managing release history. ```go func (mr *MockClientMockRecorder) GetReleaseValues(name, allValues any) *gomock.Call GetReleaseValues indicates an expected call of GetReleaseValues. ``` ```go func (mr *MockClientMockRecorder) GetSettings() *gomock.Call GetSettings indicates an expected call of GetSettings. ``` ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts any) *gomock.Call InstallChart indicates an expected call of InstallChart. ``` ```go func (mr *MockClientMockRecorder) InstallOrUpgradeChart(ctx, spec, opts any) *gomock.Call InstallOrUpgradeChart indicates an expected call of InstallOrUpgradeChart. ``` ```go func (mr *MockClientMockRecorder) LintChart(spec any) *gomock.Call LintChart indicates an expected call of LintChart. ``` ```go func (mr *MockClientMockRecorder) ListDeployedReleases() *gomock.Call ListDeployedReleases indicates an expected call of ListDeployedReleases. ``` ```go func (mr *MockClientMockRecorder) ListReleaseHistory(name, max any) *gomock.Call ListReleaseHistory indicates an expected call of ListReleaseHistory. ``` ```go func (mr *MockClientMockRecorder) ListReleasesByStateMask(arg0 any) *gomock.Call ListReleasesByStateMask indicates an expected call of ListReleasesByStateMask. ``` ```go func (mr *MockClientMockRecorder) RollbackRelease(spec any) *gomock.Call RollbackRelease indicates an expected call of RollbackRelease. ``` ```go func (mr *MockClientMockRecorder) RunChartTests(releaseName any) *gomock.Call RunChartTests indicates an expected call of RunChartTests. ``` ```go func (mr *MockClientMockRecorder) SetDebugLog(debugLog any) *gomock.Call SetDebugLog indicates an expected call of SetDebugLog. ``` ```go func (mr *MockClientMockRecorder) TemplateChart(spec, options any) *gomock.Call TemplateChart indicates an expected call of TemplateChart. ``` ```go func (mr *MockClientMockRecorder) UninstallRelease(spec any) *gomock.Call UninstallRelease indicates an expected call of UninstallRelease. ``` ```go func (mr *MockClientMockRecorder) UninstallReleaseByName(name any) *gomock.Call UninstallReleaseByName indicates an expected call of UninstallReleaseByName. ``` ```go func (mr *MockClientMockRecorder) UpdateChartRepos() *gomock.Call UpdateChartRepos indicates an expected call of UpdateChartRepos. ``` ```go func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec, opts any) *gomock.Call UpgradeChart indicates an expected call of UpgradeChart. ``` -------------------------------- ### MockClient InstallChart Method - Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.0/mock Mocks the InstallChart method for testing Helm chart installations. It accepts a context, chart specifications, and optional parameters, returning the installed release and any errors. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, ...) (*release.Release, error) { // ... implementation details ... } ``` -------------------------------- ### MockClient: Install and Upgrade Charts (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.2/mock_tab=versions Handles the installation and upgrading of Helm charts. These methods accept a context and a ChartSpec, returning the deployed release information or an error. They are fundamental for managing application lifecycles with Helm. ```go type MockClient + func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) + func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) type MockClientMockRecorder + func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call + func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call ``` -------------------------------- ### Mock Helm Client: Install or Upgrade Chart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.9.4/mock Mocks the InstallOrUpgradeChart method, which handles both installation and upgrading of Helm charts. Useful for testing logic that conditionally installs or updates charts. ```go func (m *MockClient) InstallOrUpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) { // Implementation omitted for brevity } ``` -------------------------------- ### MockClient: InstallChart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.10/mock Mocks the InstallChart method for installing a Helm chart. It takes a context, chart specification, and generic options, returning the deployed release or an error. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) { // Implementation omitted for brevity } ``` -------------------------------- ### Mock Helm Client InstallOrUpgradeChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/mock Mocks the InstallOrUpgradeChart method, which handles both installing a new chart and upgrading an existing one. This is useful for testing combined installation and upgrade workflows. ```go func (m *MockClient) InstallOrUpgradeChart(ctx context.Context, spec *helmclient.ChartSpec, ...) (*release.Release, error) { // Implementation omitted for brevity } ``` -------------------------------- ### Mock Helm Client Recorder: Install Chart Expectations Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.9.4/mock Sets expectations for the InstallChart method. This recorder helps in defining the expected arguments and return values for mocked chart installations. ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call { // Implementation omitted for brevity } ``` -------------------------------- ### MockClient: Install, Upgrade, and List Releases (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.11.2/mock_tab=versions This snippet covers mocking the InstallChart, UpgradeChart, and ListReleasesByStateMask methods of the MockClient. This is useful for testing deployment pipelines, upgrade processes, and release listing functionalities in a controlled environment. ```Go package main import ( "context" "github.com/golang/mock/gomock" "github.com/mittwald/go-helm-client" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/release" ) func main() { ctrl := gomock.NewController(nil) mockClient := helmclient.NewMockClient(ctrl) // Mocking InstallChart installSpec := &helmclient.ChartSpec{} ctx := context.Background() mockRelease := &release.Release{} mockClient.EXPECT().InstallChart(ctx, installSpec).Return(mockRelease, nil) // Mocking UpgradeChart upgradeSpec := &helmclient.ChartSpec{} mockClient.EXPECT().UpgradeChart(ctx, upgradeSpec).Return(mockRelease, nil) // Mocking ListReleasesByStateMask stateMask := action.ListDeployed var releases []*release.Release mockClient.EXPECT().ListReleasesByStateMask(stateMask).Return(releases, nil) // Example usage (would typically be in a test) // installedRelease, err := mockClient.InstallChart(ctx, installSpec) // upgradedRelease, err := mockClient.UpgradeChart(ctx, upgradeSpec) // listedReleases, err := mockClient.ListReleasesByStateMask(stateMask) } ``` -------------------------------- ### Go: MockClient Install, Upgrade, and List Releases Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.3/mock_tab=versions Mocks for installing, upgrading, and listing Helm releases. These are essential for testing Helm deployment and management workflows. ```go type MockClient + func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) + func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) type MockClientMockRecorder + func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call + func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call ``` ```go type MockClient + func (m *MockClient) ListReleasesByStateMask(arg0 action.ListStates) ([]*release.Release, error) type MockClientMockRecorder + func (mr *MockClientMockRecorder) ListReleasesByStateMask(arg0 interface{}) *gomock.Call ``` -------------------------------- ### Go: MockClient Install and Upgrade Chart Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.6/mock_tab=versions Mocks the installation and upgrade of Helm charts. These functions take a context and a ChartSpec, returning the deployed release information or an error. ```go type MockClient struct { ctrl *gomock.Controller recorder *MockClientMockRecorder } func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpec) (*release.Release, error) type MockClientMockRecorder struct { // Context InstallChart *gomock.Call UpgradeChart *gomock.Call } func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallChart", reflect.TypeOf((*MockClient)(nil).InstallChart), ctx, spec) } func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpgradeChart", reflect.TypeOf((*MockClient)(nil).UpgradeChart), ctx, spec) } ``` -------------------------------- ### Go Mock Client Recorder - Install Chart Expectation Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.9.1/mock Configures expectations for the InstallChart method. This recorder allows specifying the expected `ctx` and `spec` arguments and controlling the mocked `*release.Release` and `error` returned by the mock. ```go func (mr *MockClientMockRecorder) InstallChart(ctx, spec interface{}) *gomock.Call { // ... implementation details ... } ``` -------------------------------- ### Create Helm Client from Options (Go) Source: https://context7.com/context7/pkg_go_dev_github_com_mittwald_go-helm-client/llms.txt Initializes a basic Helm client with custom namespace and repository settings. It requires the 'github.com/mittwald/go-helm-client' package and outputs logs to standard output. ```go package main import ( "log" "os" helmclient "github.com/mittwald/go-helm-client" ) func main() { opt := &helmclient.Options{ Namespace: "default", RepositoryCache: "/tmp/.helmcache", RepositoryConfig: "/tmp/.helmrepo", Debug: true, Linting: false, Output: os.Stdout, } client, err := helmclient.New(opt) if err != nil { log.Fatalf("Failed to create helm client: %v", err) } log.Printf("Helm client created successfully for namespace: %s", opt.Namespace) } ``` -------------------------------- ### Go: MockClient for Release Management (Install, Upgrade, Uninstall) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.1.1/mock_tab=versions This code defines MockClient methods for installing, upgrading, and uninstalling Helm releases. It's crucial for testing the lifecycle management of Helm deployments in a controlled environment. ```go package main import ( "context" "github.com/helm/helm/pkg/action" "github.com/helm/helm/pkg/release" ) type MockClient struct { // ... other fields } func (m *MockClient) InstallChart(ctx context.Context, spec *action.ChartSpec) (*release.Release, error) { // Implementation details return nil, nil } func (m *MockClient) UpgradeChart(ctx context.Context, spec *action.ChartSpec) (*release.Release, error) { // Implementation details return nil, nil } func (m *MockClient) UninstallReleaseByName(name string) error { // Implementation details return nil } ``` -------------------------------- ### MockClient: InstallChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.8/mock Mocks the InstallChart method of the MockClient. This method installs a chart based on the provided specification and generic Helm options. It requires a context, chart specification, and options. It returns a pointer to a release.Release object and an error. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts *helmclient.GenericHelmOptions) (*release.Release, error) { // Implementation for mocking InstallChart } ``` -------------------------------- ### MockClientMockRecorder: InstallOrUpgradeChart Method Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/mock InstallOrUpgradeChart is a mock method for handling chart installations or upgrades. It accepts a context, chart specification, and options. ```go func (mr *MockClientMockRecorder) InstallOrUpgradeChart(ctx, spec, opts any) *gomock.Call ``` -------------------------------- ### MockClient: Install, Upgrade, and List Releases (Go) Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.5.0/mock_tab=versions Demonstrates mocking for core Helm operations: InstallChart, UpgradeChart, and ListReleasesByStateMask. These mocks are essential for testing Helm deployment pipelines and release management logic. ```go package main import ( "context" "github.com/golang/mock/gomock" "github.com/mittwald/go-helm-client" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/release" ) func main() { ctrl := gomock.NewController(nil) defer ctrl.Finish() m := helmclient.NewMockClient(ctrl) ctx := context.Background() spec := &helmclient.ChartSpec{} // Mocking InstallChart m.EXPECT().InstallChart(ctx, spec).Return(&release.Release{}, nil) // Mocking UpgradeChart m.EXPECT().UpgradeChart(ctx, spec).Return(&release.Release{}, nil) // Mocking ListReleasesByStateMask m.EXPECT().ListReleasesByStateMask(action.ListDeployed).Return([]*release.Release{}, nil) } ``` -------------------------------- ### Mock Helm Client: Install Chart in Go Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/%40v0.12.5/mock This method mocks the installation of a Helm chart. It accepts a context, a chart specification, and optional arguments. The mock returns the deployed release object and an error, useful for testing chart deployment workflows. ```go func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpec, opts ...interface{}) (*release.Release, error) { // Mock logic managed by GoMock. return nil, nil // Placeholder return values ``` -------------------------------- ### Go: InstallChart Method for HelmClient Source: https://pkg.go.dev/github.com/mittwald/go-helm-client/index_tab=doc Installs a Helm chart using the provided chart specification and options. It returns the resulting release object. Namespace and other context are derived from the client's options. ```go func (c *HelmClient) InstallChart(ctx context.Context, spec *ChartSpec, opts *GenericHelmOptions) (*release.Release, error) ```