adapters

package
v0.0.0-...-12cbc32 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisCacheManager

func NewRedisCacheManager(config types.Configuration) *cache.ChainCache

NewRedisCacheManager ...

Types

type CredentialMetadataMongoAdapter

type CredentialMetadataMongoAdapter struct {
	// contains filtered or unexported fields
}

CredentialMetadataMongoAdapter stores credential metadata for openstack credentials. Note the data stores here is a long-term cache, though the information is unlikely to change, this should not be treated as the ultimate source of truth, the upstream openstack server should be.

func NewCredentialMetadataMongoAdapter

func NewCredentialMetadataMongoAdapter(conf *types.Configuration) (*CredentialMetadataMongoAdapter, error)

NewCredentialMetadataMongoAdapter ...

func (*CredentialMetadataMongoAdapter) GetCredential

func (ma *CredentialMetadataMongoAdapter) GetCredential(owner string, credID string) (types.CredentialMetadata, error)

GetCredential gets the metadata for a single credential

func (*CredentialMetadataMongoAdapter) ListCredentials

func (ma *CredentialMetadataMongoAdapter) ListCredentials(owner string, projectID, projectName string) ([]types.CredentialMetadata, error)

ListCredentials list all credential metadata stored for a user.

Filter by project ID/name if they are specified (non-empty)

func (*CredentialMetadataMongoAdapter) SaveCredential

func (ma *CredentialMetadataMongoAdapter) SaveCredential(cred *types.Credential, metadata types.CredentialMetadata) error

SaveCredential upsert the credential metadata record to mongodb

type CredentialMicroservice

type CredentialMicroservice struct {
	// contains filtered or unexported fields
}

CredentialMicroservice ...

func NewCredentialMicroservice

func NewCredentialMicroservice(queryConn messaging2.QueryConnection, eventConn messaging2.EventConnection) *CredentialMicroservice

NewCredentialMicroservice ...

func (CredentialMicroservice) CreateCredential

func (svc CredentialMicroservice) CreateCredential(ctx context.Context, actor, emulator string, cred service.CredentialModel) error

CreateCredential creates a credential via credential microservice

func (CredentialMicroservice) DeleteCredential

func (svc CredentialMicroservice) DeleteCredential(ctx context.Context, actor, emulator, ID string) error

DeleteCredential deletes a credential

func (CredentialMicroservice) GetCredential

func (svc CredentialMicroservice) GetCredential(ctx context.Context, actor, emulator, ID string) (*types.Credential, error)

GetCredential ...

func (CredentialMicroservice) ListCredentials

func (svc CredentialMicroservice) ListCredentials(ctx context.Context, actor, emulator string) ([]service.CredentialModel, error)

ListCredentials list the enabled openstack credential that actor owns

func (CredentialMicroservice) ListCredentialsByTag

func (svc CredentialMicroservice) ListCredentialsByTag(ctx context.Context, actor, emulator, tagName string) ([]types.Credential, error)

ListCredentialsByTag list the enabled openstack credential that actor owns that has the specified tagName

func (CredentialMicroservice) TagCredential

func (svc CredentialMicroservice) TagCredential(ctx context.Context, actor, emulator string, ID string, tags map[string]string) error

TagCredential update/add tags for a credential

type EventAdapter

type EventAdapter struct {
	// contains filtered or unexported fields
}

EventAdapter communicates to IncomingEventPort

func NewEventAdapter

func NewEventAdapter(conn messaging2.EventConnection) *EventAdapter

NewEventAdapter ...

func (*EventAdapter) SetHandlers

func (adapter *EventAdapter) SetHandlers(handlers ports.IncomingEventHandlers)

SetHandlers sets the mapping of event type to event handlers

func (*EventAdapter) Start

func (adapter *EventAdapter) Start(ctx context.Context, wg *sync.WaitGroup) error

Start starts the adapter

type EventOut

type EventOut struct {
	// contains filtered or unexported fields
}

EventOut implements ports.OutgoingEvents, this will be pass as argument to ports.IncomingEventHandlers

func (EventOut) EventApplicationCredentialsCreateFailed

func (e EventOut) EventApplicationCredentialsCreateFailed(response providers.CreateApplicationCredentialResponse)

EventApplicationCredentialsCreateFailed ...

func (EventOut) EventApplicationCredentialsCreated

func (e EventOut) EventApplicationCredentialsCreated(response providers.CreateApplicationCredentialResponse)

EventApplicationCredentialsCreated ...

func (EventOut) EventApplicationCredentialsDeleteFailed

func (e EventOut) EventApplicationCredentialsDeleteFailed(response providers.DeleteApplicationCredentialResponse)

EventApplicationCredentialsDeleteFailed ...

func (EventOut) EventApplicationCredentialsDeleted

func (e EventOut) EventApplicationCredentialsDeleted(response providers.DeleteApplicationCredentialResponse)

EventApplicationCredentialsDeleted ...

func (EventOut) Nothing

func (e EventOut) Nothing()

Nothing is used to explicitly denote that no events will be published by a handler

type OpenStackAdapter

type OpenStackAdapter struct {
	// contains filtered or unexported fields
}

OpenStackAdapter is used to access metadata from OpenStack clusters.

func NewOpenStackAdapter

func NewOpenStackAdapter() *OpenStackAdapter

NewOpenStackAdapter creates a new *OpenStackAdapter.

func (*OpenStackAdapter) AuthenticationTest

func (o *OpenStackAdapter) AuthenticationTest(ctx context.Context, credential types.Environment) error

AuthenticationTest attempts to list all the available projects in an OpenStack cluster.

func (*OpenStackAdapter) CreateApplicationCredential

func (o *OpenStackAdapter) CreateApplicationCredential(ctx context.Context, credential types.Credential, scope providers.ProjectScope, name string) (types.ApplicationCredential, error)

CreateApplicationCredential creates an application credential with the given name.

func (*OpenStackAdapter) DeleteApplicationCredential

func (o *OpenStackAdapter) DeleteApplicationCredential(ctx context.Context, credential types.Credential, idOrName string) error

DeleteApplicationCredential deletes an application credential

func (*OpenStackAdapter) GetApplicationCredential

func (o *OpenStackAdapter) GetApplicationCredential(ctx context.Context, credential types.Credential, id string) (*providers.ApplicationCredential, error)

GetApplicationCredential attempts to retrieve a specific OpenStack application credential by ID. If a cached value exists, it will be returned rather than contacting the OpenStackCluster.

func (*OpenStackAdapter) GetFlavor

func (o *OpenStackAdapter) GetFlavor(ctx context.Context, credential types.Credential, id string, region string) (*providers.Flavor, error)

GetFlavor attempts to retrieve a specific OpenStack flavor by ID. If a cached value exists, it will be returned rather than contacting the OpenStackCluster.

func (*OpenStackAdapter) GetImage

func (o *OpenStackAdapter) GetImage(ctx context.Context, credential types.Credential, id string, region string) (*providers.OpenStackImage, error)

GetImage attempts to retrieve a specific OpenStack image by ID. If a cached value exists, it will be returned rather than contacting the OpenStackCluster.

func (*OpenStackAdapter) GetProject

func (o *OpenStackAdapter) GetProject(ctx context.Context, credential types.Credential, id string) (*providers.Project, error)

GetProject attempts to retrieve a specific OpenStack Project by ID. If a cached value exists, it will be returned rather than contacting the OpenStackCluster.

func (*OpenStackAdapter) GetToken

func (o *OpenStackAdapter) GetToken(ctx context.Context, credential types.Credential) (*providers.Token, error)

GetToken issues a token.

func (*OpenStackAdapter) InspectCredential

func (o *OpenStackAdapter) InspectCredential(ctx context.Context, credential types.Credential) (types.CredentialMetadata, error)

InspectCredential inspects a credential.

func (*OpenStackAdapter) ListApplicationCredentials

func (o *OpenStackAdapter) ListApplicationCredentials(ctx context.Context, credential types.Credential) ([]providers.ApplicationCredential, error)

ListApplicationCredentials ...

func (*OpenStackAdapter) ListCatalog

func (o *OpenStackAdapter) ListCatalog(ctx context.Context, credential types.Credential) ([]providers.CatalogEntry, error)

ListCatalog returns a list of catalog.

func (*OpenStackAdapter) ListFlavors

func (o *OpenStackAdapter) ListFlavors(ctx context.Context, credential types.Credential, region string) ([]providers.Flavor, error)

ListFlavors attempts to list all the available flavors in an OpenStack cluster.

func (*OpenStackAdapter) ListImages

func (o *OpenStackAdapter) ListImages(ctx context.Context, credential types.Credential, region string) ([]providers.OpenStackImage, error)

ListImages ...

func (*OpenStackAdapter) ListProjects

func (o *OpenStackAdapter) ListProjects(ctx context.Context, credential types.Credential) ([]providers.Project, error)

ListProjects attempts to list all the available projects in an OpenStack/ cluster.

func (*OpenStackAdapter) ListRecordset

func (o *OpenStackAdapter) ListRecordset(ctx context.Context, credential types.Credential, zone string) ([]providers.DNSRecordset, error)

ListRecordset returns a list of DNS recordset. This uses REST api directly instead of using CLI.

https://docs.openstack.org/api-ref/dns/dns-api-v2-index.html

func (*OpenStackAdapter) ListRegions

func (o *OpenStackAdapter) ListRegions(ctx context.Context, credential types.Credential) ([]providers.Region, error)

ListRegions attempts to list all the regions that is available to user in an OpenStack cluster.

Note: this retrieves regions from catalog entry for nova service rather than region list. This is because regions can be disabled by endpoint filtering. This will only return regions that is reported in the catalog nova endpoints.

func (*OpenStackAdapter) ListZone

func (o *OpenStackAdapter) ListZone(ctx context.Context, credential types.Credential) ([]providers.DNSZone, error)

ListZone returns a list of DNS zones.

type OpenStackCLI

type OpenStackCLI interface {
	// contains filtered or unexported methods
}

OpenStackCLI is an interface that comprises the necessary operations for interacting with the OpenStack CLI

type OpenStackCLIAdapter

type OpenStackCLIAdapter struct {
	// contains filtered or unexported fields
}

OpenStackCLIAdapter is a concrete implementation of the OpenStackCLI interface

type OpenStackHTTPClient

type OpenStackHTTPClient interface {
	MakePaginatedRequest(ctx context.Context, endpointURL string, tokenID string, paginationMarker string, apiVersion string, resource string, limit int) ([]byte, error)
	ParsePaginationMarker(input string) (string, error)
}

OpenStackHTTPClient is an interface for the http client.

TODO If we add more operations that uses the REST api directly, consider using gophercloud SDK.

type OpenStackHTTPClientAdapter

type OpenStackHTTPClientAdapter struct {
}

OpenStackHTTPClientAdapter is the concrete implementation of the OpenStackHTTPClient interface

func (OpenStackHTTPClientAdapter) Do

Do send an HTTP request and returns an HTTP response, following policy (e.g. redirects, cookies, auth) as configured on the client.

func (OpenStackHTTPClientAdapter) MakePaginatedRequest

func (o OpenStackHTTPClientAdapter) MakePaginatedRequest(ctx context.Context, endpointURL string, tokenID string, paginationMarker string, apiVersion string, resource string, limit int) ([]byte, error)

MakePaginatedRequest makes an HTTP request to an openstack endpoint and returns the response body in []byte.

endpointURL is the URL of the OpenStack service, the one you get from `openstack catalog list`.

apiVersion is the version of the api, e.g. "v2"

tokenID is the auth token to use, if you don't have a token credential, authenticate with OpenStack KeyStone to get a token.

limit is the pagination limit, if non-positive, then no limit.

func (OpenStackHTTPClientAdapter) NewRequestWithContext

func (o OpenStackHTTPClientAdapter) NewRequestWithContext(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

NewRequestWithContext creates an HTTP request with the provided context. The context passed in should have a deadline/timeout.

func (OpenStackHTTPClientAdapter) ParsePaginationMarker

func (o OpenStackHTTPClientAdapter) ParsePaginationMarker(input string) (string, error)

ParsePaginationMarker parse the pagination marker to use with MakeHTTPRequest.

input is from response body of a request to list resources, generally it is under a key named "next".

type ProviderMetadataClient

type ProviderMetadataClient struct {
	// contains filtered or unexported fields
}

ProviderMetadataClient ...

func NewProviderMetadataClient

func NewProviderMetadataClient(queryConn messaging2.QueryConnection) *ProviderMetadataClient

NewProviderMetadataClient ...

func (ProviderMetadataClient) GetMetadata

func (svc ProviderMetadataClient) GetMetadata(ctx context.Context, actor, emulator string, providerID common.ID) (map[string]interface{}, error)

GetMetadata fetches metadata for a provider

func (ProviderMetadataClient) ListOpenStackProvider

func (svc ProviderMetadataClient) ListOpenStackProvider(ctx context.Context, actor, emulator string) ([]service.ProviderModel, error)

ListOpenStackProvider ...

type ProviderRedisStore

type ProviderRedisStore struct {
	// contains filtered or unexported fields
}

ProviderRedisStore fixes an issue in the store.RedisStore compliance with the store.StoreInterface.

func (*ProviderRedisStore) Clear

func (m *ProviderRedisStore) Clear() error

Clear complies with the store.StoreInterface.

func (*ProviderRedisStore) Delete

func (m *ProviderRedisStore) Delete(key interface{}) error

Delete complies with the store.StoreInterface.

func (*ProviderRedisStore) Get

func (m *ProviderRedisStore) Get(key interface{}) (interface{}, error)

Get complies with the store.StoreInterface.

func (*ProviderRedisStore) GetType

func (m *ProviderRedisStore) GetType() string

GetType complies with the store.StoreInterface.

func (*ProviderRedisStore) GetWithTTL

func (m *ProviderRedisStore) GetWithTTL(key interface{}) (interface{}, time.Duration, error)

GetWithTTL complies with the store.StoreInterface.

func (*ProviderRedisStore) Invalidate

func (m *ProviderRedisStore) Invalidate(options store.InvalidateOptions) error

Invalidate complies with the store.StoreInterface.

func (*ProviderRedisStore) Set

func (m *ProviderRedisStore) Set(key interface{}, value interface{}, options *store.Options) error

Set complies with the store.StoreInterface.

type QueryAdapter

type QueryAdapter struct {
	// contains filtered or unexported fields
}

QueryAdapter implements ports.IncomingQueryPort & ports.OutgoingQueryPort

func (*QueryAdapter) Close

func (adapter *QueryAdapter) Close() error

Close ...

func (*QueryAdapter) Init

func (adapter *QueryAdapter) Init(conf types.Configuration)

Init perform initialization on the adapter

func (*QueryAdapter) InitChannel

func (adapter *QueryAdapter) InitChannel(c chan types.CloudEventRequest)

InitChannel takes in the data channel for depositing incoming message

func (*QueryAdapter) Start

func (adapter *QueryAdapter) Start(ctx context.Context) error

Start starts the queue subscriber

type QueryReplyer

type QueryReplyer struct {
	// contains filtered or unexported fields
}

QueryReplyer implements types.QueryReply and allows the domain to send a response.

func (QueryReplyer) Reply

func (r QueryReplyer) Reply(ce cloudevents.Event) error

Reply send a response

type UTCTime

type UTCTime struct {
}

UTCTime is a source of current UTC time

func (UTCTime) Now

func (utc UTCTime) Now() time.Time

Now returns current UTC time

type WorkspaceMicroservice

type WorkspaceMicroservice struct {
	// contains filtered or unexported fields
}

WorkspaceMicroservice ...

func NewWorkspaceMicroservice

func NewWorkspaceMicroservice(queryConn messaging2.QueryConnection, eventConn messaging2.EventConnection) *WorkspaceMicroservice

NewWorkspaceMicroservice ...

func (WorkspaceMicroservice) CreateWorkspaceForProviderAsync

func (svc WorkspaceMicroservice) CreateWorkspaceForProviderAsync(ctx context.Context, actor, emulator string, providerID common.ID) error

CreateWorkspaceForProviderAsync creates workspace for a user for a provider. The creation is async, it only sends the request, it does not wait for the response.

Creating workspace using the default name, since the combination of (owner, name, default_provider_id) is unique (checked by the DB index), so if the workspace already exists, new workspace won't be created, this makes the operation idempotent.

Jump to

Keyboard shortcuts

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