diff --git a/cmd/vela-kubernetes/apply.go b/cmd/vela-kubernetes/apply.go new file mode 100644 index 0000000..7ef5e24 --- /dev/null +++ b/cmd/vela-kubernetes/apply.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" +) + +// Apply represents the plugin configuration for Apply config information. +type Apply struct { + // Kubernetes files or directories to apply + Files []string +} + +// Validate verifies the Apply is properly configured. +func (a *Apply) Validate() error { + logrus.Trace("validating apply configuration") + + // verify files are provided + if len(a.Files) == 0 { + return fmt.Errorf("no apply files provided") + } + + return nil +} diff --git a/cmd/vela-kubernetes/apply_test.go b/cmd/vela-kubernetes/apply_test.go new file mode 100644 index 0000000..b17c19e --- /dev/null +++ b/cmd/vela-kubernetes/apply_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_Apply_Validate(t *testing.T) { + // setup types + a := &Apply{ + Files: []string{"files"}, + } + + err := a.Validate() + if err != nil { + t.Errorf("Validate returned err: %v", err) + } +} + +func TestKubernetes_Apply_Validate_NoFiles(t *testing.T) { + // setup types + a := &Apply{} + + err := a.Validate() + if err == nil { + t.Errorf("Validate should have returned err") + } +}