Skip to content

Commit 5c78bf7

Browse files
author
NETIZEN-11
committed
Merge remote-tracking branch 'upstream/main' into feat/issue-4450-pr3-api-types
2 parents 0382674 + c59c2a6 commit 5c78bf7

152 files changed

Lines changed: 2250 additions & 364 deletions

File tree

Some content is hidden

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

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ All submissions, including submissions by project members, require review. We
5757
use GitHub pull requests for this purpose. Consult [GitHub Help] for more
5858
information on using pull requests.
5959

60+
Process for code reviews. Before requesting human review, a PR must:
61+
62+
* All tests passing
63+
* All linting passing
64+
* Meeting project code quality requirements, including passing all configured static analysis / SonarCloud quality gates and not reducing automated test coverage for the affected components
65+
* The comments from the first run of automatically generated comments (AI generated comments, SonarCloud comments, bot generated comments, etc.) of the PR are addressed (addressing further re-runs of AI are optional)
66+
* If it is not possible to resolve an automatic comment, please add a sub-comment indicating why the automated comment cannot be resolved or ask for help in resolving the comment
67+
6068
## Community Guidelines
6169

6270
This project follows a [Code of Conduct].
@@ -126,7 +134,7 @@ It's usually a good idea to test locally for the following:
126134

127135
#### Update docs
128136

129-
Docs are under [documentation/]. Refer to (the README,md)[documentation/README.md] in the folder to details about
137+
Docs are under [documentation/](documentation/). Refer to the [README.md](documentation/README.md) in the folder for details about
130138
documentation contributions.
131139

132140

commands/fn/doc/cmdfndoc.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,12 @@ type Runner struct {
5858
Ctx context.Context
5959
}
6060

61-
func (r *Runner) runE(c *cobra.Command, _ []string) error {
61+
func (r *Runner) runE(_ *cobra.Command, _ []string) error {
6262
if r.Image == "" {
6363
return errors.New("image must be specified")
6464
}
65-
resolveFunc := (&runneroptions.RunnerOptions{}).ResolveToImageForCLIFunc(runneroptions.GHCRImagePrefix)
66-
image, err := resolveFunc(c.Context(), r.Image)
67-
if err != nil {
68-
return err
69-
}
65+
resolveFunc := runneroptions.ResolveToImageForCLIFunc(runneroptions.GHCRImagePrefix)
66+
image := resolveFunc(r.Image)
7067
var out, errout bytes.Buffer
7168
dockerRunArgs := []string{
7269
"run",

commands/pkg/diff/cmddiff_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestCmdExecute(t *testing.T) {
6161
dest := filepath.Join(w.WorkspaceDirectory, g.RepoName)
6262

6363
getRunner := get.NewRunner(fake.CtxWithDefaultPrinter(), "")
64-
getRunner.Command.SetArgs([]string{"file://" + g.RepoDirectory + ".git/", "./"})
64+
getRunner.Command.SetArgs([]string{"file://" + g.RepoDirectory + ".git/"})
6565
err := getRunner.Command.Execute()
6666
assert.NoError(t, err)
6767

commands/pkg/get/cmdget.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package get
1717
import (
1818
"context"
1919
"os"
20+
"path/filepath"
2021
"strings"
2122

2223
docs "github.com/kptdev/kpt/internal/docs/generated/pkgdocs"
@@ -76,9 +77,11 @@ type Runner struct {
7677

7778
func (r *Runner) preRunE(_ *cobra.Command, args []string) error {
7879
const op errors.Op = "cmdget.preRunE"
80+
// Track if destination was explicitly provided
81+
explicitDest := len(args) > 1
7982
if len(args) == 1 {
8083
args = append(args, pkg.CurDir)
81-
} else {
84+
} else if filepath.Clean(args[1]) != "." {
8285
_, err := os.Lstat(args[1])
8386
if err == nil || os.IsExist(err) {
8487
resolvedPath, err := argutil.ResolveSymlink(r.ctx, args[1])
@@ -88,7 +91,7 @@ func (r *Runner) preRunE(_ *cobra.Command, args []string) error {
8891
args[1] = resolvedPath
8992
}
9093
}
91-
t, err := parse.GitParseArgs(r.ctx, args)
94+
t, err := parse.GitParseArgs(r.ctx, args, explicitDest)
9295
if err != nil {
9396
return errors.E(op, err)
9497
}

commands/pkg/get/cmdget_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func TestCmdMainBranch_execute(t *testing.T) {
111111
}
112112

113113
r := get.NewRunner(fake.CtxWithDefaultPrinter(), "kpt")
114-
r.Command.SetArgs([]string{"file://" + g.RepoDirectory + ".git/", "./"})
114+
r.Command.SetArgs([]string{"file://" + g.RepoDirectory + ".git/"})
115115
err = r.Command.Execute()
116116

117117
assert.NoError(t, err)
@@ -159,9 +159,9 @@ func TestCmd_fail(t *testing.T) {
159159
r := get.NewRunner(fake.CtxWithDefaultPrinter(), "kpt")
160160
r.Command.SilenceErrors = true
161161
r.Command.SilenceUsage = true
162-
r.Command.SetArgs([]string{"file://" + filepath.Join("not", "real", "dir") + ".git/@master", "./"})
162+
r.Command.SetArgs([]string{"file://" + filepath.Join("not", "real", "dir") + ".git/@master", "nonexistent"})
163163

164-
defer os.RemoveAll("dir")
164+
defer os.RemoveAll("nonexistent")
165165

166166
err := r.Command.Execute()
167167
if !assert.Error(t, err) {
@@ -234,7 +234,7 @@ func TestCmd_Execute_flagAndArgParsing(t *testing.T) {
234234
assert.NoError(t, err)
235235
assert.Equal(t, "master", r.Get.Git.Ref)
236236
assert.Equal(t, "something://foo", r.Get.Git.Repo)
237-
assert.Equal(t, filepath.Join(pathPrefix, w.WorkspaceDirectory, "foo"), r.Get.Destination)
237+
assert.Equal(t, filepath.Join(pathPrefix, w.WorkspaceDirectory), r.Get.Destination)
238238
},
239239
},
240240
"repo arg is split up correctly into ref, directory and repo": {
@@ -247,10 +247,10 @@ func TestCmd_Execute_flagAndArgParsing(t *testing.T) {
247247
assert.Equal(t, fmt.Sprintf("file://%s", repo), r.Get.Git.Repo)
248248
assert.Equal(t, "master", r.Get.Git.Ref)
249249
assert.Equal(t, "/blueprints/java", r.Get.Git.Directory)
250-
assert.Equal(t, filepath.Join(pathPrefix, w.WorkspaceDirectory, "java"), r.Get.Destination)
250+
assert.Equal(t, filepath.Join(pathPrefix, w.WorkspaceDirectory), r.Get.Destination)
251251
},
252252
},
253-
"current working dir -- should use package name": {
253+
"current working dir -- should use current directory directly": {
254254
argsFunc: func(repo, _ string) []string {
255255
return []string{fmt.Sprintf("file://%s.git/blueprints/java", repo), "foo/../bar/../"}
256256
},
@@ -260,7 +260,7 @@ func TestCmd_Execute_flagAndArgParsing(t *testing.T) {
260260
assert.Equal(t, fmt.Sprintf("file://%s", repo), r.Get.Git.Repo)
261261
assert.Equal(t, "master", r.Get.Git.Ref)
262262
assert.Equal(t, "/blueprints/java", r.Get.Git.Directory)
263-
assert.Equal(t, filepath.Join(pathPrefix, w.WorkspaceDirectory, "java"), r.Get.Destination)
263+
assert.Equal(t, filepath.Join(pathPrefix, w.WorkspaceDirectory), r.Get.Destination)
264264
},
265265
},
266266
"clean relative path": {

e2e/testdata/fn-render/all-resource-deletion/.expected/diff.patch

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Kptfile b/Kptfile
2-
index 3c93e9e..fe0bc96 100644
2+
index 3c93e9e..5404a5a 100644
33
--- a/Kptfile
44
+++ b/Kptfile
55
@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1
@@ -12,7 +12,7 @@ index 3c93e9e..fe0bc96 100644
1212
pipeline:
1313
mutators:
1414
- image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest
15-
@@ -12,3 +15,8 @@ pipeline:
15+
@@ -12,3 +15,16 @@ pipeline:
1616
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
1717
configMap:
1818
tier: backend
@@ -21,6 +21,14 @@ index 3c93e9e..fe0bc96 100644
2121
+ - type: Rendered
2222
+ status: "True"
2323
+ reason: RenderSuccess
24+
+ renderStatus:
25+
+ mutationSteps:
26+
+ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest
27+
+ exitCode: 0
28+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
29+
+ exitCode: 0
30+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
31+
+ exitCode: 0
2432
diff --git a/delete-all.yaml b/delete-all.yaml
2533
index 3c86d8b..6754b0a 100644
2634
--- a/delete-all.yaml

e2e/testdata/fn-render/basicpipeline-semver/.expected/diff.patch

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/Kptfile b/Kptfile
2-
index 2336da4..eae3be3 100644
2+
index 2336da4..ca2bcea 100644
33
--- a/Kptfile
44
+++ b/Kptfile
5-
@@ -2,13 +2,20 @@ apiVersion: kpt.dev/v1
5+
@@ -2,13 +2,34 @@ apiVersion: kpt.dev/v1
66
kind: Kptfile
77
metadata:
88
name: app
@@ -25,6 +25,20 @@ index 2336da4..eae3be3 100644
2525
+ - type: Rendered
2626
+ status: "True"
2727
+ reason: RenderSuccess
28+
+ renderStatus:
29+
+ mutationSteps:
30+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.3
31+
+ exitCode: 0
32+
+ results:
33+
+ - message: namespace [default] updated to "staging", 1 value(s) changed
34+
+ severity: info
35+
+ - message: all `depends-on` annotations are up-to-date. no `namespace` changed
36+
+ severity: info
37+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4
38+
+ exitCode: 0
39+
+ results:
40+
+ - message: set 4 labels in total
41+
+ severity: info
2842
diff --git a/resources.yaml b/resources.yaml
2943
index 1f15150..936d957 100644
3044
--- a/resources.yaml

e2e/testdata/fn-render/basicpipeline-symlink/.expected/diff.patch

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Kptfile b/Kptfile
2-
index 1307fb5..f645d75 100644
2+
index 1307fb5..fee64dc 100644
33
--- a/Kptfile
44
+++ b/Kptfile
55
@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1
@@ -12,7 +12,7 @@ index 1307fb5..f645d75 100644
1212
pipeline:
1313
mutators:
1414
- image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
15-
@@ -10,3 +13,8 @@ pipeline:
15+
@@ -10,3 +13,14 @@ pipeline:
1616
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
1717
configMap:
1818
tier: backend
@@ -21,6 +21,12 @@ index 1307fb5..f645d75 100644
2121
+ - type: Rendered
2222
+ status: "True"
2323
+ reason: RenderSuccess
24+
+ renderStatus:
25+
+ mutationSteps:
26+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
27+
+ exitCode: 0
28+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
29+
+ exitCode: 0
2430
diff --git a/resources.yaml b/resources.yaml
2531
index f2eec52..84cfb26 100644
2632
--- a/resources.yaml

e2e/testdata/fn-render/basicpipeline-wasm/.expected/diff.patch

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/Kptfile b/Kptfile
2-
index 17a7822..94b6f80 100644
2+
index 17a7822..98fa855 100644
33
--- a/Kptfile
44
+++ b/Kptfile
5-
@@ -12,3 +12,8 @@ pipeline:
5+
@@ -12,3 +12,22 @@ pipeline:
66
- image: ghcr.io/kptdev/krm-functions-catalog/wasm/set-labels:v0.2.4
77
configMap:
88
tier: backend
@@ -11,6 +11,20 @@ index 17a7822..94b6f80 100644
1111
+ - type: Rendered
1212
+ status: "True"
1313
+ reason: RenderSuccess
14+
+ renderStatus:
15+
+ mutationSteps:
16+
+ - image: ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:v0.5.1
17+
+ exitCode: 0
18+
+ results:
19+
+ - message: namespace [default] updated to "staging", 1 value(s) changed
20+
+ severity: info
21+
+ - message: all `depends-on` annotations are up-to-date. no `namespace` changed
22+
+ severity: info
23+
+ - image: ghcr.io/kptdev/krm-functions-catalog/wasm/set-labels:v0.2.4
24+
+ exitCode: 0
25+
+ results:
26+
+ - message: set 4 labels in total
27+
+ severity: info
1428
diff --git a/resources.yaml b/resources.yaml
1529
index eed43d6..c1de2b0 100644
1630
--- a/resources.yaml

e2e/testdata/fn-render/basicpipeline/.expected/diff.patch

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Kptfile b/Kptfile
2-
index 1307fb5..f645d75 100644
2+
index 1307fb5..fee64dc 100644
33
--- a/Kptfile
44
+++ b/Kptfile
55
@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1
@@ -12,7 +12,7 @@ index 1307fb5..f645d75 100644
1212
pipeline:
1313
mutators:
1414
- image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
15-
@@ -10,3 +13,8 @@ pipeline:
15+
@@ -10,3 +13,14 @@ pipeline:
1616
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
1717
configMap:
1818
tier: backend
@@ -21,6 +21,12 @@ index 1307fb5..f645d75 100644
2121
+ - type: Rendered
2222
+ status: "True"
2323
+ reason: RenderSuccess
24+
+ renderStatus:
25+
+ mutationSteps:
26+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
27+
+ exitCode: 0
28+
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
29+
+ exitCode: 0
2430
diff --git a/resources.yaml b/resources.yaml
2531
index f2eec52..84cfb26 100644
2632
--- a/resources.yaml

0 commit comments

Comments
 (0)