Documentation
¶
Overview ¶
Package get contains libraries for fetching packages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClonerUsingGitExec ¶
ClonerUsingGitExec uses a local git install, as opposed to say, some remote API, to obtain a local clone of a remote repo.
Types ¶
type Command ¶
type Command struct {
// Git contains information about the git repo to fetch
kptfile.Git
// Destination is the output directory to clone the package to. Defaults to the name of the package --
// either the base repo name, or the base subdirectory name.
Destination string
// Name is the name to give the package. Defaults to the destination.
Name string
// Remove directory before copying to it.
Clean bool
}
Command fetches a package from a git repository and copies it to a local directory.
Example ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/kptfile"
"github.com/GoogleContainerTools/kpt/internal/util/get"
)
func main() {
err := get.Command{Git: kptfile.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "v1.0",
}}.Run()
if err != nil {
// handle error
}
}
Example (Branch) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/kptfile"
"github.com/GoogleContainerTools/kpt/internal/util/get"
)
func main() {
err := get.Command{Git: kptfile.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "refs/heads/v1.0",
}}.Run()
if err != nil {
// handle error
}
}
Example (Commit) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/kptfile"
"github.com/GoogleContainerTools/kpt/internal/util/get"
)
func main() {
err := get.Command{Git: kptfile.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "8186bef8e5c0621bf80fa8106bd595aae8b62884",
}}.Run()
if err != nil {
// handle error
}
}
Example (Destination) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/kptfile"
"github.com/GoogleContainerTools/kpt/internal/util/get"
)
func main() {
err := get.Command{
Git: kptfile.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "v1.0",
},
Destination: "destination-dir"}.Run()
if err != nil {
// handle error
}
}
Example (Subdir) ¶
package main
import (
"path/filepath"
"github.com/GoogleContainerTools/kpt/internal/kptfile"
"github.com/GoogleContainerTools/kpt/internal/util/get"
)
func main() {
err := get.Command{
Git: kptfile.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "v1.0",
Directory: filepath.Join("path", "to", "package"),
},
}.Run()
if err != nil {
// handle error
}
}
Example (Tag) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/kptfile"
"github.com/GoogleContainerTools/kpt/internal/util/get"
)
func main() {
err := get.Command{Git: kptfile.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "refs/tags/v1.0",
}}.Run()
if err != nil {
// handle error
}
}
func (*Command) DefaultValues ¶
DefaultValues sets values to the default values if they were unspecified
Click to show internal directories.
Click to hide internal directories.