Skip to content

Commit 39644a8

Browse files
authored
Merge pull request #4346 from Nordix/lib-refactor-3-errors-fnruntime
refactor - 3: move internal errors and fnruntime packages to pkg/lib/
2 parents 0a74fbe + cb2be10 commit 39644a8

File tree

69 files changed

+498
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+498
-486
lines changed

commands/alpha/wasm/pull/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 The kpt Authors
1+
// Copyright 2022,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import (
2121
"path/filepath"
2222

2323
"github.com/kptdev/kpt/internal/docs/generated/wasmdocs"
24-
"github.com/kptdev/kpt/internal/errors"
24+
"github.com/kptdev/kpt/pkg/lib/errors"
2525
"github.com/kptdev/kpt/pkg/wasm"
2626
"github.com/spf13/cobra"
2727
)

commands/alpha/wasm/push/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 The kpt Authors
1+
// Copyright 2022,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import (
2121
"path"
2222

2323
"github.com/kptdev/kpt/internal/docs/generated/wasmdocs"
24-
"github.com/kptdev/kpt/internal/errors"
24+
"github.com/kptdev/kpt/pkg/lib/errors"
2525
"github.com/kptdev/kpt/pkg/wasm"
2626
"github.com/spf13/cobra"
2727
)

commands/fn/doc/cmdfndoc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 The kpt Authors
1+
// Copyright 2019,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@ import (
2323
"os/exec"
2424

2525
"github.com/kptdev/kpt/internal/docs/generated/fndocs"
26-
"github.com/kptdev/kpt/internal/fnruntime"
2726
"github.com/kptdev/kpt/internal/util/cmdutil"
27+
"github.com/kptdev/kpt/pkg/lib/fnruntime"
2828
"github.com/kptdev/kpt/pkg/printer"
2929
"github.com/spf13/cobra"
3030
)
@@ -64,8 +64,8 @@ func (r *Runner) runE(c *cobra.Command, _ []string) error {
6464
if r.Image == "" {
6565
return errors.New("image must be specified")
6666
}
67-
// TODO: We probably should be going through the runner
68-
image, err := fnruntime.ResolveToImageForCLI(c.Context(), r.Image)
67+
resolveFunc := fnruntime.ResolveToImageForCLIFunc(fnruntime.GHCRImagePrefix)
68+
image, err := resolveFunc(c.Context(), r.Image)
6969
if err != nil {
7070
return err
7171
}

commands/fn/render/cmdrender.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The kpt Authors
1+
// Copyright 2021,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,11 +23,11 @@ import (
2323
"os"
2424

2525
docs "github.com/kptdev/kpt/internal/docs/generated/fndocs"
26-
"github.com/kptdev/kpt/internal/fnruntime"
2726
"github.com/kptdev/kpt/internal/util/argutil"
2827
"github.com/kptdev/kpt/internal/util/cmdutil"
2928
"github.com/kptdev/kpt/internal/util/pathutil"
3029
"github.com/kptdev/kpt/internal/util/render"
30+
"github.com/kptdev/kpt/pkg/lib/fnruntime"
3131
"github.com/kptdev/kpt/pkg/printer"
3232
"github.com/spf13/cobra"
3333
"sigs.k8s.io/kustomize/kyaml/filesys"
@@ -84,7 +84,7 @@ type Runner struct {
8484
}
8585

8686
func (r *Runner) InitDefaults() {
87-
r.RunnerOptions.InitDefaults()
87+
r.RunnerOptions.InitDefaults(fnruntime.GHCRImagePrefix)
8888
}
8989

9090
func (r *Runner) preRunE(_ *cobra.Command, args []string) error {

commands/live/init/cmdliveinit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 The kpt Authors
1+
// Copyright 2020,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -26,13 +26,13 @@ import (
2626
"time"
2727

2828
"github.com/kptdev/kpt/internal/docs/generated/livedocs"
29-
"github.com/kptdev/kpt/internal/errors"
3029
"github.com/kptdev/kpt/internal/pkg"
3130
"github.com/kptdev/kpt/internal/util/attribution"
3231
"github.com/kptdev/kpt/internal/util/pathutil"
3332
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
3433
rgfilev1alpha1 "github.com/kptdev/kpt/pkg/api/resourcegroup/v1alpha1"
3534
"github.com/kptdev/kpt/pkg/kptfile/kptfileutil"
35+
"github.com/kptdev/kpt/pkg/lib/errors"
3636
"github.com/kptdev/kpt/pkg/lib/types"
3737
"github.com/kptdev/kpt/pkg/printer"
3838
"github.com/spf13/cobra"

commands/live/migrate/migratecmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 The kpt Authors
1+
// Copyright 2020,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -25,12 +25,12 @@ import (
2525

2626
initialization "github.com/kptdev/kpt/commands/live/init"
2727
"github.com/kptdev/kpt/internal/docs/generated/livedocs"
28-
"github.com/kptdev/kpt/internal/errors"
2928
"github.com/kptdev/kpt/internal/pkg"
3029
"github.com/kptdev/kpt/internal/util/argutil"
3130
"github.com/kptdev/kpt/internal/util/pathutil"
3231
rgfilev1alpha1 "github.com/kptdev/kpt/pkg/api/resourcegroup/v1alpha1"
3332
"github.com/kptdev/kpt/pkg/kptfile/kptfileutil"
33+
"github.com/kptdev/kpt/pkg/lib/errors"
3434
"github.com/kptdev/kpt/pkg/lib/types"
3535
"github.com/kptdev/kpt/pkg/live"
3636
"github.com/spf13/cobra"

commands/pkg/get/cmdget.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 The kpt Authors
1+
// Copyright 2019,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -20,14 +20,14 @@ import (
2020
"strings"
2121

2222
docs "github.com/kptdev/kpt/internal/docs/generated/pkgdocs"
23-
"github.com/kptdev/kpt/internal/errors"
2423
"github.com/kptdev/kpt/internal/pkg"
2524
"github.com/kptdev/kpt/internal/util/argutil"
2625
"github.com/kptdev/kpt/internal/util/cmdutil"
2726
"github.com/kptdev/kpt/internal/util/get"
2827
"github.com/kptdev/kpt/internal/util/parse"
2928
"github.com/kptdev/kpt/internal/util/pathutil"
3029
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
30+
"github.com/kptdev/kpt/pkg/lib/errors"
3131
"github.com/kptdev/kpt/pkg/lib/types"
3232
"github.com/spf13/cobra"
3333
"sigs.k8s.io/kustomize/kyaml/filesys"

commands/pkg/update/cmdupdate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 The kpt Authors
1+
// Copyright 2019,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -22,13 +22,13 @@ import (
2222
"strings"
2323

2424
docs "github.com/kptdev/kpt/internal/docs/generated/pkgdocs"
25-
"github.com/kptdev/kpt/internal/errors"
2625
"github.com/kptdev/kpt/internal/pkg"
2726
"github.com/kptdev/kpt/internal/util/argutil"
2827
"github.com/kptdev/kpt/internal/util/cmdutil"
2928
"github.com/kptdev/kpt/internal/util/pathutil"
3029
"github.com/kptdev/kpt/internal/util/update"
3130
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
31+
"github.com/kptdev/kpt/pkg/lib/errors"
3232
"github.com/kptdev/kpt/pkg/lib/types"
3333
"github.com/spf13/cobra"
3434
"sigs.k8s.io/kustomize/kyaml/filesys"

e2e/fn_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//go:build docker
22
// +build docker
33

4-
// Copyright 2021 The kpt Authors
4+
// Copyright 2021,2026 The kpt Authors
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import (
2323
"strings"
2424
"testing"
2525

26-
"github.com/kptdev/kpt/internal/fnruntime"
26+
"github.com/kptdev/kpt/pkg/lib/fnruntime"
2727
"github.com/kptdev/kpt/pkg/test/runner"
2828
)
2929

e2e/testdata/fn-eval/exec-function-stderr/.expected/config.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 The kpt Authors
1+
# Copyright 2021,2026 The kpt Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -18,9 +18,4 @@ testType: eval
1818
stdErr: |
1919
[RUNNING] "./function.sh"
2020
[PASS] "./function.sh" in 0s
21-
Stderr:
22-
"Hello world 0!"
23-
"Hello world 1!"
24-
"Hello world 2!"
25-
"Hello world 3!"
26-
...(18 line(s) truncated, use '--truncate-output=false' to disable)
21+
Stderr: Hello world 0!, Hello world 1!, Hello world 2!, Hello world 3!, Hello world 4!, Hello world 5!, Hello world 6!, Hello world 7!, Hello world 8!, Hello world 9!, Hello world 10!, Hello world 11!, Hello world 12!, Hello world 13!, Hello world 14!, Hello world 15!, Hello world 16!, Hello world 17!, Hello world 18!, Hello world 19!, Hello world 20!,

0 commit comments

Comments
 (0)