Skip to content

Commit

Permalink
Merge pull request #104 from Peefy/fix-krm-kcl-print-output
Browse files Browse the repository at this point in the history
fix: krm kcl print output
  • Loading branch information
Peefy authored Oct 16, 2024
2 parents 6915920 + 376143c commit 910df89
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
k8s.io/apimachinery v0.31.1
k8s.io/cli-runtime v0.31.1
k8s.io/client-go v0.31.1
kcl-lang.io/cli v0.10.3
kcl-lang.io/cli v0.10.4-0.20241016021654-a8eb2b56bdd8
kcl-lang.io/kpm v0.10.0
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/kustomize/kyaml v0.17.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1439,8 +1439,8 @@ k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7F
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kcl-lang.io/cli v0.10.3 h1:LwVr60IG6wFnhFDL4nGdq3u7Be0/rio9yT4uNTPaSTA=
kcl-lang.io/cli v0.10.3/go.mod h1:rhJTKGuav/B8SJO8VLM07TRWzBVdEo/tAfnCKjL71fo=
kcl-lang.io/cli v0.10.4-0.20241016021654-a8eb2b56bdd8 h1:GGbmIDVpN30/zEocYwMGVYbN7h80GPSz0ootfXV+xjk=
kcl-lang.io/cli v0.10.4-0.20241016021654-a8eb2b56bdd8/go.mod h1:rhJTKGuav/B8SJO8VLM07TRWzBVdEo/tAfnCKjL71fo=
kcl-lang.io/kcl-go v0.10.3 h1:S2t+RdIl1d9bhIqcw7rd0Zk/Th2u7kSaAgASbbOuw+w=
kcl-lang.io/kcl-go v0.10.3/go.mod h1:kcXB9Ws4MTMj6zp5YXGxkx+Z4HieIrtlYDnFDhfs2mg=
kcl-lang.io/kcl-openapi v0.9.0 h1:HUnc5pUGde83PI5CAe1ZvZhdbcxD9X2ABUp1tV+oYqw=
Expand Down
16 changes: 16 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ spec:
`,
expectResult: `a: Hello World!`,
},
{
name: "KCLRunWithDebugPrint",
config: `apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: my-kcl-fn
namespace: foo
spec:
source: |
print("hello world")
{
data = 1
}
`,
expectResult: `data: 1`,
},
}
for _, tc := range testcases {
tc := tc
Expand Down
4 changes: 2 additions & 2 deletions pkg/edit/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type KCLEntryOrigin struct {
func KCLEntryOriginTmpDirCleanup(entry *KCLEntryOrigin) {
if entry.tmpDir != "" {
if _, err := os.Stat(entry.tmpDir); err == nil {
err = os.RemoveAll(entry.tmpDir)
_ = os.RemoveAll(entry.tmpDir)
}
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func SourceToTempEntry(src string, opts ...getter.ClientOption) (*KCLEntryOrigin
// May be a inline code source.
tmpDir, err := os.MkdirTemp("", "kcl-sandbox")
if err != nil {
return &KCLEntryOrigin{"", ""}, fmt.Errorf("error creating temp directory: %v", err)
return &KCLEntryOrigin{"", ""}, fmt.Errorf("error creating temp directory: %v", err)
}
// Write kcl code in the temp file.
file := filepath.Join(tmpDir, "prog.k")
Expand Down

0 comments on commit 910df89

Please sign in to comment.