get

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 21 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

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

	// IsDeploymentInstance indicates if the package is forked for deployment.
	// If forked package has defined deploy hooks, those will be executed post fork.
	IsDeploymentInstance bool

	// 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 (
	"fmt"

	"github.com/nephio-project/porch/internal/kpt/util/get"
	kptfilev1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
	"github.com/nephio-project/porch/pkg/kpt/printer/fake"
)

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 {
		fmt.Print(err.Error())
	}
}
Output:

Example (Branch)
package main

import (
	"fmt"

	"github.com/nephio-project/porch/internal/kpt/util/get"
	kptfilev1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
	"github.com/nephio-project/porch/pkg/kpt/printer/fake"
)

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 {
		fmt.Print(err.Error())
	}
}
Output:

Example (Commit)
package main

import (
	"fmt"

	"github.com/nephio-project/porch/internal/kpt/util/get"
	kptfilev1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
	"github.com/nephio-project/porch/pkg/kpt/printer/fake"
)

func main() {
	err := get.Command{Git: &kptfilev1.Git{
		Repo: "https://github.com/example-org/example-repo",
		Ref:  "8186bef8e5c0621bf80fa8106bd595aae8b62884",
	}}.Run(fake.CtxWithDefaultPrinter())
	if err != nil {
		fmt.Print(err.Error())
	}
}
Output:

Example (Destination)
package main

import (
	"fmt"

	"github.com/nephio-project/porch/internal/kpt/util/get"
	kptfilev1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
	"github.com/nephio-project/porch/pkg/kpt/printer/fake"
)

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 {
		fmt.Print(err.Error())
	}
}
Output:

Example (Subdir)
package main

import (
	"fmt"
	"path/filepath"

	"github.com/nephio-project/porch/internal/kpt/util/get"
	kptfilev1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
	"github.com/nephio-project/porch/pkg/kpt/printer/fake"
)

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 {
		fmt.Print(err.Error())
	}
}
Output:

Example (Tag)
package main

import (
	"fmt"

	"github.com/nephio-project/porch/internal/kpt/util/get"
	kptfilev1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
	"github.com/nephio-project/porch/pkg/kpt/printer/fake"
)

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 {
		fmt.Print(err.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(ctx context.Context) error

Run runs the Command.

Jump to

Keyboard shortcuts

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