aliases

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0, MIT Imports: 4 Imported by: 0

README

Go SemVer Aliases devel codecov Go Report Card GoDoc

A simple Go package to create deduplicated version aliases based on valid SemVer release names.

The library takes care of optional prefixed releases (v) as well as all version names are deduplicated and sorted in lexicographic order.

For example this library can be used to create SemVer and custom aliases for tagging Docker images.

Usage

package main

import (
	"fmt"

	aliases "github.com/joseluisq/semver-aliases"
)

func main() {
	// 1. Create alias names based on a given release
	versionAliases := aliases.FromVersion("v1.0.0")
	fmt.Printf("%#v\n", versionAliases)
	//	[]string{"1", "1.0", "1.0.0"}

	extras := []string{"latest", "stable", "v1.0.0", "1.0"}
	composed := append(versionAliases, extras...)
	fmt.Printf("%#v\n", composed)
	//	[]string{"1", "1.0", "1.0.0", "latest", "stable", "v1.0.0", "1.0"}

	// 2. Or create alias names based on a list of names (deduplicated and sorted)
	tags := aliases.FromVersionNames(composed)
	fmt.Printf("%#v\n", tags)
	//	[]string{"1", "1.0", "1.0.0", "latest", "stable"}

	// 3. Or create version names with its items suffixed (sorted)
	suffixed := aliases.GetVersionNamesSuffixed(versionAliases, "linux-amd64")
	fmt.Printf("%#v\n", suffixed)
	//	[]string{"1-linux-amd64", "1.0-linux-amd64", "1.0.0-linux-amd64"}
}

Examples

Documentation

pkg.go.dev/github.com/joseluisq/semver-aliases

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in current work by you, as defined in the Apache-2.0 license, shall be dual licensed as described below, without any additional terms or conditions.

Feel free to send some Pull request or issue.

License

This work is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

© 2020-present Jose Quintana

Documentation

Overview

Package aliases creates deduplicated version aliases based on valid Semver release names.

Library takes care of optional prefixed releases (`v`) as well as all version names are deduplicated and sorted in lexicographic order. For example this library can be used to create Semver and custom aliases for tagging Docker images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromVersion

func FromVersion(version string) []string

FromVersion creates tag aliases based on a valid Semver release.

func FromVersionNames

func FromVersionNames(names []string) []string

FromVersionNames validates and returns deduplicated tag aliases.

func GetVersionNamesSuffixed

func GetVersionNamesSuffixed(names []string, suffix string) []string

GetVersionNamesSuffixed returns a version names with its items suffixed.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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