-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add patch object to plugin (#10)
Co-authored-by: David Vader <[email protected]>
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |