Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(76)

Side by Side Diff: cmd/juju/status.go

Issue 6810065: all: gofmt (Closed)
Patch Set: all: gofmt Created 12 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cmd/juju/set.go ('k') | cmd/juju/status_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "strconv" 5 "strconv"
6 6
7 "launchpad.net/gnuflag" 7 "launchpad.net/gnuflag"
8 "launchpad.net/juju-core/cmd" 8 "launchpad.net/juju-core/cmd"
9 "launchpad.net/juju-core/environs" 9 "launchpad.net/juju-core/environs"
10 "launchpad.net/juju-core/juju" 10 "launchpad.net/juju-core/juju"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 machines, err := st.AllMachines() 97 machines, err := st.AllMachines()
98 if err != nil { 98 if err != nil {
99 return nil, err 99 return nil, err
100 } 100 }
101 for _, m := range machines { 101 for _, m := range machines {
102 v[m.Id()] = m 102 v[m.Id()] = m
103 } 103 }
104 return v, nil 104 return v, nil
105 } 105 }
106 106
107 // fetchAllServices returns a map representing a mapping of service 107 // fetchAllServices returns a map representing a mapping of service
108 // names to services. 108 // names to services.
109 func fetchAllServices(st *state.State) (map[string]*state.Service, error) { 109 func fetchAllServices(st *state.State) (map[string]*state.Service, error) {
110 v := make(map[string]*state.Service) 110 v := make(map[string]*state.Service)
111 services, err := st.AllServices() 111 services, err := st.AllServices()
112 if err != nil { 112 if err != nil {
113 return nil, err 113 return nil, err
114 } 114 }
115 for _, s := range services { 115 for _, s := range services {
116 v[s.Name()] = s 116 v[s.Name()] = s
117 } 117 }
118 return v, nil 118 return v, nil
119 } 119 }
120 120
121 // processMachines gathers information about machines. 121 // processMachines gathers information about machines.
122 func processMachines(machines map[int]*state.Machine, instances map[string]envir ons.Instance) (map[int]interface{}, error) { 122 func processMachines(machines map[int]*state.Machine, instances map[string]envir ons.Instance) (map[int]interface{}, error) {
123 r := make(map[int]interface{}) 123 r := make(map[int]interface{})
124 for _, m := range machines { 124 for _, m := range machines {
125 instid, err := m.InstanceId() 125 instid, err := m.InstanceId()
126 if err, ok := err.(*state.NotFoundError); ok { 126 if err, ok := err.(*state.NotFoundError); ok {
127 r[m.Id()] = map[string]interface{}{ 127 r[m.Id()] = map[string]interface{}{
128 "instance-id": "pending", 128 "instance-id": "pending",
129 } 129 }
130 } else if err != nil { 130 } else if err != nil {
131 return nil, err 131 return nil, err
132 } else { 132 } else {
133 instance, ok := instances[instid] 133 instance, ok := instances[instid]
134 if !ok { 134 if !ok {
135 // Double plus ungood. There is an instance id r ecorded for this machine in the state, 135 // Double plus ungood. There is an instance id r ecorded for this machine in the state,
136 » » » » // yet the environ cannot find that id. 136 » » » » // yet the environ cannot find that id.
137 return nil, fmt.Errorf("instance %s for machine %d not found", instid, m.Id()) 137 return nil, fmt.Errorf("instance %s for machine %d not found", instid, m.Id())
138 } 138 }
139 r[m.Id()] = checkError(processMachine(m, instance)) 139 r[m.Id()] = checkError(processMachine(m, instance))
140 } 140 }
141 } 141 }
142 return r, nil 142 return r, nil
143 } 143 }
144 144
145 func processMachine(machine *state.Machine, instance environs.Instance) (map[str ing]interface{}, error) { 145 func processMachine(machine *state.Machine, instance environs.Instance) (map[str ing]interface{}, error) {
146 r := m() 146 r := m()
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 264
265 func m() map[string]interface{} { return make(map[string]interface{}) } 265 func m() map[string]interface{} { return make(map[string]interface{}) }
266 266
267 func checkError(m map[string]interface{}, err error) map[string]interface{} { 267 func checkError(m map[string]interface{}, err error) map[string]interface{} {
268 if err != nil { 268 if err != nil {
269 return map[string]interface{}{"status-error": err.Error()} 269 return map[string]interface{}{"status-error": err.Error()}
270 } 270 }
271 return m 271 return m
272 } 272 }
OLDNEW
« no previous file with comments | « cmd/juju/set.go ('k') | cmd/juju/status_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b