github.com/uchennaokeke444/nomad@v0.11.8/nomad/structs/service_identities.go (about) 1 package structs 2 3 import "errors" 4 5 // An SIToken is the important bits of a Service Identity token generated by Consul. 6 type SIToken struct { 7 TaskName string // the nomad task backing the consul service (native or sidecar) 8 AccessorID string 9 SecretID string 10 } 11 12 // An SITokenAccessor is a reference to a created Service Identity token on 13 // behalf of an allocation's task. 14 type SITokenAccessor struct { 15 NodeID string 16 AllocID string 17 AccessorID string 18 TaskName string 19 20 // Raft index 21 CreateIndex uint64 22 } 23 24 // SITokenAccessorsRequest is used to operate on a set of SITokenAccessor, like 25 // recording a set of accessors for an alloc into raft. 26 type SITokenAccessorsRequest struct { 27 Accessors []*SITokenAccessor 28 } 29 30 // DeriveSITokenRequest is used to request Consul Service Identity tokens from 31 // the Nomad Server for the named tasks in the given allocation. 32 type DeriveSITokenRequest struct { 33 NodeID string 34 SecretID string 35 AllocID string 36 Tasks []string 37 QueryOptions 38 } 39 40 func (r *DeriveSITokenRequest) Validate() error { 41 switch { 42 case r.NodeID == "": 43 return errors.New("missing node ID") 44 case r.SecretID == "": 45 return errors.New("missing node SecretID") 46 case r.AllocID == "": 47 return errors.New("missing allocation ID") 48 case len(r.Tasks) == 0: 49 return errors.New("no tasks specified") 50 default: 51 return nil 52 } 53 } 54 55 type DeriveSITokenResponse struct { 56 // Tokens maps from Task Name to its associated SI token 57 Tokens map[string]string 58 59 // Error stores any error that occurred. Errors are stored here so we can 60 // communicate whether it is retryable 61 Error *RecoverableError 62 63 QueryMeta 64 }