Documentation
¶
Index ¶
- Variables
- func GetAllScopes(sp ServiceProvider, perms *api.Permissions) []string
- func KnownInitializers() map[config.ServiceProviderType]Initializer
- type Constructor
- type ConstructorFunc
- type Factory
- type Github
- func (g *Github) GetBaseUrl() string
- func (g *Github) GetOAuthEndpoint() string
- func (g *Github) GetServiceProviderUrlForRepo(repoUrl string) (string, error)
- func (g *Github) GetType() api.ServiceProviderType
- func (g *Github) LookupToken(ctx context.Context, cl client.Client, binding *api.SPIAccessTokenBinding) (*api.SPIAccessToken, error)
- func (g *Github) TranslateToScopes(permission api.Permission) []string
- type Initializer
- type Probe
- type ProbeFunc
- type Quay
- func (g *Quay) GetBaseUrl() string
- func (g *Quay) GetOAuthEndpoint() string
- func (g *Quay) GetServiceProviderUrlForRepo(repoUrl string) (string, error)
- func (g *Quay) GetType() api.ServiceProviderType
- func (g *Quay) LookupToken(ctx context.Context, cl client.Client, binding *api.SPIAccessTokenBinding) (*api.SPIAccessToken, error)
- func (g *Quay) TranslateToScopes(permission api.Permission) []string
- type ServiceProvider
Constants ¶
This section is empty.
Variables ¶
var GithubInitializer = Initializer{ Probe: githubProbe{}, Constructor: ConstructorFunc(newGithub), }
var QuayInitializer = Initializer{ Probe: quayProbe{}, Constructor: ConstructorFunc(newQuay), }
Functions ¶
func GetAllScopes ¶
func GetAllScopes(sp ServiceProvider, perms *api.Permissions) []string
GetAllScopes is a helper method to translate all the provided permissions into a list of service-provided-specific scopes.
func KnownInitializers ¶ added in v0.2.1
func KnownInitializers() map[config.ServiceProviderType]Initializer
KnownInitializers returns a map of service provider initializers known at compile time. The Factory.Initializers should be set to this value under normal circumstances.
Types ¶
type Constructor ¶ added in v0.2.1
type Constructor interface { // Construct creates a new instance of service provider Construct(factory *Factory, baseUrl string) (ServiceProvider, error) }
Constructor is able to produce a new service provider instance using data from the provided Factory and the base URL of the service provider.
type ConstructorFunc ¶ added in v0.2.1
type ConstructorFunc func(factory *Factory, baseUrl string) (ServiceProvider, error)
ConstructorFunc converts a compatible function into the Constructor interface
func (ConstructorFunc) Construct ¶ added in v0.2.1
func (c ConstructorFunc) Construct(factory *Factory, baseUrl string) (ServiceProvider, error)
type Factory ¶
type Factory struct { Configuration config.Configuration Client *http.Client Initializers map[config.ServiceProviderType]Initializer }
Factory is able to construct service providers from repository URLs.
func (*Factory) FromRepoUrl ¶
func (f *Factory) FromRepoUrl(repoUrl string) (ServiceProvider, error)
FromRepoUrl returns the service provider instance able to talk to the repository on the provided URL.
type Github ¶
type Github struct {
Configuration config.Configuration
}
func (*Github) GetBaseUrl ¶
func (*Github) GetOAuthEndpoint ¶
func (*Github) GetServiceProviderUrlForRepo ¶
func (*Github) GetType ¶
func (g *Github) GetType() api.ServiceProviderType
func (*Github) LookupToken ¶
func (g *Github) LookupToken(ctx context.Context, cl client.Client, binding *api.SPIAccessTokenBinding) (*api.SPIAccessToken, error)
func (*Github) TranslateToScopes ¶
func (g *Github) TranslateToScopes(permission api.Permission) []string
type Initializer ¶ added in v0.2.1
type Initializer struct { Probe Probe Constructor Constructor }
Initializer is struct that contains all necessary data to initialize a service provider instance from a URL using a Factory.
type Probe ¶ added in v0.2.1
type Probe interface { // Examine returns the base url of the service provider, if the provided URL can be handled by that provider or // an empty string if it cannot. The provided http client can be used to perform requests against the URL if needed. Examine(cl *http.Client, url string) (string, error) }
Probe is a simple function that can determine whether a URL can be handled by a certain service provider.
type ProbeFunc ¶ added in v0.2.1
ProbeFunc provides the Probe implementation for compatible functions
type Quay ¶
type Quay struct {
Configuration config.Configuration
}
func (*Quay) GetBaseUrl ¶
func (*Quay) GetOAuthEndpoint ¶
func (*Quay) GetServiceProviderUrlForRepo ¶
func (*Quay) GetType ¶
func (g *Quay) GetType() api.ServiceProviderType
func (*Quay) LookupToken ¶
func (g *Quay) LookupToken(ctx context.Context, cl client.Client, binding *api.SPIAccessTokenBinding) (*api.SPIAccessToken, error)
func (*Quay) TranslateToScopes ¶
func (g *Quay) TranslateToScopes(permission api.Permission) []string
type ServiceProvider ¶
type ServiceProvider interface { // LookupToken tries to match an SPIAccessToken object with the requirements expressed in the provided binding. // This usually searches kubernetes (using the provided client) and the service provider itself (using some specific // mechanism (usually an http client)). LookupToken(ctx context.Context, cl client.Client, binding *api.SPIAccessTokenBinding) (*api.SPIAccessToken, error) // GetBaseUrl returns the base URL of the service provider this instance talks to. This info is saved with the // SPIAccessTokens so that later on, the OAuth service can use it to construct the OAuth flow URLs. GetBaseUrl() string // TranslateToScopes translates the provided permission object into (a set of) service-provider-specific scopes. TranslateToScopes(permission api.Permission) []string // GetType merely returns the type of the service provider this instance talks to. GetType() api.ServiceProviderType // GetOAuthEndpoint returns the URL of the OAuth initiation. This must point to the SPI oauth service, NOT //the service provider itself. GetOAuthEndpoint() string }
ServiceProvider abstracts the interaction with some service provider