1package atc 2 3import ( 4 "errors" 5 "regexp" 6) 7 8type Worker struct { 9 // not garden_addr, for backwards-compatibility 10 GardenAddr string `json:"addr"` 11 BaggageclaimURL string `json:"baggageclaim_url"` 12 13 CertsPath *string `json:"certs_path,omitempty"` 14 15 HTTPProxyURL string `json:"http_proxy_url,omitempty"` 16 HTTPSProxyURL string `json:"https_proxy_url,omitempty"` 17 NoProxy string `json:"no_proxy,omitempty"` 18 19 ActiveContainers int `json:"active_containers"` 20 ActiveVolumes int `json:"active_volumes"` 21 ActiveTasks int `json:"active_tasks"` 22 23 ResourceTypes []WorkerResourceType `json:"resource_types"` 24 25 Platform string `json:"platform"` 26 Tags []string `json:"tags"` 27 Team string `json:"team"` 28 Name string `json:"name"` 29 Version string `json:"version"` 30 StartTime int64 `json:"start_time"` 31 Ephemeral bool `json:"ephemeral"` 32 State string `json:"state"` 33} 34 35var ErrInvalidWorkerVersion = errors.New("invalid worker version, only numeric characters are allowed") 36var ErrMissingWorkerGardenAddress = errors.New("missing garden address") 37var ErrNoWorkers = errors.New("no workers available for checking") 38 39func (w Worker) Validate() error { 40 if w.Version != "" && !regexp.MustCompile(`^[0-9\.]+$`).MatchString(w.Version) { 41 return ErrInvalidWorkerVersion 42 } 43 44 if len(w.GardenAddr) == 0 { 45 return ErrMissingWorkerGardenAddress 46 } 47 48 return nil 49} 50 51type WorkerResourceType struct { 52 Type string `json:"type"` 53 Image string `json:"image"` 54 Version string `json:"version"` 55 Privileged bool `json:"privileged"` 56 UniqueVersionHistory bool `json:"unique_version_history"` 57} 58 59type PruneWorkerResponseBody struct { 60 Stderr string `json:"stderr"` 61} 62