Last active
November 12, 2017 22:41
-
-
Save jhgaylor/5fb4ade3489d24684f3a5970745c1faa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ci | |
import ( | |
"crypto/tls" | |
rc "github.com/concourse/fly/rc" | |
"github.com/concourse/go-concourse/concourse" | |
) | |
type target struct { | |
baseTarget rc.Target | |
token *rc.TargetToken | |
} | |
func NewTarget(baseTarget rc.Target, token rc.TargetToken) *target { | |
return &target{ | |
baseTarget: baseTarget, | |
token: &token, | |
} | |
} | |
func (t *target) Client() concourse.Client { | |
return t.baseTarget.Client() | |
} | |
func (t *target) Team() concourse.Team { | |
return t.baseTarget.Team() | |
} | |
func (t *target) CACert() string { | |
return t.baseTarget.CACert() | |
} | |
func (t *target) TLSConfig() *tls.Config { | |
return t.baseTarget.TLSConfig() | |
} | |
func (t *target) URL() string { | |
return t.baseTarget.URL() | |
} | |
func (t *target) Token() *rc.TargetToken { | |
return t.token | |
} | |
func (t *target) IsWorkerVersionCompatible(workerVersion string) (bool, error) { | |
return t.baseTarget.IsWorkerVersionCompatible(workerVersion) | |
} | |
func (t *target) TokenAuthorization() (string, bool) { | |
return t.baseTarget.TokenAuthorization() | |
} | |
func (t *target) Validate() error { | |
return t.baseTarget.Validate() | |
} | |
func (t *target) ValidateWithWarningOnly() error { | |
return t.baseTarget.ValidateWithWarningOnly() | |
} | |
func (t *target) WorkerVersion() (string, error) { | |
return t.baseTarget.WorkerVersion() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func NewCI( | |
teamName string, | |
url string, | |
username string, | |
password string, | |
insecure bool, | |
caCert string, | |
) (*ConcourseCI, error) { | |
authTarget, _ := rc.NewBasicAuthTarget("dev-sugar", url, teamName, insecure, username, password, caCert, false) | |
fmt.Printf("CI: got a basic auth target.\n") | |
token, _ := authTarget.Team().AuthToken() | |
fmt.Printf("CI: got an auth token using basic auth creds.\n") | |
rctoken := rc.TargetToken(token) | |
target := NewTarget(authTarget, rctoken) | |
webRequestGenerator := rata.NewRequestGenerator(target.Client().URL(), web.Routes) | |
ci := &ConcourseCI{ | |
target: target, | |
webRequestGenerator: webRequestGenerator, | |
} | |
return ci, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment