Documentation
¶
Index ¶
- func CryptoRandomHex(len int) (string, error)
- func GetEmailFromAccessToken(token *string) (string, error)
- func NewRedisClient() (*redis.Client, error)
- func Pub(client *redis.Client, channel string, payload string) error
- func ReadINI(iniPath string) (map[string]string, error)
- func Sub(pubsub *redis.PubSub, persist bool, f func(string)) error
- func TriggerSlack(slackToken, channelName, text string, blocks []*Blocks) error
- func TriggerSlackOutdated(slackToken string, legacySlackMsg *LegacySlackMsg) error
- type Blocks
- type LegacyAttachment
- type LegacyField
- type LegacySlackMsg
- type Payload
- type TextPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEmailFromAccessToken ¶
func NewRedisClient ¶
func NewRedisClient() (*redis.Client, error)
func ReadINI ¶
Sample: vaultConf := "/login/vault/vault.conf" vaultProps, err := ReadINI(vaultConf) endpoint := vaultProps["endpoint"]
if os.IsNotExist(err) || strings.TrimSpace(endpoint) == "" { beego.Info("getVaultInstance ", err) panic("please check vault properties") }
ReadINI read ini file into map
func TriggerSlack ¶
blocks sample:
titleBlock := &Blocks{ Type: "section", Text: &TextPayload{ Type: "mrkdwn", Text: "*Bastionhost bastionhost-sample installation complete*", }, }
bodyBlock := &Blocks{ Type: "section", Text: &TextPayload{ Type: "mrkdwn", Text: "ClusterID: bp59t7fd0ttl3j541hng\nClusterName: OSSTestDal13\nLogin URL: `tsh login --proxy osstestdal13-0278914c3cb0e2be944d47de59947e32-0039.us-south.containers.appdomain.cloud:443`", }, }
blocks := make([]*Blocks, 0) blocks = append(blocks, titleBlock) blocks = append(blocks, bodyBlock)
func TriggerSlackOutdated ¶
func TriggerSlackOutdated(slackToken string, legacySlackMsg *LegacySlackMsg) error
Types ¶
type Blocks ¶
type Blocks struct { Type string `json:"type"` Text *TextPayload `json:"text"` }
type LegacyAttachment ¶
type LegacyAttachment struct { MrkdwnIn []string `json:"mrkdwn_in"` Color string `json:"color"` Pretext string `json:"pretext"` AuthorName string `json:"author_name"` AuthorIcon string `json:"author_icon"` Title string `json:"title"` Text string `json:"text"` Fields []*LegacyField `json:"fields"` ThumbURL string `json:"thumb_url"` }
type LegacyField ¶
type LegacySlackMsg ¶
type LegacySlackMsg struct { Channel string `json:"channel"` Text string `json:"text"` Attachments []*LegacyAttachment `json:"attachments"` }
type TextPayload ¶
Click to show internal directories.
Click to hide internal directories.