bufmoduleref

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: Apache-2.0 Imports: 16 Imported by: 49

Documentation

Index

Constants

View Source
const (
	// Main is the default reference used if no other reference is specified.
	Main = "main"
)

Variables

This section is empty.

Functions

func IsCommitModuleReference

func IsCommitModuleReference(moduleReference ModuleReference) bool

IsCommitModuleReference returns true if the ModuleReference references a commit.

If false, this means the ModuleReference references a branch or tag. Branch and tag disambiguation needs to be done server-side.

func IsCommitReference

func IsCommitReference(reference string) bool

IsCommitReference returns whether the provided reference is a commit.

func ModulePinEqual

func ModulePinEqual(a ModulePin, b ModulePin) bool

ModulePinEqual returns true if a equals b.

func ModuleReferenceEqual

func ModuleReferenceEqual(a ModuleReference, b ModuleReference) bool

ModuleReferenceEqual returns true if a equals b.

func NewProtoModulePinForModulePin

func NewProtoModulePinForModulePin(modulePin ModulePin) *modulev1alpha1.ModulePin

NewProtoModulePinForModulePin returns a new proto ModulePin for the given ModulePin.

func NewProtoModulePinsForModulePins

func NewProtoModulePinsForModulePins(modulePins ...ModulePin) []*modulev1alpha1.ModulePin

NewProtoModulePinsForModulePins maps the given module pins into the protobuf representation.

func NewProtoModuleReferenceForModuleReference

func NewProtoModuleReferenceForModuleReference(moduleReference ModuleReference) *modulev1alpha1.ModuleReference

NewProtoModuleReferenceForModuleReference returns a new proto ModuleReference for the given ModuleReference.

func NewProtoModuleReferencesForModuleReferences

func NewProtoModuleReferencesForModuleReferences(moduleReferences ...ModuleReference) []*modulev1alpha1.ModuleReference

NewProtoModuleReferencesForModuleReferences maps the given module references into the protobuf representation.

func PutDependencyModulePinsToBucket

func PutDependencyModulePinsToBucket(
	ctx context.Context,
	writeBucket storage.WriteBucket,
	modulePins []ModulePin,
) error

PutDependencyModulePinsToBucket writes the module dependencies to the write bucket in the form of a lock file.

func SortFileInfos

func SortFileInfos(fileInfos []FileInfo)

SortFileInfos sorts the FileInfos by Path.

This should be treated as the default sorting mechanism.

func SortFileInfosByExternalPath

func SortFileInfosByExternalPath(fileInfos []FileInfo)

SortFileInfosByExternalPath sorts the FileInfos by ExternalPath.

func SortModulePins

func SortModulePins(modulePins []ModulePin)

SortModulePins sorts the ModulePins.

func ValidateBranch

func ValidateBranch(branch string) error

ValidateBranch verifies the given repository branch is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateCommit

func ValidateCommit(commit string) error

ValidateCommit verifies the given commit is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateModuleFilePath

func ValidateModuleFilePath(path string) error

ValidateModuleFilePath validates that the module file path is not empty. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateModulePinsUniqueByIdentity

func ValidateModulePinsUniqueByIdentity(modulePins []ModulePin) error

ValidateModulePinsUniqueByIdentity returns an error if the module pins contain any duplicates.

This only checks remote, owner, repository.

func ValidateModuleReferencesUniqueByIdentity

func ValidateModuleReferencesUniqueByIdentity(moduleReferences []ModuleReference) error

ValidateModuleReferencesUniqueByIdentity returns an error if the module references contain any duplicates.

This only checks remote, owner, repository.

func ValidateOrganization

func ValidateOrganization(organization string) error

ValidateOrganization verifies the given organization name is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateOwner

func ValidateOwner(owner string, ownerType string) error

ValidateOwner verifies the given owner name is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateProtoModulePin

func ValidateProtoModulePin(protoModulePin *modulev1alpha1.ModulePin) error

ValidateProtoModulePin verifies the given module pin is well-formed. It performs client-side validation only, and is limited to fields we do not think will change in the future.

func ValidateProtoModuleReference

func ValidateProtoModuleReference(protoModuleReference *modulev1alpha1.ModuleReference) error

ValidateProtoModuleReference verifies the given module reference is well-formed. It performs client-side validation only, and is limited to fields we do not think will change in the future.

func ValidateReference

func ValidateReference(reference string) error

ValidateReference validates that the given ModuleReference reference is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateRemoteHasNoPaths added in v1.5.0

func ValidateRemoteHasNoPaths(remote string) error

ValidateRemoteHasNoPaths validates that the given remote address contains no paths/subdirectories after the root It performs client-side validation only, and is limited to fields we do not think will change in the future.

func ValidateRemoteNotEmpty added in v1.5.0

func ValidateRemoteNotEmpty(remote string) error

ValidateRemoteNotEmpty validates that the given remote address is not an empty string It performs client-side validation only, and is limited to fields we do not think will change in the future.

func ValidateRepository

func ValidateRepository(repository string) error

ValidateRepository verifies the given repository name is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateTag

func ValidateTag(tag string) error

ValidateTag verifies the given tag is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

func ValidateUser

func ValidateUser(user string) error

ValidateUser verifies the given user name is well-formed. It performs client-side validation only, and is limited to properties we do not think will change in the future.

Types

type FileInfo

type FileInfo interface {
	// Path is the path of the file relative to the root it is contained within.
	// This will be normalized, validated and never empty,
	// This will be unique within a given Image.
	Path() string

	//   Path: one/one.proto
	//   RootDirPath: proto
	//   ExternalPath: /foo/bar/proto/one/one.proto
	ExternalPath() string
	// IsImport returns true if this file is an import.
	IsImport() bool
	// ModuleIdentity is the module that this file came from.
	//
	// Note this *can* be nil if we did not build from a named module.
	// All code must assume this can be nil.
	// Note that nil checking should work since the backing type is always a pointer.
	ModuleIdentity() ModuleIdentity
	// Commit is the commit for the module that this file came from.
	//
	// This will only be set if ModuleIdentity is set. but may not be set
	// even if ModuleIdentity is set, that is commit is optional information
	// even if we know what module this file came from.
	Commit() string
	// WithIsImport returns this FileInfo with the given IsImport value.
	WithIsImport(isImport bool) FileInfo
	// contains filtered or unexported methods
}

FileInfo contains module file info.

func NewFileInfo

func NewFileInfo(
	path string,
	externalPath string,
	isImport bool,
	moduleIdentity ModuleIdentity,
	commit string,
) (FileInfo, error)

NewFileInfo returns a new FileInfo.

TODO: we should make moduleIdentity and commit options. TODO: we don't validate commit

type ModuleIdentity

type ModuleIdentity interface {
	ModuleOwner

	Repository() string

	// IdentityString is the string remote/owner/repository.
	IdentityString() string
	// contains filtered or unexported methods
}

ModuleIdentity is a module identity.

It just contains remote, owner, repository.

This is shared by ModuleReference and ModulePin.

func ModuleIdentityForString

func ModuleIdentityForString(path string) (ModuleIdentity, error)

ModuleIdentityForString returns a new ModuleIdentity for the given string.

This parses the path in the form remote/owner/repository

TODO: we may want to add a special error if we detect / or @ as this may be a common mistake.

func NewModuleIdentity

func NewModuleIdentity(
	remote string,
	owner string,
	repository string,
) (ModuleIdentity, error)

NewModuleIdentity returns a new ModuleIdentity.

type ModuleOwner

type ModuleOwner interface {
	Remote() string
	Owner() string
	// contains filtered or unexported methods
}

ModuleOwner is a module owner.

It just contains remote, owner.

This is shared by ModuleIdentity.

func ModuleOwnerForString

func ModuleOwnerForString(path string) (ModuleOwner, error)

ModuleOwnerForString returns a new ModuleOwner for the given string.

This parses the path in the form remote/owner.

func NewModuleOwner

func NewModuleOwner(
	remote string,
	owner string,
) (ModuleOwner, error)

NewModuleOwner returns a new ModuleOwner.

type ModulePin

type ModulePin interface {
	ModuleIdentity

	// Prints remote/owner/repository:commit, which matches ModuleReference
	fmt.Stringer

	// all of these will be set
	Branch() string
	Commit() string
	CreateTime() time.Time
	// contains filtered or unexported methods
}

ModulePin is a module pin.

It references a specific point in time of a Module.

Note that a commit does this itself, but we want all this information. This is what is stored in a buf.lock file.

func DependencyModulePinsForBucket

func DependencyModulePinsForBucket(
	ctx context.Context,
	readBucket storage.ReadBucket,
) ([]ModulePin, error)

DependencyModulePinsForBucket reads the module dependencies from the lock file in the bucket.

func NewModulePin

func NewModulePin(
	remote string,
	owner string,
	repository string,
	branch string,
	commit string,
	createTime time.Time,
) (ModulePin, error)

NewModulePin returns a new validated ModulePin.

func NewModulePinForProto

func NewModulePinForProto(protoModulePin *modulev1alpha1.ModulePin) (ModulePin, error)

NewModulePinForProto returns a new ModulePin for the given proto ModulePin.

func NewModulePinsForProtos

func NewModulePinsForProtos(protoModulePins ...*modulev1alpha1.ModulePin) ([]ModulePin, error)

NewModulePinsForProtos maps the Protobuf equivalent into the internal representation.

type ModuleReference

type ModuleReference interface {
	ModuleIdentity

	// Prints either remote/owner/repository:{branch,commit}
	// If the reference is equal to MainBranch, prints remote/owner/repository.
	fmt.Stringer

	// Either branch, tag, or commit
	Reference() string
	// contains filtered or unexported methods
}

ModuleReference is a module reference.

It references either a branch, tag, or a commit. Note that since commits belong to branches, we can deduce the branch from the commit when resolving.

func ModuleReferenceForString

func ModuleReferenceForString(path string) (ModuleReference, error)

ModuleReferenceForString returns a new ModuleReference for the given string. If a branch or commit is not provided, the "main" branch is used.

This parses the path in the form remote/owner/repository{:branch,:commit}.

func NewModuleReference

func NewModuleReference(
	remote string,
	owner string,
	repository string,
	reference string,
) (ModuleReference, error)

NewModuleReference returns a new validated ModuleReference.

func NewModuleReferenceForProto

func NewModuleReferenceForProto(protoModuleReference *modulev1alpha1.ModuleReference) (ModuleReference, error)

NewModuleReferenceForProto returns a new ModuleReference for the given proto ModuleReference.

func NewModuleReferencesForProtos

func NewModuleReferencesForProtos(protoModuleReferences ...*modulev1alpha1.ModuleReference) ([]ModuleReference, error)

NewModuleReferencesForProtos maps the Protobuf equivalent into the internal representation.

Jump to

Keyboard shortcuts

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