secretpath

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package secretpath implements utility functions for manipulating paths compatible with SecretHub (e.g. namespaces, repositories, directories, secrets and versions).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddVersion

func AddVersion(path string, version int) string

AddVersion adds a version suffix to a given path, removing trailing separators if necessary. If the path already contains a version suffix, it is replaced by the given version number. Negative version numbers are converted to ":latest".

func Base

func Base(path string) string

Base returns the last element of a path. Trailing separators and version numbers are removed.

func Clean

func Clean(path string) string

Clean returns the shortest path name equivalent to the given path by lexical processing. It removes trailing and multiple separator elements. Version suffixes are not removed.

func Count

func Count(path string) int

Count returns the number of elements in a path, excluding the version suffix.

func HasVersion

func HasVersion(path string) bool

HasVersion returns true when a version suffix is specified in the path. Note that even if the specified version suffix is invalid, this function still returns true.

func Join

func Join(elements ...string) string

Join joins any number of elements into a path, adding a separator if necessary. Empty string elements are ignored.

func Namespace

func Namespace(path string) string

Namespace returns the first element of a path, removing trailing separators.

func Parent

func Parent(path string) string

Parent returns all but the last element of a path, removing trailing separators. If a path contains only one element, it returns an empty string.

func Repo

func Repo(path string) string

Repo returns the first two elements of a path, removing trailing separators. If a path contains less than two elements, it returns the empty string.

func Version

func Version(path string) int

Version returns the version number suffix of a path, returning -1 when :latest, no version suffix, or negative version numbers are given. If an invalid suffix is set, 0 is returned.

Types

type NaturalSort

type NaturalSort []string

NaturalSort implements the sort.Interface by natural sorting.

func (NaturalSort) Len

func (s NaturalSort) Len() int

func (NaturalSort) Less

func (s NaturalSort) Less(i, j int) bool

func (NaturalSort) Swap

func (s NaturalSort) Swap(i, j int)

Jump to

Keyboard shortcuts

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