WIP: something
This commit is contained in:
parent
619a86b7f8
commit
7b327b38e7
5
example/db-operator/package.yaml
Normal file
5
example/db-operator/package.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
name: db-operator
|
||||
version: 1.0.0
|
||||
image:
|
||||
tag: 1.15.3
|
||||
repository: db-operator
|
20
example/db-operator/workload/workload.yaml
Normal file
20
example/db-operator/workload/workload.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
workload:
|
||||
kind: Deployment
|
||||
replicas: 1
|
||||
containers:
|
||||
- name: controller
|
||||
image: {{ .Image }}
|
||||
imagePullPolicy: Always
|
||||
commands:
|
||||
- sh
|
||||
args:
|
||||
- -c
|
||||
- 'sleep 1000'
|
||||
- name: ubuntu
|
||||
image: ubuntu:latest
|
||||
imagePullPolicy: Always
|
||||
commands:
|
||||
- sh
|
||||
args:
|
||||
- -c
|
||||
- 'sleep 1000'
|
11
go.mod
Normal file
11
go.mod
Normal file
@ -0,0 +1,11 @@
|
||||
module git.badhouseplants.net/allanger/shoebill
|
||||
|
||||
go 1.21.3
|
||||
|
||||
require github.com/stretchr/testify v1.8.4
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
10
go.sum
Normal file
10
go.sum
Normal file
@ -0,0 +1,10 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
9
internal/controller/controller.go
Normal file
9
internal/controller/controller.go
Normal file
@ -0,0 +1,9 @@
|
||||
package controller
|
||||
|
||||
type Client struct {}
|
||||
|
||||
func (cli *Client) Install () error {
|
||||
// Generate the package from templates
|
||||
|
||||
return nil
|
||||
}
|
9
internal/templater/templater.go
Normal file
9
internal/templater/templater.go
Normal file
@ -0,0 +1,9 @@
|
||||
package templater
|
||||
|
||||
// Datasource for template rendering
|
||||
type TemplateDS struct {
|
||||
}
|
||||
|
||||
func (tds *TemplateDS) Render() {
|
||||
|
||||
}
|
1
internal/templater/templater_test.go
Normal file
1
internal/templater/templater_test.go
Normal file
@ -0,0 +1 @@
|
||||
package templater_test
|
6
pkg/types/image/image.go
Normal file
6
pkg/types/image/image.go
Normal file
@ -0,0 +1,6 @@
|
||||
package image
|
||||
|
||||
type Image struct {
|
||||
Repository string
|
||||
Tag string
|
||||
}
|
14
pkg/types/pkgdef/pkfdef.go
Normal file
14
pkg/types/pkgdef/pkfdef.go
Normal file
@ -0,0 +1,14 @@
|
||||
package pkgdef
|
||||
|
||||
|
||||
type Package struct {
|
||||
Name string
|
||||
Version string
|
||||
AppVersion string
|
||||
Image *Image
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
Repository string
|
||||
Tag string
|
||||
}
|
18
pkg/types/workload/workload.go
Normal file
18
pkg/types/workload/workload.go
Normal file
@ -0,0 +1,18 @@
|
||||
package workload
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Workload struct {
|
||||
Kind string
|
||||
Replicas int
|
||||
}
|
||||
|
||||
func (wd *Workload) ValidateKind() error {
|
||||
if wd.Kind == "Deployment" || wd.Kind == "StatefulSet" || wd.Kind == "DaemonSet" {
|
||||
return nil
|
||||
}
|
||||
err := fmt.Errorf("kind is not valid, expect Deployment|StatefulSet|DaemonSet, got %s", wd.Kind)
|
||||
return err
|
||||
}
|
40
pkg/types/workload/workload_test.go
Normal file
40
pkg/types/workload/workload_test.go
Normal file
@ -0,0 +1,40 @@
|
||||
package workload_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.badhouseplants.net/allanger/shoebill/pkg/types/workload"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUnitKindValidatorDeployment(t *testing.T) {
|
||||
wd := &workload.Workload{
|
||||
Kind: "Deployment",
|
||||
}
|
||||
err := wd.ValidateKind()
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestUnitKindValidatorStatefulSet(t *testing.T) {
|
||||
wd := &workload.Workload{
|
||||
Kind: "StatefulSet",
|
||||
}
|
||||
err := wd.ValidateKind()
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestUnitKindValidatorDeamonSet(t *testing.T) {
|
||||
wd := &workload.Workload{
|
||||
Kind: "DaemonSet",
|
||||
}
|
||||
err := wd.ValidateKind()
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestUnitKindValidatorInvalid(t *testing.T) {
|
||||
wd := &workload.Workload{
|
||||
Kind: "Invalid",
|
||||
}
|
||||
err := wd.ValidateKind()
|
||||
assert.ErrorContains(t, err, "got Invalid")
|
||||
}
|
Loading…
Reference in New Issue
Block a user