forked from open-component-model/ocm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
134 lines (109 loc) · 4.21 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package credentials
import (
"context"
"ocm.software/ocm/api/credentials/extensions/repositories/directcreds"
"ocm.software/ocm/api/credentials/internal"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/runtime"
)
const (
KIND_CREDENTIALS = internal.KIND_CREDENTIALS
KIND_CONSUMER = internal.KIND_CONSUMER
KIND_REPOSITORY = internal.KIND_REPOSITORY
)
const CONTEXT_TYPE = internal.CONTEXT_TYPE
const AliasRepositoryType = internal.AliasRepositoryType
type (
Context = internal.Context
ContextProvider = internal.ContextProvider
RepositoryTypeScheme = internal.RepositoryTypeScheme
Repository = internal.Repository
Credentials = internal.Credentials
CredentialsSource = internal.CredentialsSource
CredentialsChain = internal.CredentialsChain
CredentialsSpec = internal.CredentialsSpec
RepositorySpec = internal.RepositorySpec
)
type (
ConsumerIdentity = internal.ConsumerIdentity
ConsumerIdentityProvider = internal.ConsumerIdentityProvider
ProviderIdentity = internal.ProviderIdentity
UsageContext = internal.UsageContext
StringUsageContext = internal.StringUsageContext
IdentityMatcher = internal.IdentityMatcher
IdentityMatcherInfo = internal.IdentityMatcherInfo
IdentityMatcherInfos = internal.IdentityMatcherInfos
IdentityMatcherRegistry = internal.IdentityMatcherRegistry
)
type (
GenericRepositorySpec = internal.GenericRepositorySpec
GenericCredentialsSpec = internal.GenericCredentialsSpec
DirectCredentials = internal.DirectCredentials
)
func DefaultContext() internal.Context {
return internal.DefaultContext
}
func FromContext(ctx context.Context) Context {
return internal.FromContext(ctx)
}
func FromProvider(p ContextProvider) Context {
return internal.FromProvider(p)
}
func DefinedForContext(ctx context.Context) (Context, bool) {
return internal.DefinedForContext(ctx)
}
func NewCredentialsSpec(name string, repospec RepositorySpec) CredentialsSpec {
return internal.NewCredentialsSpec(name, repospec)
}
func NewGenericCredentialsSpec(name string, repospec *GenericRepositorySpec) CredentialsSpec {
return internal.NewGenericCredentialsSpec(name, repospec)
}
func NewGenericRepositorySpec(data []byte, unmarshaler runtime.Unmarshaler) (RepositorySpec, error) {
return internal.NewGenericRepositorySpec(data, unmarshaler)
}
func NewCredentials(props common.Properties) Credentials {
return internal.NewCredentials(props)
}
func CredentialsFromList(props ...string) Credentials {
creds := DirectCredentials{}
for i := 1; i < len(props); i += 2 {
creds[props[i-1]] = props[i]
}
return creds
}
func CredentialsSpecFromList(props ...string) CredentialsSpec {
creds := DirectCredentials{}
for i := 1; i < len(props); i += 2 {
creds[props[i-1]] = props[i]
}
return directcreds.NewCredentials(creds.Properties())
}
func ToGenericCredentialsSpec(spec CredentialsSpec) (*GenericCredentialsSpec, error) {
return internal.ToGenericCredentialsSpec(spec)
}
func ToGenericRepositorySpec(spec RepositorySpec) (*GenericRepositorySpec, error) {
return internal.ToGenericRepositorySpec(spec)
}
func ErrUnknownCredentials(name string) error {
return internal.ErrUnknownCredentials(name)
}
// CredentialsForConsumer determine effective credentials for a consumer.
// If no credentials are configured no error and nil is returned.
// It evaluates a found credentials source for the consumer to determine the
// final credential properties.
func CredentialsForConsumer(ctx ContextProvider, id ConsumerIdentity, matchers ...IdentityMatcher) (Credentials, error) {
return internal.CredentialsForConsumer(ctx, id, false, matchers...)
}
// RequiredCredentialsForConsumer like CredentialsForConsumer, but an errors is returned
// if no credentials are found.
func RequiredCredentialsForConsumer(ctx ContextProvider, id ConsumerIdentity, matchers ...IdentityMatcher) (Credentials, error) {
return internal.CredentialsForConsumer(ctx, id, true, matchers...)
}
var (
CompleteMatch = internal.CompleteMatch
NoMatch = internal.NoMatch
PartialMatch = internal.PartialMatch
)
func NewConsumerIdentity(typ string, attrs ...string) ConsumerIdentity {
return internal.NewConsumerIdentity(typ, attrs...)
}