forked from crossplane-contrib/function-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.go
More file actions
20 lines (16 loc) · 690 Bytes
/
Copy pathvalidate.go
File metadata and controls
20 lines (16 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package main
import (
"github.com/crossplane-contrib/function-shell/input/v1alpha1"
"github.com/crossplane/function-sdk-go/resource"
"k8s.io/apimachinery/pkg/util/validation/field"
)
// ValidateParameters validates the Parameters object.
func ValidateParameters(p *v1alpha1.Parameters, oxr *resource.Composite) *field.Error {
if p.ShellCommand == "" && p.ShellCommandField == "" {
return field.Required(field.NewPath("parameters"), "one of ShellCommand or ShellCommandField is required")
}
if p.ShellCommand != "" && p.ShellCommandField != "" {
return field.Required(field.NewPath("parameters"), "exactly one of ShellCommand or ShellCommandField is required")
}
return nil
}