helper

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DomainVar      = "domain"
	InsecureVar    = "insecure"
	TokenVar       = "token"
	PortVar        = "port"
	JWTProfileFile = "jwt_profile_file"
	JWTProfileJSON = "jwt_profile_json"
)
View Source
const (
	OrgIDVar = "org_id"
)

Variables

View Source
var (
	ImportOptionalOrgAttribute = NewImportAttribute(OrgIDVar, ConvertID, true)

	SemicolonPlaceholder = "__SEMICOLON__"
)
View Source
var (
	// ZitadelGeneratedIdPattern matches IDs like 123456789012345678
	// ZITADEL IDs have 18 digits
	ZitadelGeneratedIdPattern   = `\d{18}`
	ZitadelGeneratedIdOnlyRegex = regexp.MustCompile(fmt.Sprintf(`^%s$`, ZitadelGeneratedIdPattern))

	OrgIDResourceField = &schema.Schema{
		Type:        schema.TypeString,
		Optional:    true,
		Description: "ID of the organization",
		ForceNew:    true,
		ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics {
			_, err := ConvertID(i.(string))
			return diag.FromErr(err)
		},
	}

	ResourceIDDatasourceField = &schema.Schema{
		Type:        schema.TypeString,
		Required:    true,
		Description: "ID of the resource",
	}
	OrgIDDatasourceField = &schema.Schema{
		Type:        schema.TypeString,
		Optional:    true,
		Description: "ID of the organization",
	}
)

Functions

func ConvertBool added in v1.1.0

func ConvertBool(importValue string) (interface{}, error)

func ConvertEmpty

func ConvertEmpty(importValue string) (interface{}, error)

func ConvertID

func ConvertID(id string) (interface{}, error)

func ConvertJSON

func ConvertJSON(importValue string) (interface{}, error)

func ConvertNonEmpty

func ConvertNonEmpty(importValue string) (interface{}, error)

func CtxSetOrgID added in v1.0.2

func CtxSetOrgID(ctx context.Context, orgID string) context.Context

func CtxWithID added in v1.0.2

func CtxWithID(ctx context.Context, d *schema.ResourceData) context.Context

func CtxWithOrgID added in v1.0.2

func CtxWithOrgID(ctx context.Context, d *schema.ResourceData) context.Context

func DescriptionEnumValuesList

func DescriptionEnumValuesList(enum map[int32]string) string

func EnumValueMap

func EnumValueMap(enum map[int32]string) map[string]int32

func EnumValueValidation

func EnumValueValidation(ty string, checkValue interface{}, enumValues map[string]int32) diag.Diagnostics

func EnumValuesValidation

func EnumValuesValidation(ty string, checkValuesSet interface{}, enumValues map[string]int32) diag.Diagnostics

func GetAddAndDelete

func GetAddAndDelete(current []string, desired []string) ([]string, []string)

func GetAdminClient

func GetAdminClient(info *ClientInfo) (*admin.Client, error)

func GetID

func GetID(d *schema.ResourceData, idVar string) string

func GetManagementClient

func GetManagementClient(info *ClientInfo) (*management.Client, error)

func GetOkSetToStringSlice

func GetOkSetToStringSlice(d *schema.ResourceData, value string) []string

func GetStringFromAttr

func GetStringFromAttr(ctx context.Context, attrs map[string]attr.Value, key string) string

func IgnoreAlreadyExistsError

func IgnoreAlreadyExistsError(err error) error

func IgnoreIfNotFoundError

func IgnoreIfNotFoundError(err error) error

func IgnorePreconditionError

func IgnorePreconditionError(err error) error

func ImportIDValidationError

func ImportIDValidationError(givenID string, requiredKeys, optionalKeys []string, err error) error

ImportIDValidationError wraps err with a help message about the expected format if it is not nil

func ImportWithAttributes

func ImportWithAttributes(attrs ...importAttribute) *schema.ResourceImporter

func ImportWithEmptyID

func ImportWithEmptyID(attributes ...importAttribute) *schema.ResourceImporter

ImportWithEmptyID returns a ResourceImporter that does not use the first import string position value for the states SetID call. It uses a dummy value, instead.

func ImportWithID

func ImportWithID(idVar string, attributes ...importAttribute) *schema.ResourceImporter

ImportWithID is a convenience function that calls ImportWithAttributes. It returns a ResourceImporter that expects a ZITADEL ID number at the first import string position along with other given attributes. idVar is only relevant for the error message, the resources SetID function is called with first argument ID

func ImportWithIDAndOptionalOrg

func ImportWithIDAndOptionalOrg(idVar string, attributes ...importAttribute) *schema.ResourceImporter

ImportWithIDAndOptionalOrg is a convenience function that calls ImportWithID and passes an optional attribute for the org ID along with the other given attributes.

func ImportWithIDAndOptionalOrgAndSecret

func ImportWithIDAndOptionalOrgAndSecret(idVar, secretKey string) *schema.ResourceImporter

ImportWithIDAndOptionalOrgAndSecret is a convenience function that calls ImportWithIDAndOptionalOrg and passes an optional attribute for the secret var at secretKey.

func ImportWithIDAndOptionalSecret

func ImportWithIDAndOptionalSecret(idVar, secretKey string) *schema.ResourceImporter

ImportWithIDAndOptionalSecret is a convenience function that calls ImportWithID and passes an optional attribute for the secret var at secretKey.

func ImportWithOptionalOrg

func ImportWithOptionalOrg(attributes ...importAttribute) *schema.ResourceImporter

ImportWithOptionalOrg is a convenience function that calls ImportWithAttributes. It returns a ResourceImporter that accepts an optional organization id along with other given attributes

func InstanceFormFilePost

func InstanceFormFilePost(clientInfo *ClientInfo, endpoint, path string) diag.Diagnostics

func NewClientWithInterceptorFromKeyFile

func NewClientWithInterceptorFromKeyFile(issuer, keyPath string, scopes []string) (*http.Client, error)

func NewClientWithInterceptorFromKeyFileData

func NewClientWithInterceptorFromKeyFileData(issuer string, data []byte, scopes []string) (*http.Client, error)

func NewImportAttribute

func NewImportAttribute(key string, value ConvertStringFunc, optional bool) importAttribute

func OrgFormFilePost

func OrgFormFilePost(clientInfo *ClientInfo, endpoint, path, orgID string) diag.Diagnostics

func SetToStringSlice

func SetToStringSlice(set *schema.Set) []string

Types

type ClientInfo

type ClientInfo struct {
	Domain  string
	Issuer  string
	KeyPath string
	Data    []byte
	Options []zitadel.Option
}

func GetClientInfo

func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile string, jwtProfileJSON string, port string) (*ClientInfo, error)

type ConvertStringFunc

type ConvertStringFunc func(string) (interface{}, error)

type ImportAttributes

type ImportAttributes []importAttribute

func (ImportAttributes) Len

func (i ImportAttributes) Len() int

func (ImportAttributes) Less

func (i ImportAttributes) Less(j, k int) bool

Less makes the attributes sortable by putting the optional attributes to the end and the org id to the beginning of the optional attributes

func (ImportAttributes) Swap

func (i ImportAttributes) Swap(j, k int)

type Interceptor

type Interceptor struct {
	// contains filtered or unexported fields
}

func (Interceptor) RoundTrip

func (i Interceptor) RoundTrip(r *http.Request) (*http.Response, error)

type Stringified

type Stringified struct {
	Str string
}

func (*Stringified) String

func (s *Stringified) String() string

type Stringify

type Stringify interface {
	String() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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