seeder

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 20 Imported by: 4

README

strategy-rest-seeder

WIP

Go Report Card

Executes a series of instructions against an endpoint using a specified authentication on a given strategy.

Problem space

Often we are faced with external products/services either self-hosted or SaaS where they require some level of configuration this often happens at CI (deploy) time, or on continous basis.

A complete definition contains an auth map and a seed map, you will

Auth

Is a map of authentication objects used by each action respectively.

ouath1:
  type: OAuthClientCredentials
  username: randClientIdOrUsernameForBasicAuth
  password: randClientSecret
  oauth:
    serverUrl: http://localhost:8080/token
    scopes:
      - https://www.some-api-provider.com/scopes-example1
    endpointParams:
      foo:
        - bar
        - baz
  httpHeaders:
    X-Foo: bar
basic1:
  type: BasicAuth
  username: randClientIdOrUsernameForBasicAuth
  password: randClientSecret
  httpHeaders:
    X-Foo: bar

Strategy

Strategy is a setting against which to perform one or more rest calls to ensure an idempotent update.

The top level seed can contain multiple blocks of the below type - RestAction

# the name of the Action is the property itself 
# should conform to YAML language specifications
find-put-post-not-found-id:
  endpoint: https://postman-echo.com
  strategy: FIND/PUT/POST
  getEndpointSuffix: /get?json=emtpy&notfound=bar
  postEndpointSuffix: /post
  findByJsonPathExpr: "$.array[?(@.name=='fubar')].id"
  authMapRef: ouath1
  payloadTemplate: |
    { "value": "$foo" }
  variables:
    foo: bar
  # RunTime Vars are captured from a PUT or POST and can be used further down the strategy tree
  runtimeVars:
    someId: "$.array[?(@.name=='fubar')].id"

Each Strategy option is defined below, and can be extended.

GET/POST

FindPostStrategyFunc strategy calls a GET endpoint and if item FOUND it does NOT do a POST this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

FIND/POST

FindPostStrategyFunc strategy calls a GET endpoint and if item FOUND it does NOT do a POST this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

PUT/POST

PutPostStrategyFunc is useful when the resource is created a user specified Id the PUT endpoint DOES NOT support a creation of the resource. PUT should throw a 4XX for the POST fallback to take effect

GET/PUT/POST

GetPutPostStrategyFunc known ID and only know a name or other indicator the pathExpression must not evaluate to an empty string in order to for the PUT to be called else POST will be called as item was not present.

FIND/PUT/POST

FindPutPostStrategyFunc is useful when the resource Id is unknown i.e. handled by the system. providing a pathExpression will evaluate the response. the pathExpression must not evaluate to an empty string in order to for the PUT to be called else POST will be called as item was not present

FIND/PATCH/POST

FindPutPatchStrategyFunc is the same as FindPutPostStrategyFunc but uses PATCH instead of PUT

FIND/DELETE
FIND/DELETE/POST

FindDeletePostStrategyFunc is useful for when you cannot update a resource but it can be safely destroyed an recreated

PUT

Rest Action

Rest Action is the individual action that gets made for each strategy.

endpoint

Endpoint is the baseUrl for the action

strategy

strategy identifier - see strategies e.g. FIND/PUT/POST

suffixes

Each Method called as part the restAction can specify a suffix.

This is useful for non standard or non Richardson Maturity Model Level 2+ compliant endpoints.

getEndpointSuffix

suffix to apply to the GET endpoint in FIND or GET e.g.: /get?json=provided&valid=true

postEndpointSuffix

suffix to apply to the POST endpoint

putEndpointSuffix

suffix to apply to the PUT endpoint

patchEndpointSuffix

suffix to apply to the PATCH endpoint

findByJsonPathExpr

Specifies the JSONPathExpression to apply to returned response, JSONPath as specified here with additional operators and functions defined here e.g.: $.array[?(@.name=='fubar')].id

authMapRef

The auth object to use for the requests in this RestAction, see auth for more details.

payloadTemplate

JSON formatted string.

HAS TO BE VALID JSON

e.g.:

payloadTemplate: |
  {
    "value": "$foo"
  }
variables

Variables are replaced in payloads in memory, using both environment variables and inject Vars from variables.

e.g.:

variables: 
  foo: bar
  bar: bazquz
runtimeVars

still WiP

RunTime Vars are captured from a PUT or POST and can be used further down the strategy tree on a separate Action. if a match is found it is exposed via a special prefix #

e.g.:

runtimeVars:
  actionOneId: "$.id"
# the name of the action
action1:
  endpoint: https://postman-echo.com
  strategy: FIND/PUT/POST
  getEndpointSuffix: /get?json=provided&valid=true
  postEndpointSuffix: /post
  putEndpointSuffix: /put
  findByJsonPathExpr: "$.array[?(@.name=='fubar')].id"
  authMapRef: ouath1
  payloadTemplate: |
      {
      "value": "$foo"
      }
  variables:
      foo: bar
  runtimeVars:
      actionOneId: "$.id"
action2: 
  endpoint: https://postman-echo.com
  strategy: FIND/PUT/POST
  getEndpointSuffix: /get?json=provided&valid=true
  postEndpointSuffix: /post
  putEndpointSuffix: /put
  findByJsonPathExpr: "$.array[?(@.name=='fubar')].id"
  authMapRef: ouath1
  payloadTemplate: |
      {
      "value": "$foo"
      "action1Id": "#{actionOneId}"
      }
  variables:
      foo: bazqux
  runtimeVars:
      someId: "$.array[?(@.name=='fubar')].id"

Contribution

...

Todo fill me out

...

standard go styling and contribution guide lines

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v0.10.0

func Bool(v bool) *bool

Bool returns a pointer value for the bool value passed in.

func Byte added in v0.10.0

func Byte(v byte) *byte

Byte returns a pointer value for the byte value passed in.

func FindDeletePostStrategyFunc

func FindDeletePostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

FindDeletePostStrategyFunc is useful for when you cannot update a resource but it can be safely destroyed an recreated

func FindPatchPostStrategyFunc

func FindPatchPostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

FindPatchPostStrategyFunc same as FindPutPostStrategyFunc but uses PATCH instead of PUT

func FindPostStrategyFunc

func FindPostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

FindPostStrategyFunc strategy calls a GET endpoint and expects a list of items to match against a FilterPathExpre and if item ***FOUND*** it does _NOT_ do a ***POST*** this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

func FindPutPostStrategyFunc

func FindPutPostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

FindPutPostStrategyFunc is useful when the resource Id is unknown i.e. handled by the system. providing a pathExpression will evaluate the response. the pathExpression must not evaluate to an empty string in order to for the PUT to be called else POST will be called as item was not present

func GetPostStrategyFunc

func GetPostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

GetPostStrategyFunc strategy calls a GET endpoint by an ID and if item ***FOUND*** it does _NOT_ do a ***POST*** this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

func GetPutPostStrategyFunc

func GetPutPostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

GetPutPostStrategyFunc known ID and only know a name or other indicator the pathExpression must not evaluate to an empty string in order to for the PUT to be called else POST will be called as item was not present

func Int added in v0.10.0

func Int(v int) *int

Int returns a pointer value for the int value passed in.

func NewAuth added in v0.10.0

func NewAuth(am AuthMap) *actionAuthMap

func NewClientCredentialsGrant added in v0.10.0

func NewClientCredentialsGrant(v AuthConfig) *clientcredentials.Config

func NewPasswordCredentialsGrant added in v0.10.0

func NewPasswordCredentialsGrant(v AuthConfig) *passwordGrantConfig

func PutPostStrategyFunc

func PutPostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

PutPostStrategyFunc is useful when the resource is created a user specified Id the PUT endpoint DOES NOT support a creation of the resource. PUT should throw a 4XX for the POST fallback to take effect

func PutStrategyFunc

func PutStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error

PutStrategyFunc calls a PUT endpoint fails if an error occurs useful when there is a known Id of a resource and PUT supports creation

func String added in v0.10.0

func String(v string) *string

String returns a pointer value for the string value passed in.

Types

type Action added in v0.10.0

type Action struct {
	Name                 string  `yaml:"name" json:"name"`
	Strategy             string  `yaml:"strategy" json:"strategy"`
	Order                *int    `yaml:"order,omitempty" json:"order,omitempty"`
	Endpoint             string  `yaml:"endpoint" json:"endpoint"`
	GetEndpointSuffix    *string `yaml:"getEndpointSuffix,omitempty" json:"getEndpointSuffix,omitempty"`
	PostEndpointSuffix   *string `yaml:"postEndpointSuffix,omitempty" json:"postEndpointSuffix,omitempty"`
	PatchEndpointSuffix  *string `yaml:"patchEndpointSuffix,omitempty" json:"patchEndpointSuffix,omitempty"`
	PutEndpointSuffix    *string `yaml:"putEndpointSuffix,omitempty" json:"putEndpointSuffix,omitempty"`
	DeleteEndpointSuffix *string `yaml:"deleteEndpointSuffix,omitempty" json:"deleteEndpointSuffix,omitempty"`
	FindByJsonPathExpr   string  `yaml:"findByJsonPathExpr,omitempty" json:"findByJsonPathExpr,omitempty"`
	PayloadTemplate      string  `yaml:"payloadTemplate" json:"payloadTemplate"`
	PatchPayloadTemplate string  `yaml:"patchPayloadTemplate,omitempty" json:"patchPayloadTemplate,omitempty"`
	// +kubebuilder:pruning:PreserveUnknownFields
	RuntimeVars map[string]string `yaml:"runtimeVars,omitempty" json:"runtimeVars,omitempty"`
	AuthMapRef  string            `yaml:"authMapRef" json:"authMapRef"`
	// +kubebuilder:pruning:PreserveUnknownFields
	HttpHeaders *map[string]string `yaml:"httpHeaders,omitempty" json:"httpHeaders,omitempty"`
	// +kubebuilder:pruning:PreserveUnknownFields
	// +kubebuilder:validation:Schemaless
	// +kubebuilder:validation:Optional
	Variables KvMapVarsAny `yaml:"variables,omitempty" json:"variables,omitempty"`
	// contains filtered or unexported fields
}

+k8s:deepcopy-gen=true +kubebuilder:object:generate=true

Action defines the single action to make agains an endpoint and selecting a strategy

Endpoint is the base url to make the requests against GetEndpointSuffix can be used to specify a direct ID or query params PostEndpointSuffix RuntimeVars should include a Json Path Expression eg. myRuntimeVar: "$.bar"

func (*Action) DeepCopy added in v0.10.0

func (in *Action) DeepCopy() *Action

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Action.

func (*Action) DeepCopyInto added in v0.10.0

func (in *Action) DeepCopyInto(out *Action)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Action) WithHeader added in v0.10.0

func (a *Action) WithHeader() *Action

WithHeader allows the overwrite of default Accept and Content-Type headers both default to `application/json` and adding additional header params on per Action basis. NOTE: each rest call inside the action will inherit the same header

func (*Action) WithName added in v0.10.0

func (a *Action) WithName(name string) *Action

type AuthConfig added in v0.10.0

type AuthConfig struct {
	Name string `yaml:"name" json:"name"`
	// AuthStrategyType must be specified
	// and conform to the type's enum
	AuthStrategy AuthType `yaml:"type" json:"type"`
	// Username must be specified with all AuthTypes
	// will be ignored for CustomToken
	// an empty string can be provided in that case
	Username string `yaml:"username" json:"username"`
	// Password will be used as client secret in the oauth flows
	// and in basic flow as well as the StaticToken value in the header.
	//
	// Can be provided in a configmanager https://github.com/dnitsch/configmanager#config-tokens format
	Password    string       `yaml:"password" json:"password"`
	OAuth       *ConfigOAuth `yaml:"oauth,omitempty" json:"oauth,omitempty"`
	CustomToken *CustomToken `yaml:"custom,omitempty" json:"custom,omitempty"`
}

+k8s:deepcopy-gen=true +kubebuilder:object:generate=true Auth holds the auth strategy for all Seeders

func (*AuthConfig) DeepCopy added in v0.10.0

func (in *AuthConfig) DeepCopy() *AuthConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthConfig.

func (*AuthConfig) DeepCopyInto added in v0.10.0

func (in *AuthConfig) DeepCopyInto(out *AuthConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type AuthMap added in v0.10.0

type AuthMap map[string]AuthConfig

+k8s:deepcopy-gen=true +kubebuilder:object:generate=true

func (AuthMap) DeepCopy added in v0.10.0

func (in AuthMap) DeepCopy() AuthMap

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthMap.

func (AuthMap) DeepCopyInto added in v0.10.0

func (in AuthMap) DeepCopyInto(out *AuthMap)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type AuthType added in v0.10.0

type AuthType string

+kubebuilder:validation:Enum=NoAuth;BasicAuth;OAuthClientCredentials;OAuthPassCredentials;CustomToToken;StaticToken AuthType specifies the type of authentication to perform currently only a single authType per instance is allowed

const (
	NoAuth        AuthType = "NoAuth"
	Basic         AuthType = "BasicAuth"
	OAuth         AuthType = "OAuthClientCredentials"
	OAuthPassword AuthType = "OAuthPassCredentials"
	CustomToToken AuthType = "CustomToToken"
	StaticToken   AuthType = "StaticToken"
)

type CMRetrieve added in v0.12.0

type CMRetrieve interface {
	RetrieveWithInputReplaced(input string, config generator.GenVarsConfig) (string, error)
}

type CapturedRuntimeVars added in v0.11.4

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

Runtime vars captured by JSON path expression from the response

type Client added in v0.10.0

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

type ConfigOAuth added in v0.10.0

type ConfigOAuth struct {
	ServerUrl string   `yaml:"serverUrl" json:"serverUrl"`
	Scopes    []string `yaml:"scopes" json:"scopes"`
	// +kubebuilder:pruning:PreserveUnknownFields
	EndpointParams          map[string][]string `yaml:"endpointParams" json:"endpointParams"`
	OAuthSendParamsInHeader bool                `yaml:"oAuthSendParamsInHeader" json:"oAuthSendParamsInHeader"`
	// for grant_type=password use these for the addition RO auth
	ResourceOwnerUser     *string `yaml:"resourceOwnerUser,omitempty" json:"resourceOwnerUser,omitempty"`
	ResourceOwnerPassword *string `yaml:"resourceOwnerPass,omitempty" json:"resourceOwnerPass,omitempty"`
}

func (*ConfigOAuth) DeepCopy added in v0.10.0

func (in *ConfigOAuth) DeepCopy() *ConfigOAuth

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigOAuth.

func (*ConfigOAuth) DeepCopyInto added in v0.10.0

func (in *ConfigOAuth) DeepCopyInto(out *ConfigOAuth)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type CustomFlowAuth added in v0.10.0

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

func NewCustomFlowAuth added in v0.10.0

func NewCustomFlowAuth() *CustomFlowAuth

func (*CustomFlowAuth) Token added in v0.10.0

NOTE: for oauth an basicAuthToToken it might make sense to build a in-memory map of tokens to strategy name

func (*CustomFlowAuth) WithAuthMap added in v0.10.0

func (cfa *CustomFlowAuth) WithAuthMap(v KvMapVarsAny) *CustomFlowAuth

func (*CustomFlowAuth) WithAuthUrl added in v0.10.0

func (cfa *CustomFlowAuth) WithAuthUrl(v string) *CustomFlowAuth

func (*CustomFlowAuth) WithHeaderKey added in v0.10.0

func (cfa *CustomFlowAuth) WithHeaderKey(v string) *CustomFlowAuth

WithHeaderKey overwrites the detault `Authorization`

func (*CustomFlowAuth) WithResponseKey added in v0.10.0

func (cfa *CustomFlowAuth) WithResponseKey(v string) *CustomFlowAuth

WithResponseKey overwrites the default "$.access_token"

func (*CustomFlowAuth) WithSendInHeader added in v0.10.0

func (cfa *CustomFlowAuth) WithSendInHeader(v bool) *CustomFlowAuth

WithSendInHeader sends custom request in the header

as opposed to a in url encoded form in body POST

func (*CustomFlowAuth) WithTokenPrefix added in v0.10.0

func (cfa *CustomFlowAuth) WithTokenPrefix(v string) *CustomFlowAuth

WithTokenPrefix overwrites the detault `Bearer`

type CustomToken added in v0.10.0

type CustomToken struct {
	// Url to use to POST the customRequest
	AuthUrl string `yaml:"authUrl" json:"authUrl"`
	// +kubebuilder:pruning:PreserveUnknownFields
	// +kubebuilder:validation:Schemaless
	//
	// holds the K/V credential pair. e.g.
	//
	// email: some@one.com
	// password: pass123
	// id: 12312345
	//
	// will post this body or send in header params that payload
	CustomAuthMap KvMapVarsAny `yaml:"credential" json:"credential"`
	// whether to send the values in the header as params
	// defaults to false and CustomAuthMap
	// is posted in the body as json post
	SendInHeader bool `yaml:"inHeader,omitempty" json:"inHeader,omitempty"`
	// +kubebuilder:default="$.access_token"
	// JSONPath expression to use to get the token from response
	//
	// e.g. "$.token"
	//
	// empty will take the entire response as the token - raw response must be string
	ResponseKey string `yaml:"responseKey" json:"responseKey" `
	// +kubebuilder:default=Authorization
	// if omitted `Authorization` will be used
	// Could be X-API-Token etc..
	HeaderKey string `yaml:"headerKey" json:"headerKey"`
	// +kubebuilder:default=Bearer
	// Token prefix - if omitted Bearer will be used
	// e.g. Admin ==> `Authorization: "Admin [TOKEN]"`
	TokenPrefix string `yaml:"tokenPrefix" json:"tokenPrefix"`
}

+k8s:deepcopy-gen=true +kubebuilder:object:generate=true CustomToken stores the required data to call and process custom auth Endpoints returning a token. the token will need to be extracted from the response it will then need adding to subsequent requests in the header under specified key and in specified format

func (*CustomToken) DeepCopy added in v0.10.0

func (in *CustomToken) DeepCopy() *CustomToken

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomToken.

func (*CustomToken) DeepCopyInto added in v0.10.0

func (in *CustomToken) DeepCopyInto(out *CustomToken)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type CustomTokenResponse added in v0.10.0

type CustomTokenResponse struct {
	HeaderKey   string
	TokenPrefix string
	TokenValue  string
}

type Diagnostic added in v0.10.0

type Diagnostic struct {
	Status          int
	Name            string
	Message         string
	HostPathMethod  string
	ProceedFallback bool
	IsFatal         bool
}

func (*Diagnostic) Error added in v0.10.0

func (d *Diagnostic) Error() string

func (*Diagnostic) WithIsFatal added in v0.10.0

func (d *Diagnostic) WithIsFatal(v bool) *Diagnostic

func (*Diagnostic) WithMessage added in v0.10.0

func (d *Diagnostic) WithMessage(m string) *Diagnostic

func (*Diagnostic) WithProceedFallback added in v0.10.0

func (d *Diagnostic) WithProceedFallback(v bool) *Diagnostic

func (*Diagnostic) WithStatus added in v0.10.0

func (d *Diagnostic) WithStatus(s int) *Diagnostic

type KvMapVarsAny added in v0.10.0

type KvMapVarsAny map[string]any

+kubebuilder:object:generate=false +k8s:deepcopy-gen=false

NOTE: currently need to generate the below functions manually To allow for both integer or string in x-kubernetes unknown fields

func (*KvMapVarsAny) DeepCopy added in v0.10.0

func (in *KvMapVarsAny) DeepCopy() *KvMapVarsAny

func (*KvMapVarsAny) DeepCopyInto added in v0.10.0

func (in *KvMapVarsAny) DeepCopyInto(out *KvMapVarsAny)

type SeederImpl added in v0.10.0

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

func NewSeederImpl added in v0.10.0

func NewSeederImpl(log log.Loggeriface) *SeederImpl

func (*SeederImpl) FindDeletePost added in v0.10.0

func (r *SeederImpl) FindDeletePost(ctx context.Context, action *Action) error

FindDeletePost

func (*SeederImpl) FindPatchPost added in v0.10.0

func (r *SeederImpl) FindPatchPost(ctx context.Context, action *Action) error

FindPatchPost is same as FindPutPost strategy but uses PATCH

func (*SeederImpl) FindPathByExpression added in v0.10.0

func (r *SeederImpl) FindPathByExpression(resp []byte, pathExpression string) (string, error)

func (*SeederImpl) FindPost added in v0.10.0

func (r *SeederImpl) FindPost(ctx context.Context, action *Action) error

FindPost strategy calls a GET endpoint and if item ***FOUND it does NOT do a POST*** this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

func (*SeederImpl) FindPutPost added in v0.10.0

func (r *SeederImpl) FindPutPost(ctx context.Context, action *Action) error

FindPutPost strategy gets an item either by specifying a known ID in the endpoint suffix or by pathExpression. Get can look for a response in an array or in a single response object. once a single item that matches is found and the relevant ID is extracted it will do a PUT else it will do a POST as the item can be created

func (*SeederImpl) GetPost added in v0.10.0

func (r *SeederImpl) GetPost(ctx context.Context, action *Action) error

GetPost strategy calls a GET endpoint and if item ***FOUND it does NOT do a POST*** this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

func (*SeederImpl) GetPutPost added in v0.10.0

func (r *SeederImpl) GetPutPost(ctx context.Context, action *Action) error

GetPutPost strategy gets an item by specifying a known ID in the endpoint suffix If a non error or non empty response is found it will do a PUT else it will do a POST as the item can be created

func (*SeederImpl) Put added in v0.10.0

func (r *SeederImpl) Put(ctx context.Context, action *Action) error

Put strategy calls a PUT endpoint if standards compliant this should be an idempotent operation

func (*SeederImpl) PutPost added in v0.10.0

func (r *SeederImpl) PutPost(ctx context.Context, action *Action) error

Put strategy calls a PUT endpoint if standards compliant this should be an idempotent operation

func (*SeederImpl) RuntimeVars added in v0.10.0

func (r *SeederImpl) RuntimeVars() map[string]any

func (*SeederImpl) SetRuntimeVar added in v0.10.0

func (r *SeederImpl) SetRuntimeVar(key string, val any)

func (*SeederImpl) TemplatePayload added in v0.10.0

func (r *SeederImpl) TemplatePayload(payload string, vars KvMapVarsAny) string

TemplatePayload parses input payload and replaces all $var ${var} with existing global env variable as well as injected from inside RestAction into the local context

func (*SeederImpl) WithAuth added in v0.10.0

func (r *SeederImpl) WithAuth(a AuthMap) *SeederImpl

WithAuth assigns auth options used by AuthMapRef within the actions

func (*SeederImpl) WithClient added in v0.10.0

func (r *SeederImpl) WithClient(c Client) *SeederImpl

type Seeders added in v0.10.0

type Seeders map[string]Action

+k8s:deepcopy-gen=true +kubebuilder:object:generate=true

func (Seeders) DeepCopy added in v0.10.0

func (in Seeders) DeepCopy() Seeders

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Seeders.

func (Seeders) DeepCopyInto added in v0.10.0

func (in Seeders) DeepCopyInto(out *Seeders)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Status added in v0.10.0

type Status int
const (
	StatusFatal Status = iota
	StatusRetryable
)

type StrategyConfig added in v0.10.0

type StrategyConfig struct {
	AuthConfig AuthMap `yaml:"auth" json:"auth"`
	Seeders    Seeders `yaml:"seed" json:"seed"`
}

+kubebuilder:object:generate=true +k8s:deepcopy-gen=true StrategyConfig defines top level Spec

func (*StrategyConfig) DeepCopy added in v0.10.0

func (in *StrategyConfig) DeepCopy() *StrategyConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StrategyConfig.

func (*StrategyConfig) DeepCopyInto added in v0.10.0

func (in *StrategyConfig) DeepCopyInto(out *StrategyConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type StrategyFunc

type StrategyFunc func(ctx context.Context, action *Action, rest *SeederImpl) error

type StrategyRestSeeder

type StrategyRestSeeder struct {
	Strategy map[StrategyType]StrategyFunc
	// contains filtered or unexported fields
}

func New

New initializes a default StrategySeeder with error log level and os.StdErr as log writer uses standard http.Client as rest client for rest SeederImplementation

func (*StrategyRestSeeder) Execute

func (s *StrategyRestSeeder) Execute(ctx context.Context) error

Execute the built actions list

func (*StrategyRestSeeder) WithActions

func (s *StrategyRestSeeder) WithActions(actions map[string]Action) *StrategyRestSeeder

WithActions builds the actions list empty actions will result in no restActions executing

func (*StrategyRestSeeder) WithActionsList added in v0.12.0

func (s *StrategyRestSeeder) WithActionsList(actions []Action) *StrategyRestSeeder

WithActionsList same as WithActions but accepts a list

func (*StrategyRestSeeder) WithAuth

WithAuth adds the AuthLogic to the entire seeder NOTE: might make more sense to have a per RestAction authTemplate (might make it very inefficient)

func (*StrategyRestSeeder) WithAuthFromList added in v0.12.0

func (s *StrategyRestSeeder) WithAuthFromList(ra []AuthConfig) *StrategyRestSeeder

WithAuthFromList same as WithAuth but accepts a list

func (*StrategyRestSeeder) WithConfigManager added in v0.12.0

func (s *StrategyRestSeeder) WithConfigManager(configManager CMRetrieve) *StrategyRestSeeder

WithConfigManager overwrites the default ConfigManager

func (*StrategyRestSeeder) WithConfigManagerOptions added in v0.12.0

func (s *StrategyRestSeeder) WithConfigManagerOptions(configManagerOptions *generator.GenVarsConfig) *StrategyRestSeeder

WithConfigManagerOptions overwrites the default ConfigManager Options

func (*StrategyRestSeeder) WithRestClient

func (s *StrategyRestSeeder) WithRestClient(rc Client) *StrategyRestSeeder

WithRestClient overwrites the default RestClient

type StrategyType

type StrategyType string
const (
	GET_POST         StrategyType = "GET/POST"
	FIND_POST        StrategyType = "FIND/POST"
	PUT_POST         StrategyType = "PUT/POST"
	GET_PUT_POST     StrategyType = "GET/PUT/POST"
	FIND_PUT_POST    StrategyType = "FIND/PUT/POST"
	FIND_PATCH_POST  StrategyType = "FIND/PATCH/POST"
	FIND_DELETE      StrategyType = "FIND/DELETE"
	FIND_DELETE_POST StrategyType = "FIND/DELETE/POST"
	PUT              StrategyType = "PUT"
)

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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