utils

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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) *v20230301.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 NewAgentConfiguration added in v0.2.0

func NewAgentConfiguration(t *testing.T, authorityID, provisionerName, attestSlug string) *v20230301.AgentConfiguration

func NewAuthority

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

func NewCollection added in v0.2.0

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

func NewCollectionInstance added in v0.2.0

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

func NewEndpointConfiguration added in v0.2.0

func NewEndpointConfiguration(t *testing.T, authorityID, provisionerName string) *v20230301.EndpointConfiguration

func NewJWK added in v0.2.0

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

func NewManagedConfiguration added in v0.2.0

func NewManagedConfiguration(t *testing.T, agentConfigID string, endpointConfigID string) *v20230301.ManagedConfiguration

func NewOIDCProvisioner added in v0.2.0

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

func NewWebhook added in v0.2.0

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

func Slug added in v0.2.0

func Slug(t *testing.T) string

func SmallstepAPIClientFromEnv

func SmallstepAPIClientFromEnv() (*v20230301.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 Str](ctx context.Context, remote *S, priorState AttributeGetter, p path.Path) (types.String, diag.Diagnostics)

func ToStringPointer added in v0.2.0

func ToStringPointer[In Str, Out Str](str *In) *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

type Str added in v0.2.0

Jump to

Keyboard shortcuts

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