vsphere

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 28 Imported by: 3

Documentation

Overview

Package vsphere holds utilities for bootstrapping a vSphere API client from the metadata injected by the VSphereSource. Within a receive adapter, users can create a new vSphere SOAP API client with automatic keep-alive:

client, err := vsphere.NewSOAPClient(ctx)

To properly release vSphere API resources, it is recommended to log out when the client is not needed anymore:

defer client.Logout(context.Background())

This is modeled after the Bindings pattern.

Index

Constants

View Source
const (
	// replay history from this time by default
	CheckpointDefaultAge = 5 * time.Minute
	// create checkpoint every frequency but only on changes
	CheckpointDefaultPeriod = 10 * time.Second
)
View Source
const (
	VolumeName       = "vsphere-binding"
	DefaultMountPath = "/var/bindings/vsphere" // filepath.Join isn't const.

)

Variables

View Source
var (
	ErrInvalidInterval = errors.New("invalid checkpoint time interval")
)

Functions

func NewAdapter

func NewAdapter(ctx context.Context, processed adapter.EnvConfigAccessor, ceClient cloudevents.Client) adapter.Adapter

func NewEnvConfig

func NewEnvConfig() adapter.EnvConfigAccessor

func NewRESTClient added in v0.19.0

func NewRESTClient(ctx context.Context) (*rest.Client, error)

NewRESTClient returns a vCenter REST API client with active keep-alive. Use Logout() to release resources and perform a clean logout from vCenter.

func NewSOAPClient added in v0.19.0

func NewSOAPClient(ctx context.Context) (*govmomi.Client, error)

NewSOAPClient returns a vCenter SOAP API client with active keep-alive. Use Logout() to release resources and perform a clean logout from vCenter.

func ReadKey

func ReadKey(key string) (string, error)

ReadKey reads the key from the secret.

Types

type CheckpointConfig added in v0.21.0

type CheckpointConfig struct {
	// max replay window
	MaxAge time.Duration `json:"maxAge"`
	// create checkpoints at given frequency
	Period time.Duration `json:"period"`
}

CheckpointConfig influences the checkpoint behavior. It configures the maximum age of the replay (look-back) window when starting the event stream and the period of saving the checkpoint

func (*CheckpointConfig) MarshalJSON added in v0.21.0

func (c *CheckpointConfig) MarshalJSON() ([]byte, error)

MarshalJSON defines custom marshalling logic to support human-readable time input on the checkpoint configuration, e.g. "10m" or "1h".

func (*CheckpointConfig) UnmarshalJSON added in v0.21.0

func (c *CheckpointConfig) UnmarshalJSON(b []byte) error

UnmarshalJSON defines custom marshalling logic to support human-readable time input on the checkpoint configuration, e.g. "10m" or "1h". Using numbers without time suffix as input will fail encoding/decoding.

type EnvConfig

type EnvConfig struct {
	Insecure   bool   `envconfig:"VC_INSECURE" default:"false"`
	Address    string `envconfig:"VC_URL" required:"true"`
	SecretPath string `envconfig:"VC_SECRET_PATH" default:""`
}

Jump to

Keyboard shortcuts

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