repository

package
v0.0.0-...-c7d747a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextRevisionNumber

func NextRevisionNumber(revs []string) (string, error)

func ToApiConditions

func ToApiConditions(kf kptfile.KptFile) []api.Condition

func ToApiReadinessGates

func ToApiReadinessGates(kf kptfile.KptFile) []api.ReadinessGate

func ValidateWorkspaceName

func ValidateWorkspaceName(workspace v1alpha1.WorkspaceName) error

ValidateWorkspaceName validates WorkspaceName. It must:

  • be at least 1 and at most 63 characters long
  • contain only lowercase alphanumeric characters or '-'
  • start and end with an alphanumeric character.

'/ ' should never be allowed, because we use '/' to delimit branch names (e.g. the 'drafts/' prefix).

Types

type Credential

type Credential interface {
	Valid() bool
	ToAuthMethod() transport.AuthMethod
}

type CredentialResolver

type CredentialResolver interface {
	ResolveCredential(ctx context.Context, namespace, name string) (Credential, error)
}

type Function

type Function interface {
	Name() string
	GetFunction() (*v1alpha1.Function, error)
	GetCRD() (*configapi.Function, error)
}

Function is an abstract function.

type FunctionRepository

type FunctionRepository interface {
	// TODO: Should repository understand functions, or just packages (and function is just a package in an OCI repo?)
	ListFunctions(ctx context.Context) ([]Function, error)
}

type ListPackageFilter

type ListPackageFilter struct {
	// KubeObjectName matches the generated kubernetes object name.
	KubeObjectName string

	// Package matches the name of the package (spec.package)
	Package string
}

ListPackageFilter is a predicate for filtering Package objects; only matching Package objects will be returned.

func (*ListPackageFilter) Matches

func (f *ListPackageFilter) Matches(p Package) bool

Matches returns true if the provided Package satisfies the conditions in the filter.

type ListPackageRevisionFilter

type ListPackageRevisionFilter struct {
	// KubeObjectName matches the generated kubernetes object name.
	KubeObjectName string

	// Package matches the name of the package (spec.package)
	Package string

	// WorkspaceName matches the description of the package (spec.workspaceName)
	WorkspaceName v1alpha1.WorkspaceName

	// Revision matches the revision of the package (spec.revision)
	Revision string
}

ListPackageRevisionFilter is a predicate for filtering PackageRevision objects; only matching PackageRevision objects will be returned.

func (*ListPackageRevisionFilter) Matches

Matches returns true if the provided PackageRevision satisfies the conditions in the filter.

type Package

type Package interface {
	// KubeObjectName returns an encoded name for the object that should be unique.
	// More "readable" values are returned by Key()
	KubeObjectName() string

	// Key returns the "primary key" of the package.
	Key() PackageKey

	// GetPackage returns the object representing this package
	GetPackage() *v1alpha1.Package

	// GetLatestRevision returns the name of the package revision that is the "latest" package
	// revision belonging to this package
	GetLatestRevision() string
}

Package is an abstract package.

type PackageDraft

type PackageDraft interface {
	UpdateResources(ctx context.Context, new *v1alpha1.PackageRevisionResources, task *v1alpha1.Task) error
	// Updates desired lifecycle of the package. The lifecycle is applied on Close.
	UpdateLifecycle(ctx context.Context, new v1alpha1.PackageRevisionLifecycle) error
	// Finish round of updates.
	Close(ctx context.Context) (PackageRevision, error)
}

type PackageKey

type PackageKey struct {
	Repository, Package string
}

func (PackageKey) String

func (n PackageKey) String() string

type PackageResources

type PackageResources struct {
	Contents map[string]string
}

TODO: "sigs.k8s.io/kustomize/kyaml/filesys" FileSystem?

type PackageRevision

type PackageRevision interface {
	// KubeObjectName returns an encoded name for the object that should be unique.
	// More "readable" values are returned by Key()
	KubeObjectName() string

	// KubeObjectNamespace returns the namespace in which the PackageRevision
	// belongs.
	KubeObjectNamespace() string

	// UID returns a unique identifier for the PackageRevision.
	UID() types.UID

	// Key returns the "primary key" of the package.
	Key() PackageRevisionKey

	// Lifecycle returns the current lifecycle state of the package.
	Lifecycle() v1alpha1.PackageRevisionLifecycle

	// UpdateLifecycle updates the desired lifecycle of the package. This can only
	// be used for Published package revisions to go from Published to DeletionProposed
	// or vice versa. Draft revisions should use PackageDraft.UpdateLifecycle.
	UpdateLifecycle(ctx context.Context, new v1alpha1.PackageRevisionLifecycle) error

	// GetPackageRevision returns the PackageRevision ("DRY") API representation of this package-revision
	GetPackageRevision(context.Context) (*v1alpha1.PackageRevision, error)

	// GetResources returns the PackageRevisionResources ("WET") API representation of this package-revision
	// TODO: return PackageResources or filesystem abstraction?
	GetResources(context.Context) (*v1alpha1.PackageRevisionResources, error)

	// GetUpstreamLock returns the kpt lock information.
	GetUpstreamLock(context.Context) (kptfile.Upstream, kptfile.UpstreamLock, error)

	// GetKptfile returns the Kptfile for hte package
	GetKptfile(context.Context) (kptfile.KptFile, error)

	// GetLock returns the current revision's lock information.
	// This will be the upstream info for downstream revisions.
	GetLock() (kptfile.Upstream, kptfile.UpstreamLock, error)
}

PackageRevision is an abstract package version. We have a single object for both Revision and Resources, because conceptually they are one object. The best way we've found (so far) to represent them in k8s is as two resources, but they map to the same object. Interesting reading: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#differing-representations

type PackageRevisionKey

type PackageRevisionKey struct {
	Repository, Package, Revision string
	WorkspaceName                 v1alpha1.WorkspaceName
}

func (PackageRevisionKey) String

func (n PackageRevisionKey) String() string

type Repository

type Repository interface {
	// ListPackageRevisions lists the existing package revisions in the repository
	ListPackageRevisions(ctx context.Context, filter ListPackageRevisionFilter) ([]PackageRevision, error)

	// CreatePackageRevision creates a new package revision
	CreatePackageRevision(ctx context.Context, obj *v1alpha1.PackageRevision) (PackageDraft, error)

	// DeletePackageRevision deletes a package revision
	DeletePackageRevision(ctx context.Context, old PackageRevision) error

	// UpdatePackageRevision updates a package
	UpdatePackageRevision(ctx context.Context, old PackageRevision) (PackageDraft, error)

	// ListPackages lists all packages in the repository
	ListPackages(ctx context.Context, filter ListPackageFilter) ([]Package, error)

	// CreatePackage creates a new package
	CreatePackage(ctx context.Context, obj *v1alpha1.Package) (Package, error)

	// DeletePackage deletes a package
	DeletePackage(ctx context.Context, old Package) error
}

Repository is the interface for interacting with packages in repositories TODO: we may need interface to manage repositories too. Stay tuned.

type UserInfo

type UserInfo struct {
	Name  string
	Email string
}

type UserInfoProvider

type UserInfoProvider interface {
	// GetUserInfo returns the information about the user on whose behalf the request is being
	// processed, if any. If user cannot be determnined, returns nil.
	GetUserInfo(ctx context.Context) *UserInfo
}

UserInfoProvider providers name of the authenticated user on whose behalf the request is being processed.

Jump to

Keyboard shortcuts

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