* Fix config loading, install device and call sanitize
Syncs the cfg.install.device to the installspec.target
As on manual-install the device can actually come from a flag and its
not on the cloud-config, we need to initialize the InstallSpec with the
value of the cfg.Install.Device as by that time we already have the
final value of the install target.
Also calls sanitize on config and specs and warns if anything goes wrong
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
* Fix platform override and tests
The sanitize method for Config was never called so we never noticed that
its overriding the platform, even if we pass the WithPLatform option.
This patch fixes it by only overriding platform by default on sanitize
if the platform is empty, otherwise leave the platform on it values.
Also fixes the tests to use test facilities and a small fix to not try
to load the platform values form yaml
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
* Init the Install in the Config init
Just in case something tries to access it so they dont find a nil
Also adjusts some more tests
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
---------
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
By default get 30 releases and skip any pre-releases found.
Allow toggling showing pre-releases both for upgrade and for listing
them
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
Looks like we only get a small subset of the releases so we cant check
for a specific number in the list that we get
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
* 🐛 Fix version list
First version in the list is the latest one.
Alos moves the check for same version above the current place, so it can
check before asking if you want to update to the same version
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
* 🌱 Rework versioning for upgrade
Use the semver lib to parse the versions into a proper collection where
it can be parsed and versions compared and sorted properly
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
* 🤖 lint
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
---------
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
* Do not merge all cmdline arguments to generic config
Instead allow only specific Kairos config ones, this should not be known by the collector but doing it this way as a temporary hack to release 2.0 and then we can do properly
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Remove fmt.Println
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Lint
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* imports
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Filter using a cloud config structure
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Pass a filter function
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Exclude collector config from config.Config yaml
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Fix issue with test now that a yaml tag gets ignored
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* cleanup FilterKeys func
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add comment
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
---------
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
https://go.dev/doc/modules/major-version
This way we can bump the kairos dependency on the provider-kairos repo
which otherwise produced the error:
```
~/workspace/kairos/provider-kairos (main)*$ go get -u github.com/kairos-io/kairos@v2.0.0-alpha3
go: github.com/kairos-io/kairos@v2.0.0-alpha3: invalid version: module contains a go.mod file, so module path must match major version ("github.com/kairos-io/kairos/v2")
```
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Co-authored-by: Itxaka <itxaka.garcia@spectrocloud.com>
* Introduce config/collector package
to split the collection of config sources out of the config package.
Each consumer of the new package will take care of unmarshalling the
yaml to a specific Config struct, do validations etc.
* Add tests and remove garbage
* Follow all config_url chains and test it
* Add missing options file and refactor cmdline code
* Consolidate the way we merge configs no matter where they come from
* Allow and use only files with valid headers
Config is specific to Kairos while Collector is generic. This
will allow us to do validations which are just related to Kairos at the
config level, while including every type of key and querying of the full
yaml at the Collector level splitting the responsibilities of each
package.
---------
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Looks like the schema for the user thinks groups is a string, while checking the code it seems to be more a list of strings and that matches with the yip library and how it parses the groups.
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
Don't fail when config_url is not accessible
but rather print a Warning.
Fixes#885
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Co-authored-by: Dimitris Karakasilis <dimitris@karakasilis.me>
* Validate yaml
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* lint feedback
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Validate User name with JsonSchema
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* WIP users validation
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add multiple examples for ssh keys
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add example of complex validation with AnyOf
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Better business rule example with P2P
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Test with message for empty network_token
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Split into a file for each sub section
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add install schema validations
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add to main schema
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add more tests for p2p
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add install schema
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Validate fields between new and old schema
It also adds the missing ones
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Lint
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Remove temp debugging functions
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add new fields in old schema
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add documentation for all exported
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Move schemas into a directory of their own
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Add missing dot at end of comment
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* Rebase master and add local_file to bundles
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
---------
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
* ✨ custom user bind and ephemeral mounts
Users can now specify custom and ephemeral mounts in cloud-init under
the `install` section, e.g.:
```
users:
- name: kairos
...
install:
auto: true
device: "auto"
bind_mounts:
- /mnt/bind1
- /mnt/bind2
ephemeral_mounts:
- /mnt/ephemeral
- /mnt/ephemeral2
...
```
Ephemeral mounts are mounted as RW - but changes are discarded when the
machine is restart.
Bind mounts will persist changes after restarted.
This is a fix for #210
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Add the custom user mount to /cos/run/cos-layout.env
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Add docs for custom user mounts in configuration example
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Reuse test_install function
DRY the code, change how we call the function install_test
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Enable custom mount tests and install tests
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Enable tests in CI
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Remove duplicate if check
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Remove uneeded fmt.Println ...
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Use separate label for custom mounts
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* 🔧 Earthfile - DRY ginkgo
We repeat this a more than twice so just extract to own
target...
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Correct return type for ContainElements
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Remove CLOUD_INIT from custom mounts test
This is not needed here.
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* Fix qemu-test-* earthly targets
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* 🔧 Fix CPU passing to VM
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* 🔧 remove apt cache after install qemu
Helps deal with space running out in the CI.
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
* 📖 Document custom mounts
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
---------
Signed-off-by: Oz Tiram <oz@spectrocloud.com>
Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
* 🌱 Return configuration data from the agent
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
* 🤖 Cover query by tests
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Regression introduced in https://github.com/kairos-io/kairos/pull/502.
Now also files like .lst inside the initramfs are globbed inside /oem/90_custom.yaml
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
* 🌱 Glob all configs found
This allows to read all the configs found during scanning - this is especially useful in first boot as it allows
to have separate config file logic split into several files
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
* 🌱 Simplify config merge logic
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
* WIP
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
* 🌱 Make the function work
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: mudler <mudler@kairos.io>
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Signed-off-by: mudler <mudler@kairos.io>
Co-authored-by: Dimitris Karakasilis <dimitris@karakasilis.me>
* 🐛 Setup / as shared mount on alpine
Since this is not handled in the boot process, we do this in our devoted file to setup the rootfs configuration
Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
* 🐧 Correctly detect alpine flavors
Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
refactor: move from io/ioutil to io and os packages
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.
[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* ⬆️ Bump Kairos repositories
Signed-off-by: Ettore Di Giacinto <mudler@mocaccino.org>
* 🐧 Find out which grub to call
Signed-off-by: Ettore Di Giacinto <mudler@mocaccino.org>
Signed-off-by: Ettore Di Giacinto <mudler@mocaccino.org>
* 🎨 Do not need to prefix '.' on queries
* ✨ Add recovery to stateapi
* ✨ Add cloudconfig SDK
* ✨ Unify post-install/firstboot hooks
This also adds capabilities to add grub option at first boot rather than
after installation as for bundles.
* 🤖 Optimize tests to wait for state to change
* ✨ Add state api
This is related to https://github.com/kairos-io/kairos/issues/34.
Starts to unify the API to retrieve the state in the sdk to have a common place to query system status information.
* 🤖 Add test
* Update go.mod
* ⚙️ Fine-tune detection of partitions
* 🤖 Add more fine-grained tests
* 🎨 Add /dev/ to partition name
* 🤖 Fixup tests
* ⚙️ Remount accessors
* ✨ Add state partition to cloud-init paths
* 📝 Upper case Kairos in motd
* 🎨 Add mounts sdk
* 🎨 Set grub options via SDK
* 🎨 Make it more idiomatic
* 🐛 Fixup grub option quoting
* ⚙️ Copy discovery to oem if found
* ✨ Add environment block to install
* ⚙️ Use /oem for mount in kcrypt post-hook
* 📝 Update docs with installer env reference
* 🤖 Add test deps
* ⚙️ Be consistent and set env also for post-hooks
* ⚙️ propagate env in post-hooks
* 🤖 Add bundles and sysext test
* ✨ Exec bundles also after install
* 🤖 Adapt tests
* 🎨 Create dir only if doesn't exist
* 🎨 Return err on mount
* 🎨 Make bundle errors failure as an option
* 🎨 Minor fixups
* debug
* 🤖 Fix spec
* 🤖 Get correct version for bundle test
* 🎨 Fixups
* 🤖 systemd-sysext is available only on opensuse for now
From now on images built from this repo are the c3os core images.
c3os core images contains only the base image, framework files and the c3os agent.
This also sets up tests accordingly to run only to cover the c3os-agent.
Now there is a `install` section in the config that has the fields that previously where in `c3os` but
were actually only used during install phase.
Also the k3s and c3os config were moved to the provider instead that in the global config.
This changeset also adds a `config_url` and `options` keyword in the c3os config.
Along with that the config logic is changed so the configuration is taken also from boot commands and merged in the final installed config file.
* 🎨 Split off cli into separate binaries
This commit splits off the cli into 3 binaries:
- agent
- cli
- provider
The provider now is a separate component that can be tested by itself
and have its own lifecycle. This paves the way to a ligher c3os variant,
HA support and other features that can be provided on runtime.
This is working, but still there are low hanging fruit to care about.
Fixes#14
* 🤖 Add provider bin to releases
* ⚙️ Handle signals
* ⚙️ Reduce buildsize footprint
* 🎨 Scan for providers also in /system/providers
* 🤖 Run goreleaser
* 🎨 Refactoring