Skip to content

Commit

Permalink
Improved integration, notifier show & list commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
vhadianto committed Feb 21, 2024
1 parent ee5adf3 commit 600f9ad
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 92 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

"mounts": [
"source=${localWorkspaceFolder}/../pipe-fittings,target=/workspaces/pipe-fittings,type=bind,consistency=cached",
"source=${localWorkspaceFolder}/../flowpipe-sdk-go,target=/workspaces/flowpipe-sdk-go,type=bind,consistency=cached"
"source=${localWorkspaceFolder}/../flowpipe-sdk-go,target=/workspaces/flowpipe-sdk-go,type=bind,consistency=cached",
"source=go-build-cache,target=/root/.cache/go-build,type=volume"
],

"features": {
Expand All @@ -33,6 +34,6 @@
"HashiCorp.HCL"]
}
},

"postStartCommand": ".devcontainer/scripts/post-start-command.sh"
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/*.fp linguist-language=HCL
**/*.fpc linguist-language=HCL
2 changes: 1 addition & 1 deletion .github/workflows/devcontainer-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Flowpipe repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: flowpipe

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flowpipe-container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

# Checks out the Flowpipe repository code.
- name: Checkout Flowpipe repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: flowpipe # Directory path under $GITHUB_WORKSPACE to place the repository.

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/flowpipe-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ jobs:
fi
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: flowpipe
ref: ${{ github.event.ref }}

- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.PIPE_FITTINGS_DEPLOY_PRIVATE_KEY }}
repository: turbot/pipe-fittings
path: pipe-fittings
ref: main

- name: Checkout Flowpipe SDK Go repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.FLOWPIPE_GO_SDK_DEPLOY_PRIVATE_KEY }}
repository: turbot/flowpipe-sdk-go
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ jobs:
MARIADB_DATABASE: flowpipe-test
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=3
# Install MailHog for SMTP mail testing
Expand All @@ -56,20 +56,20 @@ jobs:

steps:
- name: Checkout Flowpipe repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: flowpipe

- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.PIPE_FITTINGS_DEPLOY_PRIVATE_KEY }}
repository: turbot/pipe-fittings
path: pipe-fittings
ref: main

- name: Checkout Flowpipe SDK Go repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.FLOWPIPE_GO_SDK_DEPLOY_PRIVATE_KEY }}
repository: turbot/flowpipe-sdk-go
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
MARIADB_DATABASE: flowpipe-test
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=3
# Install MailHog for SMTP mail testing
Expand All @@ -55,20 +55,20 @@ jobs:

steps:
- name: Checkout Flowpipe repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: flowpipe

- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.PIPE_FITTINGS_DEPLOY_PRIVATE_KEY }}
repository: turbot/pipe-fittings
path: pipe-fittings
ref: main

- name: Checkout Flowpipe SDK Go repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.FLOWPIPE_GO_SDK_DEPLOY_PRIVATE_KEY }}
repository: turbot/flowpipe-sdk-go
Expand Down
27 changes: 25 additions & 2 deletions internal/es/estest/test_suite_mod/integrations.fpc
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ integration "slack" "my_slack_app" {
signing_secret = "Q#$$#@#$$#W"
}

integration "email" "email_integration_1" {

}

notifier "my_notifier" {
description = "my notifier with 2 notifies"

notify {
integration = integration.webform.default
channel = "fake one"
subject = "bar"
}

notify {
integration = integration.webform.default
to = ["just some things here"]
to = ["a", "b", "c"]
channel = "foo"
}
}

Expand All @@ -24,4 +30,21 @@ integration "slack" "my_other_slack_app" {

# optional - if you want to verify the source
signing_secret = "Q#$$#@#$$#W"
}
}

notifier "slack_notify" {
description = "slack notifer with some notifies"

notify {
integration = integration.slack.my_other_slack_app
channel = "fake one"
subject = "bar"
}

notify {
integration = integration.email.email_integration_1
to = ["billie", "bob", "joe"]
cc = ["angus", "brian", "charlie", "dave"]
bcc = ["eddie", "frank", "george", "harry"]
}
}
46 changes: 15 additions & 31 deletions internal/types/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"fmt"
"github.com/turbot/go-kit/helpers"

"github.com/logrusorgru/aurora"
flowpipeapiclient "github.com/turbot/flowpipe-sdk-go"
Expand All @@ -20,16 +19,14 @@ type ListIntegrationResponse struct {
}

type FpIntegration struct {
Name string `json:"name"`
Type string `json:"type"`
Description *string `json:"description,omitempty"`
Title *string `json:"title,omitempty"`
Documentation *string `json:"documentation,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
FileName string `json:"file_name,omitempty"`
StartLineNumber int `json:"start_line_number,omitempty"`
EndLineNumber int `json:"end_line_number,omitempty"`
Url *string `json:"url,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
Description *string `json:"description,omitempty"`
Title *string `json:"title,omitempty"`
FileName string `json:"file_name,omitempty"`
StartLineNumber int `json:"start_line_number,omitempty"`
EndLineNumber int `json:"end_line_number,omitempty"`
Url *string `json:"url,omitempty"`
}

func (f FpIntegration) String(_ *sanitize.Sanitizer, opts sanitize.RenderOptions) string {
Expand All @@ -39,7 +36,7 @@ func (f FpIntegration) String(_ *sanitize.Sanitizer, opts sanitize.RenderOptions
// left := au.BrightBlack("[")
// right := au.BrightBlack("]")
keyWidth := 10
if f.Description != nil {
if f.Description != nil || f.Url != nil {
keyWidth = 13
}

Expand All @@ -52,13 +49,7 @@ func (f FpIntegration) String(_ *sanitize.Sanitizer, opts sanitize.RenderOptions
output += fmt.Sprintf("%-*s%s\n", keyWidth, au.Blue("Description:"), *f.Description)
}
if f.Url != nil {
output += fmt.Sprintf("%-*s%s\n", keyWidth, au.Blue("URL:"), *f.Url)
}
if len(f.Tags) > 0 {
output += fmt.Sprintf("%s\n", au.Blue("Tags:"))
for k, v := range f.Tags {
output += fmt.Sprintf(" %s %s\n", au.Cyan(k+":"), v)
}
output += fmt.Sprintf("%-*s%s\n", keyWidth, au.Blue("Request URL:"), *f.Url)
}

return output
Expand All @@ -81,16 +72,10 @@ func ListIntegrationResponseFromAPI(apiResp *flowpipeapiclient.ListIntegrationRe

func FpIntegrationFromAPI(apiIntegration flowpipeapiclient.FpIntegration) FpIntegration {
res := FpIntegration{
Name: typehelpers.SafeString(apiIntegration.Name),
Type: typehelpers.SafeString(apiIntegration.Type),
Description: apiIntegration.Description,
Title: apiIntegration.Title,
Documentation: apiIntegration.Documentation,
}
if !helpers.IsNil(apiIntegration.Tags) {
res.Tags = *apiIntegration.Tags
} else {
res.Tags = make(map[string]string)
Name: typehelpers.SafeString(apiIntegration.Name),
Type: typehelpers.SafeString(apiIntegration.Type),
Description: apiIntegration.Description,
Title: apiIntegration.Title,
}
return res
}
Expand All @@ -101,7 +86,6 @@ func FpIntegrationFromModIntegration(integration modconfig.Integration) (*FpInte
Type: integration.GetIntegrationType(),
Url: integration.GetIntegrationImpl().Url,
Description: integration.GetHclResourceImpl().Description,
Tags: integration.GetTags(),
}

resp.FileName = integration.GetIntegrationImpl().FileName
Expand Down Expand Up @@ -156,5 +140,5 @@ func (p PrintableIntegration) GetTable() (*printers.Table, error) {
}

func (PrintableIntegration) getColumns() (columns []string) {
return []string{"NAME", "TYPE", "DESCRIPTION", "URL"}
return []string{"NAME", "TYPE", "DESCRIPTION", "REQUEST URL"}
}
Loading

0 comments on commit 600f9ad

Please sign in to comment.