mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-05-30 19:25:06 +00:00
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>
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/kairos-io/kairos/v2/pkg/config"
|
|
"gopkg.in/yaml.v3"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("prepareConfiguration", func() {
|
|
path := "/foo/bar"
|
|
url := "https://example.com"
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
It("returns a file path with no modifications", func() {
|
|
source, err := prepareConfiguration(ctx, path)
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(source).To(Equal(path))
|
|
})
|
|
|
|
It("creates a configuration file containing the given url", func() {
|
|
source, err := prepareConfiguration(ctx, url)
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(source).ToNot(Equal(path))
|
|
|
|
f, err := os.Open(source)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
var cfg config.Config
|
|
err = yaml.NewDecoder(f).Decode(&cfg)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(cfg.ConfigURL).To(Equal(url))
|
|
})
|
|
|
|
It("cleans up the configuration file after context is done", func() {
|
|
source, err := prepareConfiguration(ctx, url)
|
|
cancel()
|
|
|
|
_, err = os.Stat(source)
|
|
Expect(os.IsNotExist(err))
|
|
})
|
|
})
|