Skip to content

Commit cb605b1

Browse files
committed
initial commit
0 parents  commit cb605b1

28 files changed

+1476
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @eliastor

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See GitHub's documentation for more information on this file:
2+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3+
version: 2
4+
updates:
5+
- package-ecosystem: "gomod"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
16+
with:
17+
fetch-depth: 0
18+
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
19+
with:
20+
go-version-file: "go.mod"
21+
cache: true
22+
- name: Import GPG key
23+
uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0
24+
id: import_gpg
25+
with:
26+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
passphrase: ${{ secrets.PASSPHRASE }}
28+
- name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0
30+
with:
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.github/workflows/test.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- "README.md"
7+
- "docs/**"
8+
- "examples/**"
9+
push:
10+
paths-ignore:
11+
- "README.md"
12+
- "docs/**"
13+
- "examples/**"
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build:
20+
name: Build
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 5
23+
steps:
24+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
25+
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
26+
with:
27+
go-version-file: "go.mod"
28+
cache: true
29+
- run: go mod download
30+
- run: go build -v .
31+
- name: Run linters
32+
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
33+
with:
34+
version: latest
35+
36+
generate:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
40+
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
41+
with:
42+
go-version-file: "go.mod"
43+
cache: true
44+
- run: go generate ./...
45+
- name: git diff
46+
run: |
47+
git diff --compact-summary --exit-code || \
48+
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
49+
50+
# Run acceptance tests in a matrix with Terraform CLI versions
51+
test:
52+
name: Terraform Provider Acceptance Tests
53+
needs: build
54+
runs-on: ubuntu-latest
55+
timeout-minutes: 15
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
# list whatever Terraform versions here you would like to support
60+
terraform:
61+
- "1.1.*"
62+
- "1.2.*"
63+
- "1.3.*"
64+
- "1.4.*"
65+
- "1.5.*"
66+
steps:
67+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
68+
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
69+
with:
70+
go-version-file: "go.mod"
71+
cache: true
72+
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
73+
with:
74+
terraform_version: ${{ matrix.terraform }}
75+
terraform_wrapper: false
76+
- run: go mod download
77+
- env:
78+
TF_ACC: "1"
79+
run: go test -v -cover ./internal/provider/
80+
timeout-minutes: 10

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*.dll
2+
*.exe
3+
.DS_Store
4+
example.tf
5+
terraform.tfplan
6+
terraform.tfstate
7+
bin/
8+
dist/
9+
modules-dev/
10+
/pkg/
11+
website/.vagrant
12+
website/.bundle
13+
website/build
14+
website/node_modules
15+
.vagrant/
16+
*.backup
17+
./*.tfstate
18+
.terraform/
19+
*.log
20+
*.bak
21+
*~
22+
.*.swp
23+
.idea
24+
*.iml
25+
*.test
26+
*.iml
27+
28+
website/vendor
29+
30+
# Test exclusions
31+
!command/test-fixtures/**/*.tfstate
32+
!command/test-fixtures/**/.terraform/
33+
34+
# Keep windows files with windows line endings
35+
*.winfile eol=crlf

.golangci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Visit https://golangci-lint.run/ for usage documentation
2+
# and information on other useful linters
3+
issues:
4+
max-per-linter: 0
5+
max-same-issues: 0
6+
7+
linters:
8+
disable-all: true
9+
enable:
10+
- durationcheck
11+
- errcheck
12+
- exportloopref
13+
- forcetypeassert
14+
- godot
15+
- gofmt
16+
- gosimple
17+
- ineffassign
18+
- makezero
19+
- misspell
20+
- nilerr
21+
- predeclared
22+
- staticcheck
23+
- tenv
24+
- unconvert
25+
- unparam
26+
- unused
27+
- vet

.goreleaser.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
3+
before:
4+
hooks:
5+
# this is just an example and not a requirement for provider building/publishing
6+
- go mod tidy
7+
builds:
8+
- env:
9+
# goreleaser does not work with CGO, it could also complicate
10+
# usage by users in CI/CD systems like Terraform Cloud where
11+
# they are unable to install libraries.
12+
- CGO_ENABLED=0
13+
mod_timestamp: '{{ .CommitTimestamp }}'
14+
flags:
15+
- -trimpath
16+
ldflags:
17+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
18+
goos:
19+
- freebsd
20+
- windows
21+
- linux
22+
- darwin
23+
goarch:
24+
- amd64
25+
- '386'
26+
- arm
27+
- arm64
28+
ignore:
29+
- goos: darwin
30+
goarch: '386'
31+
binary: '{{ .ProjectName }}_v{{ .Version }}'
32+
archives:
33+
- format: zip
34+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
35+
checksum:
36+
extra_files:
37+
- glob: 'terraform-registry-manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
39+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
40+
algorithm: sha256
41+
signs:
42+
- artifacts: checksum
43+
args:
44+
# if you are using this in a GitHub action or some other automated pipeline, you
45+
# need to pass the batch flag to indicate its not interactive.
46+
- "--batch"
47+
- "--local-user"
48+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
49+
- "--output"
50+
- "${signature}"
51+
- "--detach-sign"
52+
- "${artifact}"
53+
release:
54+
extra_files:
55+
- glob: 'terraform-registry-manifest.json'
56+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
57+
# If you want to manually examine the release before its live, uncomment this line:
58+
# draft: true
59+
changelog:
60+
skip: true

LICENSE

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
The Clear BSD License
2+
3+
Copyright (c) [2023] [Ilya Toropchenko]
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted (subject to the limitations in the disclaimer
8+
below) provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
16+
17+
* Neither the name of the copyright holder nor the names of its
18+
contributors may be used to endorse or promote products derived from this
19+
software without specific prior written permission.
20+
21+
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
22+
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
default: test doc-gen
2+
3+
.PHONY: test
4+
5+
test:
6+
podman run --name terraform-provider-chromedp-test --rm -d -p 3000:3000 docker.io/browserless/chrome:latest
7+
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m || podman stop terraform-provider-chromedp-test
8+
podman stop terraform-provider-chromedp-test
9+
doc-gen:
10+
go generate ./...
11+
install:
12+
go install

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Terraform Provider ChromeDP
2+
3+
This providers allows you to use [chromedp](https://github.com/chromedp/chromedp) in terraform in form of recipes.
4+
5+
6+
## Requirements
7+
8+
- [Terraform](https://www.terraform.io/downloads.html) >= 1.0
9+
- [Go](https://golang.org/doc/install) >= 1.19
10+
11+
## Building The Provider
12+
13+
1. Clone the repository
14+
1. Enter the repository directory
15+
1. Build the provider using the Go `install` command:
16+
17+
```shell
18+
go install
19+
```
20+
21+
## Using the provider
22+
23+
Please refer do examples/.
24+
25+
## Developing the Provider
26+
27+
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
28+
29+
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
30+
31+
To use provider in sample terraform code `~/.terraformrc` must be edited:
32+
33+
```hcl
34+
provider_installation {
35+
36+
dev_overrides {
37+
"hashicorp.com/eliastor/chromedp" = "<your go bin path>"
38+
}
39+
40+
direct {}
41+
}
42+
```
43+
44+
45+
To generate or update documentation, run `go generate`.
46+
47+
In order to run the full suite of Acceptance tests, run `make testacc`.
48+
49+
```shell
50+
make testacc
51+
```
52+
53+
54+
## Supported actions
55+
56+
- [x] Navigate
57+
- [x] Wait_visible
58+
- [x] Click
59+
- [x] Value (getting content of forms, inputs, textareas, selects, or any other element with a '.value' field.)
60+
- [x] Text (getting text content of the element)
61+
- [x] Focus
62+
- [x] Cookies (setting cookies)
63+
- [x] Screenshots
64+
## Roadmap
65+
- [ ] browserless.io support
66+
- [ ] Text
67+
- [ ] Downloads
68+
- [ ] Uploads
69+
- [ ] Send keys
70+
- [ ] Submit
71+
- [ ] Emulate different viewports

0 commit comments

Comments
 (0)