-
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.
If the deploy job name is not set, an internal error will occur. This commit adds validation logic so that we can ensure that the deploy job name is provided if the deploy job command is specified.
- Loading branch information
Showing
3 changed files
with
40 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,22 @@ | ||
package validation | ||
|
||
import ( | ||
"errors" | ||
|
||
apps "github.com/ninech/apis/apps/v1alpha1" | ||
) | ||
|
||
// ConfigValidator validates a Config | ||
type ConfigValidator struct { | ||
Config apps.Config | ||
} | ||
|
||
// Validate validates the config | ||
func (c ConfigValidator) Validate() error { | ||
if c.Config.DeployJob != nil { | ||
if len(c.Config.DeployJob.Name) == 0 { | ||
return errors.New("deploy job name cannot be empty") | ||
} | ||
} | ||
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
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