diff --git a/cmd/vela-kubernetes/patch.go b/cmd/vela-kubernetes/patch.go new file mode 100644 index 0000000..92c6c67 --- /dev/null +++ b/cmd/vela-kubernetes/patch.go @@ -0,0 +1,29 @@ +// Copyright (c) 2020 Target Brands, Inc. All rights reserved. +// +// Use of this source code is governed by the LICENSE file in this repository. + +package main + +import ( + "fmt" + + "github.com/sirupsen/logrus" +) + +// Patch represents the plugin configuration for Patch config information. +type Patch struct { + // container images from files to patch + Images []string +} + +// Validate verifies the Patch is properly configured. +func (p *Patch) Validate() error { + logrus.Trace("validating config configuration") + + // verify images are provided + if len(p.Images) == 0 { + return fmt.Errorf("no config images provided") + } + + return nil +} diff --git a/cmd/vela-kubernetes/patch_test.go b/cmd/vela-kubernetes/patch_test.go new file mode 100644 index 0000000..0d1663d --- /dev/null +++ b/cmd/vela-kubernetes/patch_test.go @@ -0,0 +1,31 @@ +// Copyright (c) 2020 Target Brands, Inc. All rights reserved. +// +// Use of this source code is governed by the LICENSE file in this repository. + +package main + +import ( + "testing" +) + +func TestKubernetes_Patch_Validate(t *testing.T) { + // setup types + p := &Patch{ + Images: []string{"images"}, + } + + err := p.Validate() + if err != nil { + t.Errorf("Validate returned err: %v", err) + } +} + +func TestKubernetes_Patch_Validate_NoImages(t *testing.T) { + // setup types + p := &Patch{} + + err := p.Validate() + if err == nil { + t.Errorf("Validate should have returned err") + } +}