From dd4088d76e4cd8f3e6fd5ceca6a2df65b312d89e Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Tue, 31 Jul 2018 15:05:20 -0700 Subject: [PATCH] Clean up the CircleCI module's API credentials loading --- _site/content/posts/modules/circleci.md | 10 ++++------ circleci/client.go | 7 ++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/_site/content/posts/modules/circleci.md b/_site/content/posts/modules/circleci.md index 4a2df2d9..351a54de 100644 --- a/_site/content/posts/modules/circleci.md +++ b/_site/content/posts/modules/circleci.md @@ -16,12 +16,6 @@ Displays build information for your CircleCI account. wtf/circleci/ ``` -## Required ENV Variables - -Key: `WTF_CIRCLE_API_KEY`
-Value: Your CircleCI API -token. - ## Keyboard Commands None. @@ -30,6 +24,7 @@ None. ```yaml circleci: + apiKey: "3276d7155dd9ee27b8b14f8743a408a9" enabled: true position: top: 4 @@ -41,6 +36,9 @@ circleci: ### Attributes +`apiKey`
+Value: Your CircleCI API token. + `enabled`
Determines whether or not this module is executed and if its data displayed onscreen.
Values: `true`, `false`. diff --git a/circleci/client.go b/circleci/client.go index 16d7eb82..8a796722 100644 --- a/circleci/client.go +++ b/circleci/client.go @@ -9,6 +9,8 @@ import ( "net/http" "net/url" "os" + + "github.com/senorprogrammer/wtf/wtf" ) const APIEnvKey = "WTF_CIRCLE_API_KEY" @@ -59,7 +61,10 @@ func circleRequest(path string) (*http.Response, error) { } func apiKey() string { - return os.Getenv(APIEnvKey) + return wtf.Config.UString( + "wtf.mods.circleci.apiKey", + os.Getenv(APIEnvKey), + ) } func parseJson(obj interface{}, text io.Reader) {