serializer

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ToID provides common mappings from strings to domain.TargetState, e.g. for dogus.

Functions

func ConvertComponents

func ConvertComponents(components []TargetComponent) ([]domain.Component, error)

ConvertComponents takes a slice of TargetComponent and returns a new slice with their DTO equivalent.

func ConvertDogus

func ConvertDogus(dogus []TargetDogu) ([]domain.Dogu, error)

func ToDomainTargetState

func ToDomainTargetState(stateString string) (domain.TargetState, error)

ToDomainTargetState maps a string to a domain.TargetState or returns an error if this is not possible.

func ToSerializerTargetState

func ToSerializerTargetState(domainState domain.TargetState) (string, error)

ToSerializerTargetState maps a domain.TargetState to a string or returns an error if this is not possible.

Types

type BlueprintApi

type BlueprintApi string

BlueprintApi represents an API version for a specific serialized format of domain.Blueprint.

const (
	// V1 is the API version of the BlueprintV1 json format of the classic-CES and which is used with the cesapp.
	V1 BlueprintApi = "v1"
	// V2 is the API version of the BlueprintV2 json format used in the MultiNode-CES inside kubernetes, e.g. for Blueprint-CRs.
	V2 BlueprintApi = "v2"
)

type BlueprintMaskApi

type BlueprintMaskApi string

BlueprintMaskApi represents an API version for a specific serialized format of domain.BlueprintMask.

const (
	// BlueprintMaskAPIV1 is the API version used by the Classic-CES and the MultiNode-CES as it has no environment specific fields.
	BlueprintMaskAPIV1 BlueprintMaskApi = "v1"
)

type BlueprintMaskSerializer

type BlueprintMaskSerializer interface {
	// Serialize translates a domain.BlueprintMask into a string representation.
	// Returns an error if the blueprint cannot be deserialized for any reason.
	Serialize(mask domain.BlueprintMask) (string, error)

	// Deserialize translates a string into a domain.BlueprintMask.
	// Returns a domain.InvalidBlueprintError if the given string has syntax or simple semantic errors.
	Deserialize(rawBlueprintMask string) (domain.BlueprintMask, error)
}

type BlueprintSerializer

type BlueprintSerializer interface {
	// Serialize translates a domain.Blueprint into a string representation.
	// Returns an error if the blueprint cannot be deserialized for any reason.
	Serialize(blueprint domain.Blueprint) (string, error)

	// Deserialize translates a string into a domain.Blueprint.
	// Returns a domain.InvalidBlueprintError if the given string has syntax or simple semantic errors.
	Deserialize(rawBlueprint string) (domain.Blueprint, error)
}

BlueprintSerializer can serialize a domain.Blueprint to a string. The format is implementation specific. Add a new implementation if you want either another format, e.g. json, xml, or if you change your specific structure in that format.

type GeneralBlueprint

type GeneralBlueprint struct {
	// API is used to distinguish between different versions of the used API and impacts directly the interpretation of
	// this blueprint. Must not be empty.
	//
	// This field MUST NOT be MODIFIED or REMOVED because the API is paramount for distinguishing between different
	// blueprint version implementations.
	API BlueprintApi `json:"blueprintApi"`
}

GeneralBlueprint defines the minimum set to parse the blueprint API version string in order to select the right blueprint handling strategy. This is necessary in order to accommodate maximal changes in different blueprint API versions.

type GeneralBlueprintMask

type GeneralBlueprintMask struct {
	// API is used to distinguish between different versions of the used API and impacts directly the interpretation of
	// this blueprint mask. Must not be empty.
	//
	// This field MUST NOT be MODIFIED or REMOVED because the API is paramount for distinguishing between different
	// blueprint mask version implementations.
	API BlueprintMaskApi `json:"blueprintMaskApi"`
}

GeneralBlueprintMask defines the minimum set to parse the blueprint mask API version string in order to select the right blueprint mask handling strategy. This is necessary in order to accommodate maximal changes in different blueprint mask API versions.

type PlatformConfig

type PlatformConfig struct {
	ResourceConfig     ResourceConfig     `json:"resource,omitempty"`
	ReverseProxyConfig ReverseProxyConfig `json:"reverseProxy,omitempty"`
}

type ResourceConfig

type ResourceConfig struct {
	MinVolumeSize string `json:"minVolumeSize,omitempty"`
}

type ReverseProxyConfig

type ReverseProxyConfig struct {
	MaxBodySize      string `json:"maxBodySize,omitempty"`
	RewriteTarget    string `json:"rewriteTarget,omitempty"`
	AdditionalConfig string `json:"additionalConfig,omitempty"`
}

type TargetComponent

type TargetComponent struct {
	// Name defines the name of the component including its distribution namespace, f. i. "k8s/k8s-dogu-operator". Must not be empty.
	Name string `json:"name"`
	// Version defines the version of the component that is to be installed. Must not be empty if the targetState is "present";
	// otherwise it is optional and is not going to be interpreted.
	Version string `json:"version"`
	// TargetState defines a state of installation of this component. Optional field, but defaults to "TargetStatePresent"
	TargetState string `json:"targetState"`
	// DeployConfig defines a generic property map for the component configuration. This field is optional.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +kubebuilder:validation:Schemaless
	DeployConfig map[string]interface{} `json:"deployConfig,omitempty"`
}

func ConvertToComponentDTOs

func ConvertToComponentDTOs(components []domain.Component) ([]TargetComponent, error)

ConvertToComponentDTOs takes a slice of Component DTOs and returns a new slice with their domain equivalent.

type TargetDogu

type TargetDogu struct {
	// Name defines the name of the dogu including its namespace, f. i. "official/nginx". Must not be empty.
	Name string `json:"name"`
	// Version defines the version of the dogu that is to be installed. Must not be empty if the targetState is "present";
	// otherwise it is optional and is not going to be interpreted.
	Version string `json:"version"`
	// TargetState defines a state of installation of this dogu. Optional field, but defaults to "TargetStatePresent"
	TargetState    string         `json:"targetState"`
	PlatformConfig PlatformConfig `json:"platformConfig,omitempty"`
}

TargetDogu defines a Dogu, its version, and the installation state in which it is supposed to be after a blueprint was applied.

func ConvertToDoguDTOs

func ConvertToDoguDTOs(dogus []domain.Dogu) ([]TargetDogu, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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