From 583f4719410772d05d86592d8793fcfe00aa4dcc Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Fri, 23 Aug 2024 07:34:24 -0500 Subject: [PATCH] Bump `atc0005/go-teams-notify` to v2.13.0-rc.1 Test latest dependency changes. --- go.mod | 2 +- go.sum | 4 +- .../atc0005/go-teams-notify/v2/README.md | 11 ++++ .../v2/adaptivecard/adaptivecard.go | 62 +++++++++++++++++++ .../v2/adaptivecard/getters.go | 1 + vendor/modules.txt | 2 +- 6 files changed, 78 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index bd5c426..664811f 100644 --- a/go.mod +++ b/go.mod @@ -13,4 +13,4 @@ go 1.19 // // replace github.com/atc0005/go-teams-notify/v2 => ../go-teams-notify -require github.com/atc0005/go-teams-notify/v2 v2.12.0 +require github.com/atc0005/go-teams-notify/v2 v2.13.0-rc.1 diff --git a/go.sum b/go.sum index 1fe26d7..97f0a1d 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/atc0005/go-teams-notify/v2 v2.12.0 h1:68H9lzOeoSHsw6dK6XLWd0VtcnKW2EV0ZExZVHVEGhY= -github.com/atc0005/go-teams-notify/v2 v2.12.0/go.mod h1:WSv9moolRsBcpZbwEf6gZxj7h0uJlJskJq5zkEWKO8Y= +github.com/atc0005/go-teams-notify/v2 v2.13.0-rc.1 h1:iZ4aQadhWBeVhpBrG7rGJdz3wq7boNZlH37scoznC3Y= +github.com/atc0005/go-teams-notify/v2 v2.13.0-rc.1/go.mod h1:WSv9moolRsBcpZbwEf6gZxj7h0uJlJskJq5zkEWKO8Y= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/vendor/github.com/atc0005/go-teams-notify/v2/README.md b/vendor/github.com/atc0005/go-teams-notify/v2/README.md index 25e7563..1766fab 100644 --- a/vendor/github.com/atc0005/go-teams-notify/v2/README.md +++ b/vendor/github.com/atc0005/go-teams-notify/v2/README.md @@ -38,6 +38,7 @@ A package to send messages to a Microsoft Teams channel. - [Basic](#basic) - [Specify proxy server](#specify-proxy-server) - [User Mention](#user-mention) + - [CodeBlock](#codeblock) - [Tables](#tables) - [Set custom user agent](#set-custom-user-agent) - [Add an Action](#add-an-action) @@ -396,6 +397,14 @@ deprecated][o365-connector-retirement-announcement] `MessageCard` card format. - File: [user-mention-verbose](./examples/adaptivecard/user-mention-verbose/main.go) - this example does not necessarily reflect an optimal implementation +#### CodeBlock + +This example illustrates the use of a [`CodeBlock`][adaptivecard-codeblock]. +This feature is not available in the legacy [🚫 +deprecated][o365-connector-retirement-announcement] `MessageCard` card format. + +- File: [codeblock](./examples/adaptivecard/codeblock/main.go) + #### Tables These examples illustrates the use of a [`Table`][adaptivecard-table]. This @@ -511,4 +520,6 @@ using either this library or the original project. [adaptivecard-user-mentions]: [adaptivecard-table]: +[adaptivecard-codeblock]: + diff --git a/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/adaptivecard.go b/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/adaptivecard.go index 40cbe4a..fd36eb1 100644 --- a/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/adaptivecard.go +++ b/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/adaptivecard.go @@ -323,6 +323,13 @@ const ( TypeElementTextRun string = "TextRun" // Introduced in version 1.2 ) +// Known extension types for an Adaptive Card element. +// +// - https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html#codeblock-in-adaptive-cards +const ( + TypeElementMSTeamsCodeBlock string = "CodeBlock" +) + // Sentinel errors for this package. var ( // ErrInvalidType indicates that an invalid type was specified. @@ -601,6 +608,15 @@ type Element struct { // Separator, when true, indicates that a separating line shown should be // drawn at the top of the element. Separator bool `json:"separator,omitempty"` + + // CodeSnippet provides the content for a CodeBlock element, specific to MSTeams. + CodeSnippet string `json:"codeSnippet,omitempty"` + + // Language specifies the language of a CodeBlock element, specific to MSTeams. + Language string `json:"language,omitempty"` + + // StartLineNumber specifies the initial line number of CodeBlock element, specific to MSTeams. + StartLineNumber int `json:"startLineNumber,omitempty"` } // Container is an Element type that allows grouping items together. @@ -1374,6 +1390,10 @@ func (e Element) Validate() error { v.SelfValidate(TableRows(e.Rows)) v.SelfValidate(TableColumnDefinitions(e.Columns)) + + case e.Type == TypeElementMSTeamsCodeBlock: + v.NotEmptyValue(e.CodeSnippet, "CodeSnippet", e.Type, ErrMissingValue) + v.NotEmptyValue(e.Language, "Language", e.Type, ErrMissingValue) } // Return the last recorded validation error, or nil if no validation @@ -3145,6 +3165,48 @@ func (c *Card) AddContainer(prepend bool, container Container) error { return nil } +// NewCodeBlock creates a new CodeBlock element with snippet, language, and +// optional firstLine. This is an MSTeams extension element. +// +// Supported languages include: +// +// - Bash +// - C +// - C# +// - C++ +// - CSS +// - DOS +// - Go +// - GraphQL +// - HTML +// - Java +// - JavaScript +// - JSON +// - Perl +// - PHP +// - PlainText +// - PowerShell +// - Python +// - SQL +// - TypeScript +// - Verilog +// - VHDL +// - Visual Basic +// - XML +// +// See +// https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format +// for additional languages that may be supported. +func NewCodeBlock(snippet string, language string, firstLine int) Element { + codeBlock := Element{ + Type: TypeElementMSTeamsCodeBlock, + CodeSnippet: snippet, + Language: language, + StartLineNumber: firstLine, + } + return codeBlock +} + // cardBodyHasMention indicates whether an Adaptive Card body contains all // specified Mention values. For every user mention, we require at least one // match in an applicable Element in the Card Body. diff --git a/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/getters.go b/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/getters.go index c46224e..dbf56a6 100644 --- a/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/getters.go +++ b/vendor/github.com/atc0005/go-teams-notify/v2/adaptivecard/getters.go @@ -33,6 +33,7 @@ func supportedElementTypes() []string { TypeElementTable, // Introduced in version 1.5 TypeElementTextBlock, TypeElementTextRun, + TypeElementMSTeamsCodeBlock, } } diff --git a/vendor/modules.txt b/vendor/modules.txt index a17ee83..b53e7b7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/atc0005/go-teams-notify/v2 v2.12.0 +# github.com/atc0005/go-teams-notify/v2 v2.13.0-rc.1 ## explicit; go 1.14 github.com/atc0005/go-teams-notify/v2 github.com/atc0005/go-teams-notify/v2/adaptivecard