Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cnrm annotation to merge3 #2605

Merged
merged 1 commit into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/util/merge/merge3.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"path/filepath"
"strings"

"github.com/GoogleContainerTools/kpt/internal/util/attribution"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/kio/filters"
Expand Down Expand Up @@ -357,7 +358,7 @@ func (*resourceHandler) equals(r1, r2 *yaml.RNode) (bool, error) {

func stripKyamlAnnos(n *yaml.RNode) error {
for _, a := range []string{mergeSourceAnnotation, kioutil.PathAnnotation, kioutil.IndexAnnotation,
kioutil.LegacyPathAnnotation, kioutil.LegacyIndexAnnotation} {
kioutil.LegacyPathAnnotation, kioutil.LegacyIndexAnnotation, attribution.CNRMMetricsAnnotation} {
err := n.PipeE(yaml.ClearAnnotation(a))
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion internal/util/update/resource-merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/GoogleContainerTools/kpt/internal/errors"
"github.com/GoogleContainerTools/kpt/internal/pkg"
"github.com/GoogleContainerTools/kpt/internal/types"
pkgdiff "github.com/GoogleContainerTools/kpt/internal/util/diff"
"github.com/GoogleContainerTools/kpt/internal/util/merge"
"github.com/GoogleContainerTools/kpt/internal/util/pkgutil"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
Expand Down Expand Up @@ -125,7 +126,7 @@ func (u ResourceMergeUpdater) updatePackage(subPkgPath, localPath, updatedPath,
// Package deleted from upstream
case originalExists && localExists && !updatedExists:
// Check the diff. If there are local changes, we keep the subpackage.
diff, err := copyutil.Diff(originalPath, localPath)
diff, err := pkgdiff.PkgDiff(originalPath, localPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to have a unified way to compare diff. We use pkgdiff in rest of the places and it handles the annotation comparison as well.

if err != nil {
return errors.E(op, types.UniquePath(localPath), err)
}
Expand Down