Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions tempelis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

type options struct {
dryRun bool
validateOnly bool
config string
restrictions string
authConfig string
Expand All @@ -37,6 +38,7 @@ type options struct {
func parseOptions() options {
var o options
flag.BoolVar(&o.dryRun, "dry-run", true, "does nothing if true (which is the default)")
flag.BoolVar(&o.validateOnly, "validate-only", false, "only validate config without connecting to Slack (useful for presubmits)")
flag.StringVar(&o.config, "config", "", "path to a configuration file, or directory of files")
flag.StringVar(&o.restrictions, "restrictions", "", "path to a configuration file containing restrictions")
flag.StringVar(&o.authConfig, "auth", "", "path to slack auth")
Expand All @@ -47,11 +49,6 @@ func parseOptions() options {
func main() {
o := parseOptions()

sc, err := slack.LoadConfig(o.authConfig)
if err != nil {
log.Fatalf("Failed to load slack auth config: %v.\n", err)
}

stat, err := os.Stat(o.config)
if err != nil {
log.Fatalf("Failed to stat %s: %v\n", o.config, err)
Expand All @@ -73,6 +70,17 @@ func main() {
log.Fatalf("Failed to load config: %v\n", err)
}

// If validate-only mode, just validate the config and exit
if o.validateOnly {
log.Println("Configuration validation successful!")
return
}

sc, err := slack.LoadConfig(o.authConfig)
if err != nil {
log.Fatalf("Failed to load slack auth config: %v.\n", err)
}

r := reconciler.New(slack.New(sc), p.Config)
if err := r.Reconcile(o.dryRun); err != nil {
log.Fatalf("Reconciliation failed: %v\n", err)
Expand Down