From d4460d07a6cb827aa370af45cf9236f5a7a9c1fa Mon Sep 17 00:00:00 2001
From: lijianguo <lijianguo1991@outlook.com>
Date: Tue, 10 Dec 2024 11:12:34 +0800
Subject: [PATCH] chore(config): ConfigVar not omitempty

---
 cmd/config.go      | 12 ++++++------
 cmd/config_test.go | 20 ++++++++++----------
 go.mod             |  2 +-
 go.sum             |  4 ++--
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/cmd/config.go b/cmd/config.go
index 3b0aa852..40b69e4c 100644
--- a/cmd/config.go
+++ b/cmd/config.go
@@ -29,7 +29,7 @@ func (d *DryccCmd) ConfigInfo(appID string, ptype string, group string, version
 	}
 	// init output struct
 	cv := api.ConfigInfo{
-		Group: make(map[string][]api.KV),
+		Group: make(map[string][]api.ConfigVar),
 		Ptype: make(map[string]api.PtypeValue),
 	}
 	for _, value := range sortConfigValues(config.Values) {
@@ -38,10 +38,10 @@ func (d *DryccCmd) ConfigInfo(appID string, ptype string, group string, version
 			(group != "" && value.Group == group) ||
 			(ptype == "" && group == "") {
 			if value.Group != "" {
-				cv.Group[value.Group] = append(cv.Group[value.Group], api.KV{Name: value.Name, Value: value.Value})
+				cv.Group[value.Group] = append(cv.Group[value.Group], api.ConfigVar{Name: value.Name, Value: value.Value})
 			} else if value.Ptype != "" {
 				temp := cv.Ptype[value.Ptype]
-				temp.Env = append(temp.Env, api.KV{Name: value.Name, Value: value.Value})
+				temp.Env = append(temp.Env, api.ConfigVar{Name: value.Name, Value: value.Value})
 				cv.Ptype[value.Ptype] = temp
 
 				if len(config.ValuesRefs[value.Ptype]) != 0 {
@@ -122,9 +122,9 @@ func (d *DryccCmd) ConfigUnset(appID string, ptype string, group string, configV
 		valuesMap := api.ConfigValue{
 			Ptype: ptype,
 			Group: group,
-			KV: api.KV{
+			ConfigVar: api.ConfigVar{
 				Name:  configVar,
-				Value: "",
+				Value: nil,
 			},
 		}
 		valuesMaps = append(valuesMaps, valuesMap)
@@ -341,7 +341,7 @@ func parseConfig(ptype, group string, configVars []string) ([]api.ConfigValue, e
 			value := api.ConfigValue{
 				Ptype: ptype,
 				Group: group,
-				KV: api.KV{
+				ConfigVar: api.ConfigVar{
 					Name:  captures[1],
 					Value: captures[2],
 				},
diff --git a/cmd/config_test.go b/cmd/config_test.go
index afb3f62e..21ab3b8c 100644
--- a/cmd/config_test.go
+++ b/cmd/config_test.go
@@ -19,11 +19,11 @@ func TestParseConfig(t *testing.T) {
 
 	actual, err := parseConfig("", "", []string{"FOO=bar"})
 	assert.NoError(t, err)
-	assert.Equal(t, actual, []api.ConfigValue{{KV: api.KV{Name: "FOO", Value: "bar"}}}, "map")
+	assert.Equal(t, actual, []api.ConfigValue{{ConfigVar: api.ConfigVar{Name: "FOO", Value: "bar"}}}, "map")
 
 	actual, err = parseConfig("", "", []string{"FOO="})
 	assert.NoError(t, err)
-	assert.Equal(t, actual, []api.ConfigValue{{KV: api.KV{Name: "FOO", Value: ""}}}, "map")
+	assert.Equal(t, actual, []api.ConfigValue{{ConfigVar: api.ConfigVar{Name: "FOO", Value: ""}}}, "map")
 }
 
 func TestFormatConfig(t *testing.T) {
@@ -33,28 +33,28 @@ func TestFormatConfig(t *testing.T) {
 		{
 			Ptype: "web",
 			Group: "",
-			KV: api.KV{
+			ConfigVar: api.ConfigVar{
 				Name:  "TEST",
 				Value: "testing",
 			},
 		}, {
 			Ptype: "web",
 			Group: "",
-			KV: api.KV{
+			ConfigVar: api.ConfigVar{
 				Name:  "NCC",
 				Value: "1701",
 			},
 		}, {
 			Ptype: "web",
 			Group: "",
-			KV: api.KV{
+			ConfigVar: api.ConfigVar{
 				Name:  "TRUE",
 				Value: false,
 			},
 		}, {
 			Ptype: "web",
 			Group: "",
-			KV: api.KV{
+			ConfigVar: api.ConfigVar{
 				Name:  "FLOAT",
 				Value: 12.34,
 			},
@@ -95,14 +95,14 @@ func TestConfigSet(t *testing.T) {
 				Values: []api.ConfigValue{
 					{
 						Ptype: "web",
-						KV: api.KV{
+						ConfigVar: api.ConfigVar{
 							Name:  "TRUE",
 							Value: "false",
 						},
 					},
 					{
 						Ptype: "web",
-						KV: api.KV{
+						ConfigVar: api.ConfigVar{
 							Name:  "DEBUG",
 							Value: "true",
 						},
@@ -162,9 +162,9 @@ func TestConfigUnset(t *testing.T) {
 				Values: []api.ConfigValue{
 					{
 						Ptype: "web",
-						KV: api.KV{
+						ConfigVar: api.ConfigVar{
 							Name:  "FOO",
-							Value: "",
+							Value: nil,
 						},
 					},
 				},
diff --git a/go.mod b/go.mod
index 8282a1ce..f8c202ab 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.23
 require (
 	github.com/containerd/console v1.0.4
 	github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
-	github.com/drycc/controller-sdk-go v0.0.0-20241128052705-94f8d2dcc087
+	github.com/drycc/controller-sdk-go v0.0.0-20241210030451-bd35b03af548
 	github.com/drycc/pkg v0.0.0-20241028091700-8caca001c932
 	github.com/minio/selfupdate v0.6.0
 	github.com/olekukonko/tablewriter v0.0.5
diff --git a/go.sum b/go.sum
index 23def561..fd7f0e03 100644
--- a/go.sum
+++ b/go.sum
@@ -9,8 +9,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
 github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
-github.com/drycc/controller-sdk-go v0.0.0-20241128052705-94f8d2dcc087 h1:cbniB2KxxeV72y/7KILVorTTxlzCF41xtBysDT1FjJg=
-github.com/drycc/controller-sdk-go v0.0.0-20241128052705-94f8d2dcc087/go.mod h1:F9ViuoVcZ/OG1WnfZBYH6j4v6mb5B+RW9FLaCopADoo=
+github.com/drycc/controller-sdk-go v0.0.0-20241210030451-bd35b03af548 h1:eU8e0vViXNIltGCRlIWcNMZ2YCrAkfDtYXaa/wdJI4Q=
+github.com/drycc/controller-sdk-go v0.0.0-20241210030451-bd35b03af548/go.mod h1:F9ViuoVcZ/OG1WnfZBYH6j4v6mb5B+RW9FLaCopADoo=
 github.com/drycc/pkg v0.0.0-20241028091700-8caca001c932 h1:tUfkfjmFmlm9n0dYp1NoHcFK6+APD/wHZ2We6CKXDSI=
 github.com/drycc/pkg v0.0.0-20241028091700-8caca001c932/go.mod h1:upGcZF/RCEqidGjSnWHh/txRC1I4GPsRGvF8/+bDfwU=
 github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
