Skip to content

Commit

Permalink
feat: merge resource spec into component spec (#86)
Browse files Browse the repository at this point in the history
Because

- We've retired the connector resource, there is no need to have two
specifications for resource and component. We can merge them into one.

This commit:

- Merges the resource spec into the component spec.

Note:

- We keep the old resource spec for now. It will be removed soon.
  • Loading branch information
donch1989 committed Apr 17, 2024
1 parent 8203316 commit a6de70e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/base/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ func (c *Connector) LoadConnectorDefinition(definitionJSONBytes []byte, tasksJSO
if err != nil {
return err
}

// deprecated, will be removed soon
def.Spec.ResourceSpecification, err = c.refineResourceSpec(def.Spec.ResourceSpecification)
if err != nil {
return err
Expand All @@ -88,6 +90,9 @@ func (c *Connector) LoadConnectorDefinition(definitionJSONBytes []byte, tasksJSO
if err != nil {
return err
}
connectionPropStruct := &structpb.Struct{Fields: map[string]*structpb.Value{}}
connectionPropStruct.Fields["connection"] = structpb.NewStructValue(def.Spec.ResourceSpecification)
def.Spec.ComponentSpecification.Fields["properties"] = structpb.NewStructValue(connectionPropStruct)

def.Spec.DataSpecifications, err = c.generateDataSpecs(def.Title, availableTasks)
if err != nil {
Expand Down
22 changes: 22 additions & 0 deletions pkg/base/testdata/wantConnectorDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@
"type": "object"
}
],
"properties": {
"connection": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": true,
"instillShortDescription": "",
"properties": {
"api_key": {
"description": "Fill your OpenAI API key. To find your keys, visit your OpenAI's API Keys page.",
"instillCredentialField": true,
"instillShortDescription": "Fill your OpenAI API key. To find your keys, visit your OpenAI's API Keys page.",
"instillUIOrder": 0,
"title": "API Key",
"type": "string"
}
},
"required": [
"api_key"
],
"title": "OpenAI Connector Resource",
"type": "object"
}
},
"title": "OpenAI Component",
"type": "object"
},
Expand Down

0 comments on commit a6de70e

Please sign in to comment.