-
Notifications
You must be signed in to change notification settings - Fork 787
/
provider.go
45 lines (38 loc) · 1.06 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package chats
import (
"fmt"
"github.com/jenkins-x/jx/pkg/auth"
"github.com/jenkins-x/jx/pkg/util"
)
// CreateChatProvider represents an integration interface to chat
type ChatProvider interface {
GetChannelMetrics(name string) (*ChannelMetrics, error)
}
// ChannelMetrics metrics for a channel
type ChannelMetrics struct {
ID string
Name string
URL string
MemberCount int
Members []string
}
func (m *ChannelMetrics) ToMarkdown() string {
return util.MarkdownLink(m.Name, m.URL)
}
// CreateChatProvider creates a new chat provider if one is available for the given kind
func CreateChatProvider(kind string, server *auth.AuthServer, userAuth *auth.UserAuth, batchMode bool) (ChatProvider, error) {
switch kind {
case Slack:
return CreateSlackChatProvider(server, userAuth, batchMode)
default:
return nil, fmt.Errorf("Unsupported chat provider kind: %s", kind)
}
}
func ProviderAccessTokenURL(kind string, url string) string {
switch kind {
case Slack:
return "https://my.slack.com/services/new/bot"
default:
return ""
}
}