Documentation
¶
Index ¶
- Constants
- Variables
- func CompleteMatch(pattern, cur, id ConsumerIdentity) bool
- func ErrUnknownConsumer(name string) error
- func ErrUnknownCredentials(name string) error
- func ErrUnknownRepository(kind, name string) error
- func NoMatch(pattern, cur, id ConsumerIdentity) bool
- func PartialMatch(pattern, cur, id ConsumerIdentity) bool
- func RegisterIdentityMatcher(typ string, matcher IdentityMatcher, desc string)
- type AliasRegistry
- type Builder
- func (b Builder) Bound() (Context, context.Context)
- func (b Builder) New(m ...datacontext.BuilderMode) Context
- func (b Builder) WithConfig(ctx config.Context) Builder
- func (b Builder) WithContext(ctx context.Context) Builder
- func (b Builder) WithRepositoyTypeScheme(scheme RepositoryTypeScheme) Builder
- func (b Builder) WithStandardConumerMatchers(matchers IdentityMatcherRegistry) Builder
- type ConsumerIdentity
- func (i ConsumerIdentity) Copy() ConsumerIdentity
- func (i ConsumerIdentity) Equals(o ConsumerIdentity) bool
- func (i ConsumerIdentity) Key() []byte
- func (i ConsumerIdentity) Match(obj map[string]string) bool
- func (i ConsumerIdentity) SetNonEmptyValue(name, value string)
- func (i ConsumerIdentity) String() string
- func (i ConsumerIdentity) Type() string
- type Context
- type ContextProvider
- type Credentials
- type CredentialsChain
- type CredentialsSource
- type CredentialsSpec
- type DefaultCredentialsSpec
- func (s *DefaultCredentialsSpec) Credentials(ctx Context, creds ...CredentialsSource) (Credentials, error)
- func (s *DefaultCredentialsSpec) GetCredentialsName() string
- func (s *DefaultCredentialsSpec) GetRepositorySpec(Context) RepositorySpec
- func (s DefaultCredentialsSpec) MarshalJSON() ([]byte, error)
- func (s *DefaultCredentialsSpec) UnmarshalJSON(data []byte) error
- type DirectCredentials
- func (c DirectCredentials) Copy() DirectCredentials
- func (c DirectCredentials) Credentials(Context, ...CredentialsSource) (Credentials, error)
- func (c DirectCredentials) ExistsProperty(name string) bool
- func (c DirectCredentials) GetProperty(name string) string
- func (c DirectCredentials) Properties() common.Properties
- func (c DirectCredentials) PropertyNames() sets.String
- func (c DirectCredentials) String() string
- type GenericCredentialsSpec
- func (s *GenericCredentialsSpec) Credentials(ctx Context, creds ...CredentialsSource) (Credentials, error)
- func (s *GenericCredentialsSpec) GetCredentialsName() string
- func (s *GenericCredentialsSpec) GetRepositorySpec(context Context) RepositorySpec
- func (s GenericCredentialsSpec) MarshalJSON() ([]byte, error)
- func (s *GenericCredentialsSpec) UnmarshalJSON(data []byte) error
- type GenericRepositorySpec
- type IdentityMatcher
- type IdentityMatcherInfo
- type IdentityMatcherInfos
- type IdentityMatcherRegistry
- type Repository
- type RepositorySpec
- type RepositoryType
- type RepositoryTypeScheme
- type SetAliasFunction
- type UnknownRepositorySpec
Constants ¶
const ( ID_TYPE = ATTR_TYPE ATTR_TYPE = "type" ATTR_USERNAME = "username" ATTR_PASSWORD = "password" ATTR_SERVER_ADDRESS = "serverAddress" ATTR_IDENTITY_TOKEN = "identityToken" ATTR_REGISTRY_TOKEN = "registryToken" ATTR_TOKEN = "token" ATTR_AWS_ACCESS_KEY_ID = "awsAccessKeyID" ATTR_AWS_SECRET_ACCESS_KEY = "awsSecretAccessKey" ATTR_KEY = "key" )
const ( KIND_CREDENTIALS = "credentials" KIND_CONSUMER = "consumer" KIND_REPOSITORY = "repository" )
const AliasRepositoryType = "Alias"
const CONTEXT_TYPE = "credentials" + datacontext.OCM_CONTEXT_SUFFIX
CONTEXT_TYPE is the global type for a credential context.
Variables ¶
var DefaultContext = Builder{}.New(datacontext.MODE_SHARED)
DefaultContext is the default context initialized by init functions.
var DefaultRepositoryTypeScheme = NewRepositoryTypeScheme(nil)
DefaultRepositoryTypeScheme contains all globally known access serializer.
var StandardIdentityMatchers = NewMatcherRegistry()
Functions ¶
func CompleteMatch ¶
func CompleteMatch(pattern, cur, id ConsumerIdentity) bool
func ErrUnknownConsumer ¶
func ErrUnknownCredentials ¶
func ErrUnknownRepository ¶
func NoMatch ¶
func NoMatch(pattern, cur, id ConsumerIdentity) bool
func PartialMatch ¶
func PartialMatch(pattern, cur, id ConsumerIdentity) bool
func RegisterIdentityMatcher ¶
func RegisterIdentityMatcher(typ string, matcher IdentityMatcher, desc string)
Types ¶
type AliasRegistry ¶
type AliasRegistry interface {
SetAlias(ctx Context, name string, spec RepositorySpec, creds CredentialsSource) error
}
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (Builder) New ¶
func (b Builder) New(m ...datacontext.BuilderMode) Context
func (Builder) WithRepositoyTypeScheme ¶
func (b Builder) WithRepositoyTypeScheme(scheme RepositoryTypeScheme) Builder
func (Builder) WithStandardConumerMatchers ¶
func (b Builder) WithStandardConumerMatchers(matchers IdentityMatcherRegistry) Builder
type ConsumerIdentity ¶
ConsumerIdentity describes the identity of a credential consumer.
func IdentityByURL ¶
func IdentityByURL(url string) ConsumerIdentity
IdentityByURL return a simple url identity.
func (ConsumerIdentity) Copy ¶
func (i ConsumerIdentity) Copy() ConsumerIdentity
Copy copies identity.
func (ConsumerIdentity) Equals ¶
func (i ConsumerIdentity) Equals(o ConsumerIdentity) bool
Equals compares two identities.
func (ConsumerIdentity) Key ¶
func (i ConsumerIdentity) Key() []byte
Key returns the object digest of an identity.
func (ConsumerIdentity) Match ¶
func (i ConsumerIdentity) Match(obj map[string]string) bool
Match implements the selector interface.
func (ConsumerIdentity) SetNonEmptyValue ¶
func (i ConsumerIdentity) SetNonEmptyValue(name, value string)
SetNonEmptyValue sets a key-value pair only if the value is not empty.
func (ConsumerIdentity) String ¶
func (i ConsumerIdentity) String() string
String returns the string representation of an identity.
func (ConsumerIdentity) Type ¶
func (i ConsumerIdentity) Type() string
Type returns the required consumer type.
type Context ¶
type Context interface { datacontext.Context ContextProvider config.ContextProvider AttributesContext() datacontext.AttributesContext RepositoryTypes() RepositoryTypeScheme RepositorySpecForConfig(data []byte, unmarshaler runtime.Unmarshaler) (RepositorySpec, error) RepositoryForSpec(spec RepositorySpec, creds ...CredentialsSource) (Repository, error) RepositoryForConfig(data []byte, unmarshaler runtime.Unmarshaler, creds ...CredentialsSource) (Repository, error) CredentialsForSpec(spec CredentialsSpec, creds ...CredentialsSource) (Credentials, error) CredentialsForConfig(data []byte, unmarshaler runtime.Unmarshaler, cred ...CredentialsSource) (Credentials, error) GetCredentialsForConsumer(ConsumerIdentity, ...IdentityMatcher) (CredentialsSource, error) SetCredentialsForConsumer(identity ConsumerIdentity, creds CredentialsSource) SetAlias(name string, spec RepositorySpec, creds ...CredentialsSource) error ConsumerIdentityMatchers() IdentityMatcherRegistry }
func ForContext ¶
ForContext returns the Context to use for context.Context. This is either an explicit context or the default context.
type ContextProvider ¶
type ContextProvider interface {
CredentialsContext() Context
}
type Credentials ¶
type Credentials interface { CredentialsSource ExistsProperty(name string) bool GetProperty(name string) string PropertyNames() sets.String Properties() common.Properties }
func CredentialsForConsumer ¶
func CredentialsForConsumer(ctx ContextProvider, id ConsumerIdentity, unknownAsError bool, matchers ...IdentityMatcher) (Credentials, error)
type CredentialsChain ¶
type CredentialsChain []CredentialsSource
CredentialsChain is a chain of credentials, where the credential i+1 (is present) is used to resolve credential i.
func (CredentialsChain) Credentials ¶
func (c CredentialsChain) Credentials(ctx Context, creds ...CredentialsSource) (Credentials, error)
type CredentialsSource ¶
type CredentialsSource interface {
Credentials(Context, ...CredentialsSource) (Credentials, error)
}
CredentialsSource is a factory for effective credentials.
type CredentialsSpec ¶
type CredentialsSpec interface { CredentialsSource GetCredentialsName() string GetRepositorySpec(Context) RepositorySpec }
CredentialsSpec describes a dedicated credential provided by some repository.
func NewCredentialsSpec ¶
func NewCredentialsSpec(name string, repospec RepositorySpec) CredentialsSpec
type DefaultCredentialsSpec ¶
type DefaultCredentialsSpec struct { RepositorySpec RepositorySpec CredentialsName string }
func (*DefaultCredentialsSpec) Credentials ¶
func (s *DefaultCredentialsSpec) Credentials(ctx Context, creds ...CredentialsSource) (Credentials, error)
func (*DefaultCredentialsSpec) GetCredentialsName ¶
func (s *DefaultCredentialsSpec) GetCredentialsName() string
func (*DefaultCredentialsSpec) GetRepositorySpec ¶
func (s *DefaultCredentialsSpec) GetRepositorySpec(Context) RepositorySpec
func (DefaultCredentialsSpec) MarshalJSON ¶
func (s DefaultCredentialsSpec) MarshalJSON() ([]byte, error)
MarshalJSON implements a custom json unmarshal method.
func (*DefaultCredentialsSpec) UnmarshalJSON ¶
func (s *DefaultCredentialsSpec) UnmarshalJSON(data []byte) error
UnmarshalJSON implements a custom default json unmarshal method. It should not be used because it always used the default context.
type DirectCredentials ¶
type DirectCredentials common.Properties
func NewCredentials ¶
func NewCredentials(props common.Properties) DirectCredentials
func (DirectCredentials) Copy ¶
func (c DirectCredentials) Copy() DirectCredentials
func (DirectCredentials) Credentials ¶
func (c DirectCredentials) Credentials(Context, ...CredentialsSource) (Credentials, error)
func (DirectCredentials) ExistsProperty ¶
func (c DirectCredentials) ExistsProperty(name string) bool
func (DirectCredentials) GetProperty ¶
func (c DirectCredentials) GetProperty(name string) string
func (DirectCredentials) Properties ¶
func (c DirectCredentials) Properties() common.Properties
func (DirectCredentials) PropertyNames ¶
func (c DirectCredentials) PropertyNames() sets.String
func (DirectCredentials) String ¶
func (c DirectCredentials) String() string
type GenericCredentialsSpec ¶
type GenericCredentialsSpec struct { RepositorySpec *GenericRepositorySpec CredentialsName string }
func NewGenericCredentialsSpec ¶
func NewGenericCredentialsSpec(name string, repospec *GenericRepositorySpec) *GenericCredentialsSpec
func ToGenericCredentialsSpec ¶
func ToGenericCredentialsSpec(spec CredentialsSpec) (*GenericCredentialsSpec, error)
func (*GenericCredentialsSpec) Credentials ¶
func (s *GenericCredentialsSpec) Credentials(ctx Context, creds ...CredentialsSource) (Credentials, error)
func (*GenericCredentialsSpec) GetCredentialsName ¶
func (s *GenericCredentialsSpec) GetCredentialsName() string
func (*GenericCredentialsSpec) GetRepositorySpec ¶
func (s *GenericCredentialsSpec) GetRepositorySpec(context Context) RepositorySpec
func (GenericCredentialsSpec) MarshalJSON ¶
func (s GenericCredentialsSpec) MarshalJSON() ([]byte, error)
MarshalJSON implements a custom json unmarshal method.
func (*GenericCredentialsSpec) UnmarshalJSON ¶
func (s *GenericCredentialsSpec) UnmarshalJSON(data []byte) error
UnmarshalJSON implements a custom json unmarshal method for a unstructured typed object.
type GenericRepositorySpec ¶
type GenericRepositorySpec struct {
runtime.UnstructuredVersionedTypedObject `json:",inline"`
}
func ToGenericRepositorySpec ¶
func ToGenericRepositorySpec(spec RepositorySpec) (*GenericRepositorySpec, error)
func (*GenericRepositorySpec) Evaluate ¶
func (s *GenericRepositorySpec) Evaluate(ctx Context) (RepositorySpec, error)
func (*GenericRepositorySpec) Repository ¶
func (s *GenericRepositorySpec) Repository(ctx Context, creds Credentials) (Repository, error)
type IdentityMatcher ¶
type IdentityMatcher func(pattern, cur, id ConsumerIdentity) bool
IdentityMatcher checks whether id matches against pattern and if this match is better than the one for cur.
func AndMatcher ¶
func AndMatcher(matchers ...IdentityMatcher) IdentityMatcher
func OrMatcher ¶
func OrMatcher(matchers ...IdentityMatcher) IdentityMatcher
type IdentityMatcherInfo ¶
type IdentityMatcherInfo struct { Type string Matcher IdentityMatcher Description string }
type IdentityMatcherInfos ¶
type IdentityMatcherInfos []IdentityMatcherInfo
func (IdentityMatcherInfos) Description ¶
func (l IdentityMatcherInfos) Description(i int) string
func (IdentityMatcherInfos) Key ¶
func (l IdentityMatcherInfos) Key(i int) string
func (IdentityMatcherInfos) Size ¶
func (l IdentityMatcherInfos) Size() int
type IdentityMatcherRegistry ¶
type IdentityMatcherRegistry interface { Register(typ string, matcher IdentityMatcher, desc string) Get(typ string) (IdentityMatcher, string) List() IdentityMatcherInfos }
func NewMatcherRegistry ¶
func NewMatcherRegistry() IdentityMatcherRegistry
type Repository ¶
type Repository interface { ExistsCredentials(name string) (bool, error) LookupCredentials(name string) (Credentials, error) WriteCredentials(name string, creds Credentials) (Credentials, error) }
type RepositorySpec ¶
type RepositorySpec interface { runtime.VersionedTypedObject Repository(Context, Credentials) (Repository, error) }
func CreateRepositorySpec ¶
func CreateRepositorySpec(t runtime.TypedObject) (RepositorySpec, error)
func NewGenericRepositorySpec ¶
func NewGenericRepositorySpec(data []byte, unmarshaler runtime.Unmarshaler) (RepositorySpec, error)
type RepositoryType ¶
type RepositoryType interface { runtime.TypedObjectDecoder runtime.VersionedTypedObject }
type RepositoryTypeScheme ¶
type RepositoryTypeScheme interface { runtime.Scheme AddKnownTypes(s RepositoryTypeScheme) GetRepositoryType(name string) RepositoryType Register(name string, atype RepositoryType) DecodeRepositorySpec(data []byte, unmarshaler runtime.Unmarshaler) (RepositorySpec, error) CreateRepositorySpec(obj runtime.TypedObject) (RepositorySpec, error) }
func NewRepositoryTypeScheme ¶
func NewRepositoryTypeScheme(defaultRepoDecoder runtime.TypedObjectDecoder, base ...RepositoryTypeScheme) RepositoryTypeScheme
type SetAliasFunction ¶
type SetAliasFunction func(ctx Context, name string, spec RepositorySpec, creds CredentialsSource) error
type UnknownRepositorySpec ¶
type UnknownRepositorySpec struct {
runtime.UnstructuredVersionedTypedObject `json:",inline"`
}
func (*UnknownRepositorySpec) Repository ¶
func (r *UnknownRepositorySpec) Repository(Context, Credentials) (Repository, error)