forked from forj-oss/forjj-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github_creds.go
37 lines (31 loc) · 879 Bytes
/
github_creds.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
package main
import "fmt"
type UserPasswordCreds struct {
Name string `yaml:"name,omitempty"`
password string
}
func (t *UserPasswordCreds) SetFrom(d *GithubUserStruct) (status bool) {
status = SetIfSet(&t.Name, d.Username)
return
}
func (t *UserPasswordCreds) UpdateFrom(d *GithubUserStruct) (status bool) {
status = SetOrClean(&t.Name, d.Username)
return
}
func (t *UserPasswordCreds) setPassword(password string) (_ error) {
if t.Name == "" && password == "" {
return
}
if t.Name == "" {
return fmt.Errorf("You set the github user password, but the github user name is missing. " +
"Please, update your Forjfile.")
}
if password == "" {
return fmt.Errorf("Password for '%s' is missing. Please set the github password and retry.", t.Name)
}
t.password = password
return
}
func (t *UserPasswordCreds) GetPassword() string {
return t.password
}