From ba38772760e731955c2c8cca394f098e7c64a398 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Tue, 31 Jul 2018 15:08:44 -0700 Subject: [PATCH] Clean up the GitLab module's API credentials loading --- _site/content/posts/modules/gitlab.md | 9 ++++----- gitlab/widget.go | 7 ++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/_site/content/posts/modules/gitlab.md b/_site/content/posts/modules/gitlab.md index 1e48abe0..671dfe74 100644 --- a/_site/content/posts/modules/gitlab.md +++ b/_site/content/posts/modules/gitlab.md @@ -24,11 +24,6 @@ All open merge requests created by you. wtf/gitlab/ ``` -## Required ENV Variables - -Key: `WTF_GITLAB_TOKEN`
-Action: A GitLab personal access token. Requires at least `api` access. - ## Keyboard Commands Key: `/`
@@ -50,6 +45,7 @@ wtf/gitlab/ ```yaml gitlab: + apiKey: "3276d7155dd9ee27b8b14f8743a408a9" enabled: true position: top: 2 @@ -65,6 +61,9 @@ gitlab: ### Attributes +`apiKey`
+Value: A GitLab personal access token. Requires at least `api` access. + `enabled`
Determines whether or not this module is executed and if its data displayed onscreen.
Values: `true`, `false`. diff --git a/gitlab/widget.go b/gitlab/widget.go index 2a9324d5..081abd80 100644 --- a/gitlab/widget.go +++ b/gitlab/widget.go @@ -34,9 +34,14 @@ type Widget struct { } func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { - apiKey := os.Getenv("WTF_GITLAB_TOKEN") + apiKey := wtf.Config.UString( + "wtf.mods.gitlab.apiKey", + os.Getenv("WTF_GITLAB_TOKEN"), + ) + baseURL := wtf.Config.UString("wtf.mods.gitlab.domain") gitlab := glb.NewClient(nil, apiKey) + if baseURL != "" { gitlab.SetBaseURL(baseURL) }