Browse Source

Revert all the renamings breaking the API

Alfonso Acosta 6 months ago
parent
commit
92a3aac4eb

+ 3
- 3
api/v11/api.go View File

@@ -9,15 +9,15 @@ import (
9 9
 	"github.com/weaveworks/flux/api/v6"
10 10
 )
11 11
 
12
-type ListWorkloadsOptions struct {
12
+type ListServicesOptions struct {
13 13
 	Namespace string
14
-	Workloads []flux.ResourceID
14
+	Services  []flux.ResourceID
15 15
 }
16 16
 
17 17
 type Server interface {
18 18
 	v10.Server
19 19
 
20
-	ListWorkloadsWithOptions(ctx context.Context, opts ListWorkloadsOptions) ([]v6.WorkloadStatus, error)
20
+	ListServicesWithOptions(ctx context.Context, opts ListServicesOptions) ([]v6.ControllerStatus, error)
21 21
 }
22 22
 
23 23
 type Upstream interface {

+ 3
- 3
api/v6/api.go View File

@@ -16,7 +16,7 @@ type ImageStatus struct {
16 16
 	Containers []Container
17 17
 }
18 18
 
19
-// ReadOnlyReason enumerates the reasons that a workload is
19
+// ReadOnlyReason enumerates the reasons that a controller is
20 20
 // considered read-only. The zero value is considered "OK", since the
21 21
 // zero value is what prior versions of the daemon will effectively
22 22
 // send.
@@ -30,7 +30,7 @@ const (
30 30
 	ReadOnlyNotReady ReadOnlyReason = "NotReady"
31 31
 )
32 32
 
33
-type WorkloadStatus struct {
33
+type ControllerStatus struct {
34 34
 	ID         flux.ResourceID
35 35
 	Containers []Container
36 36
 	ReadOnly   ReadOnlyReason
@@ -68,7 +68,7 @@ type NotDeprecated interface {
68 68
 	Export(context.Context) ([]byte, error)
69 69
 
70 70
 	// v6
71
-	ListWorkloads(ctx context.Context, namespace string) ([]WorkloadStatus, error)
71
+	ListServices(ctx context.Context, namespace string) ([]ControllerStatus, error)
72 72
 	ListImages(ctx context.Context, spec update.ResourceSpec) ([]ImageStatus, error)
73 73
 	UpdateManifests(context.Context, update.Spec) (job.ID, error)
74 74
 	SyncStatus(ctx context.Context, ref string) ([]string, error)

+ 3
- 3
cmd/fluxctl/list_workloads_cmd.go View File

@@ -46,7 +46,7 @@ func (opts *workloadListOpts) RunE(cmd *cobra.Command, args []string) error {
46 46
 
47 47
 	ctx := context.Background()
48 48
 
49
-	workloads, err := opts.API.ListWorkloads(ctx, opts.namespace)
49
+	workloads, err := opts.API.ListServices(ctx, opts.namespace)
50 50
 	if err != nil {
51 51
 		return err
52 52
 	}
@@ -70,7 +70,7 @@ func (opts *workloadListOpts) RunE(cmd *cobra.Command, args []string) error {
70 70
 	return nil
71 71
 }
72 72
 
73
-type workloadStatusByName []v6.WorkloadStatus
73
+type workloadStatusByName []v6.ControllerStatus
74 74
 
75 75
 func (s workloadStatusByName) Len() int {
76 76
 	return len(s)
@@ -84,7 +84,7 @@ func (s workloadStatusByName) Swap(a, b int) {
84 84
 	s[a], s[b] = s[b], s[a]
85 85
 }
86 86
 
87
-func policies(s v6.WorkloadStatus) string {
87
+func policies(s v6.ControllerStatus) string {
88 88
 	var ps []string
89 89
 	if s.Automated {
90 90
 		ps = append(ps, string(policy.Automated))

+ 2
- 2
cmd/fluxctl/release_cmd.go View File

@@ -196,7 +196,7 @@ func (opts *workloadReleaseOpts) RunE(cmd *cobra.Command, args []string) error {
196 196
 	fmt.Fprintf(cmd.OutOrStderr(), "Monitoring rollout ...\n")
197 197
 	for {
198 198
 		completed := 0
199
-		workloads, err := opts.API.ListWorkloadsWithOptions(ctx, v11.ListWorkloadsOptions{Workloads: result.Result.AffectedResources()})
199
+		workloads, err := opts.API.ListServicesWithOptions(ctx, v11.ListServicesOptions{Services: result.Result.AffectedResources()})
200 200
 		if err != nil {
201 201
 			return err
202 202
 		}
@@ -226,7 +226,7 @@ func (opts *workloadReleaseOpts) RunE(cmd *cobra.Command, args []string) error {
226 226
 	}
227 227
 }
228 228
 
229
-func writeRolloutStatus(workload v6.WorkloadStatus, verbosity int) {
229
+func writeRolloutStatus(workload v6.ControllerStatus, verbosity int) {
230 230
 	w := newTabwriter()
231 231
 	fmt.Fprintf(w, "WORKLOAD\tCONTAINER\tIMAGE\tRELEASE\tREPLICAS\n")
232 232
 

+ 8
- 8
daemon/daemon.go View File

@@ -98,19 +98,19 @@ func (d *Daemon) getResources(ctx context.Context) (map[string]resource.Resource
98 98
 	return resources, globalReadOnly, nil
99 99
 }
100 100
 
101
-func (d *Daemon) ListWorkloads(ctx context.Context, namespace string) ([]v6.WorkloadStatus, error) {
102
-	return d.ListWorkloadsWithOptions(ctx, v11.ListWorkloadsOptions{Namespace: namespace})
101
+func (d *Daemon) ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error) {
102
+	return d.ListServicesWithOptions(ctx, v11.ListServicesOptions{Namespace: namespace})
103 103
 }
104 104
 
105
-func (d *Daemon) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
106
-	if opts.Namespace != "" && len(opts.Workloads) > 0 {
105
+func (d *Daemon) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
106
+	if opts.Namespace != "" && len(opts.Services) > 0 {
107 107
 		return nil, errors.New("cannot filter by 'namespace' and 'workloads' at the same time")
108 108
 	}
109 109
 
110 110
 	var clusterWorkloads []cluster.Workload
111 111
 	var err error
112
-	if len(opts.Workloads) > 0 {
113
-		clusterWorkloads, err = d.Cluster.SomeWorkloads(opts.Workloads)
112
+	if len(opts.Services) > 0 {
113
+		clusterWorkloads, err = d.Cluster.SomeWorkloads(opts.Services)
114 114
 	} else {
115 115
 		clusterWorkloads, err = d.Cluster.AllWorkloads(opts.Namespace)
116 116
 	}
@@ -123,7 +123,7 @@ func (d *Daemon) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWork
123 123
 		return nil, err
124 124
 	}
125 125
 
126
-	var res []v6.WorkloadStatus
126
+	var res []v6.ControllerStatus
127 127
 	for _, workload := range clusterWorkloads {
128 128
 		readOnly := v6.ReadOnlyOK
129 129
 		var policies policy.Set
@@ -140,7 +140,7 @@ func (d *Daemon) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWork
140 140
 		if workload.SyncError != nil {
141 141
 			syncError = workload.SyncError.Error()
142 142
 		}
143
-		res = append(res, v6.WorkloadStatus{
143
+		res = append(res, v6.ControllerStatus{
144 144
 			ID:         workload.ID,
145 145
 			Containers: containers2containers(workload.ContainersOrNil()),
146 146
 			ReadOnly:   readOnly,

+ 7
- 7
daemon/daemon_test.go View File

@@ -107,7 +107,7 @@ func TestDaemon_ListWorkloads(t *testing.T) {
107 107
 	ctx := context.Background()
108 108
 
109 109
 	// No namespace
110
-	s, err := d.ListWorkloads(ctx, "")
110
+	s, err := d.ListServices(ctx, "")
111 111
 	if err != nil {
112 112
 		t.Fatalf("Error: %s", err.Error())
113 113
 	}
@@ -116,7 +116,7 @@ func TestDaemon_ListWorkloads(t *testing.T) {
116 116
 	}
117 117
 
118 118
 	// Just namespace
119
-	s, err = d.ListWorkloads(ctx, ns)
119
+	s, err = d.ListServices(ctx, ns)
120 120
 	if err != nil {
121 121
 		t.Fatalf("Error: %s", err.Error())
122 122
 	}
@@ -125,7 +125,7 @@ func TestDaemon_ListWorkloads(t *testing.T) {
125 125
 	}
126 126
 
127 127
 	// Invalid NS
128
-	s, err = d.ListWorkloads(ctx, invalidNS)
128
+	s, err = d.ListServices(ctx, invalidNS)
129 129
 	if err != nil {
130 130
 		t.Fatalf("Error: %s", err.Error())
131 131
 	}
@@ -143,7 +143,7 @@ func TestDaemon_ListWorkloadsWithOptions(t *testing.T) {
143 143
 	ctx := context.Background()
144 144
 
145 145
 	t.Run("no filter", func(t *testing.T) {
146
-		s, err := d.ListWorkloadsWithOptions(ctx, v11.ListWorkloadsOptions{})
146
+		s, err := d.ListServicesWithOptions(ctx, v11.ListServicesOptions{})
147 147
 		if err != nil {
148 148
 			t.Fatalf("Error: %s", err.Error())
149 149
 		}
@@ -152,7 +152,7 @@ func TestDaemon_ListWorkloadsWithOptions(t *testing.T) {
152 152
 		}
153 153
 	})
154 154
 	t.Run("filter id", func(t *testing.T) {
155
-		s, err := d.ListWorkloadsWithOptions(ctx, v11.ListWorkloadsOptions{
155
+		s, err := d.ListServicesWithOptions(ctx, v11.ListServicesOptions{
156 156
 			Namespace: "",
157 157
 			Services:  []flux.ResourceID{flux.MustParseResourceID(wl)}})
158 158
 		if err != nil {
@@ -164,7 +164,7 @@ func TestDaemon_ListWorkloadsWithOptions(t *testing.T) {
164 164
 	})
165 165
 
166 166
 	t.Run("filter id and namespace", func(t *testing.T) {
167
-		_, err := d.ListWorkloadsWithOptions(ctx, v11.ListWorkloadsOptions{
167
+		_, err := d.ListServicesWithOptions(ctx, v11.ListServicesOptions{
168 168
 			Namespace: "foo",
169 169
 			Services:  []flux.ResourceID{flux.MustParseResourceID(wl)}})
170 170
 		if err == nil {
@@ -173,7 +173,7 @@ func TestDaemon_ListWorkloadsWithOptions(t *testing.T) {
173 173
 	})
174 174
 
175 175
 	t.Run("filter unsupported id kind", func(t *testing.T) {
176
-		_, err := d.ListWorkloadsWithOptions(ctx, v11.ListWorkloadsOptions{
176
+		_, err := d.ListServicesWithOptions(ctx, v11.ListServicesOptions{
177 177
 			Namespace: "foo",
178 178
 			Services:  []flux.ResourceID{flux.MustParseResourceID("default:unsupportedkind/goodbyeworld")}})
179 179
 		if err == nil {

+ 7
- 7
http/client/client.go View File

@@ -53,19 +53,19 @@ func New(c *http.Client, router *mux.Router, endpoint string, t Token) *Client {
53 53
 	}
54 54
 }
55 55
 
56
-func (c *Client) ListWorkloads(ctx context.Context, namespace string) ([]v6.WorkloadStatus, error) {
57
-	var res []v6.WorkloadStatus
58
-	err := c.Get(ctx, &res, transport.ListWorkloads, "namespace", namespace)
56
+func (c *Client) ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error) {
57
+	var res []v6.ControllerStatus
58
+	err := c.Get(ctx, &res, transport.ListServices, "namespace", namespace)
59 59
 	return res, err
60 60
 }
61 61
 
62
-func (c *Client) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
63
-	var res []v6.WorkloadStatus
62
+func (c *Client) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
63
+	var res []v6.ControllerStatus
64 64
 	var services []string
65
-	for _, svc := range opts.Workloads {
65
+	for _, svc := range opts.Services {
66 66
 		services = append(services, svc.String())
67 67
 	}
68
-	err := c.Get(ctx, &res, transport.ListWorkloadsWithOptions, "namespace", opts.Namespace, "services", strings.Join(services, ","))
68
+	err := c.Get(ctx, &res, transport.ListServicesWithOptions, "namespace", opts.Namespace, "services", strings.Join(services, ","))
69 69
 	return res, err
70 70
 }
71 71
 

+ 6
- 6
http/daemon/server.go View File

@@ -48,8 +48,8 @@ func NewRouter() *mux.Router {
48 48
 
49 49
 func NewHandler(s api.Server, r *mux.Router) http.Handler {
50 50
 	handle := HTTPServer{s}
51
-	r.Get(transport.ListWorkloads).HandlerFunc(handle.ListWorkloadsWithOptions)
52
-	r.Get(transport.ListWorkloadsWithOptions).HandlerFunc(handle.ListWorkloadsWithOptions)
51
+	r.Get(transport.ListServices).HandlerFunc(handle.ListServicesWithOptions)
52
+	r.Get(transport.ListServicesWithOptions).HandlerFunc(handle.ListServicesWithOptions)
53 53
 	r.Get(transport.ListImages).HandlerFunc(handle.ListImagesWithOptions)
54 54
 	r.Get(transport.ListImagesWithOptions).HandlerFunc(handle.ListImagesWithOptions)
55 55
 	r.Get(transport.UpdateManifests).HandlerFunc(handle.UpdateManifests)
@@ -146,8 +146,8 @@ func (s HTTPServer) UpdateManifests(w http.ResponseWriter, r *http.Request) {
146 146
 	transport.JSONResponse(w, r, jobID)
147 147
 }
148 148
 
149
-func (s HTTPServer) ListWorkloadsWithOptions(w http.ResponseWriter, r *http.Request) {
150
-	var opts v11.ListWorkloadsOptions
149
+func (s HTTPServer) ListServicesWithOptions(w http.ResponseWriter, r *http.Request) {
150
+	var opts v11.ListServicesOptions
151 151
 	opts.Namespace = r.URL.Query().Get("namespace")
152 152
 	services := r.URL.Query().Get("services")
153 153
 	if services != "" {
@@ -157,11 +157,11 @@ func (s HTTPServer) ListWorkloadsWithOptions(w http.ResponseWriter, r *http.Requ
157 157
 				transport.WriteError(w, r, http.StatusBadRequest, errors.Wrapf(err, "parsing service spec %q", svc))
158 158
 				return
159 159
 			}
160
-			opts.Workloads = append(opts.Workloads, id)
160
+			opts.Services = append(opts.Services, id)
161 161
 		}
162 162
 	}
163 163
 
164
-	res, err := s.server.ListWorkloadsWithOptions(r.Context(), opts)
164
+	res, err := s.server.ListServicesWithOptions(r.Context(), opts)
165 165
 	if err != nil {
166 166
 		transport.ErrorResponse(w, r, err)
167 167
 		return

+ 9
- 9
http/routes.go View File

@@ -1,15 +1,15 @@
1 1
 package http
2 2
 
3 3
 const (
4
-	ListWorkloads            = "ListWorkloads"
5
-	ListWorkloadsWithOptions = "ListWorkloadsWithOptions"
6
-	ListImages               = "ListImages"
7
-	ListImagesWithOptions    = "ListImagesWithOptions"
8
-	UpdateManifests          = "UpdateManifests"
9
-	JobStatus                = "JobStatus"
10
-	SyncStatus               = "SyncStatus"
11
-	Export                   = "Export"
12
-	GitRepoConfig            = "GitRepoConfig"
4
+	ListServices            = "ListServices"
5
+	ListServicesWithOptions = "ListServicesWithOptions"
6
+	ListImages              = "ListImages"
7
+	ListImagesWithOptions   = "ListImagesWithOptions"
8
+	UpdateManifests         = "UpdateManifests"
9
+	JobStatus               = "JobStatus"
10
+	SyncStatus              = "SyncStatus"
11
+	Export                  = "Export"
12
+	GitRepoConfig           = "GitRepoConfig"
13 13
 
14 14
 	UpdateImages           = "UpdateImages"
15 15
 	UpdatePolicies         = "UpdatePolicies"

+ 2
- 2
http/transport.go View File

@@ -29,8 +29,8 @@ func DeprecateVersions(r *mux.Router, versions ...string) {
29 29
 func NewAPIRouter() *mux.Router {
30 30
 	r := mux.NewRouter()
31 31
 
32
-	r.NewRoute().Name(ListWorkloads).Methods("GET").Path("/v6/services")
33
-	r.NewRoute().Name(ListWorkloadsWithOptions).Methods("GET").Path("/v11/services")
32
+	r.NewRoute().Name(ListServices).Methods("GET").Path("/v6/services")
33
+	r.NewRoute().Name(ListServicesWithOptions).Methods("GET").Path("/v11/services")
34 34
 	r.NewRoute().Name(ListImages).Methods("GET").Path("/v6/images")
35 35
 	r.NewRoute().Name(ListImagesWithOptions).Methods("GET").Path("/v10/images")
36 36
 

+ 6
- 6
remote/logging.go View File

@@ -36,22 +36,22 @@ func (p *ErrorLoggingServer) Export(ctx context.Context) (config []byte, err err
36 36
 	return p.server.Export(ctx)
37 37
 }
38 38
 
39
-func (p *ErrorLoggingServer) ListWorkloads(ctx context.Context, maybeNamespace string) (_ []v6.WorkloadStatus, err error) {
39
+func (p *ErrorLoggingServer) ListServices(ctx context.Context, maybeNamespace string) (_ []v6.ControllerStatus, err error) {
40 40
 	defer func() {
41 41
 		if err != nil {
42
-			p.logger.Log("method", "ListWorkloads", "error", err)
42
+			p.logger.Log("method", "ListServices", "error", err)
43 43
 		}
44 44
 	}()
45
-	return p.server.ListWorkloads(ctx, maybeNamespace)
45
+	return p.server.ListServices(ctx, maybeNamespace)
46 46
 }
47 47
 
48
-func (p *ErrorLoggingServer) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) (_ []v6.WorkloadStatus, err error) {
48
+func (p *ErrorLoggingServer) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) (_ []v6.ControllerStatus, err error) {
49 49
 	defer func() {
50 50
 		if err != nil {
51
-			p.logger.Log("method", "ListWorkloadsWithOptions", "error", err)
51
+			p.logger.Log("method", "ListServicesWithOptions", "error", err)
52 52
 		}
53 53
 	}()
54
-	return p.server.ListWorkloadsWithOptions(ctx, opts)
54
+	return p.server.ListServicesWithOptions(ctx, opts)
55 55
 }
56 56
 
57 57
 func (p *ErrorLoggingServer) ListImages(ctx context.Context, spec update.ResourceSpec) (_ []v6.ImageStatus, err error) {

+ 6
- 6
remote/metrics.go View File

@@ -48,24 +48,24 @@ func (i *instrumentedServer) Export(ctx context.Context) (config []byte, err err
48 48
 	return i.s.Export(ctx)
49 49
 }
50 50
 
51
-func (i *instrumentedServer) ListWorkloads(ctx context.Context, namespace string) (_ []v6.WorkloadStatus, err error) {
51
+func (i *instrumentedServer) ListServices(ctx context.Context, namespace string) (_ []v6.ControllerStatus, err error) {
52 52
 	defer func(begin time.Time) {
53 53
 		requestDuration.With(
54
-			fluxmetrics.LabelMethod, "ListWorkloads",
54
+			fluxmetrics.LabelMethod, "ListServices",
55 55
 			fluxmetrics.LabelSuccess, fmt.Sprint(err == nil),
56 56
 		).Observe(time.Since(begin).Seconds())
57 57
 	}(time.Now())
58
-	return i.s.ListWorkloads(ctx, namespace)
58
+	return i.s.ListServices(ctx, namespace)
59 59
 }
60 60
 
61
-func (i *instrumentedServer) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) (_ []v6.WorkloadStatus, err error) {
61
+func (i *instrumentedServer) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) (_ []v6.ControllerStatus, err error) {
62 62
 	defer func(begin time.Time) {
63 63
 		requestDuration.With(
64
-			fluxmetrics.LabelMethod, "ListWorkloadsWithOptions",
64
+			fluxmetrics.LabelMethod, "ListServicesWithOptions",
65 65
 			fluxmetrics.LabelSuccess, fmt.Sprint(err == nil),
66 66
 		).Observe(time.Since(begin).Seconds())
67 67
 	}(time.Now())
68
-	return i.s.ListWorkloadsWithOptions(ctx, opts)
68
+	return i.s.ListServicesWithOptions(ctx, opts)
69 69
 }
70 70
 
71 71
 func (i *instrumentedServer) ListImages(ctx context.Context, spec update.ResourceSpec) (_ []v6.ImageStatus, err error) {

+ 19
- 19
remote/mock.go View File

@@ -29,8 +29,8 @@ type MockServer struct {
29 29
 	ExportAnswer []byte
30 30
 	ExportError  error
31 31
 
32
-	ListWorkloadsAnswer []v6.WorkloadStatus
33
-	ListWorkloadsError  error
32
+	ListServicesAnswer []v6.ControllerStatus
33
+	ListServicesError  error
34 34
 
35 35
 	ListImagesAnswer []v6.ImageStatus
36 36
 	ListImagesError  error
@@ -63,12 +63,12 @@ func (p *MockServer) Export(ctx context.Context) ([]byte, error) {
63 63
 	return p.ExportAnswer, p.ExportError
64 64
 }
65 65
 
66
-func (p *MockServer) ListWorkloads(ctx context.Context, ns string) ([]v6.WorkloadStatus, error) {
67
-	return p.ListWorkloadsAnswer, p.ListWorkloadsError
66
+func (p *MockServer) ListServices(ctx context.Context, ns string) ([]v6.ControllerStatus, error) {
67
+	return p.ListServicesAnswer, p.ListServicesError
68 68
 }
69 69
 
70
-func (p *MockServer) ListWorkloadsWithOptions(context.Context, v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
71
-	return p.ListWorkloadsAnswer, p.ListWorkloadsError
70
+func (p *MockServer) ListServicesWithOptions(context.Context, v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
71
+	return p.ListServicesAnswer, p.ListServicesError
72 72
 }
73 73
 
74 74
 func (p *MockServer) ListImages(context.Context, update.ResourceSpec) ([]v6.ImageStatus, error) {
@@ -114,15 +114,15 @@ func ServerTestBattery(t *testing.T, wrap func(mock api.UpstreamServer) api.Upst
114 114
 	// set up
115 115
 	namespace := "the-space-of-names"
116 116
 	serviceID := flux.MustParseResourceID(namespace + "/service")
117
-	workloadsList := []flux.ResourceID{serviceID}
118
-	workloads := flux.ResourceIDSet{}
119
-	workloads.Add(workloadsList)
117
+	serviceList := []flux.ResourceID{serviceID}
118
+	services := flux.ResourceIDSet{}
119
+	services.Add(serviceList)
120 120
 
121 121
 	now := time.Now().UTC()
122 122
 
123 123
 	imageID, _ := image.ParseRef("quay.io/example.com/frob:v0.4.5")
124
-	workloadAnswer := []v6.WorkloadStatus{
125
-		v6.WorkloadStatus{
124
+	serviceAnswer := []v6.ControllerStatus{
125
+		v6.ControllerStatus{
126 126
 			ID:     flux.MustParseResourceID("foobar/hello"),
127 127
 			Status: "ok",
128 128
 			Containers: []v6.Container{
@@ -135,7 +135,7 @@ func ServerTestBattery(t *testing.T, wrap func(mock api.UpstreamServer) api.Upst
135 135
 				},
136 136
 			},
137 137
 		},
138
-		v6.WorkloadStatus{},
138
+		v6.ControllerStatus{},
139 139
 	}
140 140
 
141 141
 	imagesAnswer := []v6.ImageStatus{
@@ -175,7 +175,7 @@ func ServerTestBattery(t *testing.T, wrap func(mock api.UpstreamServer) api.Upst
175 175
 	}
176 176
 
177 177
 	mock := &MockServer{
178
-		ListWorkloadsAnswer:    workloadAnswer,
178
+		ListServicesAnswer:     serviceAnswer,
179 179
 		ListImagesAnswer:       imagesAnswer,
180 180
 		UpdateManifestsArgTest: checkUpdateSpec,
181 181
 		UpdateManifestsAnswer:  job.ID(guid.New()),
@@ -191,17 +191,17 @@ func ServerTestBattery(t *testing.T, wrap func(mock api.UpstreamServer) api.Upst
191 191
 		t.Fatal(err)
192 192
 	}
193 193
 
194
-	ss, err := client.ListWorkloads(ctx, namespace)
194
+	ss, err := client.ListServices(ctx, namespace)
195 195
 	if err != nil {
196 196
 		t.Error(err)
197 197
 	}
198
-	if !reflect.DeepEqual(ss, mock.ListWorkloadsAnswer) {
199
-		t.Error(fmt.Errorf("expected:\n%#v\ngot:\n%#v", mock.ListWorkloadsAnswer, ss))
198
+	if !reflect.DeepEqual(ss, mock.ListServicesAnswer) {
199
+		t.Error(fmt.Errorf("expected:\n%#v\ngot:\n%#v", mock.ListServicesAnswer, ss))
200 200
 	}
201
-	mock.ListWorkloadsError = fmt.Errorf("list workloads query failure")
202
-	ss, err = client.ListWorkloads(ctx, namespace)
201
+	mock.ListServicesError = fmt.Errorf("list services query failure")
202
+	ss, err = client.ListServices(ctx, namespace)
203 203
 	if err == nil {
204
-		t.Error("expected error from ListWorkloads, got nil")
204
+		t.Error("expected error from ListServices, got nil")
205 205
 	}
206 206
 
207 207
 	ims, err := client.ListImagesWithOptions(ctx, v10.ListImagesOptions{

+ 4
- 4
remote/rpc/baseclient.go View File

@@ -31,12 +31,12 @@ func (bc baseClient) Export(context.Context) ([]byte, error) {
31 31
 	return nil, remote.UpgradeNeededError(errors.New("Export method not implemented"))
32 32
 }
33 33
 
34
-func (bc baseClient) ListWorkloads(context.Context, string) ([]v6.WorkloadStatus, error) {
35
-	return nil, remote.UpgradeNeededError(errors.New("ListWorkloads method not implemented"))
34
+func (bc baseClient) ListServices(context.Context, string) ([]v6.ControllerStatus, error) {
35
+	return nil, remote.UpgradeNeededError(errors.New("ListServices method not implemented"))
36 36
 }
37 37
 
38
-func (bc baseClient) ListWorkloadsWithOptions(context.Context, v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
39
-	return nil, remote.UpgradeNeededError(errors.New("ListWorkloadsWithOptions method not implemented"))
38
+func (bc baseClient) ListServicesWithOptions(context.Context, v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
39
+	return nil, remote.UpgradeNeededError(errors.New("ListServicesWithOptions method not implemented"))
40 40
 }
41 41
 
42 42
 func (bc baseClient) ListImages(context.Context, update.ResourceSpec) ([]v6.ImageStatus, error) {

+ 1
- 1
remote/rpc/clientV10.go View File

@@ -31,7 +31,7 @@ func NewClientV10(conn io.ReadWriteCloser) *RPCClientV10 {
31 31
 
32 32
 func (p *RPCClientV10) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error) {
33 33
 	var resp ListImagesResponse
34
-	if err := requireWorkloadSpecKinds(opts.Spec, supportedKindsV8); err != nil {
34
+	if err := requireServiceSpecKinds(opts.Spec, supportedKindsV8); err != nil {
35 35
 		return resp.Result, remote.UnsupportedResourceKind(err)
36 36
 	}
37 37
 

+ 8
- 8
remote/rpc/clientV11.go View File

@@ -8,11 +8,11 @@ import (
8 8
 	"github.com/weaveworks/flux/api/v11"
9 9
 	"github.com/weaveworks/flux/api/v6"
10 10
 	"github.com/weaveworks/flux/remote"
11
-)
11
+	)
12 12
 
13 13
 // RPCClientV11 is the rpc-backed implementation of a server, for
14 14
 // talking to remote daemons. This version introduces methods which accept an
15
-// options struct as the first argument. e.g. ListWorkloadsWithOptions
15
+// options struct as the first argument. e.g. ListServicesWithOptions
16 16
 type RPCClientV11 struct {
17 17
 	*RPCClientV10
18 18
 }
@@ -29,16 +29,16 @@ func NewClientV11(conn io.ReadWriteCloser) *RPCClientV11 {
29 29
 	return &RPCClientV11{NewClientV10(conn)}
30 30
 }
31 31
 
32
-func (p *RPCClientV11) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
33
-	var resp ListWorkloadsResponse
34
-	for _, svc := range opts.Workloads {
35
-		if err := requireWorkloadIDKinds(svc, supportedKindsV8); err != nil {
32
+func (p *RPCClientV11) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
33
+	var resp ListServicesResponse
34
+	for _, svc := range opts.Services {
35
+		if err := requireServiceIDKinds(svc, supportedKindsV8); err != nil {
36 36
 			return resp.Result, remote.UnsupportedResourceKind(err)
37 37
 		}
38 38
 	}
39 39
 
40
-	err := p.client.Call("RPCServer.ListWorkloadsWithOptions", opts, &resp)
41
-	listWorkloadsRolloutStatus(resp.Result)
40
+	err := p.client.Call("RPCServer.ListServicesWithOptions", opts, &resp)
41
+	listServicesRolloutStatus(resp.Result)
42 42
 	if err != nil {
43 43
 		if _, ok := err.(rpc.ServerError); !ok && err != nil {
44 44
 			err = remote.FatalError{err}

+ 7
- 7
remote/rpc/clientV6.go View File

@@ -89,10 +89,10 @@ func (p *RPCClientV6) Export(ctx context.Context) ([]byte, error) {
89 89
 	return config, err
90 90
 }
91 91
 
92
-func (p *RPCClientV6) ListWorkloads(ctx context.Context, namespace string) ([]v6.WorkloadStatus, error) {
93
-	var services []v6.WorkloadStatus
94
-	err := p.client.Call("RPCServer.ListWorkloads", namespace, &services)
95
-	listWorkloadsRolloutStatus(services)
92
+func (p *RPCClientV6) ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error) {
93
+	var services []v6.ControllerStatus
94
+	err := p.client.Call("RPCServer.ListServices", namespace, &services)
95
+	listServicesRolloutStatus(services)
96 96
 	if _, ok := err.(rpc.ServerError); !ok && err != nil {
97 97
 		return nil, remote.FatalError{err}
98 98
 	}
@@ -102,13 +102,13 @@ func (p *RPCClientV6) ListWorkloads(ctx context.Context, namespace string) ([]v6
102 102
 	return services, err
103 103
 }
104 104
 
105
-func (p *RPCClientV6) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
106
-	return listWorkloadsWithOptions(ctx, p, opts, supportedKindsV6)
105
+func (p *RPCClientV6) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
106
+	return listServicesWithOptions(ctx, p, opts, supportedKindsV6)
107 107
 }
108 108
 
109 109
 func (p *RPCClientV6) ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6.ImageStatus, error) {
110 110
 	var images []v6.ImageStatus
111
-	if err := requireWorkloadSpecKinds(spec, supportedKindsV6); err != nil {
111
+	if err := requireServiceSpecKinds(spec, supportedKindsV6); err != nil {
112 112
 		return images, remote.UpgradeNeededError(err)
113 113
 	}
114 114
 

+ 7
- 7
remote/rpc/clientV7.go View File

@@ -50,10 +50,10 @@ func (p *RPCClientV7) Export(ctx context.Context) ([]byte, error) {
50 50
 	return resp.Result, err
51 51
 }
52 52
 
53
-func (p *RPCClientV7) ListWorkloads(ctx context.Context, namespace string) ([]v6.WorkloadStatus, error) {
54
-	var resp ListWorkloadsResponse
55
-	err := p.client.Call("RPCServer.ListWorkloads", namespace, &resp)
56
-	listWorkloadsRolloutStatus(resp.Result)
53
+func (p *RPCClientV7) ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error) {
54
+	var resp ListServicesResponse
55
+	err := p.client.Call("RPCServer.ListServices", namespace, &resp)
56
+	listServicesRolloutStatus(resp.Result)
57 57
 	if err != nil {
58 58
 		if _, ok := err.(rpc.ServerError); !ok && err != nil {
59 59
 			return resp.Result, remote.FatalError{err}
@@ -65,13 +65,13 @@ func (p *RPCClientV7) ListWorkloads(ctx context.Context, namespace string) ([]v6
65 65
 	return resp.Result, err
66 66
 }
67 67
 
68
-func (p *RPCClientV7) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
69
-	return listWorkloadsWithOptions(ctx, p, opts, supportedKindsV7)
68
+func (p *RPCClientV7) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
69
+	return listServicesWithOptions(ctx, p, opts, supportedKindsV7)
70 70
 }
71 71
 
72 72
 func (p *RPCClientV7) ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6.ImageStatus, error) {
73 73
 	var resp ListImagesResponse
74
-	if err := requireWorkloadSpecKinds(spec, supportedKindsV7); err != nil {
74
+	if err := requireServiceSpecKinds(spec, supportedKindsV7); err != nil {
75 75
 		return resp.Result, remote.UpgradeNeededError(err)
76 76
 	}
77 77
 

+ 3
- 3
remote/rpc/clientV8.go View File

@@ -34,13 +34,13 @@ func NewClientV8(conn io.ReadWriteCloser) *RPCClientV8 {
34 34
 	return &RPCClientV8{NewClientV7(conn)}
35 35
 }
36 36
 
37
-func (p *RPCClientV8) ListWorkloadsWithOptions(ctx context.Context, opts v11.ListWorkloadsOptions) ([]v6.WorkloadStatus, error) {
38
-	return listWorkloadsWithOptions(ctx, p, opts, supportedKindsV8)
37
+func (p *RPCClientV8) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error) {
38
+	return listServicesWithOptions(ctx, p, opts, supportedKindsV8)
39 39
 }
40 40
 
41 41
 func (p *RPCClientV8) ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6.ImageStatus, error) {
42 42
 	var resp ListImagesResponse
43
-	if err := requireWorkloadSpecKinds(spec, supportedKindsV8); err != nil {
43
+	if err := requireServiceSpecKinds(spec, supportedKindsV8); err != nil {
44 44
 		return resp.Result, remote.UnsupportedResourceKind(err)
45 45
 	}
46 46
 

+ 27
- 27
remote/rpc/compat.go View File

@@ -15,7 +15,7 @@ import (
15 15
 	"github.com/weaveworks/flux/update"
16 16
 )
17 17
 
18
-func requireWorkloadSpecKinds(ss update.ResourceSpec, kinds []string) error {
18
+func requireServiceSpecKinds(ss update.ResourceSpec, kinds []string) error {
19 19
 	id, err := ss.AsID()
20 20
 	if err != nil {
21 21
 		return nil
@@ -29,7 +29,7 @@ func requireWorkloadSpecKinds(ss update.ResourceSpec, kinds []string) error {
29 29
 	return nil
30 30
 }
31 31
 
32
-func requireWorkloadIDKinds(id flux.ResourceID, kinds []string) error {
32
+func requireServiceIDKinds(id flux.ResourceID, kinds []string) error {
33 33
 	_, kind, _ := id.Components()
34 34
 	if !contains(kinds, kind) {
35 35
 		return fmt.Errorf("Unsupported resource kind: %s", kind)
@@ -49,7 +49,7 @@ func requireSpecKinds(s update.Spec, kinds []string) error {
49 49
 		}
50 50
 	case update.ReleaseImageSpec:
51 51
 		for _, ss := range s.ServiceSpecs {
52
-			if err := requireWorkloadSpecKinds(ss, kinds); err != nil {
52
+			if err := requireServiceSpecKinds(ss, kinds); err != nil {
53 53
 				return err
54 54
 			}
55 55
 		}
@@ -72,8 +72,8 @@ func contains(ss []string, s string) bool {
72 72
 	return false
73 73
 }
74 74
 
75
-// listWorkloadsRolloutStatus polyfills the rollout status.
76
-func listWorkloadsRolloutStatus(ss []v6.WorkloadStatus) {
75
+// listServicesRolloutStatus polyfills the rollout status.
76
+func listServicesRolloutStatus(ss []v6.ControllerStatus) {
77 77
 	for i := range ss {
78 78
 		// Polyfill for daemons that list pod information in status ('X out of N updated')
79 79
 		if n, _ := fmt.Sscanf(ss[i].Status, "%d out of %d updated", &ss[i].Rollout.Updated, &ss[i].Rollout.Desired); n == 2 {
@@ -91,55 +91,55 @@ func listWorkloadsRolloutStatus(ss []v6.WorkloadStatus) {
91 91
 	}
92 92
 }
93 93
 
94
-type listWorkloadsWithoutOptionsClient interface {
95
-	ListWorkloads(ctx context.Context, namespace string) ([]v6.WorkloadStatus, error)
94
+type listServicesWithoutOptionsClient interface {
95
+	ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error)
96 96
 }
97 97
 
98
-// listWorkloadsWithOptions polyfills the ListWorkloadsWithOptions()
98
+// listServicesWithOptions polyfills the ListServiceWithOptions()
99 99
 // introduced in v11 by removing unwanted resources after fetching
100
-// all the workloads.
101
-func listWorkloadsWithOptions(ctx context.Context, p listWorkloadsWithoutOptionsClient, opts v11.ListWorkloadsOptions, supportedKinds []string) ([]v6.WorkloadStatus, error) {
102
-	if opts.Namespace != "" && len(opts.Workloads) > 0 {
103
-		return nil, errors.New("cannot filter by 'namespace' and 'workloads' at the same time")
100
+// all the services.
101
+func listServicesWithOptions(ctx context.Context, p listServicesWithoutOptionsClient, opts v11.ListServicesOptions, supportedKinds []string) ([]v6.ControllerStatus, error) {
102
+	if opts.Namespace != "" && len(opts.Services) > 0 {
103
+		return nil, errors.New("cannot filter by 'namespace' and 'services' at the same time")
104 104
 	}
105 105
 	if len(supportedKinds) > 0 {
106
-		for _, svc := range opts.Workloads {
107
-			if err := requireWorkloadIDKinds(svc, supportedKinds); err != nil {
106
+		for _, svc := range opts.Services {
107
+			if err := requireServiceIDKinds(svc, supportedKinds); err != nil {
108 108
 				return nil, remote.UnsupportedResourceKind(err)
109 109
 			}
110 110
 		}
111 111
 	}
112 112
 
113
-	all, err := p.ListWorkloads(ctx, opts.Namespace)
114
-	listWorkloadsRolloutStatus(all)
113
+	all, err := p.ListServices(ctx, opts.Namespace)
114
+	listServicesRolloutStatus(all)
115 115
 	if err != nil {
116 116
 		return nil, err
117 117
 	}
118
-	if len(opts.Workloads) == 0 {
118
+	if len(opts.Services) == 0 {
119 119
 		return all, nil
120 120
 	}
121 121
 
122
-	// Polyfill the workload IDs filter
122
+	// Polyfill the service IDs filter
123 123
 	want := map[flux.ResourceID]struct{}{}
124
-	for _, svc := range opts.Workloads {
124
+	for _, svc := range opts.Services {
125 125
 		want[svc] = struct{}{}
126 126
 	}
127
-	var workloads []v6.WorkloadStatus
127
+	var controllers []v6.ControllerStatus
128 128
 	for _, svc := range all {
129 129
 		if _, ok := want[svc.ID]; ok {
130
-			workloads = append(workloads, svc)
130
+			controllers = append(controllers, svc)
131 131
 		}
132 132
 	}
133
-	return workloads, nil
133
+	return controllers, nil
134 134
 }
135 135
 
136 136
 type listImagesWithoutOptionsClient interface {
137
-	ListWorkloads(ctx context.Context, namespace string) ([]v6.WorkloadStatus, error)
137
+	ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error)
138 138
 	ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6.ImageStatus, error)
139 139
 }
140 140
 
141 141
 // listImagesWithOptions is called by ListImagesWithOptions so we can use an
142
-// interface to dispatch .ListImages() and .ListWorkloads() to the correct
142
+// interface to dispatch .ListImages() and .ListServices() to the correct
143 143
 // API version.
144 144
 func listImagesWithOptions(ctx context.Context, client listImagesWithoutOptionsClient, opts v10.ListImagesOptions) ([]v6.ImageStatus, error) {
145 145
 	statuses, err := client.ListImages(ctx, opts.Spec)
@@ -155,14 +155,14 @@ func listImagesWithOptions(ctx context.Context, client listImagesWithoutOptionsC
155 155
 		}
156 156
 		ns, _, _ = resourceID.Components()
157 157
 	}
158
-	workloads, err := client.ListWorkloads(ctx, ns)
158
+	services, err := client.ListServices(ctx, ns)
159 159
 	if err != nil {
160 160
 		return statuses, err
161 161
 	}
162 162
 
163 163
 	policyMap := map[flux.ResourceID]map[string]string{}
164
-	for _, workload := range workloads {
165
-		policyMap[workload.ID] = workload.Policies
164
+	for _, service := range services {
165
+		policyMap[service.ID] = service.Policies
166 166
 	}
167 167
 
168 168
 	// Polyfill container fields from v10

+ 4
- 4
remote/rpc/server.go View File

@@ -68,13 +68,13 @@ func (p *RPCServer) Export(_ struct{}, resp *ExportResponse) error {
68 68
 	return err
69 69
 }
70 70
 
71
-type ListWorkloadsResponse struct {
72
-	Result           []v6.WorkloadStatus
71
+type ListServicesResponse struct {
72
+	Result           []v6.ControllerStatus
73 73
 	ApplicationError *fluxerr.Error
74 74
 }
75 75
 
76
-func (p *RPCServer) ListWorkloads(namespace string, resp *ListWorkloadsResponse) error {
77
-	v, err := p.s.ListWorkloads(context.Background(), namespace)
76
+func (p *RPCServer) ListServices(namespace string, resp *ListServicesResponse) error {
77
+	v, err := p.s.ListServices(context.Background(), namespace)
78 78
 	resp.Result = v
79 79
 	if err != nil {
80 80
 		if err, ok := errors.Cause(err).(*fluxerr.Error); ok {

Loading…
Cancel
Save