hcloudutil

package
v1.46.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIErrorDiagnostics

func APIErrorDiagnostics(err error) diag.Diagnostics

APIErrorDiagnostics creates diagnostics from the errors that occurred during an API requests.

func APIErrorIsNotFound

func APIErrorIsNotFound(err error) bool

APIErrorIsNotFound check whether the error is an API request Not Found error.

func ConfigureClient

func ConfigureClient(providerData any) (*hcloud.Client, diag.Diagnostics)

func ErrorToDiag

func ErrorToDiag(err error) diag.Diagnostics

ErrorToDiag creates a terraform diag When some hcloud errors are passed it enriches the default Error() function from them with a few more details to make them more understandable for users

func TerraformLabelsToHCloud

func TerraformLabelsToHCloud(ctx context.Context, inputLabels types.Map, outputLabels *map[string]string) diag.Diagnostics

func WaitForAction

func WaitForAction(ctx context.Context, w ProgressWatcher, a *hcloud.Action) error

WaitForAction uses ProgressWatcher to wait for the completion of a.

func WaitForActions

func WaitForActions(ctx context.Context, w ProgressWatcher, a []*hcloud.Action) error

WaitForActions uses ProgressWatcher to wait for the completion of all actions.

Types

type MockProgressWatcher

type MockProgressWatcher struct {
	mock.Mock
}

MockProgressWatcher provides a mock implementation of the ProgressWatcher interface.

func NewMockProgressWatcher

func NewMockProgressWatcher(t *testing.T) *MockProgressWatcher

NewMockProgressWatcher creates a new mock progress watcher.

func (*MockProgressWatcher) MockWatchOverallProgress

func (m *MockProgressWatcher) MockWatchOverallProgress(ctx context.Context, a []*hcloud.Action, err error) <-chan struct{}

MockWatchProgress mocks WatchProgress to return a progress and an error channel. A Go routine is started, which closes the channels and sends err into the error channel if not nil.

func (*MockProgressWatcher) MockWatchProgress

func (m *MockProgressWatcher) MockWatchProgress(ctx context.Context, a *hcloud.Action, err error) <-chan struct{}

MockWatchProgress mocks WatchProgress to return a progress and an error channel. A Go routine is started, which closes the channels and sends err into the error channel if not nil.

func (*MockProgressWatcher) WatchOverallProgress

func (m *MockProgressWatcher) WatchOverallProgress(ctx context.Context, a []*hcloud.Action) (<-chan int, <-chan error)

WatchProgress is a mock implementation of the ProgressWatcher.WatchProgress method.

func (*MockProgressWatcher) WatchProgress

func (m *MockProgressWatcher) WatchProgress(ctx context.Context, a *hcloud.Action) (<-chan int, <-chan error)

WatchProgress is a mock implementation of the ProgressWatcher.WatchProgress method.

type ProgressWatcher

type ProgressWatcher interface {
	WatchProgress(context.Context, *hcloud.Action) (<-chan int, <-chan error)
	WatchOverallProgress(ctx context.Context, actions []*hcloud.Action) (<-chan int, <-chan error)
}

ProgressWatcher encapsulates the Hetzner Cloud Action Client's WatchProgress method for easier testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL