Skip to content

Commit

Permalink
Increase Slack attachment fields count to 10 (#4)
Browse files Browse the repository at this point in the history
* Update main.go

* Update README.md
  • Loading branch information
goruha authored Apr 4, 2018
1 parent 8eadb1c commit d1e59d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ __NOTE__: The module supports up to 8 Fields in an [attachment](https://api.slac
| field8_title | SLACK_FIELD8_TITLE | Field8 title |
| field8_value | SLACK_FIELD8_VALUE | Field8 value |
| field8_short | SLACK_FIELD8_SHORT | An optional boolean indicating whether the `value` is short enough to be displayed side-by-side with other values (default `false`) |


| field9_title | SLACK_FIELD9_TITLE | Field9 title |
| field9_value | SLACK_FIELD9_VALUE | Field9 value |
| field9_short | SLACK_FIELD9_SHORT | An optional boolean indicating whether the `value` is short enough to be displayed side-by-side with other values (default `false`) |
| field10_title | SLACK_FIELD10_TITLE | Field10 title |
| field10_value | SLACK_FIELD10_VALUE | Field10 value |
| field10_short | SLACK_FIELD10_SHORT | An optional boolean indicating whether the `value` is short enough to be displayed side-by-side with other values (default `false`) |

### build the Go program locally

Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ var (
field8Title = flag.String("field8_title", os.Getenv("SLACK_FIELD8_TITLE"), "Field8 title")
field8Value = flag.String("field8_value", os.Getenv("SLACK_FIELD8_VALUE"), "Field8 value")
field8Short = flag.String("field8_short", os.Getenv("SLACK_FIELD8_SHORT"), "An optional boolean indicating whether the 'value' is short enough to be displayed side-by-side with other values (default 'false')")
field9Title = flag.String("field9_title", os.Getenv("SLACK_FIELD9_TITLE"), "Field9 title")
field9Value = flag.String("field9_value", os.Getenv("SLACK_FIELD9_VALUE"), "Field9 value")
field9Short = flag.String("field9_short", os.Getenv("SLACK_FIELD9_SHORT"), "An optional boolean indicating whether the 'value' is short enough to be displayed side-by-side with other values (default 'false')")
field10Title = flag.String("field10_title", os.Getenv("SLACK_FIELD10_TITLE"), "Field10 title")
field10Value = flag.String("field10_value", os.Getenv("SLACK_FIELD10_VALUE"), "Field10 value")
field10Short = flag.String("field10_short", os.Getenv("SLACK_FIELD10_SHORT"), "An optional boolean indicating whether the 'value' is short enough to be displayed side-by-side with other values (default 'false')")
)

func addField(fields []Field, fieldTitle string, fieldValue string, fieldShort string) []Field {
Expand Down Expand Up @@ -114,6 +120,8 @@ func main() {
fields = addField(fields, *field6Title, *field6Value, *field6Short)
fields = addField(fields, *field7Title, *field7Value, *field7Short)
fields = addField(fields, *field8Title, *field8Value, *field8Short)
fields = addField(fields, *field9Title, *field9Value, *field9Short)
fields = addField(fields, *field10Title, *field10Value, *field10Short)

if len(fields) > 0 {
attachment.Fields = fields
Expand Down

0 comments on commit d1e59d7

Please sign in to comment.