Add validate function to crd resource and do validate before creation/update (#580)
This commit is contained in:
@@ -63,6 +63,7 @@ func checkFunctionExistence(fissionClient *client.Client, fnName string) {
|
||||
Name: fnName,
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
}
|
||||
|
||||
_, err := fissionClient.FunctionGet(meta)
|
||||
if err != nil {
|
||||
fmt.Printf("function '%v' does not exist, use 'fission function create --name %v ...' to create the function\n", fnName, fnName)
|
||||
|
||||
@@ -201,7 +201,6 @@ func main() {
|
||||
envBuildCmdFlag := cli.StringFlag{Name: "buildcmd", Usage: "Build command for environment builder to build source package (optional)"}
|
||||
envExternalNetworkFlag := cli.BoolFlag{Name: "externalnetwork", Usage: "Allow environment access external network when istio feature enabled (optional, defaults to false)"}
|
||||
envTerminationGracePeriodFlag := cli.Int64Flag{Name: "graceperiod, period", Usage: "The grace time for pod to perform connection draining before termination (optional, defaults to 360 seconds)"}
|
||||
|
||||
envVersionFlag := cli.IntFlag{Name: "version", Usage: "Environment API version: defaults to 1 (means v1 interface)"}
|
||||
envSubcommands := []cli.Command{
|
||||
{Name: "create", Aliases: []string{"add"}, Usage: "Add an environment", Flags: []cli.Flag{envNameFlag, envPoolsizeFlag, envImageFlag, envBuilderImageFlag, envBuildCmdFlag, minCpu, maxCpu, minMem, maxMem, envVersionFlag, envExternalNetworkFlag, envTerminationGracePeriodFlag, specSaveFlag}, Action: envCreate},
|
||||
|
||||
+1
-2
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/controller/client"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/mqtrigger/messageQueue"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -55,7 +54,7 @@ func migrateDumpTPRResource(client *client.Client, filename string) {
|
||||
checkErr(err, "dump watches")
|
||||
timeTriggers, err := client.TimeTriggerList()
|
||||
checkErr(err, "dump time triggers")
|
||||
mqTriggers, err := client.MessageQueueTriggerList(messageQueue.NATS)
|
||||
mqTriggers, err := client.MessageQueueTriggerList(fission.MessageQueueTypeNats)
|
||||
checkErr(err, "dump message queue triggers")
|
||||
|
||||
tprResource := TPRResource{
|
||||
|
||||
+9
-10
@@ -27,7 +27,6 @@ import (
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/mqtrigger/messageQueue"
|
||||
)
|
||||
|
||||
func mqtCreate(c *cli.Context) error {
|
||||
@@ -42,14 +41,14 @@ func mqtCreate(c *cli.Context) error {
|
||||
fatal("Need a function name to create a trigger, use --function")
|
||||
}
|
||||
|
||||
mqType := c.String("mqtype")
|
||||
switch mqType {
|
||||
var mqType fission.MessageQueueType
|
||||
switch c.String("mqtype") {
|
||||
case "":
|
||||
mqType = messageQueue.NATS
|
||||
case messageQueue.NATS:
|
||||
mqType = messageQueue.NATS
|
||||
case messageQueue.ASQ:
|
||||
mqType = messageQueue.ASQ
|
||||
mqType = fission.MessageQueueTypeNats
|
||||
case fission.MessageQueueTypeNats:
|
||||
mqType = fission.MessageQueueTypeNats
|
||||
case fission.MessageQueueTypeASQ:
|
||||
mqType = fission.MessageQueueTypeASQ
|
||||
default:
|
||||
fatal("Unknown message queue type, currently only \"nats-streaming, azure-storage-queue \" is supported")
|
||||
}
|
||||
@@ -194,9 +193,9 @@ func mqtList(c *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkMQTopicAvailability(mqType string, topics ...string) {
|
||||
func checkMQTopicAvailability(mqType fission.MessageQueueType, topics ...string) {
|
||||
for _, t := range topics {
|
||||
if len(t) > 0 && !messageQueue.IsTopicValid(mqType, t) {
|
||||
if len(t) > 0 && !fission.IsTopicValid(mqType, t) {
|
||||
fatal(fmt.Sprintf("Invalid topic for %s: %s", mqType, t))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -360,7 +360,7 @@ func upgradeRestoreState(c *cli.Context) error {
|
||||
Metadata: *crdMetadataFromV1Metadata(&t.Metadata, v1state.NameChanges),
|
||||
Spec: fission.MessageQueueTriggerSpec{
|
||||
FunctionReference: *functionRefFromV1Metadata(&t.Function, v1state.NameChanges),
|
||||
MessageQueueType: t.MessageQueueType,
|
||||
MessageQueueType: fission.MessageQueueTypeNats, // only NATS is supported at that time (v1 types)
|
||||
Topic: t.Topic,
|
||||
ResponseTopic: t.ResponseTopic,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user