Skip to content

Commit

Permalink
feat: add patch object to plugin (#10)
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 e18be28 commit 8a0d2f6
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/patch.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"
)

// 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
}
31 changes: 31 additions & 0 deletions cmd/vela-kubernetes/patch_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_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")
}
}

0 comments on commit 8a0d2f6

Please sign in to comment.