providers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 13 Imported by: 5

Documentation

Index

Constants

View Source
const (
	KAPETA_ENVIRONMENT_TYPE   = "KAPETA_ENVIRONMENT_TYPE"
	HEADER_KAPETA_BLOCK       = "X-Kapeta-Block"
	HEADER_KAPETA_SYSTEM      = "X-Kapeta-System"
	HEADER_KAPETA_INSTANCE    = "X-Kapeta-Instance"
	HEADER_KAPETA_ENVIRONMENT = "X-Kapeta-Environment"
)
View Source
const DEFAULT_SERVER_PORT_TYPE = "rest"

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractConfigProvider

type AbstractConfigProvider struct {
	BlockRef                 string                 `json:"blockRef"`
	SystemID                 string                 `json:"systemId"`
	InstanceID               string                 `json:"instanceId"`
	BlockDefinition          map[string]interface{} `json:"blockDefinition"`
	EnvironmentConfiguration map[string]string      `json:"environmentConfiguration"`
}

func (*AbstractConfigProvider) GetBlockDefinition

func (a *AbstractConfigProvider) GetBlockDefinition() interface{}

func (*AbstractConfigProvider) GetBlockReference

func (a *AbstractConfigProvider) GetBlockReference() string

func (*AbstractConfigProvider) GetInstanceId

func (a *AbstractConfigProvider) GetInstanceId() string

func (*AbstractConfigProvider) GetSystemId

func (a *AbstractConfigProvider) GetSystemId() string

func (*AbstractConfigProvider) LookupEnv added in v0.2.0

func (a *AbstractConfigProvider) LookupEnv(name string) (string, bool)

func (*AbstractConfigProvider) SetIdentity

func (a *AbstractConfigProvider) SetIdentity(systemID, instanceID string)

type AssetWrapper added in v0.1.0

type AssetWrapper[T any] struct {
	Data *T `json:"data"`
}

type BlockInstanceDetails added in v0.1.0

type BlockInstanceDetails struct {
	InstanceId  string              `json:"instanceId"`
	Block       *model.Kind         `json:"block"`
	Connections []*model.Connection `json:"connections"`
}

type ConfigProvider

type ConfigProvider interface {
	GetBlockDefinition() interface{}
	GetBlockReference() string
	GetSystemId() string
	GetInstanceId() string
	GetServerPort(portType string) (string, error)
	GetServiceAddress(serviceName, portType string) (string, error)
	GetResourceInfo(resourceType, portType, resourceName string) (*ResourceInfo, error)
	GetInstanceHost(instanceID string) (string, error)
	GetServerHost() (string, error)
	GetProviderId() string
	Get(path string) interface{}
	GetOrDefault(path string, defaultValue interface{}) interface{}
	GetInstanceForConsumer(resourceName string) (*BlockInstanceDetails, error)
	GetInstanceOperator(instanceId string) (*InstanceOperator, error)
	GetInstancesForProvider(resourceName string) ([]*BlockInstanceDetails, error)
}

func NewKubernetesConfigProvider

func NewKubernetesConfigProvider(blockRef, systemID, instanceID string, blockDefinition map[string]interface{}) ConfigProvider

NewKubernetesConfigProvider creates a new instance of KubernetesConfigProvider

type DefaultCredentials added in v0.1.0

type DefaultCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Identity

type Identity struct {
	SystemID   string `json:"systemId"`
	InstanceID string `json:"instanceId"`
}

Identity struct represents the identity of a block

type InstanceOperator added in v0.1.0

type InstanceOperator struct {
	Hostname    string                          `json:"hostname"`
	Ports       map[string]InstanceOperatorPort `json:"ports"`
	Path        string                          `json:"path,omitempty"`
	Query       string                          `json:"query,omitempty"`
	Hash        string                          `json:"hash,omitempty"`
	Credentials map[string]any                  `json:"credentials,omitempty"`
	Options     map[string]any                  `json:"options,omitempty"`
}

type InstanceOperatorPort added in v0.1.0

type InstanceOperatorPort struct {
	Protocol string `json:"protocol"`
	Port     int    `json:"port"`
}

type InstanceProviderValue

type InstanceProviderValue struct {
	ID           string `json:"id"`
	PortType     string `json:"portType"`
	ResourceName string `json:"resourceName"`
}

type InstanceValue

type InstanceValue struct {
	ID string `json:"id"`
}

type KubernetesConfigProvider

type KubernetesConfigProvider struct {
	AbstractConfigProvider
	// contains filtered or unexported fields
}

KubernetesConfigProvider implements the ConfigProvider interface

func (*KubernetesConfigProvider) Get

func (k *KubernetesConfigProvider) Get(path string) interface{}

Get is an implementation of the ConfigProvider interface to get the configuration value from the object path

func (*KubernetesConfigProvider) GetInstanceForConsumer added in v0.1.0

func (k *KubernetesConfigProvider) GetInstanceForConsumer(resourceName string) (*BlockInstanceDetails, error)

func (*KubernetesConfigProvider) GetInstanceHost

func (k *KubernetesConfigProvider) GetInstanceHost(instanceID string) (string, error)

GetInstanceHost returns the hostname for the given instance ID

func (*KubernetesConfigProvider) GetInstanceOperator added in v0.1.0

func (k *KubernetesConfigProvider) GetInstanceOperator(instanceId string) (*InstanceOperator, error)

func (*KubernetesConfigProvider) GetInstancesForProvider added in v0.1.0

func (k *KubernetesConfigProvider) GetInstancesForProvider(resourceName string) ([]*BlockInstanceDetails, error)

func (*KubernetesConfigProvider) GetOrDefault

func (k *KubernetesConfigProvider) GetOrDefault(path string, defaultValue interface{}) interface{}

GetOrDefault is an implementation of the ConfigProvider interface to get the configuration value from the object path with a default value

func (*KubernetesConfigProvider) GetProviderId

func (k *KubernetesConfigProvider) GetProviderId() string

GetProviderId returns the identifier for the config provider

func (*KubernetesConfigProvider) GetResourceInfo

func (k *KubernetesConfigProvider) GetResourceInfo(resourceType, portType, resourceName string) (*ResourceInfo, error)

GetResourceInfo returns the resource info for the given resource type, port type, and resource name

func (*KubernetesConfigProvider) GetServerHost

func (k *KubernetesConfigProvider) GetServerHost() (string, error)

GetServerHost returns the host for the current process

func (*KubernetesConfigProvider) GetServerPort

func (k *KubernetesConfigProvider) GetServerPort(portType string) (string, error)

GetServerPort returns the port to listen on for the current instance

func (*KubernetesConfigProvider) GetServiceAddress

func (k *KubernetesConfigProvider) GetServiceAddress(resourceName, portType string) (string, error)

GetServiceAddress returns the service address for the given resource name and port type

type LocalConfigProvider

type LocalConfigProvider struct {
	AbstractConfigProvider

	GetPlan func() (*model.Plan, error)
	GetKind func(ref string) (*model.Kind, error)
	// contains filtered or unexported fields
}

LocalConfigProvider struct represents the local config provider

func NewLocalConfigProvider

func NewLocalConfigProvider(blockRef, systemID, instanceID string, blockDefinition map[string]interface{}) *LocalConfigProvider

NewLocalConfigProvider creates an instance of LocalConfigProvider

func (*LocalConfigProvider) Get

func (l *LocalConfigProvider) Get(path string) interface{}

func (*LocalConfigProvider) GetAsset added in v0.1.0

func (l *LocalConfigProvider) GetAsset(ref string, value any) error

func (*LocalConfigProvider) GetConfig

func (l *LocalConfigProvider) GetConfig(path string) interface{}

GetConfig gets the configuration value for the specified path

func (*LocalConfigProvider) GetInstanceForConsumer added in v0.1.0

func (l *LocalConfigProvider) GetInstanceForConsumer(resourceName string) (*BlockInstanceDetails, error)

func (*LocalConfigProvider) GetInstanceHost

func (l *LocalConfigProvider) GetInstanceHost(instanceID string) (string, error)

GetInstanceHost gets the host for the specified instance ID

func (*LocalConfigProvider) GetInstanceOperator added in v0.1.0

func (l *LocalConfigProvider) GetInstanceOperator(instanceId string) (*InstanceOperator, error)

func (*LocalConfigProvider) GetInstancesForProvider added in v0.1.0

func (l *LocalConfigProvider) GetInstancesForProvider(resourceName string) ([]*BlockInstanceDetails, error)

func (*LocalConfigProvider) GetOrDefault

func (l *LocalConfigProvider) GetOrDefault(path string, defaultValue interface{}) interface{}

GetOrDefault gets the configuration value for the specified path, or a default value if not found

func (*LocalConfigProvider) GetProviderId

func (l *LocalConfigProvider) GetProviderId() string

func (*LocalConfigProvider) GetResourceInfo

func (l *LocalConfigProvider) GetResourceInfo(resourceType, portType, resourceName string) (*ResourceInfo, error)

GetResourceInfo gets the resource information for the specified resource type, port type, and resource name

func (*LocalConfigProvider) GetServerHost

func (l *LocalConfigProvider) GetServerHost() (string, error)

GetServerHost gets the server host for the current instance

func (*LocalConfigProvider) GetServerPort

func (l *LocalConfigProvider) GetServerPort(portType string) (string, error)

GetServerPort gets the port to listen on for the current instance

func (*LocalConfigProvider) GetServiceAddress

func (l *LocalConfigProvider) GetServiceAddress(resourceName, portType string) (string, error)

GetServiceAddress gets the service address for the specified resource and port type

func (*LocalConfigProvider) InstanceStopped

func (l *LocalConfigProvider) InstanceStopped()

InstanceStopped notifies the cluster service that the instance has stopped

func (*LocalConfigProvider) RegisterInstanceWithLocalClusterService

func (l *LocalConfigProvider) RegisterInstanceWithLocalClusterService() error

RegisterInstanceWithLocalClusterService registers the instance with the cluster service

func (*LocalConfigProvider) ResolveIdentity

func (l *LocalConfigProvider) ResolveIdentity() error

ResolveIdentity resolves and verifies system and instance ID

type ResourceInfo

type ResourceInfo struct {
	Host        string                 `json:"host"`
	Port        json.Number            `json:"port"`
	Type        string                 `json:"type"`
	Protocol    string                 `json:"protocol"`
	Options     map[string]interface{} `json:"options"`
	Credentials map[string]string      `json:"credentials"`
}

ResourceInfo struct represents information about a resource

Jump to

Keyboard shortcuts

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