utils

package
v0.0.0-...-d97b457 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package utils is the uncategorized utils for zbpack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstraintToVersion

func ConstraintToVersion(constraints string, defaultVersion string) string

ConstraintToVersion converts the Semver version constraint to a minor-only version.

func Copy

func Copy(src, dst string) error

Copy copies a file or directory from src to dst.

func GetExplicitServerlessConfig

func GetExplicitServerlessConfig(config plan.ImmutableProjectConfiguration) optional.Option[bool]

GetExplicitServerlessConfig gets the serverless flag from the project configuration.

When the serverless flag is not set, it will be determined by the FORCE_CONTAINERIZED and ZBPACK_SERVERLESS environment variables. If all of them are not set, it returns None for consumers to determine the default value.

func HasFile

func HasFile(src afero.Fs, fileNames ...string) bool

HasFile checks if the given file exists in the given filesystem.

func WeakContains

func WeakContains(a, b string) bool

WeakContains is just like strings.Contains, but it's case-insensitive.

Types

type IntOrBool

type IntOrBool struct {
	IntValue  int
	BoolValue bool
	IsInt     bool
}

IntOrBool is a type that can be either an int or a bool

func (*IntOrBool) UnmarshalJSON

func (iob *IntOrBool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type Version

type Version struct {
	// Major version.
	Major uint32
	// Minor version.
	Minor uint32
	// MinorSet indicates if the minor version is set.
	MinorSet bool
	// Patch version.
	Patch uint32
	// PatchSet indicates if the patch version is set.
	PatchSet bool
	// Prerelease version. Empty = not set.
	Prerelease string
}

Version represents a semver version.

func SplitVersion

func SplitVersion(version string) (Version, error)

SplitVersion splits the version string into major, minor, patch, and prerelease.

If the version string is "8.0.0-beta1", the result will be 8, 0, 0, "beta1". If the version is a wildcard, the field will be -1.

Jump to

Keyboard shortcuts

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