Fixing the build failures from a missing GCS Key (#1480)

* Fixing the build failures from a missing GCS Key

Accidentally introduced in https://github.com/gomods/athens/pull/1428

* Adding a TODO to the drone build

* adding a step to test the Athens server startup

* Adding the JSONKey back to the default config

* use temporary image

* Switching back to the old env var for the GCS JSON Key

cc/ @marwan-at-work

* removing the ServiceAccount. we want to stick with JSONKey

* reverting to original key fetching code

* fixing build err

* bumping chart ver
This commit is contained in:
Aaron Schlesinger
2019-12-05 10:49:56 -08:00
committed by GitHub
parent e0ec46b221
commit 707b7b5413
8 changed files with 24 additions and 15 deletions
+2 -1
View File
@@ -33,6 +33,7 @@ steps:
# end to end test
- ./main & # run the just-built athens server
- sleep 3 # wait for it to spin up
- curl localhost:3000
- mkdir -p ~/happy
- mkdir -p ~/emptygopath # ensure the gopath has no modules cached.
- cd ~/happy
@@ -153,7 +154,7 @@ services:
ports:
- 6379
- name: athens-proxy
image: gomods/athens:canary
image: gomods/athens-dev:221c451 # temporary to make the build pass, revert to gomods/athens:canary after merge.
pull: always
ports:
- 3000
+1 -1
View File
@@ -1,5 +1,5 @@
name: athens-proxy
version: 0.4.0
version: 0.4.1
appVersion: 0.7.0
description: The proxy server for Go modules
icon: https://raw.githubusercontent.com/gomods/athens/master/docs/static/banner.png
@@ -101,7 +101,7 @@ spec:
- name: ATHENS_STORAGE_GCP_BUCKET
value: {{ .Values.storage.gcp.bucket | quote }}
{{- if .Values.storage.gcp.serviceAccount }}
- name: ATHENS_STORAGE_GCP_SERVICE_ACCOUNT
- name: ATHENS_STORAGE_GCP_JSON_KEY
value: {{ .Values.storage.gcp.serviceAccount | b64enc | quote }}
{{- end }}
{{- else if eq .Values.storage.type "minio" }}
+7 -2
View File
@@ -301,14 +301,19 @@ SingleFlightType = "memory"
# Env override: ATHENS_STORAGE_GCP_BUCKET
Bucket = "MY_GCP_BUCKET"
# ServiceAccount is a base64 encoded service account
# JSONKey is a base64 encoded service account
# key that allows Athens to be run outside of GCP
# but still be able to access GCS. If you are
# running Athens inside GCP, you will most
# likely not need this as GCP figures out
# internal authentication between products for you.
#
# NOTE: This config value is deprecated in favor of
# ServiceAccount above. Athens will check for it,
# but please do not rely on it being available forever.
#
# Env override: ATHENS_STORAGE_GCP_JSON_KEY
ServiceAccount = ""
JSONKey = ""
[Storage.Minio]
# Endpoint for Minio storage
+1 -1
View File
@@ -4,5 +4,5 @@ package config
type GCPConfig struct {
ProjectID string `envconfig:"GOOGLE_CLOUD_PROJECT"`
Bucket string `validate:"required" envconfig:"ATHENS_STORAGE_GCP_BUCKET"`
ServiceAccount string `envconfig:"ATHENS_STORAGE_GCP_SERVICE_ACCOUNT"`
JSONKey string `envconfig:"ATHENS_STORAGE_GCP_JSON_KEY"`
}
+1 -1
View File
@@ -122,6 +122,6 @@ func getTestConfig() *config.GCPConfig {
}
return &config.GCPConfig{
Bucket: "athens_drone_stash_bucket",
ServiceAccount: creds,
JSONKey: creds,
}
}
+2 -2
View File
@@ -49,8 +49,8 @@ func New(ctx context.Context, gcpConf *config.GCPConfig, timeout time.Duration)
func newClient(ctx context.Context, gcpConf *config.GCPConfig, timeout time.Duration) (*Storage, error) {
const op errors.Op = "gcp.newClient"
opts := []option.ClientOption{}
if gcpConf.ServiceAccount != "" {
key, err := base64.StdEncoding.DecodeString(gcpConf.ServiceAccount)
if gcpConf.JSONKey != "" {
key, err := base64.StdEncoding.DecodeString(gcpConf.JSONKey)
if err != nil {
return nil, errors.E(op, fmt.Errorf("could not decode base64 json key: %v", err))
}
+4 -1
View File
@@ -51,6 +51,9 @@ func getStorage(t testing.TB) *Storage {
bucketName := randomBucketName(os.Getenv("DRONE_PULL_REQUEST"))
cfg := getTestConfig(bucketName)
if cfg == nil {
// Don't fail if there's no test config, so that these tests don't
// fail when you run them locally
t.Log("No GCS Config found")
t.SkipNow()
}
@@ -73,7 +76,7 @@ func getTestConfig(bucket string) *config.GCPConfig {
}
return &config.GCPConfig{
Bucket: bucket,
ServiceAccount: creds,
JSONKey: creds,
ProjectID: os.Getenv("GCS_PROJECT_ID"),
}
}