schema

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSchema

func GenerateSchema(schemaType interface{}, url string) (string, error)

GenerateSchema takes the given schema type and builds a JSON Schema out of it if a URL is passed it will also add it as the $schema key, which is useful when defining a version of a Root Schema which will be available online.

func JSONSchema

func JSONSchema(version string) (string, error)

JSONSchema builds a JSON Schema based on the Root Schema and the given version this is helpful when mapping a validation error.

func Validate

func Validate(source string) error

Validate ensures that a given schema is Valid according to the Root Schema from the agent.

Types

type BundleSchema

type BundleSchema struct {
	DB         string   `json:"db_path,omitempty"`
	LocalFile  bool     `json:"local_file,omitempty"`
	Repository string   `json:"repository,omitempty"`
	Rootfs     string   `json:"rootfs_path,omitempty"`
	Targets    []string `json:"targets,omitempty"`
}

BundleSchema represents the bundle block which can be used in different places of the Kairos configuration. It is used to reference a bundle and its confguration.

type ElementalPartitions added in v0.1.3

type ElementalPartitions struct {
	OEM        *Partition `json:"oem,omitempty" mapstructure:"oem"`
	Recovery   *Partition `json:"recovery,omitempty" mapstructure:"recovery"`
	State      *Partition `json:"state,omitempty" mapstructure:"state"`
	Persistent *Partition `json:"persistent,omitempty" mapstructure:"persistent"`
}

type GrubOptionsSchema

type GrubOptionsSchema struct {
	DefaultFallback      string `json:"default_fallback,omitempty" description:"Sets default fallback logic"`
	DefaultMenuEntry     string `json:"default_menu_entry,omitempty" description:"Change GRUB menu entry"`
	ExtraActiveCmdline   string `json:"extra_active_cmdline,omitempty" description:"Additional Kernel option cmdline to apply just for active"`
	ExtraCmdline         string `json:"extra_cmdline,omitempty" description:"Additional Kernel option cmdline to apply"`
	ExtraPassiveCmdline  string `json:"extra_passive_cmdline,omitempty" description:"Additional Kernel option cmdline to apply just for passive"`
	ExtraRecoveryCmdline string `json:"extra_recovery_cmdline,omitempty" description:"Set additional boot commands when booting into recovery"`
	NextEntry            string `json:"next_entry,omitempty" description:"Set the next reboot entry."`
	SavedEntry           string `json:"saved_entry,omitempty" description:"Set the default boot entry."`
}

GrubOptionsSchema represents the grub options block which can be used in different places of the Kairos configuration. It is used to configure grub.

type Image added in v0.1.3

type Image struct {
	Size   uint   `json:"size,omitempty" mapstructure:"size"`
	Source string `json:"uri,omitempty" mapstructure:"uri"`
}

type InstallSchema

type InstallSchema struct {
	Auto                bool           `json:"auto,omitempty" description:"Set to true when installing without Pairing"`
	BindMounts          []string       `json:"bind_mounts,omitempty"`
	Bundles             []BundleSchema `json:"bundles,omitempty" description:"Add bundles in runtime"`
	NoFormat            bool           `json:"no_format,omitempty"`
	Device              string         `` /* 142-byte string literal not displayed */
	EphemeralMounts     []string       `json:"ephemeral_mounts,omitempty"`
	EncryptedPartitions []string       `json:"encrypted_partitions,omitempty"`
	Env                 []interface{}  `json:"env,omitempty"`
	GrubOptionsSchema   `json:"grub_options,omitempty"`
	Image               string `json:"image,omitempty" description:"Use a different container image for the installation"`
	PowerManagement
	SkipEncryptCopyPlugins bool                `json:"skip_copy_kcrypt_plugin,omitempty"`
	Partitions             ElementalPartitions `json:"partitions,omitempty" mapstructure:"partitions"`
	GrubDefEntry           string              `json:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"`
	ExtraPartitions        []*Partition        `json:"extra-partitions,omitempty" mapstructure:"extra-partitions"`
	Force                  bool                `json:"force,omitempty" mapstructure:"force"`
	ExtraDirsRootfs        []string            `json:"extra-dirs-rootfs,omitempty" mapstructure:"extra-dirs-rootfs"`
	Active                 Image               `json:"system,omitempty" mapstructure:"system"`
	Recovery               Image               `json:"recovery-system,omitempty" mapstructure:"recovery-system"`
	Passive                Image               `json:"passive,omitempty" mapstructure:"recovery-system"`
	// contains filtered or unexported fields
}

InstallSchema represents the install block in the Kairos configuration. It is used to drive automatic installations without user interaction.

type KConfig

type KConfig struct {
	Source string

	ValidationError error
	// contains filtered or unexported fields
}

KConfig is used to parse and validate Kairos configuration files.

func NewConfigFromYAML

func NewConfigFromYAML(s string, st interface{}) (*KConfig, error)

NewConfigFromYAML is a constructor for KConfig instances. The source of the configuration is passed in YAML and if there are any issues unmarshaling it will return an error.

func (*KConfig) HasHeader

func (kc *KConfig) HasHeader() bool

HasHeader returns true if the config has one of the valid headers.

func (*KConfig) IsValid

func (kc *KConfig) IsValid() bool

IsValid returns true if the schema rules of the configuration are valid.

type KubeVIPSchema

type KubeVIPSchema struct {
	EIP         string `json:"eip,omitempty" example:"192.168.1.110"`
	ManifestURL string `json:"manifest_url,omitempty" description:"Specify a manifest URL for KubeVIP." default:""`
	Enable      bool   `json:"enable,omitempty" description:"Enables KubeVIP"`
	Interface   bool   `json:"interface,omitempty" description:"Specifies a KubeVIP Interface" example:"ens18"`
	// contains filtered or unexported fields
}

KubeVIPSchema represents the kubevip block in the Kairos configuration. It sets the Elastic IP used in KubeVIP. Only valid with p2p.

type NoPowerManagement

type NoPowerManagement struct {
	Reboot   bool `json:"reboot,omitempty" const:"false" default:"false" description:"Reboot after installation"`
	Poweroff bool `json:"poweroff,omitempty" const:"false" default:"false" description:"Power off after installation"`
}

NoPowerManagement is a meta structure used when the user does not define any power management options or when the user does not want to reboot or poweroff the machine.

type OneOfModel

type OneOfModel interface {
	JSONSchemaOneOf() []interface{}
}

The OneOfModel interface is only needed for the tests that check the new schema contain all needed fields it can be removed once the new schema is the single source of truth.

type P2PAutoDisabled

type P2PAutoDisabled struct {
	NetworkToken string `json:"network_token,omitempty" const:"" required:"true"`
	Auto         struct {
		Enable bool `json:"enable" const:"false" required:"true"`
		Ha     struct {
			Enable bool `json:"enable" const:"false"`
		} `json:"ha"`
	} `json:"auto"`
}

P2PAutoDisabled is used to validate that when p2p.auto is disabled, then neither p2p.auto.ha not p2p.network_token can be set.

type P2PAutoEnabled

type P2PAutoEnabled struct {
	NetworkToken string `` /* 141-byte string literal not displayed */
	Auto         struct {
		Enable bool `json:"enable,omitempty" const:"true"`
		Ha     struct {
			Enable      bool `json:"enable" const:"true"`
			MasterNodes int  `` /* 167-byte string literal not displayed */
		} `json:"ha"`
	} `json:"auto,omitempty"`
}

P2PAutoEnabled is used to validate that when p2p.auto is set, p2p.network_token has to be set.

type P2PNetworkExtended

type P2PNetworkExtended struct {
}

P2PNetworkExtended is a meta structure to hold the different rules for managing the P2P network, which are not compatible between each other.

func (P2PNetworkExtended) JSONSchemaOneOf

func (P2PNetworkExtended) JSONSchemaOneOf() []interface{}

JSONSchemaOneOf defines that different which are the different valid p2p network rules and states that one and only one of them needs to be validated for the entire schema to be valid.

type P2PSchema

type P2PSchema struct {
	Role       string `json:"role,omitempty" default:"none" enum:"[\"master\",\"worker\",\"none\"]"`
	NetworkID  string `json:"network_id,omitempty" description:"User defined network-id. Can be used to have multiple clusters in the same network"`
	DNS        bool   `json:"dns,omitempty" description:"Enable embedded DNS See also: https://mudler.github.io/edgevpn/docs/concepts/overview/dns/"`
	DisableDHT bool   `` /* 135-byte string literal not displayed */
	P2PNetworkExtended
	VPN `json:"vpn,omitempty"`
	// contains filtered or unexported fields
}

P2PSchema represents the P2P block in the Kairos configuration. It is used to enables and configure the p2p full-mesh functionalities.

type Partition added in v0.1.3

type Partition struct {
	Name string `json:"name,omitempty"`
	Size uint   `json:"size,omitempty" mapstructure:"size"`
	FS   string `json:"fs,omitempty" mapstrcuture:"fs"`
}

type PlatformSchema added in v0.0.10

type PlatformSchema struct {
	OS         string
	Arch       string
	GolangArch string
}

type PowerManagement

type PowerManagement struct {
}

PowerManagement is a meta structure to hold the different rules for managing power, which are not compatible between each other.

func (PowerManagement) JSONSchemaOneOf

func (PowerManagement) JSONSchemaOneOf() []interface{}

JSONSchemaOneOf defines that different which are the different valid power management rules and states that one and only one of them needs to be validated for the entire schema to be valid.

type PowerOffOnly

type PowerOffOnly struct {
	Reboot   bool `json:"reboot,omitempty" const:"false" default:"false" description:"Reboot after installation"`
	Poweroff bool `json:"poweroff,omitempty" const:"true" default:"false" required:"true" description:"Power off after installation"`
}

PowerOffOnly is a meta structure used to enforce that when the poweroff option is set, the reboot option is not set.

type RebootOnly

type RebootOnly struct {
	Reboot   bool `json:"reboot,omitempty" const:"true" default:"false" required:"true" description:"Reboot after installation"`
	Poweroff bool `json:"poweroff,omitempty" const:"false" default:"false" description:"Power off after installation"`
}

RebootOnly is a meta structure used to enforce that when the reboot option is set, the poweroff option is not set.

type RootSchema

type RootSchema struct {
	Bundles                   []BundleSchema `json:"bundles,omitempty" description:"Add bundles in runtime"`
	ConfigURL                 string         `json:"config_url,omitempty" description:"URL download configuration from."`
	Env                       []string       `json:"env,omitempty"`
	FailOnBundleErrors        bool           `json:"fail_on_bundles_errors,omitempty"`
	GrubOptionsSchema         `json:"grub_options,omitempty"`
	Install                   InstallSchema  `json:"install,omitempty"`
	Options                   []interface{}  `json:"options,omitempty" description:"Various options."`
	Users                     []UserSchema   `json:"users,omitempty" minItems:"1" required:"true"`
	P2P                       P2PSchema      `json:"p2p,omitempty"`
	Debug                     bool           `json:"debug,omitempty" mapstructure:"debug"`
	Strict                    bool           `json:"strict,omitempty" mapstructure:"strict"`
	CloudInitPaths            []string       `json:"cloud-init-paths,omitempty" mapstructure:"cloud-init-paths"`
	EjectCD                   bool           `json:"eject-cd,omitempty" mapstructure:"eject-cd"`
	FullCloudConfig           string         `json:"fullcloudconfig,omitempty" mapstructure:"fullcloudconfig"`
	Cosign                    bool           `json:"cosign,omitempty" mapstructure:"cosign"`
	Verify                    bool           `json:"verify,omitempty" mapstructure:"verify"`
	CosignPubKey              string         `json:"cosign-key,omitempty" mapstructure:"cosign-key"`
	Arch                      string         `json:"arch,omitempty" mapstructure:"arch"`
	Platform                  PlatformSchema `json:"platform,omitempty" mapstructure:"platform"`
	SquashFsCompressionConfig []string       `json:"squash-compression,omitempty" mapstructure:"squash-compression"`
	SquashFsNoCompression     bool           `json:"squash-no-compression,omitempty" mapstructure:"squash-no-compression"`
	UkiMaxEntries             int            `json:"uki-max-entries,omitempty" mapstructure:"uki-max-entries"`
	// contains filtered or unexported fields
}

RootSchema groups all the different schema of the Kairos configuration together.

type UserSchema

type UserSchema struct {
	Name              string   `json:"name,omitempty" pattern:"([a-z_][a-z0-9_]{0,30})" required:"true" example:"kairos"`
	Passwd            string   `json:"passwd,omitempty" example:"kairos"`
	LockPasswd        bool     `json:"lockPasswd,omitempty" example:"true"`
	Groups            []string `json:"groups,omitempty" example:"admin"`
	SSHAuthorizedKeys []string `json:"ssh_authorized_keys,omitempty" examples:"[\"github:USERNAME\",\"ssh-ed25519 AAAF00BA5\"]"`
	// contains filtered or unexported fields
}

UserSchema represents the users block in the Kairos configuration. It allows the creation of users in the system.

type VPN

type VPN struct {
	Create bool                   `json:"vpn,omitempty" default:"true"`
	Use    bool                   `json:"use,omitempty" default:"true"`
	Envs   map[string]interface{} `json:"env,omitempty"`
}

VPN represents the vpn block in the Kairos configuration.

Jump to

Keyboard shortcuts

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