types

package
v0.0.0-...-e28bd7b Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceNATSQueueGroup      = "provider-openstack-queue"
	ServiceNATSWildCardSubject = "cyverse.providers.openstack.>"
	ServiceNATSDurableName     = "provider-openstack"
)

Some constants for NATS/STAN configuration

Variables

View Source
var (
	// ErrApplicationCredentialNotFound HTTP 404, happens when the application credential is not found, e.g. the application credential ID is not found.
	ErrApplicationCredentialNotFound = errors.New("could not find application credential")
	// ErrAuthentication is HTTP 401, happens when the credential is bad.
	// Note: if application credential ID does NOT exist, ErrApplicationCredentialNotFound will be used instead.
	ErrAuthentication = errors.New("the request you have made requires authentication")
)

Functions

func AuthURLComparison

func AuthURLComparison(url1, url2 *url.URL) (same bool)

AuthURLComparison return true if considered the same URL for the purpose of identify as the same OpenStack provider.

Types

type ApplicationCredential

type ApplicationCredential struct {
	Description string    `json:"description"`
	ExpiresAt   time.Time `json:"expires_at"`
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	ProjectID   string    `json:"project_id"`
	Roles       string    `json:"roles"`
	Secret      string    `json:"secret"`
	//System       interface{} `json:"system"`
	Unrestricted bool   `json:"unrestricted"`
	UserID       string `json:"user_id"`
}

ApplicationCredential is the structure returned by cli when creating an application credential

type CachePrefix

type CachePrefix string

CachePrefix is a string prefix for cache keys, which is also used as a cache tag for invalidation.

const (
	// CachePrefixListApplicationCredentials is the prefix on the cache key for the results of a
	// user requesting a list of ApplicationCredentials.
	CachePrefixListApplicationCredentials CachePrefix = "ListApplicationCredentials"

	// CachePrefixGetApplicationCredential is the prefix on the cache key for the results of a
	// user requesting a single ApplicationCredential.
	CachePrefixGetApplicationCredential CachePrefix = "GetApplicationCredential"

	// CachePrefixListFlavors is the prefix on the cache key for the results of a
	// user requesting a list of flavors.
	CachePrefixListFlavors CachePrefix = "ListFlavors"

	// CachePrefixGetFlavor is the prefix on the cache key for the results of a
	// user requesting a single flavor.
	CachePrefixGetFlavor CachePrefix = "GetFlavor"

	// CachePrefixListImages is the prefix on the cache key for the results of a
	// user requesting a list of images.
	CachePrefixListImages CachePrefix = "ListImages"

	// CachePrefixGetImage is the rpefix on the cache key for the results of a
	// user requesting a single image.
	CachePrefixGetImage CachePrefix = "GetImage"

	// CachePrefixListProjects is the prefix on the cache key for the results of a
	// user requesting a list of Projects.
	CachePrefixListProjects CachePrefix = "ListProjects"

	// CachePrefixGetProject is the rpefix on the cache key for the results of a
	// user requesting a single Project.
	CachePrefixGetProject CachePrefix = "GetProject"

	// CachePrefixListRegions is the prefix on the cache key for the results of a
	// user requesting a list of Regions.
	CachePrefixListRegions CachePrefix = "ListRegions"

	// CachePrefixListCatalog is the prefix on the cache key for the results of a
	// user requesting a list of Catalog.
	CachePrefixListCatalog CachePrefix = "ListCatalog"

	// CachePrefixListZone is the prefix on the cache key for the results of a
	// user requesting a list of DNS zone.
	CachePrefixListZone CachePrefix = "ListZone"

	// CachePrefixListRecordset is the prefix on the cache key for the results of a
	// user requesting a list of DNS recordset.
	CachePrefixListRecordset CachePrefix = "ListRecordset"
)

type CloudEventRequest

type CloudEventRequest struct {
	CloudEvent event.Event
	Replyer    QueryReply
}

CloudEventRequest is what gets comes in as a request

type Configuration

type Configuration struct {
	Messaging                messaging2.NatsStanMsgConfig
	DefaultChannelBufferSize int `envconfig:"DEFAULT_CHANNEL_BUFFER_SIZE" default:"1"`
	QueryWorkerCount         int `envconfig:"QUERY_WORKER_COUNT" default:"10"`
	// Deprecated:
	PodName       string `envconfig:"POD_NAME"`
	K8SNamespace  string `envconfig:"NAMESPACE"`
	LogLevel      string `envconfig:"LOG_LEVEL" default:"debug"`
	RedisAddress  string `envconfig:"REDIS_ADDRESS" default:"redis:6379"`
	RedisPassword string `envconfig:"REDIS_PASSWORD" default:""`
	RedisDB       string `envConfig:"REDIS_DB" default:"0"`
	// expiration period for cache entry in seconds, default to 1 hour
	CacheTTL int `envConfig:"CACHE_TTL" default:"3600"`

	MongoDBConfig db.MongoDBConfig
}

Configuration contains the settings needed to configure this microservice.

func (*Configuration) Override

func (c *Configuration) Override()

Override some config value

func (*Configuration) Validate

func (c *Configuration) Validate() error

Validate returns an error if there's something wrong with the configuration.

type Credential

type Credential struct {
	Username     string
	ID           string
	CreatedAt    time.Time
	UpdatedAt    time.Time
	OpenStackEnv Environment
}

Credential ...

func ConvertCredential

func ConvertCredential(cred service.CredentialModel) (Credential, error)

ConvertCredential converts credential service model to domain(openstack) credential

type CredentialMetadata

type CredentialMetadata struct {
	// Credential ID
	ID string `bson:"_id"`
	// Owner of the credential
	Owner     string    `bson:"owner"`
	UpdatedAt time.Time `bson:"updated_at"` // use updated_at timestamp as an identity of if the credential is still the same

	// OpenStack auth URL
	AuthURL string `bson:"os_auth_url"`
	// OpenStack Domain ID
	DomainID string `bson:"os_domain_id"`
	// OpenStack Domain Name
	DomainName string `bson:"os_domain_name"`
	// OpenStack User ID
	UserID string `bson:"user_id"`
	// ID of the OpenStack project that the credential is associated with. If the credential is unscoped, this field should be empty string.
	ProjectID string `bson:"os_project_id"`
	// Name of the OpenStack project that the credential is associated with. If the credential is unscoped, this field should be empty string.
	ProjectName string `bson:"os_project_name"`

	// timestamp of when this metadata is updated in storage, this will be useful if we implement some cron refresh
	MetadataUpdatedAt time.Time `bson:"metadata_updated_at"`
}

CredentialMetadata is metadata stored by provider-openstack-service to quickly distinguish which project a credential belongs to.

type Environment

type Environment map[string]string

Environment is environment variables represented in a key-value pairs fashion. This is used to carry OpenStack credential info and pass to OpenStack CLI.

type OpenStackCatalogEndpoint

type OpenStackCatalogEndpoint struct {
	ID        string `json:"id"`
	Interface string `json:"interface"` // type of interface, e.g. "public", "admin"
	RegionID  string `json:"region_id"`
	URL       string `json:"url"`
	Region    string `json:"region"`
}

OpenStackCatalogEndpoint is an REST endpoint for a service TODO this duplicate with types in cacao-common/service/providers

type OpenStackCatalogEntry

type OpenStackCatalogEntry struct {
	Name      string                     `json:"name"` // name of the service, e.g. "nova"
	Type      string                     `json:"type"` // service type, e.g. "compute"
	Endpoints []OpenStackCatalogEndpoint `json:"endpoints"`
}

OpenStackCatalogEntry is an entry in the catalog, basically endpoints for an openstack service. TODO this duplicate with types in cacao-common/service/providers

type OpenStackGetter

type OpenStackGetter func(context.Context, Environment, string) ([]byte, error)

OpenStackGetter represents a function that calls `openstack show` via os/exec.CommandContext and returns the output.

type QueryReply

type QueryReply interface {
	Reply(cloudevents.Event) error
}

QueryReply defines a type that can send a response of some sort.

type UserLoginEvent

type UserLoginEvent struct {
	Token   string                 `json:"token"`
	Profile map[string]interface{} `json:"profile"`
}

UserLoginEvent ...

Jump to

Keyboard shortcuts

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