settings

package
v1.71.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProdTokenURL   = "https://sso.dynatrace.com/sso/oauth2/token"
	SprintTokenURL = "https://sso-sprint.dynatracelabs.com/sso/oauth2/token"
	DevTokenURL    = "https://sso-dev.dynatracelabs.com/sso/oauth2/token"

	ProdIAMEndpointURL   = "https://api.dynatrace.com"
	SprintIAMEndpointURL = "https://api-hardening.internal.dynatracelabs.com"
	DevIAMEndpointURL    = "https://api-dev.internal.dynatracelabs.com"
)
View Source
const ContextKeyStateConfig = ContextKey("state-config")
View Source
const DYNATRACE_DUPLICATE_HIJACK = "DYNATRACE_DUPLICATE_HIJACK"
View Source
const DYNATRACE_DUPLICATE_REJECT = "DYNATRACE_DUPLICATE_REJECT"
View Source
const VALUE_ALL = "ALL"

Variables

View Source
var ExportRunning = false
View Source
var LegacyLongDecode = func(id string) string {
	key := LegacyObjIDDecode(id)
	if len(key) == 0 {
		return key
	}
	uid, err := uuid.Parse(key)
	if err != nil {
		return err.Error()
	}
	result, err := UUIDToLong(uid)
	if err != nil {
		return err.Error()
	}
	return fmt.Sprintf("%v", result)
}
View Source
var LegacyObjIDDecode = func(id string) string {
	objID := &ObjectID{ID: id}
	if e := objID.Decode(); e == nil && len(objID.Key) > 0 {
		return objID.Key
	}
	return ""
}

Functions

func ClearInsertAfter added in v1.53.0

func ClearInsertAfter(v any)

func ClearLegacyID

func ClearLegacyID(v any) *string

func Clone

func Clone[T Settings](v T) (T, error)

func FillDemoValues

func FillDemoValues(settings Settings) []string

func FindByName

func FindByName[T Settings](ctx context.Context, service RService[T], name string) (stub *api.Stub, err error)

func FromJSON

func FromJSON[T Settings](data []byte, v T) error

func GetFlawedReasons

func GetFlawedReasons(settings any) []string

func GetInsertAfter added in v1.53.0

func GetInsertAfter(settings Settings) *string

func GetInsertBefore added in v1.53.0

func GetInsertBefore(settings Settings) *string

func GetIntEnv added in v1.27.0

func GetIntEnv(name string, def, min, max int) int

func GetLegacyID

func GetLegacyID(v any) *string

func GetRestoreOnDelete added in v1.22.0

func GetRestoreOnDelete(v any) *string

func GetScope added in v1.19.0

func GetScope(settings Settings) string

func HasInsertAfter added in v1.54.1

func HasInsertAfter(settings Settings) bool

func HasInsertBefore added in v1.54.1

func HasInsertBefore(settings Settings) bool

func HijackDuplicate added in v1.23.0

func HijackDuplicate(resourceNames ...string) bool

func IsValidUUID

func IsValidUUID(u string) bool

func JoinID

func JoinID(id string, context string) string

func LegacyID

func LegacyID(id string) string

func Name

func Name(v any, id string) string

func NewSettings

func NewSettings[T Settings](service RService[T]) T

func Path

func Path(s string) func(args ...string) string

func ReadUTF

func ReadUTF(reader io.Reader) (string, error)

func RefersToMissingID added in v1.42.0

func RefersToMissingID(v any) bool

func RejectDuplicate added in v1.23.0

func RejectDuplicate(resourceNames ...string) bool

func SetID

func SetID(settings Settings, id string)

func SetInsertAfter added in v1.53.0

func SetInsertAfter(settings Settings, insertAfter string)

func SetInsertBefore added in v1.53.0

func SetInsertBefore(settings Settings, insertBefore string)

func SetLegacyID

func SetLegacyID(id string, converter func(string) string, v any)

func SetRestoreOnDelete added in v1.22.0

func SetRestoreOnDelete(restore string, v any)

func SetScope added in v1.19.0

func SetScope(settings Settings, scope string)

func SplitID

func SplitID(id string) (string, string, bool)

func SupportsFlawedReasons

func SupportsFlawedReasons(settings any) bool

func ToJSON

func ToJSON[T Settings](v T) ([]byte, error)

func UUIDToLong

func UUIDToLong(uid uuid.UUID) (int64, error)

func Validate

func Validate(settings Settings) []string

Types

type CRUDService

type CRUDService[T Settings] interface {
	List(ctx context.Context) (api.Stubs, error)
	Get(ctx context.Context, id string, v T) error
	SchemaID() string
	Create(ctx context.Context, v T) (*api.Stub, error)
	Update(ctx context.Context, id string, v T) error
	Delete(ctx context.Context, id string) error
}

func NewCRUDService

func NewCRUDService[T Settings](credentials *Credentials, schemaID string, options *ServiceOptions[T]) CRUDService[T]

type ContextKey added in v1.45.0

type ContextKey string

type Credentials

type Credentials struct {
	URL   string
	Token string
	IAM   struct {
		ClientID     string
		AccountID    string
		ClientSecret string
		TokenURL     string
		EndpointURL  string
	}
	Automation struct {
		ClientID       string
		ClientSecret   string
		TokenURL       string
		EnvironmentURL string
	}
	Cluster struct {
		URL   string
		Token string
	}
}

type DemoSettings

type DemoSettings interface {
	FillDemoValues() []string
}

type ErrorSettings

type ErrorSettings struct {
	Error error
}

func (*ErrorSettings) FillDemoValues

func (me *ErrorSettings) FillDemoValues() []string

func (*ErrorSettings) MarshalHCL

func (me *ErrorSettings) MarshalHCL(properties hcl.Properties) error

func (*ErrorSettings) Schema

func (me *ErrorSettings) Schema() map[string]*schema.Schema

func (*ErrorSettings) UnmarshalHCL

func (me *ErrorSettings) UnmarshalHCL(decoder hcl.Decoder) error

type GenericCRUDService

type GenericCRUDService[T Settings] struct {
	Service CRUDService[T]
}

func (*GenericCRUDService[T]) Create

func (me *GenericCRUDService[T]) Create(ctx context.Context, v Settings) (*api.Stub, error)

func (*GenericCRUDService[T]) Delete

func (me *GenericCRUDService[T]) Delete(ctx context.Context, id string) error

func (*GenericCRUDService[T]) Get

func (me *GenericCRUDService[T]) Get(ctx context.Context, id string, v Settings) error

func (*GenericCRUDService[T]) List

func (me *GenericCRUDService[T]) List(ctx context.Context) (api.Stubs, error)

func (*GenericCRUDService[T]) NoCache

func (me *GenericCRUDService[T]) NoCache() bool

func (*GenericCRUDService[T]) SchemaID

func (me *GenericCRUDService[T]) SchemaID() string

func (*GenericCRUDService[T]) Update

func (me *GenericCRUDService[T]) Update(ctx context.Context, id string, v Settings) error

func (*GenericCRUDService[T]) Validate

func (me *GenericCRUDService[T]) Validate(ctx context.Context, v Settings) error

type GenericRService

type GenericRService[T Settings] struct {
	Service RService[T]
}

func (*GenericRService[T]) Get

func (me *GenericRService[T]) Get(ctx context.Context, id string, v Settings) error

func (*GenericRService[T]) List

func (me *GenericRService[T]) List(ctx context.Context) (api.Stubs, error)

func (*GenericRService[T]) NoCache

func (me *GenericRService[T]) NoCache() bool

func (*GenericRService[T]) SchemaID

func (me *GenericRService[T]) SchemaID() string

type LegacyIDAware

type LegacyIDAware interface {
	LegacyID() func(id string) string
}

type ListIDCRUDService added in v1.66.0

type ListIDCRUDService[T Settings] interface {
	CRUDService[T]
	ListIDs(ctx context.Context) (api.Stubs, error)
}

type Loader

type Loader interface {
	Load(data []byte) error
}

type NoCacheService

type NoCacheService interface {
	NoCache() bool
}

type ObjectID

type ObjectID struct {
	Key   string `json:"key"`
	Scope struct {
		Class string `json:"class"`
		ID    string `json:"id"`
	} `json:"scope"`
	SchemaID string `json:"schemaID"`
	ID       string `json:"-"`
}

func (*ObjectID) Decode

func (me *ObjectID) Decode() error

func (*ObjectID) String

func (me *ObjectID) String() string

type RService

type RService[T Settings] interface {
	List(ctx context.Context) (api.Stubs, error)
	Get(ctx context.Context, id string, v T) error
	SchemaID() string
}

type RegexValidator

type RegexValidator interface {
	Validate() []string
}

type ScopeAware added in v1.19.0

type ScopeAware interface {
	SetScope(string)
	GetScope() string
}

type Service

type Service[T Settings] interface {
	List(ctx context.Context) (api.Stubs, error)
	Get(ctx context.Context, id string, v T) error
	Create(ctx context.Context, v T) (*api.Stub, error)
	Update(ctx context.Context, id string, v T) error
	Delete(ctx context.Context, id string) error
	Validate(ctx context.Context, v T) error
	SchemaID() string
}

func StaticService

func StaticService[T Settings](credentials *Credentials, schemaID string, url string, stub api.Stub) Service[T]

type ServiceOptions

type ServiceOptions[T Settings] struct {
	Get            func(args ...string) string
	List           func(args ...string) string
	CreateURL      func(v T) string
	ValidateURL    func(v T) string
	UpdateURL      func(id string, v T) string
	DeleteURL      func(id string) string
	Stubs          api.RecordStubs
	CompleteGet    func(ctx context.Context, client rest.Client, id string, v T) error
	CreateRetry    func(v T, err error) T
	OnAfterCreate  func(ctx context.Context, client rest.Client, stub *api.Stub) (*api.Stub, error)
	DeleteRetry    func(ctx context.Context, id string, err error) (bool, error)
	CreateConfirm  int
	OnChanged      func(context.Context, rest.Client, string, T) error
	OnBeforeUpdate func(id string, v T) error
	HasNoValidator bool
	Name           func(id string, v T) (string, error)
	HijackOnCreate func(ctx context.Context, err error, service RService[T], v T) (*api.Stub, error)
	Lock           func()
	Unlock         func()
	Duplicates     func(ctx context.Context, service RService[T], v T) (*api.Stub, error)
}

func DefaultServiceOptions

func DefaultServiceOptions[T Settings](basePath string) *ServiceOptions[T]

func (*ServiceOptions[T]) Hijack

func (me *ServiceOptions[T]) Hijack(fn func(ctx context.Context, err error, service RService[T], v T) (*api.Stub, error)) *ServiceOptions[T]

func (*ServiceOptions[T]) NoValidator

func (me *ServiceOptions[T]) NoValidator() *ServiceOptions[T]

func (*ServiceOptions[T]) WithAfterCreate added in v1.36.0

func (me *ServiceOptions[T]) WithAfterCreate(fn func(ctx context.Context, client rest.Client, stub *api.Stub) (*api.Stub, error)) *ServiceOptions[T]

func (*ServiceOptions[T]) WithCompleteGet added in v1.36.0

func (me *ServiceOptions[T]) WithCompleteGet(fn func(ctx context.Context, client rest.Client, id string, v T) error) *ServiceOptions[T]

func (*ServiceOptions[T]) WithCreateConfirm added in v1.22.0

func (me *ServiceOptions[T]) WithCreateConfirm(confirm int) *ServiceOptions[T]

func (*ServiceOptions[T]) WithCreateRetry

func (me *ServiceOptions[T]) WithCreateRetry(fn func(v T, err error) T) *ServiceOptions[T]

func (*ServiceOptions[T]) WithDeleteRetry

func (me *ServiceOptions[T]) WithDeleteRetry(deleteRetry func(ctx context.Context, id string, err error) (bool, error)) *ServiceOptions[T]

func (*ServiceOptions[T]) WithDuplicates added in v1.23.0

func (me *ServiceOptions[T]) WithDuplicates(fnDuplicates func(ctx context.Context, service RService[T], v T) (*api.Stub, error)) *ServiceOptions[T]

func (*ServiceOptions[T]) WithMutex

func (me *ServiceOptions[T]) WithMutex(lock func(), unlock func()) *ServiceOptions[T]

func (*ServiceOptions[T]) WithOnBeforeUpdate

func (me *ServiceOptions[T]) WithOnBeforeUpdate(fn func(id string, v T) error) *ServiceOptions[T]

func (*ServiceOptions[T]) WithOnChanged

func (me *ServiceOptions[T]) WithOnChanged(onChanged func(context.Context, rest.Client, string, T) error) *ServiceOptions[T]

func (*ServiceOptions[T]) WithStubs

func (me *ServiceOptions[T]) WithStubs(stubs api.RecordStubs) *ServiceOptions[T]

type Settings

type Settings interface {
	MarshalHCL(hcl.Properties) error
	UnmarshalHCL(hcl.Decoder) error
	Schema() map[string]*schema.Schema
}

type Storer

type Storer interface {
	Store() ([]byte, error)
}

type Validator

type Validator[T Settings] interface {
	Validate(ctx context.Context, v T) error
}

Directories

Path Synopsis
services

Jump to

Keyboard shortcuts

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