Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.
Open
Show file tree
Hide file tree
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
237 changes: 237 additions & 0 deletions config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
30 changes: 22 additions & 8 deletions mayday.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package main

import (
"archive/tar"
"bytes"
"log"
"os"
"time"

"github.com/coreos/mayday/config"
"github.com/coreos/mayday/mayday"
"github.com/coreos/mayday/mayday/plugins/command"
"github.com/coreos/mayday/mayday/plugins/docker"
Expand Down Expand Up @@ -108,25 +110,37 @@ func main() {
// viper returns an `unsupported config type ""` error if it can't find a file
// https://github.com/spf13/viper/issues/210
if strings.HasSuffix(err.Error(), `Type ""`) {
log.Fatalf("Could not find configuration file in %s",
viper.GetString("config"))
// load the default config asset
defaultConfig, err := config.Asset("config/default.json")
log.Print("Using built-in configuration defaults")
if err != nil {
log.Fatal("Error loading default config: %s", err)
}

viper.SetConfigType("json")
err = viper.MergeConfig(bytes.NewBuffer(defaultConfig))
} else {
log.Printf("Error reading configuration file.")
log.Fatalf("Fatal error reading config: %s\n", err)
}
log.Printf("Error reading configuration file.")
log.Fatalf("Fatal error reading config: %s\n", err)
} else {
log.Printf("loading config from %s", viper.ConfigFileUsed())
}

log.Printf("loading config from %s", viper.ConfigFileUsed())

var tarables []tarable.Tarable

var C Config

// fill C with configuration data
viper.Unmarshal(&C)
err = viper.Unmarshal(&C)
if err != nil {
log.Fatalf("Could not unmarshal configuration: %s", err)
}

journals, err := journal.List()
if err != nil {
log.Fatal(err)
log.Println("Could not retreive system services. Skipping...")
log.Printf("Service error: %s", err)
}

pods, rktLogs, err := rkt.GetPods()
Expand Down