WIP: something

This commit is contained in:
Nikolai Rodionov
2023-11-03 14:22:22 +01:00
parent 619a86b7f8
commit 7b327b38e7
11 changed files with 143 additions and 0 deletions

6
pkg/types/image/image.go Normal file
View File

@ -0,0 +1,6 @@
package image
type Image struct {
Repository string
Tag string
}

View 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
}

View 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
}

View 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")
}