From 08fcb379689b154b1aad8f8624aea6ff5dd6ed3b Mon Sep 17 00:00:00 2001 From: Aiden Date: Sat, 16 Aug 2025 23:32:54 +0800 Subject: [PATCH 1/2] feat(deploy): add biz model version flag for deployment --- v1/cmd/deploy/deploy.go | 15 ++++++++++++++- v1/cmd/undeploy/undeploy.go | 3 +++ v1/service/ark/types.go | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/v1/cmd/deploy/deploy.go b/v1/cmd/deploy/deploy.go index 050aa70..fada16a 100644 --- a/v1/cmd/deploy/deploy.go +++ b/v1/cmd/deploy/deploy.go @@ -41,6 +41,8 @@ import ( ) var ( + bizModelVersionFlag string + portFlag int subBundlePath string @@ -80,7 +82,10 @@ Scenario 2: Deploy a local pre-built bundle to local running ark container: Scenario 3: Build and deploy a bundle at current dir to a remote running ark container in k8s cluster with default port: arkctl deploy --pod ${namespace}/${name} -Scenario 4: Build an maven multi module project and deploy a sub module to a running ark container: +Scenario 4: Build and deploy a bundle at current dir to a remote running ark container in k8s cluster with biz model version witch is pod key from kubernetes: + arkctl deploy --pod ${namespace}/${name} --biz-model-version ${your-biz-model-version} + +Scenario 5: Build an maven multi module project and deploy a sub module to a running ark container: arkctl deploy --sub ${path/to/your/sub/module} `, Args: func(cmd *cobra.Command, args []string) error { @@ -183,6 +188,9 @@ func execParseBizModel(ctx *contextutil.Context) bool { pterm.Error.PrintOnError(fmt.Errorf("failed to parse bundle: %s", err)) return false } + if bizModelVersionFlag != "" { + bizModel.BizModelVersion = bizModelVersionFlag + } ctx.Put(ctxKeyBizModel, bizModel) style.InfoPrefix("BizBundleInfo").Println(string(runtime.MustReturnResult(json.Marshal(*bizModel)))) @@ -252,6 +260,7 @@ func execInstallInKubePod(ctx *contextutil.Context) bool { string(runtime.MustReturnResult(json.Marshal(ark.BizModel{ BizName: bizModel.BizName, BizVersion: bizModel.BizVersion, + BizModelVersion: bizModel.BizModelVersion, }))), fmt.Sprintf("http://127.0.0.1:%v/uninstallBiz", portFlag), ) @@ -301,6 +310,7 @@ func execInstallInKubePod(ctx *contextutil.Context) bool { BizName: bizModel.BizName, BizVersion: bizModel.BizVersion, BizUrl: fileutil.FileUrl(osutil.GetLocalFileProtocol() + ctx.Value(ctxKeyArkBizBundlePathInSidePod).(string)), + BizModelVersion: bizModel.BizModelVersion, }))), fmt.Sprintf("http://127.0.0.1:%v/installBiz", portFlag), ) @@ -456,6 +466,9 @@ If Provided, arkctl will try to build the project at current dir and deploy the DeployCommand.Flags().IntVar(&portFlag, "port", 1238, ` The default port of ark container is 1238 if not provided. +`) + DeployCommand.Flags().StringVar(&bizModelVersionFlag, "biz-model-version", "", ` +If provided, arkctl will use this biz model version to deploy the biz module. `) } diff --git a/v1/cmd/undeploy/undeploy.go b/v1/cmd/undeploy/undeploy.go index 398dda1..e30e4de 100644 --- a/v1/cmd/undeploy/undeploy.go +++ b/v1/cmd/undeploy/undeploy.go @@ -32,6 +32,7 @@ var ( hostFlag string = "127.0.0.1" portFlag int bizNameAndVersion string // in the format of bizName:bizVersion + bizModelVersionFlag string // biz model version, used to identify the biz model in the pod ) var ( @@ -78,6 +79,7 @@ func execUnInstallLocal(ctx *contextutil.Context) error { BizModel: ark.BizModel{ BizName: strings.Split(bizNameAndVersion, ":")[0], BizVersion: strings.Split(bizNameAndVersion, ":")[1], + BizModelVersion: bizModelVersionFlag, }, }); err != nil { pterm.Error.Printfln("uninstall %s failed: %s", bizNameAndVersion, err) @@ -130,6 +132,7 @@ func execUnInstallLocalWithPrompt(ctx *contextutil.Context) error { func init() { UnDeployCmd.Flags().IntVar(&portFlag, "port", 1238, "the port of ark container") + UnDeployCmd.Flags().StringVar(&bizModelVersionFlag, "biz-model-version", "", "the biz model version of ark container") root.RootCmd.AddCommand(UnDeployCmd) } diff --git a/v1/service/ark/types.go b/v1/service/ark/types.go index 2b98514..4280fab 100644 --- a/v1/service/ark/types.go +++ b/v1/service/ark/types.go @@ -107,6 +107,9 @@ type BizModel struct { // BizUrl is the location of source code. BizUrl fileutil.FileUrl `json:"bizUrl,omitempty"` + + // BizModelVersion is the version of this model. + BizModelVersion string `json:"bizModelVersion,omitempty"` } type BizInfo struct { From 128dafac574b32a460abeabd38cf3f17f4578b8f Mon Sep 17 00:00:00 2001 From: Aiden Date: Mon, 15 Sep 2025 14:39:34 +0800 Subject: [PATCH 2/2] fix(constant): update version to 0.2.5 --- v1/constant/constant.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v1/constant/constant.go b/v1/constant/constant.go index 0fa2c55..401af0a 100644 --- a/v1/constant/constant.go +++ b/v1/constant/constant.go @@ -18,5 +18,5 @@ package constant const ( - Version = "0.2.3" + Version = "0.2.5" )