This repository has been archived on 2023-05-06. You can view files and clone it, but cannot push or open issues or pull requests.
helix/internal/config/config.go
Dan Anglin fda0d6a682
feat: add traefik in the new containers stack
This commit adds the new containers stack which
now builds the traefik docker image and creates
the traefik docker container.

Pulumi needed to be downgraded to version 3.2.1
because later versions panic when building
the docker image.
2021-07-10 12:41:15 +01:00

60 lines
1.5 KiB
Go

package config
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Config struct {
ProjectName string `json:"project"`
Docker DockerConfig `json:"docker"`
Services ServicesConfig `json:"services"`
}
// DockerConfig contains the configuration for
// docker specific components.
type DockerConfig struct {
Network DockerNetworkConfig `json:"network"`
}
// DockerNetworkStackArgs contains arguments for
// creating the DockerNetworkStack
type DockerNetworkConfig struct {
Name string `json:"name"`
Subnet string `json:"subnet"`
Driver string `json:"driver"`
}
// Services contains a list of
// services and their configuration
type ServicesConfig struct {
Traefik TraefikConfig `json:"traefik"`
}
// TraefikConfig contains configuration for the Traefik container.
type TraefikConfig struct {
CheckNewVersion bool `json:"checkNewVersion"`
SendAnonymousUsage bool `json:"sendAnonymousUsage"`
Version string `json:"version"`
ContainerIp string `json:"containerIp"`
LogLevel string `json:"logLevel"`
}
// NewConfig creates a new Config value from a given
// JSON file.
func NewConfig(file string) (Config, error) {
var c Config
var err error
data, err := ioutil.ReadFile(file)
if err != nil {
return c, fmt.Errorf("unable to read data from %s...\n%v", file, err)
}
if err = json.Unmarshal(data, &c); err != nil {
return c, fmt.Errorf("unable to decode the JSON configuration from %s...\n%v", file, err)
}
return c, nil
}