-
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 apply object to plugin (#11)
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" | ||
) | ||
|
||
// 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 | ||
} |
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_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") | ||
} | ||
} |