@@ -3,10 +3,7 @@ package credentials
33import (
44 "context"
55
6- "google.golang.org/grpc"
7-
86 "github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
9- "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
107)
118
129// Credentials is an interface of YDB credentials required for connect with YDB
@@ -15,67 +12,25 @@ type Credentials interface {
1512 Token (context.Context ) (string , error )
1613}
1714
18- type optionsHolder struct {
19- sourceInfo string
20- }
21-
22- type option func (h * optionsHolder )
23-
24- // WithSourceInfo option append to credentials object the source info for reporting source info details on error case
25- func WithSourceInfo (sourceInfo string ) option {
26- return func (h * optionsHolder ) {
27- h .sourceInfo = sourceInfo
28- }
29- }
30-
3115// NewAccessTokenCredentials makes access token credentials object
3216// Passed options redefines default values of credentials object internal fields
33- func NewAccessTokenCredentials (accessToken string , opts ... option ) * credentials.AccessToken {
34- h := & optionsHolder {
35- sourceInfo : stack .Record (1 ),
36- }
37- for _ , o := range opts {
38- if o != nil {
39- o (h )
40- }
41- }
42- return credentials .NewAccessTokenCredentials (accessToken , credentials .WithSourceInfo (h .sourceInfo ))
17+ func NewAccessTokenCredentials (
18+ accessToken string , opts ... credentials.AccessTokenCredentialsOption ,
19+ ) * credentials.AccessToken {
20+ return credentials .NewAccessTokenCredentials (accessToken , opts ... )
4321}
4422
4523// NewAnonymousCredentials makes anonymous credentials object
4624// Passed options redefines default values of credentials object internal fields
47- func NewAnonymousCredentials (opts ... option ) * credentials.Anonymous {
48- h := & optionsHolder {
49- sourceInfo : stack .Record (1 ),
50- }
51- for _ , o := range opts {
52- if o != nil {
53- o (h )
54- }
55- }
56- return credentials .NewAnonymousCredentials (credentials .WithSourceInfo (h .sourceInfo ))
57- }
58-
59- type staticCredentialsConfig struct {
60- authEndpoint string
61- opts []grpc.DialOption
62- }
63-
64- func (s staticCredentialsConfig ) Endpoint () string {
65- return s .authEndpoint
66- }
67-
68- func (s staticCredentialsConfig ) GrpcDialOptions () []grpc.DialOption {
69- return s .opts
25+ func NewAnonymousCredentials (
26+ opts ... credentials.AnonymousCredentialsOption ,
27+ ) * credentials.Anonymous {
28+ return credentials .NewAnonymousCredentials (opts ... )
7029}
7130
7231// NewStaticCredentials makes static credentials object
73- func NewStaticCredentials (user , password , authEndpoint string , opts ... grpc.DialOption ) * credentials.Static {
74- return credentials .NewStaticCredentials (user , password ,
75- staticCredentialsConfig {
76- authEndpoint : authEndpoint ,
77- opts : opts ,
78- },
79- credentials .WithSourceInfo (stack .Record (1 )),
80- )
32+ func NewStaticCredentials (
33+ user , password , authEndpoint string , opts ... credentials.StaticCredentialsOption ,
34+ ) * credentials.Static {
35+ return credentials .NewStaticCredentials (user , password , authEndpoint , opts ... )
8136}
0 commit comments