github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/nomad/structs/config/sentinel.go (about) 1 package config 2 3 import ( 4 "github.com/hashicorp/nomad/helper" 5 "golang.org/x/exp/slices" 6 ) 7 8 // SentinelConfig is configuration specific to Sentinel 9 type SentinelConfig struct { 10 // Imports are the configured imports 11 Imports []*SentinelImport `hcl:"import,expand"` 12 } 13 14 func (s *SentinelConfig) Copy() *SentinelConfig { 15 if s == nil { 16 return nil 17 } 18 19 ns := *s 20 ns.Imports = helper.CopySlice(s.Imports) 21 return &ns 22 } 23 24 // SentinelImport is used per configured import 25 type SentinelImport struct { 26 Name string `hcl:",key"` 27 Path string `hcl:"path"` 28 Args []string `hcl:"args"` 29 } 30 31 func (s *SentinelImport) Copy() *SentinelImport { 32 if s == nil { 33 return nil 34 } 35 36 ns := *s 37 ns.Args = slices.Clone(s.Args) 38 return &ns 39 } 40 41 // Merge is used to merge two Sentinel configs together. The settings from the input always take precedence. 42 func (a *SentinelConfig) Merge(b *SentinelConfig) *SentinelConfig { 43 result := *a 44 if len(b.Imports) > 0 { 45 result.Imports = append(result.Imports, b.Imports...) 46 } 47 return &result 48 }