cf

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package cf contains the cf specific logic for the proxy

Index

Constants

View Source
const (
	CreateBrokerError = "could not retrieve service broker with name %s: %v"
	DeleteBrokerError = "could not delete service broker with GUID %s: %v"
	UpdateBrokerError = "could not update service broker with GUID %s: %v"
)
View Source
const GetOrganizationsChunkSize = 50
View Source
const OrgLabelKey = "organization_guid"

OrgLabelKey label key for CF organization visibilities

Variables

View Source
var AuthenticationType = struct {
	BASIC AuthenticationTypeValue
}{
	BASIC: "basic",
}

AuthenticationType is the supported authentication types.

View Source
var CCQueryParams = struct {
	PageSize             string
	Names                string
	ServiceBrokerGuids   string
	ServiceOfferingGuids string
	GUIDs                string
}{
	PageSize:             "per_page",
	Names:                "names",
	ServiceBrokerGuids:   "service_broker_guids",
	ServiceOfferingGuids: "service_offering_guids",
	GUIDs:                "guids",
}

CCQueryParams CF API query params

View Source
var JobFailure = struct {
	// REQUEST is when the job request failed.
	REQUEST JobFailureValue
	// STATUS is when the job finished with the status FAILED.
	STATUS JobFailureValue
	// TIMEOUT is when the job polling timeout has been occurred.
	TIMEOUT JobFailureValue
	// UNKNOWN any other unknown reason
	UNKNOWN JobFailureValue
}{
	REQUEST: "REQUEST",
	STATUS:  "STATUS",
	TIMEOUT: "TIMEOUT",
	UNKNOWN: "UNKNOWN",
}

JobFailure reason.

View Source
var JobState = struct {
	// COMPLETE is when the job is no longer executed, and it was successful.
	COMPLETE JobStateValue
	// FAILED is when the job is no longer running due to a failure.
	FAILED JobStateValue
	// PROCESSING is when the job is waiting to be run.
	PROCESSING JobStateValue
	// POLLING is when the job is waiting on an external resource to do the task
	POLLING JobStateValue
}{
	COMPLETE:   "COMPLETE",
	FAILED:     "FAILED",
	PROCESSING: "PROCESSING",
	POLLING:    "POLLING",
}

JobState is the current state of a job.

View Source
var VisibilityType = struct {
	PUBLIC       VisibilityTypeValue
	ADMIN        VisibilityTypeValue
	ORGANIZATION VisibilityTypeValue
	SPACE        VisibilityTypeValue
}{
	PUBLIC:       "public",
	ADMIN:        "admin",
	ORGANIZATION: "organization",
	SPACE:        "space",
}

Functions

func CreatePFlagsForCFClient

func CreatePFlagsForCFClient(set *pflag.FlagSet)

CreatePFlagsForCFClient adds pflags relevant to the CF client config

func DefaultEnv added in v0.7.0

func DefaultEnv(ctx context.Context, additionalPFlags ...func(set *pflag.FlagSet)) (env.Environment, error)

DefaultEnv creates a default environment for the CF service broker proxy

Types

type AuthenticationTypeValue added in v0.13.0

type AuthenticationTypeValue string

type CCAuthentication added in v0.13.0

type CCAuthentication struct {
	Type        AuthenticationTypeValue `json:"type"`
	Credentials CCCredentials           `json:"credentials"`
}

CCAuthentication CF CC authentication object

type CCBrokerCatalog added in v0.13.0

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

CCBrokerCatalog CF CC Service Offering broker catalog object

type CCBrokerRelationships added in v0.13.0

type CCBrokerRelationships struct {
	Space CCRelationship `json:"space"`
}

CCBrokerRelationships CF CC Service Broker relationships object

type CCCredentials added in v0.13.0

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

CCCredentials CF CC credentials object

type CCData added in v0.13.0

type CCData struct {
	GUID string `json:"guid"`
}

CCData CF CC relationship object

type CCError added in v0.13.0

type CCError struct {
	Code   int    `json:"code"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
}

CCError is the error object of CF CC V3

type CCErrorResponse added in v0.13.0

type CCErrorResponse struct {
	Errors []CCError `json:"errors"`
}

CCErrorResponse is the error response object of CF CC V3

type CCLinkObject added in v0.13.0

type CCLinkObject struct {
	Href   string `json:"href"`
	Method string `json:"method"`
}

CCLinkObject is the pagination link object of CF CC V3

type CCListOrganizationsResponse added in v0.13.0

type CCListOrganizationsResponse struct {
	Pagination CCPagination     `json:"pagination"`
	Resources  []CCOrganization `json:"resources"`
}

CCListOrganizationsResponse CF CC pagination response for the Organizations list

type CCListServiceBrokersResponse added in v0.13.0

type CCListServiceBrokersResponse struct {
	Pagination CCPagination      `json:"pagination"`
	Resources  []CCServiceBroker `json:"resources"`
}

CCListServiceBrokersResponse CF CC pagination response for SB list

type CCListServiceOfferingsResponse added in v0.13.0

type CCListServiceOfferingsResponse struct {
	Pagination CCPagination        `json:"pagination"`
	Resources  []CCServiceOffering `json:"resources"`
}

CCListServiceOfferingsResponse CF CC pagination response for Service Offerings list

type CCListServicePlansResponse added in v0.13.0

type CCListServicePlansResponse struct {
	Pagination CCPagination    `json:"pagination"`
	Resources  []CCServicePlan `json:"resources"`
}

CCListServicePlansResponse CF CC pagination response for Service Plans list

type CCOrganization added in v0.13.0

type CCOrganization struct {
	GUID string `json:"guid"`
	Name string `json:"name"`
}

CCOrganization CF CC partial Organization object

type CCPagination added in v0.13.0

type CCPagination struct {
	TotalResults int          `json:"total_results"`
	TotalPages   int          `json:"total_pages"`
	First        CCLinkObject `json:"first"`
	Last         CCLinkObject `json:"last"`
	Next         CCLinkObject `json:"next"`
	Previous     CCLinkObject `json:"previous"`
}

CCPagination is the pagination object of CF CC V3

type CCRelationship added in v0.13.0

type CCRelationship struct {
	Data CCData `json:"data"`
}

CCRelationship CF CC relationship object

type CCSaveServiceBrokerRequest added in v0.13.0

type CCSaveServiceBrokerRequest struct {
	Name           string            `json:"name"`
	URL            string            `json:"url"`
	Authentication *CCAuthentication `json:"authentication,omitempty"`
}

CCSaveServiceBrokerRequest used for create and update broker requests payload

type CCServiceBroker added in v0.13.0

type CCServiceBroker struct {
	GUID          string                `json:"guid"`
	Name          string                `json:"name"`
	URL           string                `json:"url"`
	Relationships CCBrokerRelationships `json:"relationships"`
}

CCServiceBroker CF CC partial Service Broker object

type CCServiceOffering added in v0.13.0

type CCServiceOffering struct {
	GUID          string                         `json:"guid"`
	Name          string                         `json:"name"`
	Relationships CCServiceOfferingRelationships `json:"relationships"`
}

CCServiceOffering CF CC partial Service Offering object

type CCServiceOfferingRelationships added in v0.13.0

type CCServiceOfferingRelationships struct {
	ServiceBroker CCRelationship `json:"service_broker"`
}

CCServiceOfferingRelationships CF CC Service Offering relationships object

type CCServicePlan added in v0.13.0

type CCServicePlan struct {
	GUID           string                     `json:"guid"`
	Name           string                     `json:"name"`
	BrokerCatalog  CCBrokerCatalog            `json:"broker_catalog"`
	VisibilityType VisibilityTypeValue        `json:"visibility_type"`
	Relationships  CCServicePlanRelationships `json:"relationships"`
}

CCServicePlan CF CC partial Service Plan object

type CCServicePlanRelationships added in v0.13.0

type CCServicePlanRelationships struct {
	ServiceOffering CCRelationship `json:"service_offering"`
}

CCServicePlanRelationships CF CC Service Plan relationships object

type ClientConfiguration

type ClientConfiguration struct {
	cfclient.Config `mapstructure:",squash"`

	PageSize        int `mapstructure:"page_size"`
	ChunkSize       int `mapstructure:"chunk_size"`
	JobPollTimeout  int `mapstructure:"job_poll_timeout"`
	JobPollInterval int `mapstructure:"job_poll_interval"`
}

ClientConfiguration holds cf client configurations

type Config added in v0.8.1

type Config struct {
	*ClientConfiguration `mapstructure:"client"`

	// CFClientProvider delays the creation of the creation of the CF client as it does remote calls during its creation which should be delayed
	// until the application is ran.
	CFClientProvider func(*cfclient.Config) (*cfclient.Client, error) `mapstructure:"-"`
}

Config type holds config info for building the cf client

func DefaultCFConfiguration added in v0.8.1

func DefaultCFConfiguration() *Config

DefaultCFConfiguration creates a default config for the CF client

func (*Config) Validate added in v0.8.1

func (c *Config) Validate() error

Validate validates the configuration and returns appropriate errors in case it is invalid

type Job added in v0.13.0

type Job struct {
	// RawErrors is a list of errors that occurred while processing the job.
	RawErrors []JobErrorDetails `json:"errors"`
	// GUID is a unique identifier for the job.
	GUID string `json:"guid"`
	// State is the state of the job.
	State JobStateValue `json:"state"`
	// Warnings are the warnings emitted by the job during its processing.
	Warnings []JobWarning `json:"warnings"`
}

type JobError added in v0.13.0

type JobError struct {
	FailureStatus JobFailureValue
	Error         error
}

type JobErrorDetails added in v0.13.0

type JobErrorDetails struct {
	// Code is a numeric code for this error.
	Code int64 `json:"code"`
	// Detail is a verbose description of the error.
	Detail string `json:"detail"`
	// Title is a short description of the error.
	Title string `json:"title"`
}

JobErrorDetails provides information regarding a job's error.

type JobFailureValue added in v0.13.0

type JobFailureValue string

type JobStateValue added in v0.13.0

type JobStateValue string

type JobWarning added in v0.13.0

type JobWarning struct {
	Detail string `json:"detail"`
}

JobWarning a warnings returned during the job polling execution.

type Organization added in v0.12.2

type Organization struct {
	Guid string `json:"guid"`
	Name string `json:"name"`
}

type OrganizationGuid added in v0.12.2

type OrganizationGuid struct {
	Guid string `json:"guid"`
}

type PlanData added in v0.13.0

type PlanData struct {
	GUID          string
	BrokerName    string
	CatalogPlanID string
	Public        bool
}

PlanData contains selected properties of a service plan in CF

type PlanMap added in v0.13.0

type PlanMap map[string]PlanData

PlanMap maps plan GUID to PlanData

type PlanResolver added in v0.13.0

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

PlanResolver provides functions for locating service plans based on data loaded from CF It just stores the data and provides querying in a thread-safe way It does not perform any data fetching

func NewPlanResolver added in v0.13.0

func NewPlanResolver() *PlanResolver

NewPlanResolver constructs a new NewPlanResolver

func (*PlanResolver) DeleteBroker added in v0.13.0

func (r *PlanResolver) DeleteBroker(brokerName string)

DeleteBroker deletes the data for a particular broker

func (*PlanResolver) GetBrokerPlans added in v0.13.0

func (r *PlanResolver) GetBrokerPlans(brokerNames []string) PlanMap

GetBrokerPlans returns all the plans from brokers with given names

func (*PlanResolver) GetPlan added in v0.13.0

func (r *PlanResolver) GetPlan(catalogPlanID, brokerName string) (PlanData, bool)

GetPlan returns the plan with given catalog ID and broker name

func (*PlanResolver) Reset added in v0.13.0

func (r *PlanResolver) Reset(
	ctx context.Context,
	brokers []platform.ServiceBroker,
	serviceOfferings []ServiceOffering,
	plans []ServicePlan,
)

Reset replaces all the data

func (*PlanResolver) ResetBroker added in v0.13.0

func (r *PlanResolver) ResetBroker(brokerName string, plans []ServicePlan)

ResetBroker replaces the data for a particular broker

func (*PlanResolver) UpdatePlan added in v0.13.0

func (r *PlanResolver) UpdatePlan(catalogPlanID, brokerName string, public bool)

UpdatePlan updates the public property of the given plan

type PlatformClient

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

PlatformClient provides an implementation of the service-broker-proxy/pkg/cf/Client interface. It is used to call into the cf that the proxy deployed at.

func NewClient

func NewClient(config *Settings) (*PlatformClient, error)

NewClient creates a new CF client from the specified configuration.

func (*PlatformClient) AddOrganizationVisibilities added in v0.12.2

func (pc *PlatformClient) AddOrganizationVisibilities(ctx context.Context, planGUID string, organizationGUIDs []string) error

AddOrganizationVisibilities appends organization visibilities to the existing list of the organizations

func (*PlatformClient) Broker added in v0.3.0

func (pc *PlatformClient) Broker() platform.BrokerClient

Broker returns platform client which can perform platform broker operations

func (*PlatformClient) CatalogFetcher added in v0.3.0

func (pc *PlatformClient) CatalogFetcher() platform.CatalogFetcher

CatalogFetcher returns platform client which can perform re-fetching of service broker catalogs

func (*PlatformClient) CreateBroker

CreateBroker implements service-broker-proxy/pkg/cf/Client.CreateBroker and provides logic for registering a new broker in CF

func (*PlatformClient) DeleteBroker

DeleteBroker implements service-broker-proxy/pkg/cf/Client.DeleteBroker and provides logic for deleting broker in CF

func (*PlatformClient) DeleteOrganizationVisibilities added in v0.12.2

func (pc *PlatformClient) DeleteOrganizationVisibilities(ctx context.Context, planGUID string, organizationGUID string) error

func (*PlatformClient) DisableAccessForPlan

func (pc *PlatformClient) DisableAccessForPlan(ctx context.Context, request *platform.ModifyPlanAccessRequest) error

DisableAccessForPlan implements service-broker-proxy/pkg/cf/ServiceVisibilityHandler.DisableAccessForPlan and provides logic for disabling the service access for a specified plan by the plan's catalog GUID.

func (*PlatformClient) EnableAccessForPlan

func (pc *PlatformClient) EnableAccessForPlan(ctx context.Context, request *platform.ModifyPlanAccessRequest) error

EnableAccessForPlan implements service-broker-proxy/pkg/cf/ServiceVisibilityHandler.EnableAccessForPlan and provides logic for enabling the service access for a specified plan by the plan's catalog GUID.

func (*PlatformClient) Fetch

Fetch implements service-broker-proxy/pkg/cf/Fetcher.Fetch and provides logic for triggering refetching of the broker's catalog

func (*PlatformClient) GetBroker added in v0.13.0

func (pc *PlatformClient) GetBroker(ctx context.Context, GUID string) (*platform.ServiceBroker, error)

GetBroker gets broker by broker GUID

func (*PlatformClient) GetBrokerByName added in v0.5.0

func (pc *PlatformClient) GetBrokerByName(ctx context.Context, name string) (*platform.ServiceBroker, error)

GetBrokerByName implements service-broker-proxy/pkg/cf/Client.GetBrokerByName and provides logic for getting a broker by name that is already registered in CF

func (*PlatformClient) GetBrokers

func (pc *PlatformClient) GetBrokers(ctx context.Context) ([]*platform.ServiceBroker, error)

GetBrokers implements service-broker-proxy/pkg/cf/Client.GetBrokers and provides logic for obtaining the brokers that are already registered in CF

func (*PlatformClient) GetVisibilitiesByBrokers added in v0.4.1

func (pc *PlatformClient) GetVisibilitiesByBrokers(ctx context.Context, brokerNames []string) ([]*platform.Visibility, error)

GetVisibilitiesByBrokers returns platform visibilities grouped by brokers based on given SM brokers. The visibilities are taken from CF cloud controller. For public plans, visibilities are created so that sync with sm visibilities is possible

func (*PlatformClient) ListOrganizationsByQuery added in v0.13.0

func (pc *PlatformClient) ListOrganizationsByQuery(ctx context.Context, query url.Values) ([]CCOrganization, error)

func (*PlatformClient) ListServiceBrokersByQuery added in v0.13.0

func (pc *PlatformClient) ListServiceBrokersByQuery(ctx context.Context, query url.Values) ([]CCServiceBroker, error)

func (*PlatformClient) ListServiceOfferingsByQuery added in v0.13.0

func (pc *PlatformClient) ListServiceOfferingsByQuery(ctx context.Context, query url.Values) ([]ServiceOffering, error)

func (*PlatformClient) ListServicePlansByQuery added in v0.13.0

func (pc *PlatformClient) ListServicePlansByQuery(ctx context.Context, query url.Values) ([]ServicePlan, error)

func (*PlatformClient) MakeRequest added in v0.12.2

MakeRequest making request to CF API with the given request params

func (*PlatformClient) PollJob added in v0.13.0

func (pc *PlatformClient) PollJob(ctx context.Context, jobURL string) (Warnings, *JobError)

PollJob - keep polling the given job until the job has terminated, an error is encountered, or config.OverallPollingTimeout is reached. In the last case, a JobTimeoutError is returned.

func (*PlatformClient) ReplaceOrganizationVisibilities added in v0.12.2

func (pc *PlatformClient) ReplaceOrganizationVisibilities(ctx context.Context, planGUID string, organizationGUIDs []string) error

ReplaceOrganizationVisibilities replaces existing list of organizations

func (*PlatformClient) ResetBroker added in v0.9.2

func (pc *PlatformClient) ResetBroker(ctx context.Context, broker *platform.ServiceBroker, deleted bool) error

ResetBroker resets the data for the given broker

func (*PlatformClient) ResetCache added in v0.9.2

func (pc *PlatformClient) ResetCache(ctx context.Context) error

ResetCache reloads all the data from CF

func (*PlatformClient) ScheduleJobPolling added in v0.13.0

func (pc *PlatformClient) ScheduleJobPolling(ctx context.Context, jobUrl string) *JobError

func (*PlatformClient) UpdateBroker

UpdateBroker implements service-broker-proxy/pkg/cf/Client.UpdateBroker and provides logic for updating a broker registration in CF

func (*PlatformClient) UpdateServicePlanVisibilityType added in v0.12.2

func (pc *PlatformClient) UpdateServicePlanVisibilityType(ctx context.Context, planGUID string, visibilityType VisibilityTypeValue) error

UpdateServicePlanVisibilityType updates service plan visibility type

func (*PlatformClient) Visibility added in v0.3.0

func (pc *PlatformClient) Visibility() platform.VisibilityClient

Visibility returns platform client which can perform visibility operations

func (*PlatformClient) VisibilityScopeLabelKey added in v0.3.0

func (pc *PlatformClient) VisibilityScopeLabelKey() string

VisibilityScopeLabelKey returns key to be used when scoping visibilities

type PlatformClientRequest added in v0.12.2

type PlatformClientRequest struct {
	CTX          context.Context
	URL          string
	Method       string
	QueryParams  url.Values
	RequestBody  interface{}
	ResponseBody interface{}
}

PlatformClientRequest provides generic request to CF API

type PlatformClientResponse added in v0.12.2

type PlatformClientResponse struct {
	JobURL     string
	StatusCode int
}

PlatformClientResponse provides async job url (if response status was 202) and the status code

type ServiceOffering added in v0.13.0

type ServiceOffering struct {
	GUID              string
	Name              string
	ServiceBrokerGuid string
}

ServiceOffering object

type ServicePlan added in v0.13.0

type ServicePlan struct {
	GUID                string
	Name                string
	CatalogPlanId       string
	ServiceOfferingGuid string
	Public              bool
}

ServicePlan object

type ServicePlanVisibilitiesResponse added in v0.12.2

type ServicePlanVisibilitiesResponse struct {
	Type          string         `json:"type"`
	Organizations []Organization `json:"organizations"`
}

type ServicePlanVisibility added in v0.12.2

type ServicePlanVisibility struct {
	ServicePlanGuid  string
	OrganizationGuid string
}

type Settings

type Settings struct {
	sbproxy.Settings `mapstructure:",squash"`

	CF *Config `mapstructure:"cf"`
}

Settings type wraps the CF client configuration

func DefaultSettings added in v0.7.0

func DefaultSettings() *Settings

DefaultSettings returns the default application settings

func NewConfig

func NewConfig(env env.Environment) (*Settings, error)

NewConfig creates Config from the provided environment

func (*Settings) Validate added in v0.2.0

func (s *Settings) Validate() error

Validate validates the application settings

type UpdateOrganizationVisibilitiesRequest added in v0.12.2

type UpdateOrganizationVisibilitiesRequest struct {
	Type          string             `json:"type"`
	Organizations []OrganizationGuid `json:"organizations"`
}

type UpdateVisibilitiesRequest added in v0.12.2

type UpdateVisibilitiesRequest struct {
	Type string `json:"type"`
}

type VisibilityTypeValue added in v0.12.2

type VisibilityTypeValue string

type Warnings added in v0.13.0

type Warnings []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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