From 17750d91f2316e508c492201a9c76ea393f66fb3 Mon Sep 17 00:00:00 2001 From: Matthias De Vriendt Date: Tue, 18 Nov 2025 13:57:38 +0100 Subject: [PATCH 1/3] show version in connector get command --- cli/render.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/render.go b/cli/render.go index 317cd08..a309d61 100644 --- a/cli/render.go +++ b/cli/render.go @@ -33,7 +33,11 @@ func renderConnector(c model.Connector) string { tbl.SetTitle(fmt.Sprintf("Connector: %s", c.ConnectorId)) tbl.AppendRow(table.Row{"Description", text.WrapSoft(c.Description, 50)}) - tbl.AppendRow(table.Row{"Runtime", c.RuntimeId}) + runtime := c.RuntimeId + if c.RuntimeVersion != "" { + runtime = fmt.Sprintf("%s:%s", c.RuntimeId, c.RuntimeVersion) + } + tbl.AppendRow(table.Row{"Runtime", runtime}) b, err := yaml.Marshal(c.Steps) fisk.FatalIfError(err, "failed to render steps") From b8dec848ce7a46d212c3014d8283faee4ae92d5c Mon Sep 17 00:00:00 2001 From: Matthias De Vriendt Date: Tue, 18 Nov 2025 14:20:50 +0100 Subject: [PATCH 2/3] render runtime_version in connector edit command --- cli/connector_command.go | 8 ++-- model/library.go | 63 ++++++++++++++++++++++++- spec/connector.go | 6 +++ spec/schemas/connector-spec.schema.json | 6 ++- 4 files changed, 77 insertions(+), 6 deletions(-) diff --git a/cli/connector_command.go b/cli/connector_command.go index 599aa14..a15b28d 100644 --- a/cli/connector_command.go +++ b/cli/connector_command.go @@ -68,7 +68,6 @@ func ConfigureConnectorCommand(parentCmd commandHost, opts *Options) { saveCmd.Arg("id", "The id of the connector to create or modify").Required().StringVar(&c.id) saveCmd.Flag("file", "Use the connector definition from the given file").Short('f').IsSetByUser(&c.fileSetByUser).Default("./ConnectFile").StringVar(&c.file) saveCmd.Flag("runtime", "The runtime id").Default("wombat").StringVar(&c.runtime) - saveCmd.Flag("runtime-version", "The runtime version").Required().StringVar(&c.runtimeVersion) copyCmd := connectorCmd.Command("copy", "Copy a connector").Action(c.copyConnector) copyCmd.Arg("id", "The id of the connector to copy").Required().StringVar(&c.id) @@ -344,9 +343,10 @@ func (c *connectorCommand) saveConnector(pc *fisk.ParseContext) error { var sp spec.ConnectorSpec if exists { sp = spec.ConnectorSpec{ - Description: conn.Description, - RuntimeId: conn.RuntimeId, - Steps: convert.ConvertStepsToSpec(conn.Steps), + Description: conn.Description, + RuntimeId: conn.RuntimeId, + RuntimeVersion: conn.RuntimeVersion, + Steps: convert.ConvertStepsToSpec(conn.Steps), } } else { if !c.fileSetByUser { diff --git a/model/library.go b/model/library.go index 3f543af..f1939c9 100644 --- a/model/library.go +++ b/model/library.go @@ -577,7 +577,68 @@ func (j *RuntimeGetResponse) UnmarshalJSON(value []byte) error { return nil } -type RuntimeListRequest map[string]interface{} +type RuntimeLatestVersionRequest struct { + // The runtime ID to find the latest version for + RuntimeId string `json:"runtime_id" yaml:"runtime_id" mapstructure:"runtime_id"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *RuntimeLatestVersionRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["runtime_id"]; raw != nil && !ok { + return fmt.Errorf("field runtime_id in RuntimeLatestVersionRequest: required") + } + type Plain RuntimeLatestVersionRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = RuntimeLatestVersionRequest(plain) + return nil +} + +type RuntimeLatestVersionResponse struct { + // True if the runtime was found + Found bool `json:"found" yaml:"found" mapstructure:"found"` + + // The runtime ID that was queried + RuntimeId string `json:"runtime_id" yaml:"runtime_id" mapstructure:"runtime_id"` + + // The latest version found, empty if none found + Version string `json:"version" yaml:"version" mapstructure:"version"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *RuntimeLatestVersionResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["found"]; raw != nil && !ok { + return fmt.Errorf("field found in RuntimeLatestVersionResponse: required") + } + if _, ok := raw["runtime_id"]; raw != nil && !ok { + return fmt.Errorf("field runtime_id in RuntimeLatestVersionResponse: required") + } + if _, ok := raw["version"]; raw != nil && !ok { + return fmt.Errorf("field version in RuntimeLatestVersionResponse: required") + } + type Plain RuntimeLatestVersionResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = RuntimeLatestVersionResponse(plain) + return nil +} + +type RuntimeListRequest struct { + // Optional filter to list versions for a specific runtime ID only + RuntimeId *string `json:"runtime_id,omitempty" yaml:"runtime_id,omitempty" mapstructure:"runtime_id,omitempty"` +} type RuntimeListResponse struct { // Runtimes corresponds to the JSON schema field "runtimes". diff --git a/spec/connector.go b/spec/connector.go index e58f7df..f3f067f 100644 --- a/spec/connector.go +++ b/spec/connector.go @@ -14,6 +14,9 @@ type ConnectorSpec struct { // version, e.g. 'wombat:edge' RuntimeId string `json:"runtime_id" yaml:"runtime_id" mapstructure:"runtime_id"` + // The version of the runtime + RuntimeVersion string `json:"runtime_version" yaml:"runtime_version" mapstructure:"runtime_version"` + // Steps corresponds to the JSON schema field "steps". Steps StepsSpec `json:"steps" yaml:"steps" mapstructure:"steps"` } @@ -30,6 +33,9 @@ func (j *ConnectorSpec) UnmarshalJSON(value []byte) error { if _, ok := raw["runtime_id"]; raw != nil && !ok { return fmt.Errorf("field runtime_id in ConnectorSpec: required") } + if _, ok := raw["runtime_version"]; raw != nil && !ok { + return fmt.Errorf("field runtime_version in ConnectorSpec: required") + } if _, ok := raw["steps"]; raw != nil && !ok { return fmt.Errorf("field steps in ConnectorSpec: required") } diff --git a/spec/schemas/connector-spec.schema.json b/spec/schemas/connector-spec.schema.json index 546990f..fe84b2f 100644 --- a/spec/schemas/connector-spec.schema.json +++ b/spec/schemas/connector-spec.schema.json @@ -12,9 +12,13 @@ "type": "string", "description": "The runtime to use for this connector. The runtime can be suffixed with the version, e.g. 'wombat:edge'" }, + "runtime_version": { + "type": "string", + "description": "The version of the runtime" + }, "steps": { "$ref": "connector-steps-model.schema.json" } }, - "required": ["description", "runtime_id", "steps"] + "required": ["description", "runtime_id", "runtime_version", "steps"] } \ No newline at end of file From 7724b9081fe04cca0af0cce214e6bce87090ef62 Mon Sep 17 00:00:00 2001 From: Matthias De Vriendt Date: Tue, 18 Nov 2025 14:49:36 +0100 Subject: [PATCH 3/3] connector create should pass runtime_version: nil instead of when not provided, so connect-node can infer latest version --- cli/connector_command.go | 8 ++++++-- client/connector.go | 13 ++++++++----- spec/connector.go | 5 +---- spec/schemas/connector-spec.schema.json | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cli/connector_command.go b/cli/connector_command.go index a15b28d..5716ac2 100644 --- a/cli/connector_command.go +++ b/cli/connector_command.go @@ -345,7 +345,7 @@ func (c *connectorCommand) saveConnector(pc *fisk.ParseContext) error { sp = spec.ConnectorSpec{ Description: conn.Description, RuntimeId: conn.RuntimeId, - RuntimeVersion: conn.RuntimeVersion, + RuntimeVersion: &conn.RuntimeVersion, Steps: convert.ConvertStepsToSpec(conn.Steps), } } else { @@ -373,7 +373,11 @@ func (c *connectorCommand) saveConnector(pc *fisk.ParseContext) error { var connector *model.Connector if !exists { - connector, err = appCtx.Client.CreateConnector(c.id, result.Description, result.RuntimeId, c.runtimeVersion, convert.ConvertStepsFromSpec(result.Steps), c.opts.Timeout) + runtimeVersion := "" + if result.RuntimeVersion != nil { + runtimeVersion = *result.RuntimeVersion + } + connector, err = appCtx.Client.CreateConnector(c.id, result.Description, result.RuntimeId, runtimeVersion, convert.ConvertStepsFromSpec(result.Steps), c.opts.Timeout) if err != nil { color.Red("Could not save connector: %s", err) os.Exit(1) diff --git a/client/connector.go b/client/connector.go index a73fb01..7e4b526 100644 --- a/client/connector.go +++ b/client/connector.go @@ -76,11 +76,14 @@ func (c *connectorClient) GetConnectorStatus(name string, timeout time.Duration) func (c *connectorClient) CreateConnector(id, description, runtimeId string, runtimeVersion string, steps model.Steps, timeout time.Duration) (*model.Connector, error) { req := model.ConnectorCreateRequest{ - Id: id, - Description: description, - RuntimeId: runtimeId, - RuntimeVersion: &runtimeVersion, - Steps: steps, + Id: id, + Description: description, + RuntimeId: runtimeId, + Steps: steps, + } + + if runtimeVersion != "" { + req.RuntimeVersion = &runtimeVersion } var resp model.ConnectorCreateResponse diff --git a/spec/connector.go b/spec/connector.go index f3f067f..336161e 100644 --- a/spec/connector.go +++ b/spec/connector.go @@ -15,7 +15,7 @@ type ConnectorSpec struct { RuntimeId string `json:"runtime_id" yaml:"runtime_id" mapstructure:"runtime_id"` // The version of the runtime - RuntimeVersion string `json:"runtime_version" yaml:"runtime_version" mapstructure:"runtime_version"` + RuntimeVersion *string `json:"runtime_version,omitempty" yaml:"runtime_version,omitempty" mapstructure:"runtime_version,omitempty"` // Steps corresponds to the JSON schema field "steps". Steps StepsSpec `json:"steps" yaml:"steps" mapstructure:"steps"` @@ -33,9 +33,6 @@ func (j *ConnectorSpec) UnmarshalJSON(value []byte) error { if _, ok := raw["runtime_id"]; raw != nil && !ok { return fmt.Errorf("field runtime_id in ConnectorSpec: required") } - if _, ok := raw["runtime_version"]; raw != nil && !ok { - return fmt.Errorf("field runtime_version in ConnectorSpec: required") - } if _, ok := raw["steps"]; raw != nil && !ok { return fmt.Errorf("field steps in ConnectorSpec: required") } diff --git a/spec/schemas/connector-spec.schema.json b/spec/schemas/connector-spec.schema.json index fe84b2f..b78b57e 100644 --- a/spec/schemas/connector-spec.schema.json +++ b/spec/schemas/connector-spec.schema.json @@ -20,5 +20,5 @@ "$ref": "connector-steps-model.schema.json" } }, - "required": ["description", "runtime_id", "runtime_version", "steps"] + "required": ["description", "runtime_id", "steps"] } \ No newline at end of file