-
Notifications
You must be signed in to change notification settings - Fork 47
/
config.go
34 lines (26 loc) · 1.07 KB
/
config.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
/*
Copyright (c) 2021 - Present. Blend Labs, Inc. All rights reserved
Blend Confidential - Restricted
*/
package slack
import (
"context"
"github.com/blend/go-sdk/env"
)
// Config represents the required fields for the config.
type Config struct {
APIToken string `json:"apiToken,omitempty" yaml:"apiToken,omitempty" env:"SLACK_TOKEN"`
Username string `json:"username,omitempty" yaml:"username,omitempty" env:"SLACK_USERNAME"`
Channel string `json:"channel,omitempty" yaml:"channel,omitempty" env:"SLACK_CHANNEL"`
IconURL string `json:"iconURL,omitempty" yaml:"iconURL,omitempty" env:"SLACK_ICON_URL"`
IconEmoji string `json:"iconEmoji,omitempty" yaml:"iconEmoji,omitempty" env:"SLACK_ICON_EMOJI"`
Webhook string `json:"webhook,omitempty" yaml:"webhook,omitempty" env:"SLACK_WEBHOOK"`
}
// Resolve includes extra steps on configutil.Read(...).
func (c *Config) Resolve(ctx context.Context) error {
return env.GetVars(ctx).ReadInto(c)
}
// IsZero returns if the config is set or not.
func (c Config) IsZero() bool {
return len(c.Channel) == 0 && len(c.Webhook) == 0
}