Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit d075892

Browse files
authored
Merge pull request #15 from patrickcping/12-include-property-blocks-with-davinci_connection-generated-resources
Convert to module generating format, add support for connector properties
2 parents 3c66ecb + 1c751d2 commit d075892

73 files changed

Lines changed: 89888 additions & 1230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/code-check.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# This GitHub action runs your tests for each commit push and/or PR. Optionally
2+
# you can turn it on using a cron schedule for regular testing.
3+
#
4+
name: Provider Code Check
5+
on:
6+
pull_request:
7+
paths-ignore:
8+
- 'README.md'
9+
- '.vscode'
10+
- '.gitignore'
11+
- 'CHANGELOG.md'
12+
- 'CONTRIBUTING.md'
13+
- 'LICENSE'
14+
push:
15+
branches: [ "main" ]
16+
paths-ignore:
17+
- 'README.md'
18+
- '.vscode'
19+
- '.gitignore'
20+
- 'CHANGELOG.md'
21+
- 'CONTRIBUTING.md'
22+
- 'LICENSE'
23+
# For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.),
24+
# we recommend testing at a regular interval not necessarily tied to code changes. This will
25+
# ensure you are alerted to something breaking due to an API change, even if the code did not
26+
# change.
27+
# schedule:
28+
# - cron: '0 13 * * *'
29+
jobs:
30+
# ensure the code builds...
31+
build:
32+
name: Build
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 5
35+
steps:
36+
37+
- name: Check out code into the Go module directory
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Go
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version-file: 'go.mod'
44+
id: go
45+
46+
- name: Get dependencies
47+
run: |
48+
go mod download
49+
50+
- name: Check dependencies
51+
run: |
52+
make depscheck
53+
54+
- name: Vet
55+
run: |
56+
make vet
57+
58+
- name: Build
59+
run: |
60+
make build
61+
62+
golangci-lint:
63+
needs: [build]
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
- uses: actions/setup-go@v5
68+
with:
69+
go-version-file: 'go.mod'
70+
71+
- id: golangci-lint-version
72+
working-directory: tools
73+
run: >-
74+
echo "version=$(
75+
go list -m all |
76+
grep github.com/golangci/golangci-lint |
77+
awk '{print $2}'
78+
)" >> $GITHUB_OUTPUT
79+
80+
- name: lint
81+
uses: golangci/golangci-lint-action@v6
82+
with:
83+
version: "${{ steps.golangci-lint-version.outputs.version }}"
84+
85+
importlint:
86+
needs: [build]
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v4
90+
- uses: actions/setup-go@v5
91+
with:
92+
go-version-file: 'go.mod'
93+
94+
- run: cd tools && go install github.com/pavius/impi/cmd/impi
95+
96+
- name: Check dependencies
97+
run: make depscheck
98+
99+
- name: import lint
100+
run: |
101+
make importlint
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "main" ]
20+
schedule:
21+
- cron: '34 8 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'go' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
43+
- name: Install Go
44+
uses: actions/setup-go@v5
45+
with:
46+
go-version-file: go.mod
47+
48+
# Initializes the CodeQL tools for scanning.
49+
- name: Initialize CodeQL
50+
uses: github/codeql-action/init@v3
51+
with:
52+
languages: ${{ matrix.language }}
53+
# If you wish to specify custom queries, you can do so here or in a config file.
54+
# By default, queries listed here will override any specified in a config file.
55+
# Prefix the list here with "+" to use these queries and those in the config file.
56+
57+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
58+
# queries: security-extended,security-and-quality
59+
60+
61+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
62+
# If this step fails, then you should remove it and run the build manually (see below)
63+
- name: Autobuild
64+
uses: github/codeql-action/autobuild@v3
65+
66+
# ℹ️ Command-line programs to run using the OS shell.
67+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
68+
69+
# If the Autobuild fails above, remove it and uncomment the following three lines.
70+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
71+
72+
# - run: |
73+
# echo "Run, Build Application using script"
74+
# ./location_of_script_within_repo/buildscript.sh
75+
76+
- name: Perform CodeQL Analysis
77+
uses: github/codeql-action/analyze@v3

.github/workflows/gosec-scan.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Security Scan"
2+
3+
# Run workflow each time code is pushed to your repository and on a schedule.
4+
# The scheduled workflow runs every at 00:00 on Sunday UTC time.
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
# The branches below must be a subset of the branches above
10+
branches: [ "main" ]
11+
schedule:
12+
- cron: '0 0 * * 0'
13+
14+
jobs:
15+
tests:
16+
runs-on: ubuntu-latest
17+
env:
18+
GO111MODULE: on
19+
steps:
20+
- name: Checkout Source
21+
uses: actions/checkout@v4
22+
- name: Run Gosec Security Scanner
23+
uses: securego/gosec@master
24+
with:
25+
# we let the report trigger content trigger a failure using the GitHub Security features.
26+
args: '-no-fail -fmt sarif -out results.sarif ./...'
27+
- name: Upload SARIF file
28+
uses: github/codeql-action/upload-sarif@v3
29+
with:
30+
# Path to SARIF file relative to the root of the repository
31+
sarif_file: results.sarif
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Refresh Connector Schema
2+
on:
3+
schedule:
4+
- cron: '0 13 1 * *'
5+
jobs:
6+
generate:
7+
name: generate schema
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-go@v5
12+
with:
13+
go-version-file: 'go.mod'
14+
15+
- name: Install DaVinci CLI
16+
run: go install github.com/patrickcping/davinci-pingcli
17+
continue-on-error: false
18+
19+
- name: Generate Connector Schema
20+
run: |
21+
davinci-pingcli connectors schema --json | jq '[.[] | .accountConfigView.items as $items | {"name": .name, "connectorId": .connectorId, "connectorCategories": .connectorCategories, "properties": (.properties // {} | with_entries(select(.key as $k | ($items // [] | map(.propertyName)) | index($k))))}]' > internal/generate/connector_schema/connector-schema.json
22+
continue-on-error: false
23+
24+
- name: Check for changes
25+
id: check_changes
26+
run: |
27+
git add -N .
28+
if git diff --compact-summary --exit-code; then
29+
echo "No changes detected"
30+
else
31+
echo "Changes detected"
32+
echo "CONTENT_CHANGED=true" >> $GITHUB_OUTPUT
33+
fi
34+
continue-on-error: false
35+
36+
- name: Create new branch
37+
id: create_branch
38+
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
39+
run: |
40+
branch_name="update-connector-schema-$(date +'%Y%m%d%H%M%S')"
41+
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
42+
git checkout -b $branch_name
43+
44+
- name: Commit changes
45+
id: commit_changes
46+
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
47+
run: |
48+
git config --local user.name "github-actions[bot]"
49+
git config --local user.email "action@github.com"
50+
git config --global push.autoSetupRemote true
51+
git add .
52+
git commit -m "Update connector schema"
53+
git push
54+
55+
- name: Create PR
56+
id: create_pr
57+
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
58+
uses: actions/github-script@v7
59+
env:
60+
BRANCH_NAME: ${{ env.BRANCH_NAME }}
61+
with:
62+
script: |
63+
const { BRANCH_NAME } = process.env
64+
const { repo, owner } = context.repo;
65+
const pr = await github.rest.pulls.create({
66+
owner,
67+
repo,
68+
title: 'Update Connector Schema',
69+
body: 'Connector Schema has changed. Please review.',
70+
head: BRANCH_NAME,
71+
base: 'main'
72+
});

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ vendor
33
env*.sh
44
output.log
55
generated*
6-
dvtf-pingctl
6+
dvtf-pingctl
7+
.davinci-pingcli.yaml

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ jq '.name = "abcde"' ./path/to/my/export.json | dvtf-pingctl generate
8989
jq '.name = "abcde"' ./path/to/my/export.json | dvtf-pingctl validate
9090
```
9191

92-
## Config Generation
92+
## Terraform HCL Config Generation
9393

94-
Generate HCL configuration from a DaVinci service JSON export file using the `dvtf-pingctl generate ...` command.
94+
Generate HCL configuration from a DaVinci service JSON export file using the `dvtf-pingctl generate ...` command. The command will generate a Terraform module by default, with variables for connector properties and variable values.
9595

9696
### Specifying an Output Path
9797

0 commit comments

Comments
 (0)