Skip to content

Commit

Permalink
feat: add apply object to plugin (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: David Vader <[email protected]>
  • Loading branch information
jbrockopp and plyr4 authored Feb 12, 2020
1 parent 8a0d2f6 commit 1702025
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cmd/vela-kubernetes/apply.go
Original file line number Diff line number Diff line change
@@ -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
}
31 changes: 31 additions & 0 deletions cmd/vela-kubernetes/apply_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
}

0 comments on commit 1702025

Please sign in to comment.