WIP: something
This commit is contained in:
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")
|
||||
}
|
Reference in New Issue
Block a user