File tree Expand file tree Collapse file tree 2 files changed +31
-15
lines changed Expand file tree Collapse file tree 2 files changed +31
-15
lines changed Original file line number Diff line number Diff line change 77``` yaml
88 matrix :
99 image : ptman/drone-plugin-matrix
10- homeserver : https://matrix.org
10+ homeserver : https://matrix.org # defaults to https://matrix.org
1111 roomid : ' !0123456789abcdef:matrix.org' # room has to already be joined
12- username : ourbot # either username
13- password : *account-password* # and password
14- userid : @ourbot:matrix.org # or userid
15- accesstoken : 0123456789abcdef # and accesstoken
16- secrets : # and a better idea
17- - source : matrix_username # is to not store
18- target : plugin_username # credentials in the git repo
19- - source : matrix_password # but instead use drone
20- target : plugin_password # secret management
12+ secrets :
13+ - matrix_username # either username ('ourbot')
14+ - matrix_password # and password ('*ourbot-password*')
15+ # - matrix_userid # or userid ('@ourbot:matrix.org')
16+ # - matrix_accesstoken # and access token ('long string of characters')
2117```
2218
2319## License
Original file line number Diff line number Diff line change @@ -11,13 +11,33 @@ import (
1111)
1212
1313func main () {
14- homeServer := os .Getenv ("PLUGIN_HOMESERVER" )
15- userName := os .Getenv ("PLUGIN_USERNAME" )
16- password := os .Getenv ("PLUGIN_PASSWORD" )
14+ // Secrets
15+ password := os .Getenv ("MATRIX_PASSWORD" )
16+ accessToken := os .Getenv ("MATRIX_ACCESSTOKEN" )
17+ // Not sure if these are secrets or nice to have close to them
18+ userName := os .Getenv ("MATRIX_USERNAME" )
19+ userID := os .Getenv ("MATRIX_USERID" )
20+
21+ // Override secrets if present
22+ if pw := os .Getenv ("PLUGIN_PASSWORD" ); pw != "" {
23+ password = pw
24+ }
25+ if at := os .Getenv ("PLUGIN_ACCESSTOKEN" ); at != "" {
26+ accessToken = at
27+ }
28+ if un := os .Getenv ("PLUGIN_USERNAME" ); un != "" {
29+ userName = un
30+ }
31+ if ui := os .Getenv ("PLUGIN_USERID" ); ui != "" {
32+ userID = ui
33+ }
1734
18- userID := os .Getenv ("PLUGIN_USERID" )
19- accessToken := os .Getenv ("PLUGIN_ACCESSTOKEN" )
35+ homeServer := os .Getenv ("PLUGIN_HOMESERVER" )
36+ if homeServer == "" {
37+ homeServer = "https://matrix.org"
38+ }
2039
40+ // TODO: resolve room aliases
2141 roomID := os .Getenv ("PLUGIN_ROOMID" )
2242 message := os .Getenv ("PLUGIN_MESSAGE" )
2343
You can’t perform that action at this time.
0 commit comments