Skip to content

Commit

Permalink
🔥 remove serviceAccountFile option and revise functions
Browse files Browse the repository at this point in the history
Signed-off-by: Rintaro Okamura <[email protected]>
  • Loading branch information
rinx committed Jun 17, 2020
1 parent 0944eb5 commit 6db3513
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 23 deletions.
1 change: 0 additions & 1 deletion charts/vald/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@ stackdriver:
{{- else }}
scopes: []
{{- end }}
service_account_file: {{ default .default.stackdriver.client.service_account_file .Values.stackdriver.client.service_account_file | quote }}
user_agent: {{ default .default.stackdriver.client.user_agent .Values.stackdriver.client.user_agent | quote }}
telemetry_enabled: {{ default .default.stackdriver.client.telemetry_enabled .Values.stackdriver.client.telemetry_enabled }}
authentication_enabled: {{ default .default.stackdriver.client.authentication_enabled .Values.stackdriver.client.authentication_enabled }}
Expand Down
3 changes: 0 additions & 3 deletions charts/vald/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,6 @@ defaults:
# @schema {"name": "defaults.observability.stackdriver.client.scopes", "type": "array", "items": {"type": "string"}}
# defaults.observability.stackdriver.client.scopes -- overrides the default OAuth2 scopes to be used for a service.
scopes: []
# @schema {"name": "defaults.observability.stackdriver.client.service_account_file", "type": "string"}
# defaults.observability.stackdriver.client.service_account_file -- a Google service account credentials file to authenticate.
service_account_file: ""
# @schema {"name": "defaults.observability.stackdriver.client.user_agent", "type": "string"}
# defaults.observability.stackdriver.client.user_agent -- sets the User-Agent.
user_agent: ""
Expand Down
89 changes: 70 additions & 19 deletions internal/observability/client/google/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,76 @@ import (

type Option = option.ClientOption

var (
WithAPIKey = option.WithAPIKey
WithAudiences = option.WithAudiences
WithCredentialsFile = option.WithCredentialsFile
WithEndpoint = option.WithEndpoint
WithQuotaProject = option.WithQuotaProject
WithRequestReason = option.WithRequestReason
WithScopes = option.WithScopes
WithServiceAccountFile = option.WithServiceAccountFile
WithUserAgent = option.WithUserAgent

// WithClientCertSource(s ClientCertSource) ClientOption
// WithCredentials(creds *google.Credentials) ClientOption
// WithGRPCConn(conn *grpc.ClientConn) ClientOption
// WithGRPCConnectionPool(size int) ClientOption
// WithGRPCDialOption(opt grpc.DialOption) ClientOption
// WithHTTPClient(client *http.Client) ClientOption
// WithTokenSource(s oauth2.TokenSource) ClientOption
)
// WithClientCertSource(s ClientCertSource) ClientOption
// WithCredentials(creds *google.Credentials) ClientOption
// WithGRPCConn(conn *grpc.ClientConn) ClientOption
// WithGRPCConnectionPool(size int) ClientOption
// WithGRPCDialOption(opt grpc.DialOption) ClientOption
// WithHTTPClient(client *http.Client) ClientOption
// WithTokenSource(s oauth2.TokenSource) ClientOption

func WithAPIKey(apiKey string) Option {
if apiKey == "" {
return nil
}
return option.WithAPIKey(apiKey)
}

func WithAudiences(audiences ...string) Option {
if len(audiences) == 0 {
return nil
}

return option.WithAudiences(audiences...)
}

func WithCredentialsFile(path string) Option {
if path == "" {
return nil
}

return option.WithCredentialsFile(path)
}

func WithEndpoint(endpoint string) Option {
if endpoint == "" {
return nil
}

return option.WithEndpoint(endpoint)
}

func WithQuotaProject(qp string) Option {
if qp == "" {
return nil
}

return option.WithQuotaProject(qp)
}

func WithRequestReason(rr string) Option {
if rr == "" {
return nil
}

return option.WithRequestReason(rr)
}

func WithScopes(scopes ...string) Option {
if len(scopes) == 0 {
return nil
}

return option.WithScopes(scopes...)
}

func WithUserAgent(ua string) Option {
if ua == "" {
return nil
}

return option.WithUserAgent(ua)
}

func WithCredentialsJSON(json string) Option {
if json != "" {
Expand Down

0 comments on commit 6db3513

Please sign in to comment.