Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
chore: flatten the output of single output tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
YCK1130 committed Jul 11, 2024
1 parent 43cff96 commit a880e8e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 137 deletions.
2 changes: 1 addition & 1 deletion application/github/v0/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ func TestComponent_CreateWebHook(t *testing.T) {
ContentType: "json",
},
wantResp: CreateWebHookResp{
Hook: HookInfo{
HookInfo: HookInfo{
ID: 1,
URL: "hook_url",
PingURL: "ping_url",
Expand Down
209 changes: 79 additions & 130 deletions application/github/v0/config/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,17 +575,8 @@
"output": {
"description": "The specific pr in GitHub repository",
"instillUIOrder": 0,
"properties": {
"pull_request": {
"$ref": "#/$defs/pull_request",
"required": [],
"instillUIOrder": 1,
"description": "A pull request in GitHub"
}
},
"required": [
"pull_request"
],
"$ref": "#/$defs/pull_request",
"required": [],
"title": "Output",
"instillFormat": "object",
"type": "object"
Expand Down Expand Up @@ -795,16 +786,9 @@
"description": "The created comment",
"instillUIOrder": 0,
"properties": {
"comment": {
"$ref": "#/$defs/review_comments",
"required": [],
"instillUIOrder": 1,
"description": "The created comment"
}
"$ref": "#/$defs/review_comments/properties"
},
"required": [
"comment"
],
"required": [],
"title": "Output",
"instillFormat": "object",
"type": "object"
Expand Down Expand Up @@ -840,16 +824,9 @@
"description": "The specific commit in GitHub repository",
"instillUIOrder": 0,
"properties": {
"commit": {
"$ref": "#/$defs/commit",
"required": [],
"instillUIOrder": 1,
"description": "A commit in GitHub"
}
"$ref": "#/$defs/commit/properties"
},
"required": [
"commit"
],
"required": [],
"title": "Output",
"instillFormat": "object",
"type": "object"
Expand Down Expand Up @@ -1031,17 +1008,9 @@
"description": "The specific issue in GitHub repository",
"instillUIOrder": 0,
"properties": {
"issue": {
"description": "An issue in GitHub",
"instillUIOrder": 1,
"$ref": "#/$defs/issue",
"title": "Issue",
"required": []
}
"$ref": "#/$defs/issue/properties"
},
"required": [
"issue"
],
"required": [],
"title": "Output",
"instillFormat": "object",
"type": "object"
Expand Down Expand Up @@ -1083,17 +1052,9 @@
"description": "The created issue",
"instillUIOrder": 0,
"properties": {
"issue": {
"$ref": "#/$defs/issue",
"required": [],
"instillUIOrder": 1,
"title": "Issue",
"description": "The created issue"
}
"$ref": "#/$defs/issue/properties"
},
"required": [
"issue"
],
"required": [],
"title": "Output",
"instillFormat": "object",
"type": "object"
Expand Down Expand Up @@ -1212,107 +1173,95 @@
"description": "The created webhook",
"instillUIOrder": 0,
"properties": {
"hook": {
"description": "The created webhook",
"title": "Webhook",
"id": {
"description": "ID of the webhook",
"instillUIOrder": 1,
"title": "Webhook ID",
"instillFormat": "integer",
"instillAcceptFormats": [
"integer"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "integer"
},
"url": {
"description": "URL of the webhook",
"instillUIOrder": 2,
"title": "Webhook URL",
"instillFormat": "string",
"instillAcceptFormats": [
"string"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "string"
},
"ping_url": {
"description": "URL to ping the webhook",
"instillUIOrder": 3,
"title": "Ping URL",
"instillFormat": "string",
"instillAcceptFormats": [
"string"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "string"
},
"test_url": {
"description": "URL to test the webhook",
"instillUIOrder": 4,
"title": "Test URL",
"instillFormat": "string",
"instillAcceptFormats": [
"string"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "string"
},
"config": {
"description": "Configuration of the webhook",
"instillUIOrder": 6,
"title": "Config",
"instillFormat": "object",
"type": "object",
"properties": {
"id": {
"description": "ID of the webhook",
"instillUIOrder": 1,
"title": "Webhook ID",
"instillFormat": "integer",
"instillAcceptFormats": [
"integer"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "integer"
},
"url": {
"description": "URL of the webhook",
"instillUIOrder": 2,
"instillUIOrder": 1,
"title": "Webhook URL",
"instillFormat": "string",
"instillAcceptFormats": [
"string"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "string"
},
"ping_url": {
"description": "URL to ping the webhook",
"instillUIOrder": 3,
"title": "Ping URL",
"content_type": {
"description": "Content type of the webhook",
"instillUIOrder": 2,
"title": "Content Type",
"instillFormat": "string",
"instillAcceptFormats": [
"string"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "string"
},
"test_url": {
"description": "URL to test the webhook",
"instillUIOrder": 4,
"title": "Test URL",
"insecure_ssl": {
"description": "Whether the webhook is insecure",
"instillUIOrder": 3,
"title": "Insecure SSL",
"instillFormat": "string",
"instillAcceptFormats": [
"string"
],
"instillUpstreamTypes": [
"value",
"reference"
],
"type": "string"
},
"config": {
"description": "Configuration of the webhook",
"instillUIOrder": 6,
"title": "Config",
"instillFormat": "object",
"type": "object",
"properties": {
"url": {
"description": "URL of the webhook",
"instillUIOrder": 1,
"title": "Webhook URL",
"instillFormat": "string",
"type": "string"
},
"content_type": {
"description": "Content type of the webhook",
"instillUIOrder": 2,
"title": "Content Type",
"instillFormat": "string",
"type": "string"
},
"insecure_ssl": {
"description": "Whether the webhook is insecure",
"instillUIOrder": 3,
"title": "Insecure SSL",
"instillFormat": "string",
"type": "string"
}
},
"required": []
}
},
"required": []
}
},
"required": [
"hook"
],
"required": [],
"title": "Output",
"instillFormat": "object",
"type": "object"
Expand Down
4 changes: 2 additions & 2 deletions application/github/v0/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type GetIssueInput struct {
}

type GetIssueResp struct {
Issue Issue `json:"issue"`
Issue
}

func (githubClient *Client) getIssueTask(ctx context.Context, props *structpb.Struct) (*structpb.Struct, error) {
Expand Down Expand Up @@ -176,7 +176,7 @@ type CreateIssueInput struct {
}

type CreateIssueResp struct {
Issue Issue `json:"issue"`
Issue
}

func (githubClient *Client) createIssueTask(ctx context.Context, props *structpb.Struct) (*structpb.Struct, error) {
Expand Down
2 changes: 1 addition & 1 deletion application/github/v0/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ type GetPullRequestInput struct {
PrNumber float64 `json:"pr_number"`
}
type GetPullRequestResp struct {
PullRequest PullRequest `json:"pull_request"`
PullRequest
}

func (githubClient *Client) getPullRequestTask(ctx context.Context, props *structpb.Struct) (*structpb.Struct, error) {
Expand Down
2 changes: 1 addition & 1 deletion application/github/v0/review_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type CreateReviewCommentInput struct {
}

type CreateReviewCommentResp struct {
ReviewComment ReviewComment `json:"comment"`
ReviewComment
}

// CreateReviewComment creates a review comment for a given pull request.
Expand Down
4 changes: 2 additions & 2 deletions application/github/v0/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type HookInfo struct {
Config HookConfig `json:"config"`
}
type CreateWebHookResp struct {
Hook HookInfo `json:"hook"`
HookInfo
}

func (githubClient *Client) createWebhookTask(ctx context.Context, props *structpb.Struct) (*structpb.Struct, error) {
Expand Down Expand Up @@ -82,7 +82,7 @@ func (githubClient *Client) createWebhookTask(ctx context.Context, props *struct
if err != nil {
return nil, err
}
resp.Hook = hookInfo
resp.HookInfo = hookInfo
out, err := base.ConvertToStructpb(resp)
if err != nil {
return nil, err
Expand Down

0 comments on commit a880e8e

Please sign in to comment.