Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

fix contorller: check the number of workloads before applying workloads #329

Merged
merged 1 commit into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ linters-settings:

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 15
min-complexity: 17

maligned:
# print struct with more effective memory layout or not, false by default
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/v1alpha2/applicationconfiguration/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ type workloads struct {
}

func (a *workloads) Apply(ctx context.Context, status []v1alpha2.WorkloadStatus, w []Workload, ao ...resource.ApplyOption) error {
if len(w) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add reason for this change and add tests

return errors.New("The number of workloads in appConfig is 0")
}
// they are all in the same namespace
var namespace = w[0].Workload.GetNamespace()
for _, wl := range w {
Expand Down