mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-08 13:17:44 +00:00
Add github.com/krishicks/yaml-patch to vendor
This commit is contained in:
39
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/file_flag.go
generated
vendored
Normal file
39
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/file_flag.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
// Thanks, Concourse!
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// FileFlag is a flag for passing a path to a file on disk. The file is
|
||||
// expected to be a file, not a directory, that actually exists.
|
||||
type FileFlag string
|
||||
|
||||
// UnmarshalFlag implements go-flag's Unmarshaler interface
|
||||
func (f *FileFlag) UnmarshalFlag(value string) error {
|
||||
stat, err := os.Stat(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if stat.IsDir() {
|
||||
return fmt.Errorf("path '%s' is a directory, not a file", value)
|
||||
}
|
||||
|
||||
abs, err := filepath.Abs(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*f = FileFlag(abs)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Path is the path to the file
|
||||
func (f FileFlag) Path() string {
|
||||
return string(f)
|
||||
}
|
||||
57
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/main.go
generated
vendored
Normal file
57
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/main.go
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
yamlpatch "github.com/krishicks/yaml-patch"
|
||||
)
|
||||
|
||||
type opts struct {
|
||||
OpsFiles []FileFlag `long:"ops-file" short:"o" value-name:"PATH" description:"Path to file with one or more operations"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
var o opts
|
||||
_, err := flags.Parse(&o)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %s\n", err)
|
||||
}
|
||||
|
||||
placeholderWrapper := yamlpatch.NewPlaceholderWrapper("{{", "}}")
|
||||
|
||||
var patches []yamlpatch.Patch
|
||||
for _, opsFile := range o.OpsFiles {
|
||||
var bs []byte
|
||||
bs, err = ioutil.ReadFile(opsFile.Path())
|
||||
if err != nil {
|
||||
log.Fatalf("error reading opsfile: %s", err)
|
||||
}
|
||||
|
||||
var patch yamlpatch.Patch
|
||||
patch, err = yamlpatch.DecodePatch(placeholderWrapper.Wrap(bs))
|
||||
if err != nil {
|
||||
log.Fatalf("error decoding opsfile: %s", err)
|
||||
}
|
||||
|
||||
patches = append(patches, patch)
|
||||
}
|
||||
|
||||
doc, err := ioutil.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
log.Fatalf("error reading from stdin: %s", err)
|
||||
}
|
||||
|
||||
mdoc := placeholderWrapper.Wrap(doc)
|
||||
for _, patch := range patches {
|
||||
mdoc, err = patch.Apply(mdoc)
|
||||
if err != nil {
|
||||
log.Fatalf("error applying patch: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("%s", placeholderWrapper.Unwrap(mdoc))
|
||||
}
|
||||
18
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/main_suite_test.go
generated
vendored
Normal file
18
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/main_suite_test.go
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/gexec"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
gexec.CleanupBuildArtifacts()
|
||||
})
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Main Suite")
|
||||
}
|
||||
14
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/main_test.go
generated
vendored
Normal file
14
vendor/github.com/krishicks/yaml-patch/cmd/yaml-patch/main_test.go
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
var _ = Describe("yaml-patch", func() {
|
||||
It("builds", func() {
|
||||
_, err := gexec.Build("github.com/krishicks/yaml-patch/cmd/yaml-patch")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user