client

package
v6.10.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectStorageAccessKeyEnv  ObjectStorageAccessKeySource = "environment variable: IONOS_S3_ACCESS_KEY"
	ObjectStorageAccessKeyCfg  ObjectStorageAccessKeySource = "Object Storage access key from config file: s3AccessKey"
	ObjectStorageAccessKeyNone ObjectStorageAccessKeySource = "Object Storage access key not provided"

	ObjectStorageSecretKeyEnv  ObjectStorageSecretKeySource = "environment variable: IONOS_S3_SECRET_KEY"
	ObjectStorageSecretKeyCfg  ObjectStorageSecretKeySource = "Object Storage secret key from config file: s3SecretKey"
	ObjectStorageSecretKeyNone ObjectStorageSecretKeySource = "Object Storage secret key not provided"
)

Variables

all possible sources in priority order

View Source
var MustDefaultErrHandler = func(err error) {
	die.Die(fmt.Errorf("failed getting client: %w", err).Error())
}
View Source
var MustObjectStorageDefaultErrHandler = func(err error) {
	die.Die(fmt.Errorf("failed getting object storage client: %w", err).Error())
}

Functions

func EnforceClient added in v6.7.2

func EnforceClient(user, pass, token, hostUrl string)

EnforceClient sets the global client instance to a new client with the given credentials ( use only for testing/special cases)

func ResolveObjectStorageCredentials added in v6.10.1

func ResolveObjectStorageCredentials() (accessKey, secretKey string, akSrc ObjectStorageAccessKeySource, skSrc ObjectStorageSecretKeySource, err error)

ResolveObjectStorageCredentials resolves Object Storage access and secret keys, tracking their source. Both keys must come from the same source; mixing is not allowed. Priority order:

  1. Environment variables IONOS_S3_ACCESS_KEY / IONOS_S3_SECRET_KEY (both must be set)
  2. s3AccessKey / s3SecretKey in the current ionosctl config profile (both must be set)

func TestCreds added in v6.7.0

func TestCreds(user, pass, token string) error

Types

type AuthSource added in v6.9.0

type AuthSource string

AuthSource represents a human-readable description of where the client's authentication credentials were sourced from.

const (
	AuthSourceEnvBearer AuthSource = "environment variable: IONOS_TOKEN"
	AuthSourceEnvBasic  AuthSource = "environment variables: IONOS_USERNAME, IONOS_PASSWORD"
	AuthSourceCfgBearer AuthSource = "credentials from config file: token"
	AuthSourceCfgBasic  AuthSource = "credentials from config file: username, password"
	AuthSourceNone      AuthSource = "no authentication provided"
)

type Client

type Client struct {
	Config     *fileconfiguration.FileConfig
	ConfigPath string // Path to the config file used to create this client, if any.
	AuthSource AuthSource

	URLOverride string // If the client was created with a specific URL override, this will hold that value. If we notice a change in the URL, we need to re-create the client.

	CloudClient          *cloudv6.APIClient
	AuthClient           *auth.APIClient
	CertManagerClient    *cert.APIClient
	RegistryClient       *containerregistry.APIClient
	DnsClient            *dns.APIClient
	LoggingServiceClient *logging.APIClient
	VMAscClient          *vmasc.AutoScalingGroupsApiService
	VPNClient            *vpn.APIClient
	CDNClient            *cdn.APIClient
	Kafka                *kafka.APIClient
	Monitoring           *monitoring.APIClient

	PostgresClient   *psql.APIClient
	PostgresClientV2 *psql2.APIClient
	MongoClient      *mongo.APIClient
	MariaClient      *mariadb.APIClient
	InMemoryDBClient *inmemorydb.APIClient
}

func Get

func Get() (*Client, error)

func Must

func Must(ehs ...func(error)) *Client

Must gets the client obj or fatally dies You can provide some optional custom error handlers as params. The err is sent to each error handler in order. The default error handler is die.Die which exits with code 1 and violently terminates the program

func NewClient added in v6.7.0

func NewClient(name, pwd, token, hostUrl string) *Client

NewClient creates a new client with the given credentials. It is used for testing purposes or when you want to create a client with specific credentials. It is highly recommended to use the Get() or Must() functions instead, as they handle the configuration file and environment variables automatically.

func (*Client) TestCreds added in v6.7.0

func (c *Client) TestCreds() error

type ConfigSource added in v6.9.1

type ConfigSource struct {
	Config *fileconfiguration.FileConfig
	Path   string
}

ConfigSource holds a loaded FileConfig (or nil) plus the path it came from.

type ObjectStorageAccessKeySource added in v6.10.1

type ObjectStorageAccessKeySource string

type ObjectStorageClient added in v6.10.1

type ObjectStorageClient struct {
	AccessKeySource ObjectStorageAccessKeySource
	SecretKeySource ObjectStorageSecretKeySource

	URLOverride string
	Region      string

	ObjectStorageClient *objectstorage.APIClient
}

func GetObjectStorage added in v6.10.1

func GetObjectStorage() (*ObjectStorageClient, error)

GetObjectStorage returns the ObjectStorageClient for the currently resolved endpoint. The endpoint is set by WithRegionalConfigOverride via viper (constants.ArgServerUrl). Falls back to the default region endpoint if not set. Cached via sync.Once.

func MustObjectStorage added in v6.10.1

func MustObjectStorage(ehs ...func(error)) *ObjectStorageClient

MustObjectStorage returns the ObjectStorageClient or fatally exits. Custom error handlers can be provided; the default handler calls die.Die.

type ObjectStorageSecretKeySource added in v6.10.1

type ObjectStorageSecretKeySource string

Jump to

Keyboard shortcuts

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