diff --git a/cmd/device-hub-cli/cmd_create.go b/cmd/device-hub-cli/cmd_create.go index 5293891..0726013 100644 --- a/cmd/device-hub-cli/cmd_create.go +++ b/cmd/device-hub-cli/cmd_create.go @@ -3,16 +3,7 @@ package main import ( - "context" - "strings" - - "github.com/fiorix/protoc-gen-cobra/iocodec" "github.com/spf13/cobra" - "github.com/thingful/device-hub/describe" - "github.com/thingful/device-hub/endpoint" - "github.com/thingful/device-hub/listener" - "github.com/thingful/device-hub/proto" - "github.com/thingful/device-hub/registry" ) var createCommand = &cobra.Command{ @@ -20,55 +11,15 @@ var createCommand = &cobra.Command{ Short: "Create listener, endpoint and profile resources", RunE: func(cmd *cobra.Command, args []string) error { - /* TODO : add ability to generate examples */ - sample := proto.CreateRequest{ - Configuration: map[string]string{}, - } - - err := roundTrip(sample, func(cli proto.HubClient, in iocodec.Decoder, out iocodec.Encoder) error { - - v := proto.CreateRequest{} - - err := in.Decode(&v) + for _, r := range _resources.R { + err := r.SendCreate() if err != nil { return err } - // validate the policy file before sending it over the wire - var params describe.Parameters - - register := registry.Default - - endpoint.Register(register) - listener.Register(register) - - switch strings.ToLower(v.Type) { - - case "listener": - params, err = register.DescribeListener(v.Kind) - case "endpoint": - params, err = register.DescribeEndpoint(v.Kind) - } - - if err != nil { - return err - } - - _, err = describe.NewValues(v.Configuration, params) - - if err != nil { - return err - } - resp, err := cli.Create(context.Background(), &v) - - if err != nil { - return err - } - - return out.Encode(resp) + } - }) - return err + return nil }, } diff --git a/cmd/device-hub-cli/cmd_delete.go b/cmd/device-hub-cli/cmd_delete.go index 40aecbf..854a2c2 100644 --- a/cmd/device-hub-cli/cmd_delete.go +++ b/cmd/device-hub-cli/cmd_delete.go @@ -3,40 +3,26 @@ package main import ( - "context" - - "github.com/fiorix/protoc-gen-cobra/iocodec" "github.com/spf13/cobra" - "github.com/thingful/device-hub/proto" ) var deleteCommand = &cobra.Command{ Use: "delete", Short: "Delete listener, profile and endpoint resources", RunE: func(cmd *cobra.Command, args []string) error { + var uri string + if len(args) > 0 { + uri = args[0] + } - sample := proto.DeleteRequest{} - - err := roundTrip(sample, func(cli proto.HubClient, in iocodec.Decoder, out iocodec.Encoder) error { - - v := proto.DeleteRequest{} - - err := in.Decode(&v) - if err != nil { - return err - } - - resp, err := cli.Delete(context.Background(), &v) + _resources.Reverse() + for _, r := range _resources.R { + err := r.SendDelete(uri) if err != nil { return err } - - return out.Encode(resp) - - }) - - return err - + } + return nil }, } diff --git a/cmd/device-hub-cli/cmd_describe.go b/cmd/device-hub-cli/cmd_describe.go deleted file mode 100644 index 2c37919..0000000 --- a/cmd/device-hub-cli/cmd_describe.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright © 2017 thingful - -package main - -import ( - "errors" - "fmt" - "strings" - - "github.com/spf13/cobra" - "github.com/thingful/device-hub/describe" - "github.com/thingful/device-hub/endpoint" - "github.com/thingful/device-hub/listener" - "github.com/thingful/device-hub/registry" -) - -var describeCommand = &cobra.Command{ - Use: "describe", - Short: "Describe parameters for endpoint and listeners", - RunE: func(cmd *cobra.Command, args []string) error { - - if len(args) != 2 { - return errors.New("describe [listener|endpoint] kind") - } - - typez := strings.ToLower(args[0]) - kind := strings.ToLower(args[1]) - - var params describe.Parameters - var err error - - register := registry.Default - - endpoint.Register(register) - listener.Register(register) - - switch typez { - case "listener": - params, err = register.DescribeListener(kind) - - case "endpoint": - params, err = register.DescribeEndpoint(kind) - - default: - return errors.New("describe [listener|endpoint] kind") - } - - if err != nil { - return err - } - for _, param := range params { - fmt.Println(param.Describe()) - } - - return nil - - }, -} diff --git a/cmd/device-hub-cli/cmd_pipe.go b/cmd/device-hub-cli/cmd_pipe.go deleted file mode 100644 index 54cefdc..0000000 --- a/cmd/device-hub-cli/cmd_pipe.go +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright © 2017 thingful - -package main - -import ( - "context" - "errors" - "fmt" - "strings" - - "github.com/fiorix/protoc-gen-cobra/iocodec" - "github.com/spf13/cobra" - "github.com/thingful/device-hub/proto" -) - -func startCommand() *cobra.Command { - - request := proto.StartRequest{ - Endpoints: []string{}, - Tags: map[string]string{}, - } - - tags := []string{} - - startCommand := &cobra.Command{ - Use: "start", - Short: "Start processing messages on a uri", - RunE: func(cmd *cobra.Command, args []string) error { - - if len(args) == 0 { - return errors.New("specify a profile") - } - - request.Profile = args[0] - - for _, m := range tags { - - bits := strings.Split(m, ":") - - if len(bits) != 2 { - return fmt.Errorf("metadata not colon (:) separated : %s", m) - } - - request.Tags[bits[0]] = bits[1] - } - - err := roundTrip(request, func(cli proto.HubClient, in iocodec.Decoder, out iocodec.Encoder) error { - - resp, err := cli.Start(context.Background(), &request) - - if err != nil { - return err - } - - return out.Encode(resp) - - }) - return err - }, - } - - startCommand.Flags().StringVarP(&request.Listener, "listener", "l", request.Listener, "listener uid to accept messages on") - startCommand.Flags().StringVarP(&request.Uri, "uri", "u", request.Uri, "uri to listen on") - startCommand.Flags().StringSliceVarP(&request.Endpoints, "endpoint", "e", request.Endpoints, "endpoint uid to push messages to, may be specified multiple times") - startCommand.Flags().StringSliceVarP(&tags, "tags", "t", tags, "colon separated (k:v) runtime tags to attach to requests, may be specified multiple times") - - return startCommand -} - -var stopCommand = &cobra.Command{ - Use: "stop", - Short: "Stop processing messages on a uri", - RunE: func(cmd *cobra.Command, args []string) error { - - v := proto.StopRequest{} - - err := roundTrip(v, func(cli proto.HubClient, in iocodec.Decoder, out iocodec.Encoder) error { - if len(args) == 0 { - return errors.New("specify a uri to stop") - } - - v.Uri = strings.TrimSpace(args[0]) - - resp, err := cli.Stop(context.Background(), &v) - - if err != nil { - return err - } - - return out.Encode(resp) - - }) - return err - }, -} - -var statusCommand = &cobra.Command{ - Use: "status", - Short: "List running pipes", - RunE: func(cmd *cobra.Command, args []string) error { - - v := proto.StatusRequest{} - - err := roundTrip(v, func(cli proto.HubClient, in iocodec.Decoder, out iocodec.Encoder) error { - - resp, err := cli.Status(context.Background(), &v) - - if err != nil { - return err - } - - return out.Encode(resp) - - }) - return err - }, -} diff --git a/cmd/device-hub-cli/cmd_show.go b/cmd/device-hub-cli/cmd_show.go index 8f86b9c..5b27ef1 100644 --- a/cmd/device-hub-cli/cmd_show.go +++ b/cmd/device-hub-cli/cmd_show.go @@ -16,20 +16,15 @@ var showCommand = &cobra.Command{ Short: "Display one or many resources", RunE: func(cmd *cobra.Command, args []string) error { - v := proto.ShowRequest{ - Filter: strings.Join(args, ","), - } - - err := roundTrip(v, func(cli proto.HubClient, in iocodec.Decoder, out iocodec.Encoder) error { - - resp, err := cli.Show(context.Background(), &v) - + err := roundTrip(func(cli proto.HubClient, in rawContent, out iocodec.Encoder) error { + req := proto.ShowRequest{ + Filter: strings.Join(args, ","), + } + resp, err := cli.Show(context.Background(), &req) if err != nil { return err } - return out.Encode(resp) - }) return err diff --git a/cmd/device-hub-cli/cmd_start.go b/cmd/device-hub-cli/cmd_start.go new file mode 100644 index 0000000..4c10baf --- /dev/null +++ b/cmd/device-hub-cli/cmd_start.go @@ -0,0 +1,92 @@ +// Copyright © 2017 thingful + +package main + +import ( + "context" + "errors" + + "github.com/fiorix/protoc-gen-cobra/iocodec" + "github.com/spf13/cobra" + "github.com/thingful/device-hub/proto" +) + +func startCommand() *cobra.Command { + + startCommand := &cobra.Command{ + Use: "start", + Short: "Start processing messages on a uri", + RunE: func(cmd *cobra.Command, args []string) error { + var profile string + + if len(args) > 0 { + profile = args[0] + } + if len(_resources.R) == 0 { + _resources.R = append(_resources.R, + resource{ + Data: map[string]interface{}{"type": "process"}}) + } + err := _resources.R[0].SendCreate(profile) + if err != nil { + return err + } + + return nil + }, + } + + startCommand.Flags().StringVarP(&_config.ProcessConf.ListenerUID, "listener", "l", _config.ProcessConf.ListenerUID, "listener uid to accept messages on") + startCommand.Flags().StringVarP(&_config.ProcessConf.URI, "uri", "u", _config.ProcessConf.URI, "uri to listen on") + startCommand.Flags().StringSliceVarP(&_config.ProcessConf.EndpointUIDs, "endpoint", "e", _config.ProcessConf.EndpointUIDs, "endpoint uid to push messages to, may be specified multiple times") + startCommand.Flags().StringSliceVarP(&_config.ProcessConf.Tags, "tags", "t", _config.ProcessConf.Tags, "colon separated (k:v) runtime tags to attach to requests, may be specified multiple times") + + return startCommand +} + +var stopCommand = &cobra.Command{ + Use: "stop", + Short: "Stop processing messages on a uri", + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + return errors.New("specify a uri to stop") + } + + err := roundTrip(func(client proto.HubClient, in rawContent, out iocodec.Encoder) error { + return stopCall(args[0], client, out) + }) + + return err + }, +} + +func stopCall(uri string, client proto.HubClient, out iocodec.Encoder) error { + req := proto.StopRequest{ + Uri: uri, + } + + resp, err := client.Stop(context.Background(), &req) + if err != nil { + return err + } + return out.Encode(resp) + +} + +var statusCommand = &cobra.Command{ + Use: "status", + Short: "List running pipes", + RunE: func(cmd *cobra.Command, args []string) error { + + err := roundTrip(func(client proto.HubClient, in rawContent, out iocodec.Encoder) error { + req := proto.StatusRequest{} + resp, err := client.Status(context.Background(), &req) + + if err != nil { + return err + } + return out.Encode(resp) + }) + return err + }, +} diff --git a/cmd/device-hub-cli/helpers.go b/cmd/device-hub-cli/helpers.go index ceb2d41..f397f13 100644 --- a/cmd/device-hub-cli/helpers.go +++ b/cmd/device-hub-cli/helpers.go @@ -9,8 +9,6 @@ import ( "io/ioutil" "net" "os" - "path" - "path/filepath" "github.com/fiorix/protoc-gen-cobra/iocodec" "github.com/thingful/device-hub/proto" @@ -108,9 +106,9 @@ func dial() (*grpc.ClientConn, proto.HubClient, error) { return conn, proto.NewHubClient(conn), nil } -type roundTripFunc func(cli proto.HubClient, in iocodec.Decoder, out iocodec.Encoder) error +type roundTripFunc func(cli proto.HubClient, in rawContent, out iocodec.Encoder) error -func roundTrip(sample interface{}, fn roundTripFunc) error { +func roundTrip(fn roundTripFunc) error { cfg := _config var em iocodec.EncoderMaker @@ -126,96 +124,16 @@ func roundTrip(sample interface{}, fn roundTripFunc) error { } } - if cfg.PrintSampleRequest { - return em.NewEncoder(os.Stdout).Encode(sample) - } - - decoders := []iocodec.Decoder{} - files := []*os.File{} - - // either no request file is not specified or set to std-in - if (cfg.RequestFile == "" && cfg.RequestDir == "") || cfg.RequestFile == "-" { - decoders = append(decoders, iocodec.DefaultDecoders["json"].NewDecoder(os.Stdin)) - - // or request file is specified - } else if cfg.RequestFile != "" { - - f, d, err := decoderFromPath(cfg.RequestFile) - - if err != nil { - return err - } - - decoders = append(decoders, d) - files = append(files, f) - - // or request dir is specified - } else if cfg.RequestDir != "" { - listing, err := ioutil.ReadDir(cfg.RequestDir) - - if err != nil { - return err - } - - for _, fi := range listing { - - fmt.Println(fi.Name()) - - folderPath := path.Join(cfg.RequestDir, fi.Name()) - f, d, err := decoderFromPath(folderPath) - - if err != nil { - return err - } - - decoders = append(decoders, d) - files = append(files, f) - - } - } - - defer func() { - for i, _ := range files { - files[i].Close() - } - }() - conn, client, err := dial() if err != nil { return err } - defer conn.Close() - for _, d := range decoders { - err := fn(client, d, em.NewEncoder(os.Stdout)) - - if err != nil { - return err - } - } - - return nil -} - -func decoderFromPath(filePath string) (*os.File, iocodec.Decoder, error) { - - f, err := os.Open(filePath) + err = fn(client, nil, em.NewEncoder(os.Stdout)) if err != nil { - return nil, nil, fmt.Errorf("request file: %v", err) - } - - ext := filepath.Ext(filePath) - - if len(ext) > 0 && ext[0] == '.' { - ext = ext[1:] - if ext != "yaml" { - return nil, nil, fmt.Errorf("invalid request file format: %q", ext) - - } + return err } - dm, _ := iocodec.DefaultDecoders["yaml"] - - return f, dm.NewDecoder(f), nil + return nil } diff --git a/cmd/device-hub-cli/main.go b/cmd/device-hub-cli/main.go index ac36c9c..23ede5a 100644 --- a/cmd/device-hub-cli/main.go +++ b/cmd/device-hub-cli/main.go @@ -17,13 +17,24 @@ import ( var RootCmd = &cobra.Command{ Use: "device-hub-cli", + PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + + err := _resources.SetResources(_config) + if err != nil { + return err + } + return nil + }, } // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -var _config = newConfig() +var ( + _config = newConfig() + _resources = newResources() +) type config struct { ServerAddr string `envconfig:"SERVER_ADDR" default:"127.0.0.1:50051"` @@ -42,6 +53,7 @@ type config struct { AuthTokenType string `envconfig:"AUTH_TOKEN_TYPE" default:"Bearer"` JWTKey string `envconfig:"JWT_KEY"` JWTKeyFile string `envconfig:"JWT_KEY_FILE"` + ProcessConf processConf } func newConfig() *config { @@ -78,7 +90,6 @@ func init() { RootCmd.AddCommand(startCommand()) RootCmd.AddCommand(stopCommand) RootCmd.AddCommand(statusCommand) - RootCmd.AddCommand(describeCommand) _config.AddFlags(RootCmd.PersistentFlags()) } diff --git a/cmd/device-hub-cli/resource.go b/cmd/device-hub-cli/resource.go new file mode 100644 index 0000000..06ccb74 --- /dev/null +++ b/cmd/device-hub-cli/resource.go @@ -0,0 +1,243 @@ +// Copyright © 2017 thingful + +package main + +import ( + "context" + "fmt" + "io/ioutil" + "path" + "path/filepath" + "sort" + "strings" + + "github.com/fiorix/protoc-gen-cobra/iocodec" + "github.com/thingful/device-hub/proto" + + yaml "gopkg.in/yaml.v2" +) + +type rawContent []byte + +func (r rawContent) Decode(target interface{}) error { + err := yaml.Unmarshal(r, target) + if err != nil { + return fmt.Errorf("error decoding data: %s", err.Error()) + } + return nil +} + +// Represent a resource file, Data is basically used to order a resourceSlice +// Raw contains the file content +type resource struct { + FileName string + Data map[string]interface{} + Raw rawContent +} + +// Load the configuration file to Data +func (r *resource) Load(filePath string) (err error) { + r.Raw, err = ioutil.ReadFile(filePath) + if err != nil { + return fmt.Errorf("failed to read file [%s]: %s", filePath, err.Error()) + } + + _, r.FileName = filepath.Split(filePath) + + r.Raw.Decode(&r.Data) + if err != nil { + return fmt.Errorf("error parsing file [%s]: %s", filePath, err.Error()) + } + return nil +} + +func (r *resource) sendCreateReq() error { + err := roundTrip(func(client proto.HubClient, in rawContent, out iocodec.Encoder) error { + req := proto.CreateRequest{} + err := r.Raw.Decode(&req) + if err != nil { + return err + } + + resp, err := client.Create(context.Background(), &req) + if err != nil { + return err + } + return out.Encode(resp) + }) + return err +} + +func (r *resource) sendStartReq(profile string) error { + err := roundTrip(func(client proto.HubClient, in rawContent, out iocodec.Encoder) error { + req := proto.StartRequest{ + Endpoints: []string{}, + Tags: map[string]string{}, + } + err := r.Raw.Decode(&_config.ProcessConf) + if err != nil { + return err + } + + if len(profile) > 0 { + req.Profile = profile + } else { + req.Profile = _config.ProcessConf.ProfileUID + } + + req.Uri = _config.ProcessConf.URI + req.Listener = _config.ProcessConf.ListenerUID + req.Endpoints = _config.ProcessConf.EndpointUIDs + + // review tags + for _, m := range _config.ProcessConf.Tags { + bits := strings.Split(m, ":") + if len(bits) != 2 { + return fmt.Errorf("metadata not colon (:) separated : %s", m) + } + req.Tags[bits[0]] = bits[1] + } + + resp, err := client.Start(context.Background(), &req) + if err != nil { + return err + } + return out.Encode(resp) + }) + return err +} + +func (r *resource) SendCreate(args ...string) error { + var uri string + if r.Data["type"] == "process" { + if len(args) > 0 { + uri = args[0] + } + return r.sendStartReq(uri) + } + return r.sendCreateReq() +} + +func (r *resource) sendStopReq(uri string) error { + err := roundTrip(func(client proto.HubClient, in rawContent, out iocodec.Encoder) error { + if uri == "" { + uri = r.Data["uri"].(string) + } + return stopCall(uri, client, out) + }) + return err +} + +func (r *resource) sendDeleteReq() error { + err := roundTrip(func(client proto.HubClient, in rawContent, out iocodec.Encoder) error { + req := proto.DeleteRequest{} + err := r.Raw.Decode(&req) + if err != nil { + return err + } + + resp, err := client.Delete(context.Background(), &req) + if err != nil { + return err + } + return out.Encode(resp) + }) + return err +} + +func (r *resource) SendDelete(uri string) error { + if r.Data["type"] == "process" { + return r.sendStopReq(uri) + } + return r.sendDeleteReq() +} + +// resourceSlice contains configs and implements sort interface using +// "process" type file as the less weight +type resourceSlice struct { + R []resource +} + +func newResources() *resourceSlice { + return &resourceSlice{} +} + +func (r *resourceSlice) Append(e resource) { + + r.R = append(r.R, e) +} + +func (r resourceSlice) Len() int { + return len(r.R) +} + +func (r resourceSlice) Less(i, j int) bool { + if r.R[j].Data["type"] == "process" { + return true + } + return false +} + +func (r resourceSlice) Swap(i, j int) { + r.R[i], r.R[j] = r.R[j], r.R[i] +} + +// Sort is required to put processes at the end when executing create cmd +func (r resourceSlice) Sort() { + sort.Sort(resourceSlice(r)) +} + +// Reverse is required to put processes at first to stop them before delete resources +func (r resourceSlice) Reverse() { + sort.Sort(sort.Reverse(resourceSlice(r))) +} + +func (r resourceSlice) Print() { + for _, f := range r.R { + fmt.Println(f.FileName) + } +} + +// GetCliConfig get config for the CLI app +func (r *resourceSlice) SetResources(cfg *config) error { + var res resource + if cfg.RequestFile != "" { + err := res.Load(cfg.RequestFile) + if err != nil { + return err + } + r.Append(res) + return nil + + } else if cfg.RequestDir != "" { + listing, err := ioutil.ReadDir(cfg.RequestDir) + if err != nil { + return err + } + + for _, f := range listing { + folderPath := path.Join(cfg.RequestDir, f.Name()) + var _res resource // check if this could be outer scoped! (conf) + err = _res.Load(folderPath) + if err != nil { + return err + } + r.Append(_res) + } + } + // Sorted with process to the end by default + r.Sort() + // TODO validate? + r.Print() + return nil +} + +// could be proto.StartRequest? +type processConf struct { + URI string `yaml:"uri"` + Type string `yaml:"type"` + EndpointUIDs []string `yaml:"endpoint-uids"` + ListenerUID string `yaml:"listener-uid"` + ProfileUID string `yaml:"profile-uid"` + Tags []string `yaml:"tags"` +} diff --git a/docs/client.md b/docs/client.md index 3ae0a9a..be02990 100644 --- a/docs/client.md +++ b/docs/client.md @@ -20,41 +20,36 @@ Client CLI Commands - Flag: -d Large Format: --request-dir Is required: Yes if -f isn't specified - Description: Directory containing client request file(s) (must be json, yaml, or xml) + Description: Directory containing client request yaml file(s) if there are process files, will be started Parameter: A filesystem path Example: device-hub-cli create -d=./test-configurations/ - Flag: -f Large Format: --request-file Is required: Yes if -d isn't specified - Description: Client request file (must be json, yaml, or xml); use "-" for stdin + json - Parameter: Directory containing client request file(s) (must be json, yaml, or xml) + Description: Client request yaml file + Parameter: Directory containing client request yaml file(s) Example: device-hub-cli create -f=./test-configurations/mqtt_listener.yaml - Command Name: delete [-d|-f]= - Description: Delete listener, profile and endpoint resources + Description: Delete listener, profile, endpoint resources and stop processes if -d is used Flags: - Flag: -d Large Format: --request-dir Is required: Yes if -f isn't specified - Description: Directory containing client request file(s) (must be json, yaml, or xml) + Description: Directory containing client request yaml file(s) if there are process files, will be stopped Parameter: A filesystem path Example: device-hub-cli delete -d=./test-configurations/ - Flag: -f Large Format: --request-file Is required: Yes if -d isn't specified - Description: Client request file (must be json, yaml, or xml); use "-" for stdin + json - Parameter: Directory containing client request file(s) (must be json, yaml, or xml) + Description: Client request yaml file + Parameter: Directory containing client request yaml file(s) Example: device-hub-cli delete -f=./test-configurations/mqtt_listener.yaml -- Command Name: describe [listener|endpoint] [mqtt|stdout] - Description: Describe parameters for endpoints and listeners - Example: device-hub-cli listener mqtt - - - Command Name: show [listener|endpoint|profile|all] Description: Display one or many resources by type or using "all" as * filter, Example: device-hub-cli show all @@ -64,28 +59,35 @@ Client CLI Commands Description: List running pipes -- Command Name: start [-e -l -u ] +- Command Name: start [-f ][-e -l -u ] Description: Start processing messages on an URI Flags: + + - Flag: -f + Description: Start processing messages using a yaml config file + Large Format: --request-file + Is required: No + - Flag: -e Description: Endpoint uid to push messages to, may be specified multiple times Large Format: --endpoint - Is required: Yes + Is required: Yes if -f isn't specified - Flag: -l Description: Listener uid to accept messages on Large Format: --listener - Is required: Yes + Is required: Yes if -f isn't specified - Flag: -u Description: Uri to listen on Large Format: --uri - Is required: Yes + Is required: Yes if -f isn't specified - Flag: -t Description: Colon separated (k:v) runtime tags to attach to requests, may be specified multiple times Large Format: --tags - + Is required: Yes if -f isn't specified + Example: device-hub-cli start -e=stdout-endpoint -l=http-listener-local-port-8085 -u=/a thingful/helsinki-bus @@ -116,10 +118,6 @@ CLI Global Flags Description: response format (json, prettyjson, yaml, or xml) Default: json -- Flag: -p - Large Format: --print-sample-request - Description: Print sample request file and exit - - Flag: --timeout Description: Client connection timeout Default: 10s diff --git a/examples/config/helsinki_process.yaml b/examples/config/helsinki_process.yaml new file mode 100644 index 0000000..57906d7 --- /dev/null +++ b/examples/config/helsinki_process.yaml @@ -0,0 +1,8 @@ +uri: /b +type: process +endpoint-uids: + - stdout-endpoint +listener-uid: mqtt-helsinki-transport-service-listener +profile-uid: thingful/helsinki-bus +tags: + - foo:bar \ No newline at end of file diff --git a/examples/config/http_listener_process.yaml b/examples/config/http_listener_process.yaml new file mode 100644 index 0000000..e437d57 --- /dev/null +++ b/examples/config/http_listener_process.yaml @@ -0,0 +1,8 @@ +uri: /a +type: process +endpoint-uids: + - http-endpoint-example.com +listener-uid: http-listener-local-port-8085 +profile-uid: thingful/device-1 +tags: + - foo:bar \ No newline at end of file diff --git a/examples/config_test.go b/examples/config_test.go index 2bbfb56..5cb9efc 100644 --- a/examples/config_test.go +++ b/examples/config_test.go @@ -49,9 +49,12 @@ func TestConfigurationFilesAreValid(t *testing.T) { err = in.Decode(&entity) assert.Nil(t, err) - assert.NotEmpty(t, entity.Kind) assert.NotEmpty(t, entity.Type) + if strings.ToLower(entity.Type) != "process" { + assert.NotEmpty(t, entity.Kind) + } + var params describe.Parameters switch strings.ToLower(entity.Type) {