From 9538ae125839351fa12393978f6179eb0f0d371f Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Thu, 15 Jul 2021 08:20:07 -0700 Subject: [PATCH 1/2] Update fork updater script --- kyaml/internal/forked/README.md | 4 ++-- kyaml/internal/forked/update-go-yaml.sh | 29 +++++++++++++------------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/kyaml/internal/forked/README.md b/kyaml/internal/forked/README.md index ee26037bb0..cbd41bff16 100644 --- a/kyaml/internal/forked/README.md +++ b/kyaml/internal/forked/README.md @@ -6,6 +6,6 @@ This code is used by the starlark runtime. We copied it in to reduce the depende ## go-yaml/yaml -This code is used extensively by kyaml. It is a copy of upstream at a particular revision that kubectl is using, with [a change we need](https://github.com/go-yaml/yaml/pull/753) cherry-picked on top. For background information on this problem, see https://github.com/kubernetes-sigs/kustomize/issues/3946. +This code is used extensively by kyaml. It is a copy of upstream at a particular revision that kubectl is using, with fixes we need cherry-picked on top ([#753](https://github.com/go-yaml/yaml/pull/753), [#766](https://github.com/go-yaml/yaml/pull/766)). For background information on this problem, see https://github.com/kubernetes-sigs/kustomize/issues/3946. -This copy was created using the [git subtree technique](https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec) and can be recreated on top of a new version of go-yaml v3 using the [update-go-yaml.sh](update-go-yaml.sh) script. Please note that there is nothing special about the fork directory, so copy-paste with manual edits will work just fine if you prefer. +This copy was created using the [git subtree technique](https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec) and can be recreated on top of a new version of go-yaml v3 using the [update-go-yaml.sh](update-go-yaml.sh) script. To add an additional go-yaml PR to be cherry-picked, simply update the script's `GO_YAML_PRS` variable. Please note that there is nothing special about the fork directory, so copy-paste with manual edits will work just fine if you prefer. diff --git a/kyaml/internal/forked/update-go-yaml.sh b/kyaml/internal/forked/update-go-yaml.sh index 4eef38738f..fab5d7984b 100755 --- a/kyaml/internal/forked/update-go-yaml.sh +++ b/kyaml/internal/forked/update-go-yaml.sh @@ -18,13 +18,12 @@ blue=$(tput setaf 4) normal=$(tput sgr0) # This should be the version of go-yaml v3 used by kubectl - # In the original fork, this is 496545a6307b2a7d7a710fd516e5e16e8ab62dbc - export GOYAML_SHA=$1 - export GOYAML_REF="goyaml-$GOYAML_SHA" +# In the original fork, this is 496545a6307b2a7d7a710fd516e5e16e8ab62dbc +export GOYAML_SHA=$1 +export GOYAML_REF="goyaml-$GOYAML_SHA" # The PRs we need to cherry-pick onto the above commit -declare -r GO_YAML_PR=753 -declare -r KUSTOMIZE_PR=4004 +declare -r GO_YAML_PRS=(753 766) REPO_ROOT=$(git rev-parse --show-toplevel) declare -r REPO_ROOT @@ -77,8 +76,11 @@ function cherry-pick(){ subtree_commit_flag="" explain "Removing the fork's tree from git, if it exists. We'll write over this commit in a moment, but \`read-tree\` requires a clean directory." -if [[ $(find kyaml/internal/forked/github.com/go-yaml/yaml -type f -delete) ]]; then - git commit --all -m "Temporarily remove go-yaml fork" +find kyaml/internal/forked/github.com/go-yaml/yaml -type f -delete + +if [[ $(git diff --exit-code kyaml/internal/forked/github.com/go-yaml/yaml) ]]; then + git add kyaml/internal/forked/github.com/go-yaml/yaml + git commit -m "Temporarily remove go-yaml fork" subtree_commit_flag="--amend" fi @@ -87,21 +89,20 @@ git fetch --depth=1 https://github.com/go-yaml/yaml.git "$GOYAML_SHA:$GOYAML_REF explain "Inserting the content we just pulled as a subtree of this repository and squash the changes into the last commit." git read-tree --prefix=kyaml/internal/forked/github.com/go-yaml/yaml/ -u "$GOYAML_REF" -git commit $subtree_commit_flag --all -m "Internal copy of go-yaml at $GOYAML_SHA" +git add kyaml/internal/forked/github.com/go-yaml/yaml +git commit $subtree_commit_flag -m "Internal copy of go-yaml at $GOYAML_SHA" explain "Subtree creation successful." -explain "Cherry-picking the commits from our go-yaml/yaml PR" -cherry-pick https://github.com/go-yaml/yaml $GO_YAML_PR +explain "Cherry-picking the commits from our go-yaml/yaml PRs" +for pr in "${GO_YAML_PRS[@]}" ; do + cherry-pick https://github.com/go-yaml/yaml "$pr" +done explain "Converting module to be internal." find kyaml/internal/forked/github.com/go-yaml/yaml -name "*.go" -type f | xargs sed -i '' s+"gopkg.in/yaml.v3"+"sigs.k8s.io/kustomize/kyaml/internal/forked/github.com/go-yaml/yaml"+g rm kyaml/internal/forked/github.com/go-yaml/yaml/go.mod git commit --all -m "Internalize forked code" -# This is only necessary in the initial forking of the code -# explain "Cherry-picking the commits from our test fixes in Kustomize PR" -# cherry-pick https://github.com/kubernetes-sigs/kustomize $KUSTOMIZE_PR - explain "SUCCEEDED." exit 0 From f082ac02cf8e9f198ba58e187612f36c2d07999d Mon Sep 17 00:00:00 2001 From: Natasha Sarkar Date: Wed, 14 Jul 2021 16:43:37 -0700 Subject: [PATCH 2/2] fix multiline scalar value issue --- kyaml/internal/forked/github.com/go-yaml/yaml/decode_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kyaml/internal/forked/github.com/go-yaml/yaml/decode_test.go b/kyaml/internal/forked/github.com/go-yaml/yaml/decode_test.go index 7b34fade29..cd71579583 100644 --- a/kyaml/internal/forked/github.com/go-yaml/yaml/decode_test.go +++ b/kyaml/internal/forked/github.com/go-yaml/yaml/decode_test.go @@ -46,6 +46,9 @@ var unmarshalTests = []struct { map[string]string{"v": "hi"}, }, { "v: hi", map[string]interface{}{"v": "hi"}, + }, { + "v: 'hi\nthis is a\nmultiline string\n'", + map[string]interface {}{"v":"hi\nthis is a\nmultiline string\n"}, }, { "v: true", map[string]string{"v": "true"},