-
Notifications
You must be signed in to change notification settings - Fork 4
/
credentials.go
61 lines (50 loc) · 2.38 KB
/
credentials.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
package main
import "log"
// NugetServerCredentials are credentials defined in the CI server and injected into this trusted image
type NugetServerCredentials struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
AdditionalProperties NugetServerCredentialsAdditionalProperties `json:"additionalProperties,omitempty"`
}
// NugetServerCredentialsAdditionalProperties has additional properties for the Nuget Server credentials
type NugetServerCredentialsAdditionalProperties struct {
APIURL string `json:"apiUrl,omitempty"`
APIKey string `json:"apiKey,omitempty"`
}
// SonarQubeServerCredentials are credentials defined in the CI server and injected into this trusted image
type SonarQubeServerCredentials struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
AdditionalProperties SonarQubeServerCredentialsAdditionalProperties `json:"additionalProperties,omitempty"`
}
// SonarQubeServerCredentialsAdditionalProperties has additional properties for the SonarQube Server credentials
type SonarQubeServerCredentialsAdditionalProperties struct {
APIURL string `json:"apiUrl,omitempty"`
Token string `json:"token,omitempty"`
}
// GetNugetServerCredentialsByName returns a credential with the specified name
func GetNugetServerCredentialsByName(c []NugetServerCredentials, name string) *NugetServerCredentials {
log.Printf("Looking for credential with name %v...", name)
for _, cred := range c {
log.Printf("Checking credential %v...", cred.Name)
if cred.Name == name {
log.Printf("Credential with name %v was retrieved.", name)
return &cred
}
}
log.Printf("Credential with name %v was not found.", name)
return nil
}
// GetSonarQubeServerCredentialsByName returns a credential with the specified name
func GetSonarQubeServerCredentialsByName(c []SonarQubeServerCredentials, name string) *SonarQubeServerCredentials {
log.Printf("Looking for credential with name %v...", name)
for _, cred := range c {
log.Printf("Checking credential %v...", cred.Name)
if cred.Name == name {
log.Printf("Credential with name %v was retrieved.", name)
return &cred
}
}
log.Printf("Credential with name %v was not found.", name)
return nil
}