(_ *cobra.Command, _ []string)
| 60 | } |
| 61 | |
| 62 | func exec(_ *cobra.Command, _ []string) { |
| 63 | cfg := adminclient.NewConfiguration() |
| 64 | cfg.Servers = []adminclient.ServerConfiguration{{ |
| 65 | URL: common.Config.ServiceAddr, |
| 66 | }} |
| 67 | cli := adminclient.NewAPIClient(cfg) |
| 68 | f := adminclient.ModelFunction{ |
| 69 | Name: config.name, |
| 70 | Runtime: adminclient.ModelRuntimeConfig{ |
| 71 | Type: fs_cmmon.WASMRuntime, |
| 72 | Config: map[string]interface{}{ |
| 73 | fs_cmmon.RuntimeArchiveConfigKey: config.archive, |
| 74 | }}, |
| 75 | Source: utils.MakeMemorySourceTubeConfig(config.inputs...), |
| 76 | Sink: *utils.MakeMemorySinkTubeConfig(config.output), |
| 77 | Replicas: config.replica, |
| 78 | } |
| 79 | |
| 80 | res, err := cli.FunctionAPI.CreateFunction(context.Background()).Body(f).Execute() |
| 81 | if err != nil { |
| 82 | if res != nil { |
| 83 | body, e := io.ReadAll(res.Body) |
| 84 | if e != nil { |
| 85 | fmt.Printf("Failed to create function: %v\n", err) |
| 86 | } else { |
| 87 | fmt.Printf("Failed to create function: %v, %s\n", err, string(body)) |
| 88 | } |
| 89 | } else { |
| 90 | fmt.Printf("Failed to create function: %v\n", err) |
| 91 | } |
| 92 | os.Exit(1) |
| 93 | } |
| 94 | if res.StatusCode != 200 { |
| 95 | fmt.Printf("Failed to create function with status code: %d\n", res.StatusCode) |
| 96 | os.Exit(1) |
| 97 | } |
| 98 | } |
nothing calls this directly
no test coverage detected