Add Nomad provider

I modeled it off the Kubernetes provider a bit. It supports setting task
config at group and task levels using services and meta attributes.
This commit is contained in:
Ian Fijolek
2022-12-25 22:29:08 -08:00
committed by CrazyMax
parent a7e8a9cd81
commit 6318e4f069
10 changed files with 505 additions and 7 deletions

View File

@@ -0,0 +1,28 @@
package model
import (
"github.com/crazy-max/diun/v4/pkg/utl"
)
// PrdNomad holds nomad provider configuration
type PrdNomad struct {
Address string `yaml:"address" json:"address,omitempty" validate:"omitempty"`
Region string `yaml:"region,omitempty" json:"region,omitempty" validate:"omitempty"`
SecretID string `yaml:"secretID,omitempty" json:"secretID,omitempty" validate:"omitempty"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty" validate:"omitempty"`
TLSInsecure *bool `yaml:"tlsInsecure" json:"tlsInsecure,omitempty" validate:"required"`
WatchByDefault *bool `yaml:"watchByDefault" json:"watchByDefault,omitempty" validate:"required"`
}
// GetDefaults gets the default values
func (s *PrdNomad) GetDefaults() *PrdNomad {
n := &PrdNomad{}
n.SetDefaults()
return n
}
// SetDefaults sets the default values
func (s *PrdNomad) SetDefaults() {
s.TLSInsecure = utl.NewFalse()
s.WatchByDefault = utl.NewFalse()
}

View File

@@ -7,6 +7,7 @@ type Providers struct {
Kubernetes *PrdKubernetes `yaml:"kubernetes,omitempty" json:"kubernetes,omitempty" label:"allowEmpty" file:"allowEmpty"`
File *PrdFile `yaml:"file,omitempty" json:"file,omitempty"`
Dockerfile *PrdDockerfile `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"`
Nomad *PrdNomad `yaml:"nomad,omitempty" json:"nomad,omitempty" label:"allowEmpty" file:"allowEmpty"`
}
// GetDefaults gets the default values