From 90d3a6bea2987933d2c938e23b4bc3472d61398c Mon Sep 17 00:00:00 2001 From: Dayuan Date: Wed, 8 May 2024 17:32:54 +0800 Subject: [PATCH] feat: adapt to the new service/job workload module --- .../internal.kusion.io/v1/marshal_test.go | 60 +++++++++---------- pkg/apis/internal.kusion.io/v1/types.go | 8 +-- .../internal.kusion.io/v1/unmarshal_test.go | 60 +++++++++---------- pkg/cmd/stack/util/util.go | 4 +- 4 files changed, 66 insertions(+), 66 deletions(-) diff --git a/pkg/apis/internal.kusion.io/v1/marshal_test.go b/pkg/apis/internal.kusion.io/v1/marshal_test.go index 575612dc..5ed2d7ea 100644 --- a/pkg/apis/internal.kusion.io/v1/marshal_test.go +++ b/pkg/apis/internal.kusion.io/v1/marshal_test.go @@ -35,7 +35,7 @@ func TestContainerMarshalJSON(t *testing.T) { Image: "nginx:v1", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, @@ -43,14 +43,14 @@ func TestContainerMarshalJSON(t *testing.T) { InitialDelaySeconds: 10, }, }, - result: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"kam.v1.workload.container.probe.Http","url":"http://localhost:80"},"initialDelaySeconds":10}}`, + result: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"catalog.service.container.probe.Http","url":"http://localhost:80"},"initialDelaySeconds":10}}`, }, { input: Container{ Image: "nginx:v1", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"cat", "/tmp/healthy"}, }, @@ -58,14 +58,14 @@ func TestContainerMarshalJSON(t *testing.T) { InitialDelaySeconds: 10, }, }, - result: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"kam.v1.workload.container.probe.Exec","command":["cat","/tmp/healthy"]},"initialDelaySeconds":10}}`, + result: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"catalog.service.container.probe.Exec","command":["cat","/tmp/healthy"]},"initialDelaySeconds":10}}`, }, { input: Container{ Image: "nginx:v1", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Tcp"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Tcp"}, TCPSocketAction: &TCPSocketAction{ URL: "127.0.0.1:8080", }, @@ -73,47 +73,47 @@ func TestContainerMarshalJSON(t *testing.T) { InitialDelaySeconds: 10, }, }, - result: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"kam.v1.workload.container.probe.Tcp","url":"127.0.0.1:8080"},"initialDelaySeconds":10}}`, + result: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"catalog.service.container.probe.Tcp","url":"127.0.0.1:8080"},"initialDelaySeconds":10}}`, }, { input: Container{ Image: "nginx:v1", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "nginx -s quit; while killall -0 nginx; do sleep 1; done"}, }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"}, }, }, }, }, - result: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"kam.v1.workload.container.probe.Exec","command":["/bin/sh","-c","echo Hello from the postStart handler \u003e /usr/share/message"]},"postStart":{"_type":"kam.v1.workload.container.probe.Exec","command":["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]}}}`, + result: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"catalog.service.container.probe.Exec","command":["/bin/sh","-c","echo Hello from the postStart handler \u003e /usr/share/message"]},"postStart":{"_type":"catalog.service.container.probe.Exec","command":["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]}}}`, }, { input: Container{ Image: "nginx:v1", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, }, }, }, - result: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"kam.v1.workload.container.probe.Http","url":"http://localhost:80"},"postStart":{"_type":"kam.v1.workload.container.probe.Http","url":"http://localhost:80"}}}`, + result: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"catalog.service.container.probe.Http","url":"http://localhost:80"},"postStart":{"_type":"catalog.service.container.probe.Http","url":"http://localhost:80"}}}`, }, } @@ -174,7 +174,7 @@ workingDir: /tmp WorkingDir: "/tmp", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, @@ -196,7 +196,7 @@ env: workingDir: /tmp readinessProbe: probeHandler: - _type: kam.v1.workload.container.probe.Http + _type: catalog.service.container.probe.Http url: http://localhost:80 initialDelaySeconds: 10 `, @@ -215,7 +215,7 @@ readinessProbe: WorkingDir: "/tmp", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"cat", "/tmp/healthy"}, }, @@ -237,7 +237,7 @@ env: workingDir: /tmp readinessProbe: probeHandler: - _type: kam.v1.workload.container.probe.Exec + _type: catalog.service.container.probe.Exec command: - cat - /tmp/healthy @@ -258,7 +258,7 @@ readinessProbe: WorkingDir: "/tmp", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Tcp"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Tcp"}, TCPSocketAction: &TCPSocketAction{ URL: "127.0.0.1:8080", }, @@ -280,7 +280,7 @@ env: workingDir: /tmp readinessProbe: probeHandler: - _type: kam.v1.workload.container.probe.Tcp + _type: catalog.service.container.probe.Tcp url: 127.0.0.1:8080 initialDelaySeconds: 10 `, @@ -299,13 +299,13 @@ readinessProbe: WorkingDir: "/tmp", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "nginx -s quit; while killall -0 nginx; do sleep 1; done"}, }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"}, }, @@ -326,13 +326,13 @@ env: workingDir: /tmp lifecycle: preStop: - _type: kam.v1.workload.container.probe.Exec + _type: catalog.service.container.probe.Exec command: - /bin/sh - -c - echo Hello from the postStart handler > /usr/share/message postStart: - _type: kam.v1.workload.container.probe.Exec + _type: catalog.service.container.probe.Exec command: - /bin/sh - -c @@ -353,13 +353,13 @@ lifecycle: WorkingDir: "/tmp", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, @@ -380,10 +380,10 @@ env: workingDir: /tmp lifecycle: preStop: - _type: kam.v1.workload.container.probe.Http + _type: catalog.service.container.probe.Http url: http://localhost:80 postStart: - _type: kam.v1.workload.container.probe.Http + _type: catalog.service.container.probe.Http url: http://localhost:80 `, }, @@ -427,7 +427,7 @@ func TestWorkloadMarshalJSON(t *testing.T) { Schedule: "* * * * *", }, }, - expected: `{"_type": "kam.v1.workload.Service", "replicas": 2, "labels": {"app": "my-service"}, "type": "Deployment"}`, + expected: `{"_type": "catalog.service.Service", "replicas": 2, "labels": {"app": "my-service"}, "type": "Deployment"}`, expectedError: nil, }, { @@ -440,7 +440,7 @@ func TestWorkloadMarshalJSON(t *testing.T) { Schedule: "* * * * *", }, }, - expected: `{"_type": "kam.v1.workload.Job", "schedule": "* * * * *"}`, + expected: `{"_type": "catalog.job.Job", "schedule": "* * * * *"}`, expectedError: nil, }, { @@ -495,7 +495,7 @@ func TestWorkloadMarshalYAML(t *testing.T) { }, }, }, - expected: `{"_type":"kam.v1.workload.Service", "replicas": 2, "labels": {"app": "my-service"}, "type": "Deployment"}`, + expected: `{"_type":"catalog.service.Service", "replicas": 2, "labels": {"app": "my-service"}, "type": "Deployment"}`, expectedError: nil, }, { @@ -508,7 +508,7 @@ func TestWorkloadMarshalYAML(t *testing.T) { Schedule: "* * * * *", }, }, - expected: `{"_type":"kam.v1.workload.Job", "schedule": "* * * * *"}`, + expected: `{"_type":"catalog.job.Job", "schedule": "* * * * *"}`, expectedError: nil, }, { diff --git a/pkg/apis/internal.kusion.io/v1/types.go b/pkg/apis/internal.kusion.io/v1/types.go index 89fe7af4..544bc76f 100644 --- a/pkg/apis/internal.kusion.io/v1/types.go +++ b/pkg/apis/internal.kusion.io/v1/types.go @@ -6,8 +6,8 @@ import ( ) const ( - BuiltinModulePrefix = "kam." - ProbePrefix = "v1.workload.container.probe." + BuiltinModulePrefix = "catalog." + ProbePrefix = "service.container.probe." TypeHTTP = BuiltinModulePrefix + ProbePrefix + "Http" TypeExec = BuiltinModulePrefix + ProbePrefix + "Exec" TypeTCP = BuiltinModulePrefix + ProbePrefix + "Tcp" @@ -217,8 +217,8 @@ type Job struct { type Type string const ( - TypeJob = "kam.v1.workload.Job" - TypeService = "kam.v1.workload.Service" + TypeJob = "catalog.job.Job" + TypeService = "catalog.service.Service" ) type Header struct { diff --git a/pkg/apis/internal.kusion.io/v1/unmarshal_test.go b/pkg/apis/internal.kusion.io/v1/unmarshal_test.go index 0d7f153c..1cd970ac 100644 --- a/pkg/apis/internal.kusion.io/v1/unmarshal_test.go +++ b/pkg/apis/internal.kusion.io/v1/unmarshal_test.go @@ -32,12 +32,12 @@ func TestContainerUnmarshalJSON(t *testing.T) { }, }, { - input: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"kam.v1.workload.container.probe.Http","url":"http://localhost:80"},"initialDelaySeconds":10}}`, + input: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"catalog.service.container.probe.Http","url":"http://localhost:80"},"initialDelaySeconds":10}}`, result: Container{ Image: "nginx:v1", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, @@ -47,12 +47,12 @@ func TestContainerUnmarshalJSON(t *testing.T) { }, }, { - input: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"kam.v1.workload.container.probe.Exec","command":["cat","/tmp/healthy"]},"initialDelaySeconds":10}}`, + input: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"catalog.service.container.probe.Exec","command":["cat","/tmp/healthy"]},"initialDelaySeconds":10}}`, result: Container{ Image: "nginx:v1", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"cat", "/tmp/healthy"}, }, @@ -62,12 +62,12 @@ func TestContainerUnmarshalJSON(t *testing.T) { }, }, { - input: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"kam.v1.workload.container.probe.Tcp","url":"127.0.0.1:8080"},"initialDelaySeconds":10}}`, + input: `{"image":"nginx:v1","readinessProbe":{"probeHandler":{"_type":"catalog.service.container.probe.Tcp","url":"127.0.0.1:8080"},"initialDelaySeconds":10}}`, result: Container{ Image: "nginx:v1", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Tcp"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Tcp"}, TCPSocketAction: &TCPSocketAction{ URL: "127.0.0.1:8080", }, @@ -77,18 +77,18 @@ func TestContainerUnmarshalJSON(t *testing.T) { }, }, { - input: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"kam.v1.workload.container.probe.Exec","command":["/bin/sh","-c","echo Hello from the postStart handler \u003e /usr/share/message"]},"postStart":{"_type":"kam.v1.workload.container.probe.Exec","command":["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]}}}`, + input: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"catalog.service.container.probe.Exec","command":["/bin/sh","-c","echo Hello from the postStart handler \u003e /usr/share/message"]},"postStart":{"_type":"catalog.service.container.probe.Exec","command":["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]}}}`, result: Container{ Image: "nginx:v1", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "nginx -s quit; while killall -0 nginx; do sleep 1; done"}, }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"}, }, @@ -97,18 +97,18 @@ func TestContainerUnmarshalJSON(t *testing.T) { }, }, { - input: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"kam.v1.workload.container.probe.Http","url":"http://localhost:80"},"postStart":{"_type":"kam.v1.workload.container.probe.Http","url":"http://localhost:80"}}}`, + input: `{"image":"nginx:v1","lifecycle":{"preStop":{"_type":"catalog.service.container.probe.Http","url":"http://localhost:80"},"postStart":{"_type":"catalog.service.container.probe.Http","url":"http://localhost:80"}}}`, result: Container{ Image: "nginx:v1", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, @@ -176,7 +176,7 @@ env: workingDir: /tmp readinessProbe: probeHandler: - _type: kam.v1.workload.container.probe.Http + _type: catalog.service.container.probe.Http url: http://localhost:80 initialDelaySeconds: 10 `, @@ -193,7 +193,7 @@ readinessProbe: WorkingDir: "/tmp", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, @@ -217,7 +217,7 @@ env: workingDir: /tmp readinessProbe: probeHandler: - _type: kam.v1.workload.container.probe.Exec + _type: catalog.service.container.probe.Exec command: - cat - /tmp/healthy @@ -236,7 +236,7 @@ readinessProbe: WorkingDir: "/tmp", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"cat", "/tmp/healthy"}, }, @@ -260,7 +260,7 @@ env: workingDir: /tmp readinessProbe: probeHandler: - _type: kam.v1.workload.container.probe.Tcp + _type: catalog.service.container.probe.Tcp url: 127.0.0.1:8080 initialDelaySeconds: 10 `, @@ -277,7 +277,7 @@ readinessProbe: WorkingDir: "/tmp", ReadinessProbe: &Probe{ ProbeHandler: &ProbeHandler{ - TypeWrapper: TypeWrapper{Type: "kam.v1.workload.container.probe.Tcp"}, + TypeWrapper: TypeWrapper{Type: "catalog.service.container.probe.Tcp"}, TCPSocketAction: &TCPSocketAction{ URL: "127.0.0.1:8080", }, @@ -301,13 +301,13 @@ env: workingDir: /tmp lifecycle: preStop: - _type: kam.v1.workload.container.probe.Exec + _type: catalog.service.container.probe.Exec command: - /bin/sh - -c - echo Hello from the postStart handler > /usr/share/message postStart: - _type: kam.v1.workload.container.probe.Exec + _type: catalog.service.container.probe.Exec command: - /bin/sh - -c @@ -326,13 +326,13 @@ lifecycle: WorkingDir: "/tmp", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "nginx -s quit; while killall -0 nginx; do sleep 1; done"}, }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Exec"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Exec"}, ExecAction: &ExecAction{ Command: []string{"/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"}, }, @@ -355,10 +355,10 @@ env: workingDir: /tmp lifecycle: preStop: - _type: kam.v1.workload.container.probe.Http + _type: catalog.service.container.probe.Http url: http://localhost:80 postStart: - _type: kam.v1.workload.container.probe.Http + _type: catalog.service.container.probe.Http url: http://localhost:80 `, result: Container{ @@ -374,13 +374,13 @@ lifecycle: WorkingDir: "/tmp", Lifecycle: &Lifecycle{ PostStart: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, }, PreStop: &LifecycleHandler{ - TypeWrapper: TypeWrapper{"kam.v1.workload.container.probe.Http"}, + TypeWrapper: TypeWrapper{"catalog.service.container.probe.Http"}, HTTPGetAction: &HTTPGetAction{ URL: "http://localhost:80", }, @@ -411,7 +411,7 @@ func TestWorkloadUnmarshalJSON(t *testing.T) { }{ { name: "Valid UnmarshalJSON for Service", - data: `{"_type": "kam.v1.workload.Service", "replicas": 1, "labels": {}, "annotations": {}, "dirs": {}, "schedule": "* * * * *"}`, + data: `{"_type": "catalog.service.Service", "replicas": 1, "labels": {}, "annotations": {}, "dirs": {}, "schedule": "* * * * *"}`, expected: Workload{ Header: Header{ Type: TypeService, @@ -429,7 +429,7 @@ func TestWorkloadUnmarshalJSON(t *testing.T) { }, { name: "Valid UnmarshalJSON for Job", - data: `{"_type": "kam.v1.workload.Job", "schedule": "* * * * *"}`, + data: `{"_type": "catalog.job.Job", "schedule": "* * * * *"}`, expected: Workload{ Header: Header{ Type: TypeJob, @@ -476,7 +476,7 @@ func TestWorkloadUnmarshalYAML(t *testing.T) { }{ { name: "Valid UnmarshalYAML for Service", - data: `_type: kam.v1.workload.Service + data: `_type: catalog.service.Service replicas: 1 labels: {} annotations: {} @@ -499,7 +499,7 @@ schedule: '* * * * *'`, }, { name: "Valid UnmarshalYAML for Job", - data: `_type: kam.v1.workload.Job + data: `_type: catalog.job.Job replicas: 1 labels: {} annotations: {} diff --git a/pkg/cmd/stack/util/util.go b/pkg/cmd/stack/util/util.go index 250c15e0..fd878a74 100644 --- a/pkg/cmd/stack/util/util.go +++ b/pkg/cmd/stack/util/util.go @@ -24,8 +24,8 @@ kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }` MainKCLFile = "main.k" MainKCLFileTemplate = `# The configuration codes in perspective of developers. import kam.v1.app_configuration as ac -import kam.v1.workload as wl -import kam.v1.workload.container as c +import catalog.service as wl +import catalog.service.container as c # Please replace the ${APPLICATION_NAME} with the name of your application, and complete the # 'AppConfiguration' instance with your own workload and accessories.