config

package
v0.2023.21 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MetricsNamespace = "redhat_appstudio"
	MetricsSubsystem = "spi"
)

Variables

View Source
var SPIInstanceIdContextKey = spiInstanceIdContextKeyType{}

all service provider types we support, including default values

Note: HostCredentials service provider does not belong here because it's not defined service provider that can be configured in any form.

Functions

func GetBaseUrl added in v0.2023.21

func GetBaseUrl(url *url.URL) string

func GetHostWithScheme added in v0.2023.21

func GetHostWithScheme(repoUrl string) (string, error)

GetHostWithScheme is a helper function to extract the scheme and host portion of the provided url.

func SetupCustomValidations added in v0.2023.21

func SetupCustomValidations(options CustomValidationOptions) error

SetupCustomValidations creates new validator instance and configures it with requested validations

func ValidateStruct added in v0.2023.21

func ValidateStruct(s interface{}) error

ValidateStruct validates struct on the preconfigured validator instance

Types

type CustomValidationOptions added in v0.2023.21

type CustomValidationOptions struct {
	AllowInsecureURLs bool
}

CustomValidationOptions

type ServiceProviderConfiguration

type ServiceProviderConfiguration struct {
	// ServiceProviderType is the type of the service provider.
	ServiceProviderType ServiceProviderType

	// ServiceProviderBaseUrl is the base URL of the service provider. This can be omitted for certain service provider
	// types, like GitHub that only can have 1 well-known base URL.
	ServiceProviderBaseUrl string `validate:"omitempty,https_only"`

	// Extra is the extra configuration required for some service providers to be able to uniquely identify them.
	Extra map[string]string

	// OAuth2Config holds oauth2 configuration of the service provider.
	// It can be nil in case provider does not support OAuth or we don't have it configured.
	OAuth2Config *oauth2.Config
}

ServiceProviderConfiguration contains configuration for a single service provider configured with the SPI. This mainly contains config.yaml of the OAuth application within the service provider.

func SpConfigFromGlobalConfig added in v0.2023.21

func SpConfigFromGlobalConfig(globalConfiguration *SharedConfiguration, spType ServiceProviderType, repoBaseUrl string) *ServiceProviderConfiguration

SpConfigFromGlobalConfig finds configuration of given `ServiceProviderType` and `repoBaseUrl` in given `SharedConfiguration`. Returns the configuration if found, or nil otherwise.

func SpConfigFromUserSecret added in v0.2023.21

func SpConfigFromUserSecret(ctx context.Context, k8sClient client.Client, namespace string, spType ServiceProviderType, repoUrl *url.URL) (*ServiceProviderConfiguration, error)

SpConfigFromUserSecret tries to find user's service provider secret. If it finds one, it creates and returns ServiceProviderConfiguration based on found secret. Returns nil if no matching secret found or in some cases error (see 'findUserServiceProviderConfigSecret' doc)

type ServiceProviderName added in v0.2023.21

type ServiceProviderName string

type ServiceProviderType

type ServiceProviderType struct {
	Name                 ServiceProviderName
	DefaultOAuthEndpoint oauth2.Endpoint // default oauth endpoint of the service provider
	DefaultHost          string          // default host of the service provider. ex.: `github.com`
	DefaultBaseUrl       string          // default base url of the service provider, typically scheme+host. ex: `https://github.com`
}
var ServiceProviderTypeGitHub ServiceProviderType = ServiceProviderType{
	Name:                 "GitHub",
	DefaultOAuthEndpoint: github.Endpoint,
	DefaultHost:          githubHost,
	DefaultBaseUrl:       "https://" + githubHost,
}
var ServiceProviderTypeGitLab ServiceProviderType = ServiceProviderType{
	Name: "GitLab",
	DefaultOAuthEndpoint: oauth2.Endpoint{
		AuthURL:  gitlabUrl + "/oauth/authorize",
		TokenURL: gitlabUrl + "/oauth/token",
	},
	DefaultHost:    gitlabHost,
	DefaultBaseUrl: gitlabUrl,
}
var ServiceProviderTypeHostCredentials ServiceProviderType = ServiceProviderType{
	Name: "HostCredentials",
}

HostCredentials service provider is used for service provider URLs that we don't support (are not in list of SupportedServiceProviderTypes). We can still provide limited functionality for them like manual token upload.

var ServiceProviderTypeQuay ServiceProviderType = ServiceProviderType{
	Name: "Quay",
	DefaultOAuthEndpoint: oauth2.Endpoint{
		AuthURL:  quaySaasBaseUrl + "/oauth/authorize",
		TokenURL: quaySaasBaseUrl + "/oauth/access_token",
	},
	DefaultHost:    quaySaasHost,
	DefaultBaseUrl: quaySaasBaseUrl,
}

func GetServiceProviderTypeByName added in v0.2023.21

func GetServiceProviderTypeByName(name ServiceProviderName) (ServiceProviderType, error)

type SharedConfiguration added in v0.7.3

type SharedConfiguration struct {
	// ServiceProviders is the list of configuration options for the individual service providers
	ServiceProviders []ServiceProviderConfiguration `validate:"omitempty,dive"`

	// BaseUrl is the URL on which the OAuth service is deployed. It is used to compose the redirect URLs for the
	// service providers in the form of `${BASE_URL}/oauth/callback` (e.g. my-host/oauth/callback).
	BaseUrl string `validate:"required,https_only"`
}

SharedConfiguration contains the specification of the known service providers as well as other configuration data shared between the SPI OAuth service and the SPI operator

func LoadFrom

func LoadFrom(configFilePath, baseUrl string) (SharedConfiguration, error)

Jump to

Keyboard shortcuts

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