mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-08 12:29:27 +00:00
Split off cli into separate binaries (#37)
* 🎨 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
This commit is contained in:
committed by
Itxaka
parent
74bfd373db
commit
63cd28d1cb
64
internal/provider/challenge_test.go
Normal file
64
internal/provider/challenge_test.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package provider_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "github.com/c3os-io/c3os/internal/provider"
|
||||
"github.com/c3os-io/c3os/pkg/bus"
|
||||
"github.com/c3os-io/c3os/pkg/config"
|
||||
"github.com/mudler/go-pluggable"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Challenge provider", func() {
|
||||
Context("network token", func() {
|
||||
e := &pluggable.Event{}
|
||||
|
||||
BeforeEach(func() {
|
||||
e = &pluggable.Event{}
|
||||
})
|
||||
|
||||
It("returns it if provided", func() {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "tests")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer os.RemoveAll(f.Name())
|
||||
|
||||
cfg := &config.Config{
|
||||
C3OS: &config.C3OS{
|
||||
NetworkToken: "foo",
|
||||
},
|
||||
}
|
||||
c := &bus.EventPayload{Config: cfg.String()}
|
||||
dat, err := json.Marshal(c)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
e.Data = string(dat)
|
||||
resp := Challenge(e)
|
||||
|
||||
Expect(string(resp.Data)).Should(ContainSubstring("foo"))
|
||||
})
|
||||
|
||||
It("generates it if not provided", func() {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "tests")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer os.RemoveAll(f.Name())
|
||||
|
||||
cfg := &config.Config{
|
||||
C3OS: &config.C3OS{
|
||||
NetworkToken: "",
|
||||
},
|
||||
}
|
||||
c := &bus.EventPayload{Config: cfg.String()}
|
||||
dat, err := json.Marshal(c)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
e.Data = string(dat)
|
||||
resp := Challenge(e)
|
||||
|
||||
Expect(len(string(resp.Data))).Should(BeNumerically(">", 12))
|
||||
})
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user