Browse Source

Revert renaming of serialized struct fields

This is to avoid confusion between names serialized data and names used in the
code.

These field names will be renamed again when versioning is in-place for the
structs.
Alfonso Acosta 8 months ago
parent
commit
51e5e0f354

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

@@ -147,11 +147,11 @@ func (opts *workloadReleaseOpts) RunE(cmd *cobra.Command, args []string) error {
147 147
 
148 148
 	ctx := context.Background()
149 149
 	spec := update.ReleaseImageSpec{
150
-		WorkloadSpecs: workloads,
151
-		ImageSpec:     image,
152
-		Kind:          kind,
153
-		Excludes:      excludes,
154
-		Force:         opts.force,
150
+		ServiceSpecs: workloads,
151
+		ImageSpec:    image,
152
+		Kind:         kind,
153
+		Excludes:     excludes,
154
+		Force:        opts.force,
155 155
 	}
156 156
 	jobID, err := opts.API.UpdateManifests(ctx, update.Spec{
157 157
 		Type:  update.Images,

+ 15
- 15
cmd/fluxctl/release_cmd_test.go View File

@@ -15,29 +15,29 @@ func TestReleaseCommand_CLIConversion(t *testing.T) {
15 15
 		expectedSpec update.ReleaseImageSpec
16 16
 	}{
17 17
 		{[]string{"--update-all-images", "--all"}, update.ReleaseImageSpec{
18
-			WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
19
-			ImageSpec:     update.ImageSpecLatest,
20
-			Kind:          update.ReleaseKindExecute,
18
+			ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
19
+			ImageSpec:    update.ImageSpecLatest,
20
+			Kind:         update.ReleaseKindExecute,
21 21
 		}},
22 22
 		{[]string{"--update-all-images", "--all", "--dry-run"}, update.ReleaseImageSpec{
23
-			WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
24
-			ImageSpec:     update.ImageSpecLatest,
25
-			Kind:          update.ReleaseKindPlan,
23
+			ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
24
+			ImageSpec:    update.ImageSpecLatest,
25
+			Kind:         update.ReleaseKindPlan,
26 26
 		}},
27 27
 		{[]string{"--update-image=alpine:latest", "--all"}, update.ReleaseImageSpec{
28
-			WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
29
-			ImageSpec:     "alpine:latest",
30
-			Kind:          update.ReleaseKindExecute,
28
+			ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
29
+			ImageSpec:    "alpine:latest",
30
+			Kind:         update.ReleaseKindExecute,
31 31
 		}},
32 32
 		{[]string{"--update-all-images", "--workload=deployment/flux"}, update.ReleaseImageSpec{
33
-			WorkloadSpecs: []update.ResourceSpec{"default:deployment/flux"},
34
-			ImageSpec:     update.ImageSpecLatest,
35
-			Kind:          update.ReleaseKindExecute,
33
+			ServiceSpecs: []update.ResourceSpec{"default:deployment/flux"},
34
+			ImageSpec:    update.ImageSpecLatest,
35
+			Kind:         update.ReleaseKindExecute,
36 36
 		}},
37 37
 		{[]string{"--update-all-images", "--all", "--exclude=deployment/test,deployment/yeah"}, update.ReleaseImageSpec{
38
-			WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
39
-			ImageSpec:     update.ImageSpecLatest,
40
-			Kind:          update.ReleaseKindExecute,
38
+			ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
39
+			ImageSpec:    update.ImageSpecLatest,
40
+			Kind:         update.ReleaseKindExecute,
41 41
 			Excludes: []flux.ResourceID{
42 42
 				flux.MustParseResourceID("default:deployment/test"),
43 43
 				flux.MustParseResourceID("default:deployment/yeah"),

+ 12
- 12
daemon/daemon.go View File

@@ -289,12 +289,12 @@ func (d *Daemon) makeLoggingJobFunc(f jobFunc) jobFunc {
289 289
 			}
290 290
 
291 291
 			return result, d.LogEvent(event.Event{
292
-				WorkloadIDs: workloadIDs,
293
-				Type:        event.EventCommit,
294
-				StartedAt:   started,
295
-				EndedAt:     started,
296
-				LogLevel:    event.LogLevelInfo,
297
-				Metadata:    metadata,
292
+				ServiceIDs: workloadIDs,
293
+				Type:       event.EventCommit,
294
+				StartedAt:  started,
295
+				EndedAt:    started,
296
+				LogLevel:   event.LogLevelInfo,
297
+				Metadata:   metadata,
298 298
 			})
299 299
 		}
300 300
 		return result, nil
@@ -690,14 +690,14 @@ func policyEvents(us policy.Updates, now time.Time) map[string]event.Event {
690 690
 			e, ok := eventsByType[eventType]
691 691
 			if !ok {
692 692
 				e = event.Event{
693
-					WorkloadIDs: []flux.ResourceID{},
694
-					Type:        eventType,
695
-					StartedAt:   now,
696
-					EndedAt:     now,
697
-					LogLevel:    event.LogLevelInfo,
693
+					ServiceIDs: []flux.ResourceID{},
694
+					Type:       eventType,
695
+					StartedAt:  now,
696
+					EndedAt:    now,
697
+					LogLevel:   event.LogLevelInfo,
698 698
 				}
699 699
 			}
700
-			e.WorkloadIDs = append(e.WorkloadIDs, workloadID)
700
+			e.ServiceIDs = append(e.ServiceIDs, workloadID)
701 701
 			eventsByType[eventType] = e
702 702
 		}
703 703
 	}

+ 3
- 3
daemon/daemon_test.go View File

@@ -883,9 +883,9 @@ func updateImage(ctx context.Context, d *Daemon, t *testing.T) job.ID {
883 883
 	return updateManifest(ctx, t, d, update.Spec{
884 884
 		Type: update.Images,
885 885
 		Spec: update.ReleaseImageSpec{
886
-			Kind:          update.ReleaseKindExecute,
887
-			WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
888
-			ImageSpec:     newHelloImage,
886
+			Kind:         update.ReleaseKindExecute,
887
+			ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
888
+			ImageSpec:    newHelloImage,
889 889
 		},
890 890
 	})
891 891
 }

+ 20
- 20
daemon/loop.go View File

@@ -322,11 +322,11 @@ func (d *Daemon) doSync(logger log.Logger, lastKnownSyncTagRev *string, warnedAb
322 322
 			case update.Containers:
323 323
 				spec := n.Spec.Spec.(update.ReleaseContainersSpec)
324 324
 				noteEvents = append(noteEvents, event.Event{
325
-					WorkloadIDs: n.Result.AffectedResources(),
326
-					Type:        event.EventRelease,
327
-					StartedAt:   started,
328
-					EndedAt:     time.Now().UTC(),
329
-					LogLevel:    event.LogLevelInfo,
325
+					ServiceIDs: n.Result.AffectedResources(),
326
+					Type:       event.EventRelease,
327
+					StartedAt:  started,
328
+					EndedAt:    time.Now().UTC(),
329
+					LogLevel:   event.LogLevelInfo,
330 330
 					Metadata: &event.ReleaseEventMetadata{
331 331
 						ReleaseEventCommon: event.ReleaseEventCommon{
332 332
 							Revision: commits[i].Revision,
@@ -344,11 +344,11 @@ func (d *Daemon) doSync(logger log.Logger, lastKnownSyncTagRev *string, warnedAb
344 344
 			case update.Images:
345 345
 				spec := n.Spec.Spec.(update.ReleaseImageSpec)
346 346
 				noteEvents = append(noteEvents, event.Event{
347
-					WorkloadIDs: n.Result.AffectedResources(),
348
-					Type:        event.EventRelease,
349
-					StartedAt:   started,
350
-					EndedAt:     time.Now().UTC(),
351
-					LogLevel:    event.LogLevelInfo,
347
+					ServiceIDs: n.Result.AffectedResources(),
348
+					Type:       event.EventRelease,
349
+					StartedAt:  started,
350
+					EndedAt:    time.Now().UTC(),
351
+					LogLevel:   event.LogLevelInfo,
352 352
 					Metadata: &event.ReleaseEventMetadata{
353 353
 						ReleaseEventCommon: event.ReleaseEventCommon{
354 354
 							Revision: commits[i].Revision,
@@ -366,11 +366,11 @@ func (d *Daemon) doSync(logger log.Logger, lastKnownSyncTagRev *string, warnedAb
366 366
 			case update.Auto:
367 367
 				spec := n.Spec.Spec.(update.Automated)
368 368
 				noteEvents = append(noteEvents, event.Event{
369
-					WorkloadIDs: n.Result.AffectedResources(),
370
-					Type:        event.EventAutoRelease,
371
-					StartedAt:   started,
372
-					EndedAt:     time.Now().UTC(),
373
-					LogLevel:    event.LogLevelInfo,
369
+					ServiceIDs: n.Result.AffectedResources(),
370
+					Type:       event.EventAutoRelease,
371
+					StartedAt:  started,
372
+					EndedAt:    time.Now().UTC(),
373
+					LogLevel:   event.LogLevelInfo,
374 374
 					Metadata: &event.AutoReleaseEventMetadata{
375 375
 						ReleaseEventCommon: event.ReleaseEventCommon{
376 376
 							Revision: commits[i].Revision,
@@ -397,11 +397,11 @@ func (d *Daemon) doSync(logger log.Logger, lastKnownSyncTagRev *string, warnedAb
397 397
 			cs[i].Message = c.Message
398 398
 		}
399 399
 		if err = d.LogEvent(event.Event{
400
-			WorkloadIDs: workloadIDs.ToSlice(),
401
-			Type:        event.EventSync,
402
-			StartedAt:   started,
403
-			EndedAt:     started,
404
-			LogLevel:    event.LogLevelInfo,
400
+			ServiceIDs: workloadIDs.ToSlice(),
401
+			Type:       event.EventSync,
402
+			StartedAt:  started,
403
+			EndedAt:    started,
404
+			LogLevel:   event.LogLevelInfo,
405 405
 			Metadata: &event.SyncEventMetadata{
406 406
 				Commits:     cs,
407 407
 				InitialSync: initialSync,

+ 2
- 2
daemon/loop_test.go View File

@@ -123,7 +123,7 @@ func TestPullAndSync_InitialSync(t *testing.T) {
123 123
 	} else if es[0].Type != event.EventSync {
124 124
 		t.Errorf("Unexpected event type: %#v", es[0])
125 125
 	} else {
126
-		gotResourceIDs := es[0].WorkloadIDs
126
+		gotResourceIDs := es[0].ServiceIDs
127 127
 		flux.ResourceIDs(gotResourceIDs).Sort()
128 128
 		if !reflect.DeepEqual(gotResourceIDs, []flux.ResourceID(expectedResourceIDs)) {
129 129
 			t.Errorf("Unexpected event workload ids: %#v, expected: %#v", gotResourceIDs, expectedResourceIDs)
@@ -298,7 +298,7 @@ func TestDoSync_WithNewCommit(t *testing.T) {
298 298
 	} else if es[0].Type != event.EventSync {
299 299
 		t.Errorf("Unexpected event type: %#v", es[0])
300 300
 	} else {
301
-		gotResourceIDs := es[0].WorkloadIDs
301
+		gotResourceIDs := es[0].ServiceIDs
302 302
 		flux.ResourceIDs(gotResourceIDs).Sort()
303 303
 		// Event should only have changed workload ids
304 304
 		if !reflect.DeepEqual(gotResourceIDs, []flux.ResourceID{flux.MustParseResourceID("default:deployment/helloworld")}) {

+ 5
- 4
event/event.go View File

@@ -40,8 +40,9 @@ type Event struct {
40 40
 	// ID is a UUID for this event. Will be auto-set when saving if blank.
41 41
 	ID EventID `json:"id"`
42 42
 
43
-	// WorkloadIDs affected by this event.
44
-	WorkloadIDs []flux.ResourceID `json:"serviceIDs"`
43
+	// Identifiers of workloads affected by this event.
44
+	// TODO: rename to WorkloadIDs after adding versioning.
45
+	ServiceIDs []flux.ResourceID `json:"serviceIDs"`
45 46
 
46 47
 	// Type is the type of event, usually "release" for now, but could be other
47 48
 	// things later
@@ -75,7 +76,7 @@ type EventWriter interface {
75 76
 
76 77
 func (e Event) WorkloadIDStrings() []string {
77 78
 	var strWorkloadIDs []string
78
-	for _, workloadID := range e.WorkloadIDs {
79
+	for _, workloadID := range e.ServiceIDs {
79 80
 		strWorkloadIDs = append(strWorkloadIDs, workloadID.String())
80 81
 	}
81 82
 	sort.Strings(strWorkloadIDs)
@@ -96,7 +97,7 @@ func (e Event) String() string {
96 97
 			strImageIDs = []string{"no image changes"}
97 98
 		}
98 99
 		if metadata.Spec.Type == "" || metadata.Spec.Type == ReleaseImageSpecType {
99
-			for _, spec := range metadata.Spec.ReleaseImageSpec.WorkloadSpecs {
100
+			for _, spec := range metadata.Spec.ReleaseImageSpec.ServiceSpecs {
100 101
 				if spec == update.ResourceSpecAll {
101 102
 					strWorkloadIDs = []string{"all workloads"}
102 103
 					break

+ 1
- 1
event/event_test.go View File

@@ -91,7 +91,7 @@ func TestEvent_ParseOldReleaseMetaData(t *testing.T) {
91 91
 	if eventData.Spec.ReleaseContainersSpec != nil {
92 92
 		t.Error("unexpectedly set .ReleaseContainersSpec")
93 93
 	}
94
-	if len(eventData.Spec.ReleaseImageSpec.WorkloadSpecs) != 1 {
94
+	if len(eventData.Spec.ReleaseImageSpec.ServiceSpecs) != 1 {
95 95
 		t.Error("expected service specs of len 1")
96 96
 	}
97 97
 }

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

@@ -234,10 +234,10 @@ func (s HTTPServer) UpdateImages(w http.ResponseWriter, r *http.Request) {
234 234
 	}
235 235
 
236 236
 	spec := update.ReleaseImageSpec{
237
-		WorkloadSpecs: serviceSpecs,
238
-		ImageSpec:     imageSpec,
239
-		Kind:          releaseKind,
240
-		Excludes:      excludes,
237
+		ServiceSpecs: serviceSpecs,
238
+		ImageSpec:    imageSpec,
239
+		Kind:         releaseKind,
240
+		Excludes:     excludes,
241 241
 	}
242 242
 	cause := update.Cause{
243 243
 		User:    r.FormValue("user"),

+ 85
- 85
release/releaser_test.go View File

@@ -251,9 +251,9 @@ func Test_InitContainer(t *testing.T) {
251 251
 
252 252
 	initSpec, _ := update.ParseResourceSpec(initWorkloadID.String())
253 253
 	spec := update.ReleaseImageSpec{
254
-		WorkloadSpecs: []update.ResourceSpec{initSpec},
255
-		ImageSpec:     update.ImageSpecLatest,
256
-		Kind:          update.ReleaseKindExecute,
254
+		ServiceSpecs: []update.ResourceSpec{initSpec},
255
+		ImageSpec:    update.ImageSpecLatest,
256
+		Kind:         update.ReleaseKindExecute,
257 257
 	}
258 258
 
259 259
 	checkout, clean := setup(t)
@@ -282,10 +282,10 @@ func Test_FilterLogic(t *testing.T) {
282 282
 		{
283 283
 			Name: "include specific service",
284 284
 			Spec: update.ReleaseImageSpec{
285
-				WorkloadSpecs: []update.ResourceSpec{hwSvcSpec},
286
-				ImageSpec:     update.ImageSpecLatest,
287
-				Kind:          update.ReleaseKindExecute,
288
-				Excludes:      []flux.ResourceID{},
285
+				ServiceSpecs: []update.ResourceSpec{hwSvcSpec},
286
+				ImageSpec:    update.ImageSpecLatest,
287
+				Kind:         update.ReleaseKindExecute,
288
+				Excludes:     []flux.ResourceID{},
289 289
 			},
290 290
 			Expected: expected{
291 291
 				Specific: update.Result{
@@ -310,10 +310,10 @@ func Test_FilterLogic(t *testing.T) {
310 310
 		}, {
311 311
 			Name: "exclude specific service",
312 312
 			Spec: update.ReleaseImageSpec{
313
-				WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
314
-				ImageSpec:     update.ImageSpecLatest,
315
-				Kind:          update.ReleaseKindExecute,
316
-				Excludes:      []flux.ResourceID{lockedSvcID},
313
+				ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
314
+				ImageSpec:    update.ImageSpecLatest,
315
+				Kind:         update.ReleaseKindExecute,
316
+				Excludes:     []flux.ResourceID{lockedSvcID},
317 317
 			},
318 318
 			Expected: expected{
319 319
 				Specific: update.Result{
@@ -342,10 +342,10 @@ func Test_FilterLogic(t *testing.T) {
342 342
 		}, {
343 343
 			Name: "update specific image",
344 344
 			Spec: update.ReleaseImageSpec{
345
-				WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
346
-				ImageSpec:     update.ImageSpecFromRef(newHwRef),
347
-				Kind:          update.ReleaseKindExecute,
348
-				Excludes:      []flux.ResourceID{},
345
+				ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
346
+				ImageSpec:    update.ImageSpecFromRef(newHwRef),
347
+				Kind:         update.ReleaseKindExecute,
348
+				Excludes:     []flux.ResourceID{},
349 349
 			},
350 350
 			Expected: expected{
351 351
 				Specific: update.Result{
@@ -371,10 +371,10 @@ func Test_FilterLogic(t *testing.T) {
371 371
 			// else: service is pending.
372 372
 			Name: "skipped & service is pending",
373 373
 			Spec: update.ReleaseImageSpec{
374
-				WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
375
-				ImageSpec:     update.ImageSpecLatest,
376
-				Kind:          update.ReleaseKindExecute,
377
-				Excludes:      []flux.ResourceID{},
374
+				ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
375
+				ImageSpec:    update.ImageSpecLatest,
376
+				Kind:         update.ReleaseKindExecute,
377
+				Excludes:     []flux.ResourceID{},
378 378
 			},
379 379
 			Expected: expected{
380 380
 				Specific: update.Result{
@@ -403,10 +403,10 @@ func Test_FilterLogic(t *testing.T) {
403 403
 		}, {
404 404
 			Name: "all overrides spec",
405 405
 			Spec: update.ReleaseImageSpec{
406
-				WorkloadSpecs: []update.ResourceSpec{hwSvcSpec, update.ResourceSpecAll},
407
-				ImageSpec:     update.ImageSpecLatest,
408
-				Kind:          update.ReleaseKindExecute,
409
-				Excludes:      []flux.ResourceID{},
406
+				ServiceSpecs: []update.ResourceSpec{hwSvcSpec, update.ResourceSpecAll},
407
+				ImageSpec:    update.ImageSpecLatest,
408
+				Kind:         update.ReleaseKindExecute,
409
+				Excludes:     []flux.ResourceID{},
410 410
 			},
411 411
 			Expected: expected{
412 412
 				Specific: update.Result{
@@ -435,10 +435,10 @@ func Test_FilterLogic(t *testing.T) {
435 435
 		}, {
436 436
 			Name: "service not in repo",
437 437
 			Spec: update.ReleaseImageSpec{
438
-				WorkloadSpecs: []update.ResourceSpec{notInRepoSpec},
439
-				ImageSpec:     update.ImageSpecLatest,
440
-				Kind:          update.ReleaseKindExecute,
441
-				Excludes:      []flux.ResourceID{},
438
+				ServiceSpecs: []update.ResourceSpec{notInRepoSpec},
439
+				ImageSpec:    update.ImageSpecLatest,
440
+				Kind:         update.ReleaseKindExecute,
441
+				Excludes:     []flux.ResourceID{},
442 442
 			},
443 443
 			Expected: expected{
444 444
 				Specific: update.Result{
@@ -481,11 +481,11 @@ func Test_Force_lockedWorkload(t *testing.T) {
481 481
 		{
482 482
 			Name: "force ignores service lock (--workload --update-image)",
483 483
 			Spec: update.ReleaseImageSpec{
484
-				WorkloadSpecs: []update.ResourceSpec{lockedSvcSpec},
485
-				ImageSpec:     update.ImageSpecFromRef(newLockedRef),
486
-				Kind:          update.ReleaseKindExecute,
487
-				Excludes:      []flux.ResourceID{},
488
-				Force:         true,
484
+				ServiceSpecs: []update.ResourceSpec{lockedSvcSpec},
485
+				ImageSpec:    update.ImageSpecFromRef(newLockedRef),
486
+				Kind:         update.ReleaseKindExecute,
487
+				Excludes:     []flux.ResourceID{},
488
+				Force:        true,
489 489
 			},
490 490
 			Expected: expected{
491 491
 				Specific: update.Result{
@@ -496,11 +496,11 @@ func Test_Force_lockedWorkload(t *testing.T) {
496 496
 		}, {
497 497
 			Name: "force does not ignore lock if updating all workloads (--all --update-image)",
498 498
 			Spec: update.ReleaseImageSpec{
499
-				WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
500
-				ImageSpec:     update.ImageSpecFromRef(newLockedRef),
501
-				Kind:          update.ReleaseKindExecute,
502
-				Excludes:      []flux.ResourceID{},
503
-				Force:         true,
499
+				ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
500
+				ImageSpec:    update.ImageSpecFromRef(newLockedRef),
501
+				Kind:         update.ReleaseKindExecute,
502
+				Excludes:     []flux.ResourceID{},
503
+				Force:        true,
504 504
 			},
505 505
 			Expected: expected{
506 506
 				Specific: update.Result{
@@ -512,11 +512,11 @@ func Test_Force_lockedWorkload(t *testing.T) {
512 512
 		{
513 513
 			Name: "force ignores service lock (--workload --update-all-images)",
514 514
 			Spec: update.ReleaseImageSpec{
515
-				WorkloadSpecs: []update.ResourceSpec{lockedSvcSpec},
516
-				ImageSpec:     update.ImageSpecLatest,
517
-				Kind:          update.ReleaseKindExecute,
518
-				Excludes:      []flux.ResourceID{},
519
-				Force:         true,
515
+				ServiceSpecs: []update.ResourceSpec{lockedSvcSpec},
516
+				ImageSpec:    update.ImageSpecLatest,
517
+				Kind:         update.ReleaseKindExecute,
518
+				Excludes:     []flux.ResourceID{},
519
+				Force:        true,
520 520
 			},
521 521
 			Expected: expected{
522 522
 				Specific: update.Result{
@@ -527,11 +527,11 @@ func Test_Force_lockedWorkload(t *testing.T) {
527 527
 		}, {
528 528
 			Name: "force does not ignore lock if updating all workloads (--all --update-all-images)",
529 529
 			Spec: update.ReleaseImageSpec{
530
-				WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
531
-				ImageSpec:     update.ImageSpecLatest,
532
-				Kind:          update.ReleaseKindExecute,
533
-				Excludes:      []flux.ResourceID{},
534
-				Force:         true,
530
+				ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
531
+				ImageSpec:    update.ImageSpecLatest,
532
+				Kind:         update.ReleaseKindExecute,
533
+				Excludes:     []flux.ResourceID{},
534
+				Force:        true,
535 535
 			},
536 536
 			Expected: expected{
537 537
 				Specific: update.Result{
@@ -584,11 +584,11 @@ func Test_Force_filteredContainer(t *testing.T) {
584 584
 		{
585 585
 			Name: "force ignores container tag pattern (--workload --update-image)",
586 586
 			Spec: update.ReleaseImageSpec{
587
-				WorkloadSpecs: []update.ResourceSpec{semverSvcSpec},
588
-				ImageSpec:     update.ImageSpecFromRef(newHwRef), // does not match filter
589
-				Kind:          update.ReleaseKindExecute,
590
-				Excludes:      []flux.ResourceID{},
591
-				Force:         true,
587
+				ServiceSpecs: []update.ResourceSpec{semverSvcSpec},
588
+				ImageSpec:    update.ImageSpecFromRef(newHwRef), // does not match filter
589
+				Kind:         update.ReleaseKindExecute,
590
+				Excludes:     []flux.ResourceID{},
591
+				Force:        true,
592 592
 			},
593 593
 			Expected: expected{
594 594
 				Specific: update.Result{
@@ -600,11 +600,11 @@ func Test_Force_filteredContainer(t *testing.T) {
600 600
 		{
601 601
 			Name: "force ignores container tag pattern (--all --update-image)",
602 602
 			Spec: update.ReleaseImageSpec{
603
-				WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
604
-				ImageSpec:     update.ImageSpecFromRef(newHwRef), // does not match filter
605
-				Kind:          update.ReleaseKindExecute,
606
-				Excludes:      []flux.ResourceID{},
607
-				Force:         true,
603
+				ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
604
+				ImageSpec:    update.ImageSpecFromRef(newHwRef), // does not match filter
605
+				Kind:         update.ReleaseKindExecute,
606
+				Excludes:     []flux.ResourceID{},
607
+				Force:        true,
608 608
 			},
609 609
 			Expected: expected{
610 610
 				Specific: update.Result{
@@ -616,11 +616,11 @@ func Test_Force_filteredContainer(t *testing.T) {
616 616
 		{
617 617
 			Name: "force complies with semver when updating all images (--workload --update-all-image)",
618 618
 			Spec: update.ReleaseImageSpec{
619
-				WorkloadSpecs: []update.ResourceSpec{semverSvcSpec},
620
-				ImageSpec:     update.ImageSpecLatest, // will filter images by semver and pick newest version
621
-				Kind:          update.ReleaseKindExecute,
622
-				Excludes:      []flux.ResourceID{},
623
-				Force:         true,
619
+				ServiceSpecs: []update.ResourceSpec{semverSvcSpec},
620
+				ImageSpec:    update.ImageSpecLatest, // will filter images by semver and pick newest version
621
+				Kind:         update.ReleaseKindExecute,
622
+				Excludes:     []flux.ResourceID{},
623
+				Force:        true,
624 624
 			},
625 625
 			Expected: expected{
626 626
 				Specific: update.Result{
@@ -632,11 +632,11 @@ func Test_Force_filteredContainer(t *testing.T) {
632 632
 		{
633 633
 			Name: "force complies with semver when updating all images (--all --update-all-image)",
634 634
 			Spec: update.ReleaseImageSpec{
635
-				WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
636
-				ImageSpec:     update.ImageSpecLatest,
637
-				Kind:          update.ReleaseKindExecute,
638
-				Excludes:      []flux.ResourceID{},
639
-				Force:         true,
635
+				ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
636
+				ImageSpec:    update.ImageSpecLatest,
637
+				Kind:         update.ReleaseKindExecute,
638
+				Excludes:     []flux.ResourceID{},
639
+				Force:        true,
640 640
 			},
641 641
 			Expected: expected{
642 642
 				Specific: update.Result{
@@ -683,10 +683,10 @@ func Test_ImageStatus(t *testing.T) {
683 683
 		{
684 684
 			Name: "image not found",
685 685
 			Spec: update.ReleaseImageSpec{
686
-				WorkloadSpecs: []update.ResourceSpec{testSvcSpec},
687
-				ImageSpec:     update.ImageSpecLatest,
688
-				Kind:          update.ReleaseKindExecute,
689
-				Excludes:      []flux.ResourceID{},
686
+				ServiceSpecs: []update.ResourceSpec{testSvcSpec},
687
+				ImageSpec:    update.ImageSpecLatest,
688
+				Kind:         update.ReleaseKindExecute,
689
+				Excludes:     []flux.ResourceID{},
690 690
 			},
691 691
 			Expected: expected{
692 692
 				Specific: update.Result{
@@ -700,10 +700,10 @@ func Test_ImageStatus(t *testing.T) {
700 700
 		}, {
701 701
 			Name: "image up to date",
702 702
 			Spec: update.ReleaseImageSpec{
703
-				WorkloadSpecs: []update.ResourceSpec{hwSvcSpec},
704
-				ImageSpec:     update.ImageSpecLatest,
705
-				Kind:          update.ReleaseKindExecute,
706
-				Excludes:      []flux.ResourceID{},
703
+				ServiceSpecs: []update.ResourceSpec{hwSvcSpec},
704
+				ImageSpec:    update.ImageSpecLatest,
705
+				Kind:         update.ReleaseKindExecute,
706
+				Excludes:     []flux.ResourceID{},
707 707
 			},
708 708
 			Expected: expected{
709 709
 				Specific: update.Result{
@@ -754,9 +754,9 @@ func Test_UpdateMultidoc(t *testing.T) {
754 754
 		registry:  mockRegistry,
755 755
 	}
756 756
 	spec := update.ReleaseImageSpec{
757
-		WorkloadSpecs: []update.ResourceSpec{"default:deployment/multi-deploy"},
758
-		ImageSpec:     update.ImageSpecLatest,
759
-		Kind:          update.ReleaseKindExecute,
757
+		ServiceSpecs: []update.ResourceSpec{"default:deployment/multi-deploy"},
758
+		ImageSpec:    update.ImageSpecLatest,
759
+		Kind:         update.ReleaseKindExecute,
760 760
 	}
761 761
 	results, err := Release(ctx, spec, log.NewNopLogger())
762 762
 	if err != nil {
@@ -802,9 +802,9 @@ func Test_UpdateList(t *testing.T) {
802 802
 		registry:  mockRegistry,
803 803
 	}
804 804
 	spec := update.ReleaseImageSpec{
805
-		WorkloadSpecs: []update.ResourceSpec{"default:deployment/list-deploy"},
806
-		ImageSpec:     update.ImageSpecLatest,
807
-		Kind:          update.ReleaseKindExecute,
805
+		ServiceSpecs: []update.ResourceSpec{"default:deployment/list-deploy"},
806
+		ImageSpec:    update.ImageSpecLatest,
807
+		Kind:         update.ReleaseKindExecute,
808 808
 	}
809 809
 	results, err := Release(ctx, spec, log.NewNopLogger())
810 810
 	if err != nil {
@@ -1067,10 +1067,10 @@ func (m *badManifests) UpdateImage(def []byte, resourceID flux.ResourceID, conta
1067 1067
 func Test_BadRelease(t *testing.T) {
1068 1068
 	cluster := mockCluster(hwSvc)
1069 1069
 	spec := update.ReleaseImageSpec{
1070
-		WorkloadSpecs: []update.ResourceSpec{update.ResourceSpecAll},
1071
-		ImageSpec:     update.ImageSpecFromRef(newHwRef),
1072
-		Kind:          update.ReleaseKindExecute,
1073
-		Excludes:      []flux.ResourceID{},
1070
+		ServiceSpecs: []update.ResourceSpec{update.ResourceSpecAll},
1071
+		ImageSpec:    update.ImageSpecFromRef(newHwRef),
1072
+		Kind:         update.ReleaseKindExecute,
1073
+		Excludes:     []flux.ResourceID{},
1074 1074
 	}
1075 1075
 	checkout1, cleanup1 := setup(t)
1076 1076
 	defer cleanup1()

+ 1
- 1
remote/mock.go View File

@@ -161,7 +161,7 @@ func ServerTestBattery(t *testing.T, wrap func(mock api.UpstreamServer) api.Upst
161 161
 	updateSpec := update.Spec{
162 162
 		Type: update.Images,
163 163
 		Spec: update.ReleaseImageSpec{
164
-			WorkloadSpecs: []update.ResourceSpec{
164
+			ServiceSpecs: []update.ResourceSpec{
165 165
 				update.ResourceSpecAll,
166 166
 			},
167 167
 			ImageSpec: update.ImageSpecLatest,

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

@@ -48,7 +48,7 @@ func requireSpecKinds(s update.Spec, kinds []string) error {
48 48
 			}
49 49
 		}
50 50
 	case update.ReleaseImageSpec:
51
-		for _, ss := range s.WorkloadSpecs {
51
+		for _, ss := range s.ServiceSpecs {
52 52
 			if err := requireWorkloadSpecKinds(ss, kinds); err != nil {
53 53
 				return err
54 54
 			}

+ 8
- 8
update/release_image.go View File

@@ -52,11 +52,11 @@ type ReleaseContext interface {
52 52
 // NB: these get sent from fluxctl, so we have to maintain the json format of
53 53
 // this. Eugh.
54 54
 type ReleaseImageSpec struct {
55
-	WorkloadSpecs []ResourceSpec `json:"serviceSpecs"`
56
-	ImageSpec     ImageSpec
57
-	Kind          ReleaseKind
58
-	Excludes      []flux.ResourceID
59
-	Force         bool
55
+	ServiceSpecs []ResourceSpec // TODO: rename to WorkloadSpecs after adding versioning
56
+	ImageSpec    ImageSpec
57
+	Kind         ReleaseKind
58
+	Excludes     []flux.ResourceID
59
+	Force        bool
60 60
 }
61 61
 
62 62
 // ReleaseType gives a one-word description of the release, mainly
@@ -96,7 +96,7 @@ func (s ReleaseImageSpec) ReleaseKind() ReleaseKind {
96 96
 func (s ReleaseImageSpec) CommitMessage(result Result) string {
97 97
 	image := strings.Trim(s.ImageSpec.String(), "<>")
98 98
 	var workloads []string
99
-	for _, spec := range s.WorkloadSpecs {
99
+	for _, spec := range s.ServiceSpecs {
100 100
 		workloads = append(workloads, strings.Trim(spec.String(), "<>"))
101 101
 	}
102 102
 	return fmt.Sprintf("Release %s to %s", image, strings.Join(workloads, ", "))
@@ -119,7 +119,7 @@ func (s ReleaseImageSpec) filters(rc ReleaseContext) ([]WorkloadFilter, []Worklo
119 119
 	var prefilters, postfilters []WorkloadFilter
120 120
 
121 121
 	ids := []flux.ResourceID{}
122
-	for _, ss := range s.WorkloadSpecs {
122
+	for _, ss := range s.ServiceSpecs {
123 123
 		if ss == ResourceSpecAll {
124 124
 			// "<all>" Overrides any other filters
125 125
 			ids = []flux.ResourceID{}
@@ -158,7 +158,7 @@ func (s ReleaseImageSpec) filters(rc ReleaseContext) ([]WorkloadFilter, []Worklo
158 158
 }
159 159
 
160 160
 func (s ReleaseImageSpec) markSkipped(results Result) {
161
-	for _, v := range s.WorkloadSpecs {
161
+	for _, v := range s.ServiceSpecs {
162 162
 		if v == ResourceSpecAll {
163 163
 			continue
164 164
 		}

Loading…
Cancel
Save