get

package
v0.36.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package get contains libraries for fetching packages.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClonerUsingGitExec

func ClonerUsingGitExec(repoSpec *git.RepoSpec, defaultRef string) error

ClonerUsingGitExec uses a local git install, as opposed to say, some remote API, to obtain a local clone of a remote repo.

Types

type Cloner

type Cloner func(repoSpec *git.RepoSpec) error

Cloner is a function that can clone a git repo.

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/pkg/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
	}
}
Output:

Example (Branch)
package main

import (
	"github.com/GoogleContainerTools/kpt/pkg/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
	}
}
Output:

Example (Commit)
package main

import (
	"github.com/GoogleContainerTools/kpt/pkg/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
	}
}
Output:

Example (Destination)
package main

import (
	"github.com/GoogleContainerTools/kpt/pkg/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
	}
}
Output:

Example (Subdir)
package main

import (
	"path/filepath"

	"github.com/GoogleContainerTools/kpt/pkg/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
	}
}
Output:

Example (Tag)
package main

import (
	"github.com/GoogleContainerTools/kpt/pkg/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
	}
}
Output:

func (*Command) DefaultValues

func (c *Command) DefaultValues() error

DefaultValues sets values to the default values if they were unspecified

func (Command) Run

func (c Command) Run() error

Run runs the Command.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL