Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use godotenv for secrets #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OPENAI_API_KEY=your_openai_api_key_here
PINECONE_API_KEY=your_pinecone_api_key_here
PINECONE_API_ENDPOINT=https://example-50709b5.svc.asia-southeast1-gcp.pinecone.io
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ go.uber.org
testfiles
gopkg.in

Dockerfile
Dockerfile

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't add the Dockerfile to the gitignore unless there is a reason

.env
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkoukk/tiktoken-go v0.1.0
github.com/sashabaranov/go-openai v1.6.1
github.com/joho/godotenv v1.5.1
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:
github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 h1:g0fAGBisHaEQ0TRq1iBvemFRf+8AEWEmBESSiWB3Vsc=
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down
6 changes: 0 additions & 6 deletions scripts/source-me.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ if [[ "${0}" == "bash" || "${0}" == "sh" ]]; then
else
script_name="${0}"
fi
dir_path="$( cd "$(dirname "$script_name")" >/dev/null 2>&1 ; pwd -P )"
secrets_path="${dir_path}/../secret"
test ! -d $secrets_path && echo "ERR: ../secret dir missing!" && return 1

export GO111MODULE=on
export GOBIN="$PWD/bin"
export GOPATH="$HOME/go"
export PATH="$PATH:$PWD/bin:$PWD/tools/protoc-3.6.1/bin"
export DOCKER_BUILDKIT=1
export OPENAI_API_KEY="$(cat ${secrets_path}/openai_api_key)"
export PINECONE_API_KEY="$(cat ${secrets_path}/pinecone_api_key)"
export PINECONE_API_ENDPOINT="$(cat ${secrets_path}/pinecone_api_endpoint)"

echo "=> Environment Variables Loaded"
3 changes: 3 additions & 0 deletions vault-web-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

"github.com/codegangsta/negroni"
"github.com/gorilla/mux"

"github.com/joho/godotenv"
)

const (
Expand All @@ -43,6 +45,7 @@ var (
)

func main() {
godotenv.Load()
// Parse command line flags + override defaults
flag.Parse()
siteConfig["DEBUG_SITE"] = strconv.FormatBool(*debugSite)
Expand Down