From 9cad10eb1a286193d28886651bc4bfb363ad5eb9 Mon Sep 17 00:00:00 2001 From: yangsoon Date: Tue, 20 Apr 2021 16:11:56 +0800 Subject: [PATCH] fix appconfig Signed-off-by: yangsoon --- .golangci.yml | 2 +- pkg/controller/v1alpha2/applicationconfiguration/apply.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index f9dfc6fa..c7ab3839 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 diff --git a/pkg/controller/v1alpha2/applicationconfiguration/apply.go b/pkg/controller/v1alpha2/applicationconfiguration/apply.go index 6c1d88a7..020b449e 100644 --- a/pkg/controller/v1alpha2/applicationconfiguration/apply.go +++ b/pkg/controller/v1alpha2/applicationconfiguration/apply.go @@ -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 { + 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 {