mirror of
https://github.com/thegeeklab/drone-matrix.git
synced 2024-11-22 02:20:38 +00:00
Use secrets that can be overridden
This commit is contained in:
parent
cb1c390141
commit
f69a402322
16
README.md
16
README.md
@ -7,17 +7,13 @@ Usage:
|
||||
```yaml
|
||||
matrix:
|
||||
image: ptman/drone-plugin-matrix
|
||||
homeserver: https://matrix.org
|
||||
homeserver: https://matrix.org # defaults to https://matrix.org
|
||||
roomid: '!0123456789abcdef:matrix.org' # room has to already be joined
|
||||
username: ourbot # either username
|
||||
password: *account-password* # and password
|
||||
userid: @ourbot:matrix.org # or userid
|
||||
accesstoken: 0123456789abcdef # and accesstoken
|
||||
secrets: # and a better idea
|
||||
- source: matrix_username # is to not store
|
||||
target: plugin_username # credentials in the git repo
|
||||
- source: matrix_password # but instead use drone
|
||||
target: plugin_password # secret management
|
||||
secrets:
|
||||
- matrix_username # either username ('ourbot')
|
||||
- matrix_password # and password ('*ourbot-password*')
|
||||
# - matrix_userid # or userid ('@ourbot:matrix.org')
|
||||
# - matrix_accesstoken # and access token ('long string of characters')
|
||||
```
|
||||
|
||||
## License
|
||||
|
30
main.go
30
main.go
@ -11,13 +11,33 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Secrets
|
||||
password := os.Getenv("MATRIX_PASSWORD")
|
||||
accessToken := os.Getenv("MATRIX_ACCESSTOKEN")
|
||||
// Not sure if these are secrets or nice to have close to them
|
||||
userName := os.Getenv("MATRIX_USERNAME")
|
||||
userID := os.Getenv("MATRIX_USERID")
|
||||
|
||||
// Override secrets if present
|
||||
if pw := os.Getenv("PLUGIN_PASSWORD"); pw != "" {
|
||||
password = pw
|
||||
}
|
||||
if at := os.Getenv("PLUGIN_ACCESSTOKEN"); at != "" {
|
||||
accessToken = at
|
||||
}
|
||||
if un := os.Getenv("PLUGIN_USERNAME"); un != "" {
|
||||
userName = un
|
||||
}
|
||||
if ui := os.Getenv("PLUGIN_USERID"); ui != "" {
|
||||
userID = ui
|
||||
}
|
||||
|
||||
homeServer := os.Getenv("PLUGIN_HOMESERVER")
|
||||
userName := os.Getenv("PLUGIN_USERNAME")
|
||||
password := os.Getenv("PLUGIN_PASSWORD")
|
||||
|
||||
userID := os.Getenv("PLUGIN_USERID")
|
||||
accessToken := os.Getenv("PLUGIN_ACCESSTOKEN")
|
||||
if homeServer == "" {
|
||||
homeServer = "https://matrix.org"
|
||||
}
|
||||
|
||||
// TODO: resolve room aliases
|
||||
roomID := os.Getenv("PLUGIN_ROOMID")
|
||||
message := os.Getenv("PLUGIN_MESSAGE")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user