You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// CredentialReader is the interface that wraps a Credential Read method
9
+
// The Reader should get credential information from somewhere (usually the runtime environment), and returns
10
+
// a Credential struct as well as a boolean that indicates whether the reading of credential pieces (ie, Username, Password and/or Token) was successful.
11
+
// Success is not strictly whether the pieces of information were found, but whether they existed in the environment to be read. A Credential struct with
12
+
// empty strings for its fields is still a valid Credential
13
+
typeCredentialReaderinterface {
14
+
Read(*url.URL) (Credential, bool)
15
+
}
16
+
17
+
// CredentialWriter is the interface wrapping the Write method for Credentials
18
+
// Write may write a credential to any form (string, another struct), and any medium (memory, file, etc).
19
+
typeCredentialWriterinterface {
20
+
Write(Credential) error
21
+
}
22
+
23
+
// CredentialReaderWriter is an interface that combines both the CredentialReader and CredentialWriter
24
+
typeCredentialReaderWriterinterface {
25
+
CredentialReader
26
+
CredentialWriter
27
+
}
28
+
29
+
// Credential encapsulates a username/password pair
30
+
typeCredentialstruct {
31
+
Usernamestring
32
+
Passwordstring
33
+
}
34
+
35
+
// Conjoin returns a string with the Credential content joined by a ':' (colon character)
36
+
func (c*Credential) Conjoin() string {
37
+
returnc.Username+":"+c.Password
38
+
}
39
+
40
+
// Base64 returns a string with the provided Credential content base64 encoded after being joined by ':' (colon character)
0 commit comments