Documentation
¶
Overview ¶
Package get contains libraries for fetching packages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// Git contains information about the git repo to fetch
Git *kptfilev1.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
// UpdateStrategy is the strategy that will be configured in the package
// Kptfile. This determines how changes will be merged when updating the
// package.
UpdateStrategy kptfilev1.UpdateStrategyType
}
Command fetches a package from a git repository, copies it to a local directory, and expands any remote subpackages.
Example ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/printer/fake"
"github.com/GoogleContainerTools/kpt/internal/util/get"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
)
func main() {
err := get.Command{Git: &kptfilev1.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "v1.0",
}}.Run(fake.CtxWithDefaultPrinter())
if err != nil {
// handle error
}
}
Example (Branch) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/printer/fake"
"github.com/GoogleContainerTools/kpt/internal/util/get"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
)
func main() {
err := get.Command{Git: &kptfilev1.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "refs/heads/v1.0",
}}.Run(fake.CtxWithDefaultPrinter())
if err != nil {
// handle error
}
}
Example (Commit) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/printer/fake"
"github.com/GoogleContainerTools/kpt/internal/util/get"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
)
func main() {
err := get.Command{Git: &kptfilev1.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "8186bef8e5c0621bf80fa8106bd595aae8b62884",
}}.Run(fake.CtxWithDefaultPrinter())
if err != nil {
// handle error
}
}
Example (Destination) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/printer/fake"
"github.com/GoogleContainerTools/kpt/internal/util/get"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
)
func main() {
err := get.Command{
Git: &kptfilev1.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "v1.0",
},
Destination: "destination-dir"}.Run(fake.CtxWithDefaultPrinter())
if err != nil {
// handle error
}
}
Example (Subdir) ¶
package main
import (
"path/filepath"
"github.com/GoogleContainerTools/kpt/internal/printer/fake"
"github.com/GoogleContainerTools/kpt/internal/util/get"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
)
func main() {
err := get.Command{
Git: &kptfilev1.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "v1.0",
Directory: filepath.Join("path", "to", "package"),
},
}.Run(fake.CtxWithDefaultPrinter())
if err != nil {
// handle error
}
}
Example (Tag) ¶
package main
import (
"github.com/GoogleContainerTools/kpt/internal/printer/fake"
"github.com/GoogleContainerTools/kpt/internal/util/get"
kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
)
func main() {
err := get.Command{Git: &kptfilev1.Git{
Repo: "https://github.com/example-org/example-repo",
Ref: "refs/tags/v1.0",
}}.Run(fake.CtxWithDefaultPrinter())
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.