Skip to content

Commit

Permalink
Merge remote-tracking branch 'dmacvicar/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewJohn committed Dec 2, 2023
2 parents 82e0ab2 + 9adc252 commit 17f9c2b
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.21
-
name: Import GPG key
id: import_gpg
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
branches:
- main
- staging
paths-ignore:
- '*.md'
- 'website/*'
Expand All @@ -19,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.18.x"]
go-version: ["1.21.x"]
steps:
- uses: actions/setup-go@v3
with:
Expand All @@ -33,17 +34,17 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.0
version: v1.52.2
only-new-issues: true
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- {os: ubuntu-latest, go: 1.18}
- {os: windows-latest, go: 1.18}
- {os: macos-latest, go: 1.18}
- {os: ubuntu-latest, go: 1.21}
- {os: windows-latest, go: 1.21}
- {os: macos-latest, go: 1.21}
timeout-minutes: 10
steps:
- name: Set up Go
Expand Down
25 changes: 23 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,33 @@ linters-settings:
gomnd:
ignored-functions:
- strings.SplitN
depguard:
rules:
main:
files:
- $all
allow:
- $gostd
- "github.com/dmacvicar/terraform-provider-libvirt"
- "github.com/community-terraform-providers/terraform-provider-ignition/v2"
- "github.com/digitalocean/go-libvirt"
- "libvirt.org/go/libvirtxml"
- "github.com/davecgh/go-spew"
- "github.com/google/uuid"
- "github.com/hashicorp/terraform-plugin-sdk/v2"
- "github.com/hooklift/iso9660"
- "github.com/mattn/goveralls"
- "github.com/stretchr/testify"
- "golang.org/x/crypto"
- "golang.org/x/lint"
revive:
rules:
- name: unused-parameter
disabled: true

linters:
enable-all: false
enable:
- ifshort
- unparam
- exhaustive
- godot
Expand All @@ -22,7 +44,6 @@ linters:
- revive
- gocritic
- misspell
- depguard
- lll
- errorlint
- errcheck
Expand Down
69 changes: 44 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
TEST?=$$(go list ./... | grep -v 'vendor')
HOSTNAME=github.com
NAMESPACE=matthewjohn
NAME=libvirt
LDFLAGS += -X version.ProviderVersion=$$(git describe --always --abbrev=40 --dirty)

:w
:q
:w
:q
:q!
BINARY=terraform-provider-${NAME}
VERSION=0.0.1
OS_ARCH=linux_amd64
# default args for tests
TEST_ARGS_DEF := -covermode=count -coverprofile=profile.cov

default: install
default: build

build:
go build -o ${BINARY}
terraform-provider-libvirt:
go build -ldflags "${LDFLAGS}"

release:
goreleaser release --rm-dist --snapshot --skip-publish --skip-sign
build: terraform-provider-libvirt

install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
install:
go install -ldflags "${LDFLAGS}"

test:
go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
# unit tests
# usage:
# - run all the unit tests: make test
# - run some particular test: make test TEST_ARGS="-run TestAccLibvirtDomain_Cpu"
test:
go test -v $(TEST_ARGS_DEF) $(TEST_ARGS) ./libvirt/...

testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
# acceptance tests
# usage:
#
# - run all the acceptance tests:
# make testacc
#
# - run some particular test:
# make testacc TEST_ARGS="-run TestAccLibvirtDomain_Cpu"
#
# - run all the network test with a verbose loglevel:
# TF_LOG=DEBUG make testacc TEST_ARGS="-run TestAccLibvirtNet*"
#
testacc:
./travis/run-tests-acceptance $(TEST_ARGS)

golangcilint:
golangci-lint run

tflint:
terraform fmt -write=false -check=true -diff=true examples/

lint: golangcilint tflint

clean:
rm -f terraform-provider-libvirt

cleanup:
./travis/cleanup.sh

.PHONY: build install test testacc tflint golangcilint lint terraform-provider-libvirt
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ What is *NOT* in scope:

* To support every advanced feature [libvirt](https://libvirt.org/) supports

This would make the mapping from terraform complicated and not maintanable. See the [How to contribute](CONTRIBUTING.md) section to understand how to approach new features.
This would make the mapping from terraform complicated and not maintainable. See the [How to contribute](CONTRIBUTING.md) section to understand how to approach new features.

## Getting started

The provider is available for auto-installation from the [Terraform Registry](https://registry.terraform.io/providers/dmacvicar/libvirt/latest).

In your `main.tf` file, specify the version you want to use:


```hcl
terraform {
required_providers {
Expand All @@ -47,7 +46,7 @@ provider "libvirt" {

And now run terraform init:

```
```console
$ terraform init
```

Expand All @@ -60,7 +59,7 @@ Here is an example that will setup the following:
(create this as main.tf and run terraform commands from this directory):
```hcl
provider "libvirt" {
uri = "qemu:///system"
uri = "qemu:///system"
}
```

Expand Down Expand Up @@ -93,7 +92,7 @@ You can also manually download the provider from the [releases section](https://

- [Go](https://golang.org/doc/install) is required for building.

```
```bash
git clone https://github.com/dmacvicar/terraform-provider-libvirt.git
cd terraform-provider-libvirt
make
Expand All @@ -115,7 +114,7 @@ Until terraform-provider-libvirt 0.4.2, qemu-agent was used by default to get ne

In current versions, we default to not to attempt connecting to it, and attempting to retrieve network interface information from the agent needs to be enabled explicitly with `qemu_agent = true`, further details [here](https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/domain.html.markdown). Note that you still need to make sure the agent is running in the OS, and that is unrelated to this option.

Note: when using bridge network configurations you need to enable the `qemu_agent = true`. otherwise you will not retrieve the ip adresses of domains.
Note: when using bridge network configurations you need to enable the `qemu_agent = true`. otherwise you will not retrieve the ip addresses of domains.

Be aware that this variables may be subject to change again in future versions.

Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ require (
github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/hooklift/iso9660 v1.0.0
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351
github.com/mattn/goveralls v0.0.11
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.4.0
golang.org/x/crypto v0.14.0
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
libvirt.org/go/libvirtxml v1.8009.0
)
Expand Down Expand Up @@ -55,19 +56,18 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/vincent-petithory/dataurl v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/tools v0.4.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
google.golang.org/grpc v1.51.0 // indirect
Expand Down
Loading

0 comments on commit 17f9c2b

Please sign in to comment.