utils

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CharSetAlphaNum is the alphanumeric character set for use with
	// RandStringFromCharSet.
	CharSetAlphaNum = "abcdefghijklmnopqrstuvwxyz012346789"

	// CharSetAlpha is the alphabetical character set for use with
	// RandStringFromCharSet.
	CharSetAlpha = "abcdefghijklmnopqrstuvwxyz"

	// Length of the resource name we wish to generate.
	ResourceNameLength = 10
)

Variables

This section is empty.

Functions

func BuildUserAgent

func BuildUserAgent(params UserAgentBuilderParams) string

BuildUserAgent takes the `UserAgentBuilderParams` and contextually builds a HTTP user agent for making API calls.

func FindGoModuleVersion

func FindGoModuleVersion(modulePath string) *string

FindGoModuleVersion digs into the build information and extracts the version of a module for use without the prefixed `v` (should it exist).

func GenerateRandomResourceName

func GenerateRandomResourceName() string

GenerateRandomResourceName builds a unique-ish resource identifier to use in tests.

func GetDefaultFromEnv

func GetDefaultFromEnv(key, fallback string) string

func RandIntRange

func RandIntRange(min int, max int) int

RandIntRange returns a random integer between min (inclusive) and max (exclusive).

func RandString

func RandString(strlen int) string

RandString generates a random alphanumeric string of the length specified.

func RandStringFromCharSet

func RandStringFromCharSet(strlen int, charSet string) string

RandStringFromCharSet generates a random string by selecting characters from the charset provided.

func RenderAvailableDocumentationValuesIntSlice

func RenderAvailableDocumentationValuesIntSlice(s []int) string

RenderAvailableDocumentationValuesIntSlice takes a slice of ints and formats it for documentation output use.

Example: [1, 2, 3] -> `1`, `2`, `3`.

func RenderAvailableDocumentationValuesStringSlice

func RenderAvailableDocumentationValuesStringSlice(s []string) string

RenderAvailableDocumentationValuesStringSlice takes a slice of strings and formats it for documentation output use.

Example: ["foo", "bar", "baz"] -> `foo`, `bar`, `baz`.

func RenderMustProviderOnlyOneOfDocumentationValuesStringSlice

func RenderMustProviderOnlyOneOfDocumentationValuesStringSlice(s []string) string

Types

type UserAgentBuilderParams

type UserAgentBuilderParams struct {
	// Version of `terraform-provider-cloudflare`.
	ProviderVersion *string

	// Version of `terraform-plugin-*` libraries that we rely on for the internal
	// operations.
	PluginVersion *string

	// Which plugin is in use. Currently only available options are
	// `terraform-plugin-sdk` and `terraform-plugin-framework`.
	PluginType *string

	// Version of Terraform that is initiating the operation. Mutually exclusive
	// with `OperatorSuffix`.
	TerraformVersion *string

	// Customised operation suffix to append to the user agent for identifying
	// traffic. Mutually exclusive with `TerraformVersion`.
	OperatorSuffix *string
}

func (*UserAgentBuilderParams) String

func (p *UserAgentBuilderParams) String() string

Jump to

Keyboard shortcuts

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