Closed gad2103 closed 5 years ago
To run locally, edit your entrypoint to pass --local
and don't use auto detection. You can't fake being on GCE locally 😄
We solved this in our project by ditching the auto importer and loading all env vars we need in a struct. After that we loop through them and resolve every value using something like the code below. Seems to be working well on every env (locally, gke and cloud functions)
import (
"context"
"github.com/GoogleCloudPlatform/berglas/pkg/berglas"
)
func berglasParser(ctx context.Context, v string) (string, error) {
if berglas.IsReference(v) {
s, err := berglas.Resolve(ctx, v)
return string(s), err
}
return v, nil
}
Yea - that's a good approach. The "auto" is supposed to be magic, but that does make it difficult to test.
hello! thanks for this library. I'm trying to speed up my development cycles and obviously its slow to rebuild/re-deploy to make sure everything works.
i was hoping to run locally before deploying to Cloud Run. However i get this error when i try
its the same error whether i run using a container or locally and it's the auto package. If i comment that import out everything works locally (sort of).
there isn't any documentation about local run vs deployed run. would be awesome to have that. for now i'm going to just do the wrong thing with env vars in a cloud function...
i am running on macOS with docker for Mac and go 1.12 otherwise. thanks again!