Merge pull request #33 from weaveworks/wcloud-templates

Support templates for commit messages and notifications in wcloud
This commit is contained in:
Tom Wilkie
2016-08-17 17:56:15 +01:00
committed by GitHub
2 changed files with 14 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"os/user"
"path/filepath" "path/filepath"
"strings" "strings"
"time" "time"
@@ -71,9 +72,15 @@ func deploy(c Client, args []string) {
usage() usage()
return return
} }
user, err := user.Current()
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
deployment := Deployment{ deployment := Deployment{
ImageName: parts[0], ImageName: parts[0],
Version: parts[1], Version: parts[1],
TriggeringUser: user.Username,
} }
if err := c.Deploy(deployment); err != nil { if err := c.Deploy(deployment); err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())

View File

@@ -12,7 +12,8 @@ type Deployment struct {
Version string `json:"version"` Version string `json:"version"`
Priority int `json:"priority"` Priority int `json:"priority"`
State string `json:"status"` State string `json:"status"`
LogKey string `json:"-"`
TriggeringUser string `json:"triggering_user"`
} }
// Config for the deployment system for a user. // Config for the deployment system for a user.
@@ -26,10 +27,13 @@ type Config struct {
// Globs of files not to change, relative to the route of the repo // Globs of files not to change, relative to the route of the repo
ConfigFileBlackList []string `json:"config_file_black_list" yaml:"config_file_black_list"` ConfigFileBlackList []string `json:"config_file_black_list" yaml:"config_file_black_list"`
CommitMessageTemplate string `json:"commit_message_template" yaml:"commit_message_template"` // See https://golang.org/pkg/text/template/
} }
// NotificationConfig describes how to send notifications // NotificationConfig describes how to send notifications
type NotificationConfig struct { type NotificationConfig struct {
SlackWebhookURL string `json:"slack_webhook_url" yaml:"slack_webhook_url"` SlackWebhookURL string `json:"slack_webhook_url" yaml:"slack_webhook_url"`
SlackUsername string `json:"slack_username" yaml:"slack_username"` SlackUsername string `json:"slack_username" yaml:"slack_username"`
MessageTemplate string `json:"message_template" yaml:"message_template"`
} }