github.com/ssube/gitlab-ci-multi-runner@v1.2.1-0.20160607142738-b8d1285632e6/executors/docker/machine/details.go (about) 1 package machine 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 "time" 7 8 "github.com/Sirupsen/logrus" 9 10 "gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers" 11 ) 12 13 type machineDetails struct { 14 Name string 15 Created time.Time `yaml:"-"` 16 Used time.Time `yaml:"-"` 17 UsedCount int 18 State machineState 19 Reason string 20 } 21 22 func (m *machineDetails) isUsed() bool { 23 return m.State != machineStateIdle 24 } 25 26 func (m *machineDetails) match(machineFilter string) bool { 27 var query string 28 if n, _ := fmt.Sscanf(m.Name, machineFilter, &query); n != 1 { 29 return false 30 } 31 return true 32 } 33 34 func (m *machineDetails) writeDebugInformation() { 35 if logrus.GetLevel() < logrus.DebugLevel { 36 return 37 } 38 39 var details struct { 40 machineDetails 41 Time string 42 CreatedAgo time.Duration 43 } 44 details.machineDetails = *m 45 details.Time = time.Now().String() 46 details.CreatedAgo = time.Since(m.Created) 47 data := helpers.ToYAML(&details) 48 ioutil.WriteFile("machines/"+details.Name+".yml", []byte(data), 0600) 49 } 50 51 type machinesDetails map[string]*machineDetails