in pkg/provider/eks/eks.go [83:122]
func (c *EKS) NewEKSClient(*kingpin.ParseContext) error {
if c.Auth != "" {
} else if c.Auth = os.Getenv("AWS_APPLICATION_CREDENTIALS"); c.Auth == "" {
return errors.Errorf("no auth provided set the auth flag or the AWS_APPLICATION_CREDENTIALS env variable")
}
// When the auth variable points to a file
// put the file content in the variable.
if content, err := os.ReadFile(c.Auth); err == nil {
c.Auth = string(content)
}
// Check if auth data is base64 encoded and decode it.
encoded, err := regexp.MatchString("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$", c.Auth)
if err != nil {
return err
}
if encoded {
auth, err := base64.StdEncoding.DecodeString(c.Auth)
if err != nil {
return errors.Wrap(err, "could not decode auth data")
}
c.Auth = string(auth)
}
credValue := &credentials.Value{}
if err = yamlGo.UnmarshalStrict([]byte(c.Auth), credValue); err != nil {
return errors.Wrap(err, "could not get credential values")
}
awsSess := awsSession.Must(awsSession.NewSession(&aws.Config{
Credentials: credentials.NewStaticCredentialsFromCreds(*credValue),
Region: aws.String(c.DeploymentVars["ZONE"]),
}))
c.sessionAWS = awsSess
c.clientEKS = eks.New(awsSess)
c.ctx = context.Background()
return nil
}