mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Rebase merge3 branch into master
This commit is contained in:
56
cmd/config/internal/commands/merge3.go
Normal file
56
cmd/config/internal/commands/merge3.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/cmd/config/cmddocs/commands"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio/filters"
|
||||
)
|
||||
|
||||
func GetMerge3Runner(name string) *Merge3Runner {
|
||||
r := &Merge3Runner{}
|
||||
c := &cobra.Command{
|
||||
Use: "merge3 --ancestor [ORIGINAL_DIR] --from [UPDATED_DIR] --to [DESTINATION_DIR]",
|
||||
Short: commands.Merge3Short,
|
||||
Long: commands.Merge3Long,
|
||||
Example: commands.Merge3Examples,
|
||||
RunE: r.runE,
|
||||
}
|
||||
fixDocs(name, c)
|
||||
//r.Command = c
|
||||
c.Flags().StringVar(&r.ancestor, "ancestor", "",
|
||||
"Path to original package")
|
||||
c.Flags().StringVar(&r.fromDir, "from", "",
|
||||
"Path to updated package")
|
||||
c.Flags().StringVar(&r.toDir, "to", "",
|
||||
"Path to destination package")
|
||||
|
||||
r.Command = c
|
||||
return r
|
||||
}
|
||||
|
||||
func Merge3Command(name string) *cobra.Command {
|
||||
return GetMerge3Runner(name).Command
|
||||
}
|
||||
|
||||
// Merge3Runner contains the run function
|
||||
type Merge3Runner struct {
|
||||
Command *cobra.Command
|
||||
ancestor string
|
||||
fromDir string
|
||||
toDir string
|
||||
}
|
||||
|
||||
func (r *Merge3Runner) runE(c *cobra.Command, args []string) error {
|
||||
err := filters.Merge3{
|
||||
OriginalPath: r.ancestor,
|
||||
UpdatedPath: r.fromDir,
|
||||
DestPath: r.toDir,
|
||||
}.Merge()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user