mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Clean up the Jenkins module's API credentials loading
This commit is contained in:
parent
ba38772760
commit
2fe8164e20
@ -17,11 +17,6 @@ width="320" height="68" alt="jenkins screenshot" />
|
||||
wtf/jenkins/
|
||||
```
|
||||
|
||||
## Required ENV Variables
|
||||
|
||||
<span class="caption">Key:</span> `WTF_JENKINS_API_KEY` <br />
|
||||
<span class="caption">Value:</span> Your <a href="https://wiki.jenkins.io/display/JENKINS/Remote+access+API">Jenkins API</a> key.
|
||||
|
||||
## Keyboard Commands
|
||||
|
||||
None.
|
||||
@ -30,6 +25,7 @@ None.
|
||||
|
||||
```yaml
|
||||
jenkins:
|
||||
apiKey: "3276d7155dd9ee27b8b14f8743a408a9"
|
||||
enabled: true
|
||||
position:
|
||||
top: 2
|
||||
@ -44,6 +40,9 @@ jenkins:
|
||||
|
||||
### Attributes
|
||||
|
||||
`apiKey` <br />
|
||||
Value: Your <a href="https://wiki.jenkins.io/display/JENKINS/Remote+access+API">Jenkins API</a> key.
|
||||
|
||||
`enabled` <br />
|
||||
Determines whether or not this module is executed and if its data displayed onscreen. <br />
|
||||
Values: `true`, `false`.
|
||||
|
@ -16,11 +16,6 @@ Displays build information for your Travis CI account.
|
||||
wtf/travisci/
|
||||
```
|
||||
|
||||
## Required ENV Variables
|
||||
|
||||
<span class="caption">Key:</span> `WTF_TRAVIS_API_TOKEN` <br />
|
||||
<span class="caption">Value:</span> Your <a href="https://developer.travis-ci.org/authentication">Travis CI API</a> access token.
|
||||
|
||||
## Keyboard Commands
|
||||
|
||||
None.
|
||||
@ -29,6 +24,7 @@ None.
|
||||
|
||||
```yaml
|
||||
travisci:
|
||||
apiKey: "3276d7155dd9ee27b8b14f8743a408a9"
|
||||
enabled: true
|
||||
position:
|
||||
top: 4
|
||||
@ -41,6 +37,9 @@ travisci:
|
||||
|
||||
### Attributes
|
||||
|
||||
`apiKey` <br />
|
||||
Value: Your <a href="https://developer.travis-ci.org/authentication">Travis CI API</a> access token.
|
||||
|
||||
`enabled` <br />
|
||||
Determines whether or not this module is executed and if its data displayed onscreen. <br />
|
||||
Values: `true`, `false`.
|
||||
|
@ -28,11 +28,10 @@ func (widget *Widget) Refresh() {
|
||||
view, err := Create(
|
||||
wtf.Config.UString("wtf.mods.jenkins.url"),
|
||||
wtf.Config.UString("wtf.mods.jenkins.user"),
|
||||
os.Getenv("WTF_JENKINS_API_KEY"),
|
||||
widget.apiKey(),
|
||||
)
|
||||
|
||||
widget.UpdateRefreshedAt()
|
||||
//widget.View.Clear()
|
||||
|
||||
var content string
|
||||
if err != nil {
|
||||
@ -50,6 +49,13 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) apiKey() string {
|
||||
return wtf.Config.UString(
|
||||
"wtf.mods.jenkins.apiKey",
|
||||
os.Getenv("WTF_JENKINS_API_KEY"),
|
||||
)
|
||||
}
|
||||
|
||||
func (widget *Widget) contentFrom(view *View) string {
|
||||
str := fmt.Sprintf(" [red]%s[white]\n", view.Name)
|
||||
|
||||
|
@ -72,7 +72,10 @@ func travisRequest(path string) (*http.Response, error) {
|
||||
}
|
||||
|
||||
func apiToken() string {
|
||||
return os.Getenv(APIEnvToken)
|
||||
return wtf.Config.UString(
|
||||
"wtf.mods.travisci.apiKey",
|
||||
os.Getenv(APIEnvToken),
|
||||
)
|
||||
}
|
||||
|
||||
func parseJson(obj interface{}, text io.Reader) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user