github.com/blend/go-sdk@v1.20220411.3/slack/config.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package slack
     9  
    10  import (
    11  	"context"
    12  
    13  	"github.com/blend/go-sdk/env"
    14  )
    15  
    16  // Config represents the required fields for the config.
    17  type Config struct {
    18  	APIToken  string `json:"apiToken,omitempty" yaml:"apiToken,omitempty" env:"SLACK_TOKEN"`
    19  	Username  string `json:"username,omitempty" yaml:"username,omitempty" env:"SLACK_USERNAME"`
    20  	Channel   string `json:"channel,omitempty" yaml:"channel,omitempty" env:"SLACK_CHANNEL"`
    21  	IconURL   string `json:"iconURL,omitempty" yaml:"iconURL,omitempty" env:"SLACK_ICON_URL"`
    22  	IconEmoji string `json:"iconEmoji,omitempty" yaml:"iconEmoji,omitempty" env:"SLACK_ICON_EMOJI"`
    23  	Webhook   string `json:"webhook,omitempty" yaml:"webhook,omitempty"  env:"SLACK_WEBHOOK"`
    24  }
    25  
    26  // Resolve includes extra steps on configutil.Read(...).
    27  func (c *Config) Resolve(ctx context.Context) error {
    28  	return env.GetVars(ctx).ReadInto(c)
    29  }
    30  
    31  // IsZero returns if the config is set or not.
    32  func (c Config) IsZero() bool {
    33  	return len(c.Channel) == 0 && len(c.Webhook) == 0
    34  }