Skip to content

Commit

Permalink
updated cred config JSON annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianwit@gmail.com authored and adrianwit@gmail.com committed Sep 16, 2019
1 parent 27ea08d commit 9326152
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cred/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type Config struct {
Key string `json:",omitempty"`
Secret string `json:",omitempty"`
Region string `json:",omitempty"`
AccountID string `json:"-"`
Token string `json:"-"`
AccountID string `json:",omitempty"`
Token string `json:",omitempty"`

//google cloud credential
ClientEmail string `json:"client_email,omitempty"`
Expand All @@ -48,7 +48,7 @@ type Config struct {
Type string `json:"type"`
ClientX509CertURL string `json:"client_x509_cert_url"`
AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url"`


//JSON string for this secret
Data string `json:",omitempty"`
Expand Down Expand Up @@ -95,6 +95,7 @@ func (c *Config) LoadFromReader(reader io.Reader, ext string) error {
return nil
}


func (c *Config) Save(filename string) error {
_ = os.Remove(filename)
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0644)
Expand Down Expand Up @@ -186,6 +187,15 @@ func (c *Config) NewJWTConfig(scopes ...string) (*jwt.Config, error) {
return result, nil
}


//JWTConfig returns jwt config and projectID
func (c *Config) JWTConfig(scopes ...string) (config *jwt.Config, projectID string, err error) {
config, err = c.NewJWTConfig(scopes...)
return config, c.ProjectID, err
}



func loadPEM(location string, password string) ([]byte, error) {
var pemBytes []byte
if IsKeyEncrypted(location) {
Expand Down Expand Up @@ -233,6 +243,10 @@ func (c *Config) ClientConfig() (*ssh.ClientConfig, error) {
return result, nil
}





//NewConfig create a new config for supplied file name
func NewConfig(filename string) (*Config, error) {
var config = &Config{}
Expand Down

0 comments on commit 9326152

Please sign in to comment.