66 "google.golang.org/grpc"
77
88 "github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
9+ "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
910)
1011
1112// Credentials is an interface of YDB credentials required for connect with YDB
@@ -29,33 +30,52 @@ func WithSourceInfo(sourceInfo string) option {
2930
3031// NewAccessTokenCredentials makes access token credentials object
3132// Passed options redefines default values of credentials object internal fields
32- func NewAccessTokenCredentials (accessToken string , opts ... option ) Credentials {
33+ func NewAccessTokenCredentials (accessToken string , opts ... option ) * credentials. AccessToken {
3334 h := & optionsHolder {
34- sourceInfo : "credentials.NewAccessTokenCredentials(token)" ,
35+ sourceInfo : stack . Record ( 1 ) ,
3536 }
3637 for _ , o := range opts {
3738 if o != nil {
3839 o (h )
3940 }
4041 }
41- return credentials .NewAccessTokenCredentials (accessToken , h .sourceInfo )
42+ return credentials .NewAccessTokenCredentials (accessToken , credentials . WithSourceInfo ( h .sourceInfo ) )
4243}
4344
4445// NewAnonymousCredentials makes anonymous credentials object
4546// Passed options redefines default values of credentials object internal fields
46- func NewAnonymousCredentials (opts ... option ) Credentials {
47+ func NewAnonymousCredentials (opts ... option ) * credentials. Anonymous {
4748 h := & optionsHolder {
48- sourceInfo : "credentials.NewAnonymousCredentials()" ,
49+ sourceInfo : stack . Record ( 1 ) ,
4950 }
5051 for _ , o := range opts {
5152 if o != nil {
5253 o (h )
5354 }
5455 }
55- return credentials .NewAnonymousCredentials (h .sourceInfo )
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
5670}
5771
5872// NewStaticCredentials makes static credentials object
59- func NewStaticCredentials (user , password , authEndpoint string , opts ... grpc.DialOption ) Credentials {
60- return credentials .NewStaticCredentials (user , password , authEndpoint , opts ... )
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+ )
6181}
0 commit comments