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/
|
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
|
## Keyboard Commands
|
||||||
|
|
||||||
None.
|
None.
|
||||||
@ -30,6 +25,7 @@ None.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jenkins:
|
jenkins:
|
||||||
|
apiKey: "3276d7155dd9ee27b8b14f8743a408a9"
|
||||||
enabled: true
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 2
|
top: 2
|
||||||
@ -44,6 +40,9 @@ jenkins:
|
|||||||
|
|
||||||
### Attributes
|
### Attributes
|
||||||
|
|
||||||
|
`apiKey` <br />
|
||||||
|
Value: Your <a href="https://wiki.jenkins.io/display/JENKINS/Remote+access+API">Jenkins API</a> key.
|
||||||
|
|
||||||
`enabled` <br />
|
`enabled` <br />
|
||||||
Determines whether or not this module is executed and if its data displayed onscreen. <br />
|
Determines whether or not this module is executed and if its data displayed onscreen. <br />
|
||||||
Values: `true`, `false`.
|
Values: `true`, `false`.
|
||||||
|
@ -16,11 +16,6 @@ Displays build information for your Travis CI account.
|
|||||||
wtf/travisci/
|
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
|
## Keyboard Commands
|
||||||
|
|
||||||
None.
|
None.
|
||||||
@ -29,6 +24,7 @@ None.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
travisci:
|
travisci:
|
||||||
|
apiKey: "3276d7155dd9ee27b8b14f8743a408a9"
|
||||||
enabled: true
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 4
|
top: 4
|
||||||
@ -41,6 +37,9 @@ travisci:
|
|||||||
|
|
||||||
### Attributes
|
### Attributes
|
||||||
|
|
||||||
|
`apiKey` <br />
|
||||||
|
Value: Your <a href="https://developer.travis-ci.org/authentication">Travis CI API</a> access token.
|
||||||
|
|
||||||
`enabled` <br />
|
`enabled` <br />
|
||||||
Determines whether or not this module is executed and if its data displayed onscreen. <br />
|
Determines whether or not this module is executed and if its data displayed onscreen. <br />
|
||||||
Values: `true`, `false`.
|
Values: `true`, `false`.
|
||||||
|
@ -28,11 +28,10 @@ func (widget *Widget) Refresh() {
|
|||||||
view, err := Create(
|
view, err := Create(
|
||||||
wtf.Config.UString("wtf.mods.jenkins.url"),
|
wtf.Config.UString("wtf.mods.jenkins.url"),
|
||||||
wtf.Config.UString("wtf.mods.jenkins.user"),
|
wtf.Config.UString("wtf.mods.jenkins.user"),
|
||||||
os.Getenv("WTF_JENKINS_API_KEY"),
|
widget.apiKey(),
|
||||||
)
|
)
|
||||||
|
|
||||||
widget.UpdateRefreshedAt()
|
widget.UpdateRefreshedAt()
|
||||||
//widget.View.Clear()
|
|
||||||
|
|
||||||
var content string
|
var content string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -50,6 +49,13 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- 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 {
|
func (widget *Widget) contentFrom(view *View) string {
|
||||||
str := fmt.Sprintf(" [red]%s[white]\n", view.Name)
|
str := fmt.Sprintf(" [red]%s[white]\n", view.Name)
|
||||||
|
|
||||||
|
@ -72,7 +72,10 @@ func travisRequest(path string) (*http.Response, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func apiToken() string {
|
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) {
|
func parseJson(obj interface{}, text io.Reader) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user