utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UUID = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)

Functions

func APIErrorMsg

func APIErrorMsg(r io.Reader) string

APIErrorMsg attempts to parse .Message from the API JSON response. Otherwise it returns the full response body.

func CACerts added in v0.2.0

func CACerts(t *testing.T) (string, string)

CACerts returns a new root and intermediate pem-encoded certificate

func Deref

func Deref[T dereferencable](v *T) (r T)

Deref gets the default value for a pointer type. This makes it easier to work with the generated API client code, which uses pointers for optional fields.

func Describe

func Describe(component string) (string, map[string]string, error)

Describe parses descriptions for a component from its schema in Smallstep's OpenAPI spec. This ensures the terraform attribute documentation is kept in sync with the API spec.

func DiagnosticsToErr added in v0.2.0

func DiagnosticsToErr(diagnostics diag.Diagnostics) error

func FixAttestationAuthority added in v0.2.0

func FixAttestationAuthority(t *testing.T, catalog string) *v20231101.AttestationAuthority

There can only be 1 per team - don't try to create a new one if one exists

func IsDurationEqual added in v0.2.0

func IsDurationEqual(a, b string) bool

func IsJSONEqual added in v0.2.0

func IsJSONEqual(a, b string) bool

func NewAccount added in v0.5.0

func NewAccount(t *testing.T) (*v20231101.Account, *v20231101.WifiAccount)

func NewAuthority

func NewAuthority(t *testing.T) *v20231101.Authority

func NewCollection added in v0.2.0

func NewCollection(t *testing.T) *v20231101.Collection

func NewCollectionInstance added in v0.2.0

func NewCollectionInstance(t *testing.T, slug string) *v20231101.CollectionInstance

func NewDeviceCollectionAccount added in v0.5.0

func NewDeviceCollectionAccount(t *testing.T) (*v20231101.DeviceCollectionAccount, string)

func NewJWK added in v0.2.0

func NewJWK(t *testing.T, pass string) (string, string)

func NewOIDCProvisioner added in v0.2.0

func NewOIDCProvisioner(t *testing.T, authorityID string) (*v20231101.Provisioner, *v20231101.OidcProvisioner)

func NewTPMDeviceCollection added in v0.5.0

func NewTPMDeviceCollection(t *testing.T, authorityID string) *v20231101.DeviceCollection

func NewWebhook added in v0.2.0

func NewWebhook(t *testing.T, provisionerID, authorityID string) *v20231101.ProvisionerWebhook

func Slug added in v0.2.0

func Slug(t *testing.T) string

func SmallstepAPIClientFromEnv

func SmallstepAPIClientFromEnv() (*v20231101.Client, error)

func SweepAttestationAuthorities added in v0.2.0

func SweepAttestationAuthorities() error

func ToEqualString added in v0.2.0

func ToEqualString(ctx context.Context, remote *string, state AttributeGetter, p path.Path, isEqual IsStringEqual) (types.String, diag.Diagnostics)

ToEqualString checks if a remote string is equivalent to a string in state and if so uses the string from state. This is used to avoid "inconsistent result after apply" errors for JSON and duration strings.

func ToIntPointer added in v0.2.0

func ToIntPointer(i64 *int64) *int

func ToOptionalBool added in v0.2.0

func ToOptionalBool(ctx context.Context, remote *bool, priorState AttributeGetter, p path.Path) (types.Bool, diag.Diagnostics)

func ToOptionalInt added in v0.2.0

func ToOptionalInt(ctx context.Context, remote *int, priorState AttributeGetter, p path.Path) (types.Int64, diag.Diagnostics)

func ToOptionalList added in v0.2.0

func ToOptionalList(ctx context.Context, remote *[]string, priorState AttributeGetter, p path.Path) (types.List, diag.Diagnostics)

func ToOptionalSet added in v0.2.0

func ToOptionalSet(ctx context.Context, remote *[]string, priorState AttributeGetter, p path.Path) (types.Set, diag.Diagnostics)

func ToOptionalString added in v0.2.0

func ToOptionalString[S ~string](ctx context.Context, remote *S, priorState AttributeGetter, p path.Path) (types.String, diag.Diagnostics)

func ToStringPointer added in v0.2.0

func ToStringPointer[Out ~string](str *string) *Out

Types

type AttributeGetter added in v0.2.0

type AttributeGetter interface {
	GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
}

type IsStringEqual added in v0.2.0

type IsStringEqual func(string, string) bool

Jump to

Keyboard shortcuts

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