Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure Go terraform-provider-libvirt experiment #813

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
cf1dd9a
Rename libvirt to libvirtc
dmacvicar Nov 12, 2020
b552ae5
port
dmacvicar Nov 19, 2020
8d6c882
port
dmacvicar Nov 20, 2020
dd17534
port
dmacvicar Nov 22, 2020
4d5f125
port
dmacvicar Nov 22, 2020
e55600a
port
dmacvicar Nov 22, 2020
5620a5e
port
dmacvicar Dec 2, 2020
fe20b3d
remove
dmacvicar Dec 2, 2020
1873a74
port
dmacvicar Dec 5, 2020
a63b9c9
test push rights to pr branch
karlskewes Dec 5, 2020
2befcb3
remove test file used to validate push rights
karlskewes Dec 6, 2020
37ea9e7
port - wait for network active
karlskewes Dec 6, 2020
ddc57db
port - partial volume create
karlskewes Dec 8, 2020
ecacc6b
port - remove subpackages disk & volume
karlskewes Dec 8, 2020
7a73944
port - volume copier
karlskewes Dec 13, 2020
e97e55f
port - volume copier - missing close, just defer it
karlskewes Dec 13, 2020
b710bc2
port - volume copier - remove var decl
karlskewes Dec 13, 2020
cc436e0
port - partial cloudinit
karlskewes Dec 13, 2020
7732822
port - more volume copying
karlskewes Dec 14, 2020
fa27318
port - volumes
karlskewes Dec 17, 2020
f669488
port - network def partial
karlskewes Dec 17, 2020
9f59d67
Merge branch 'master' of github.com:dmacvicar/terraform-provider-libv…
MalloZup Dec 19, 2020
f4fc730
port - pool partial
karlskewes Dec 19, 2020
79d9a7f
port - start network tests
karlskewes Dec 19, 2020
507d921
port - tests bulk pass - compiles but fails tests
karlskewes Dec 23, 2020
b52b7b3
port - missed some
karlskewes Dec 23, 2020
dd7470a
port - volume.go
karlskewes Dec 23, 2020
cd73a92
port - restore error var & use struct field directly
karlskewes Dec 23, 2020
1c97ccf
port - use struct field directly
karlskewes Dec 23, 2020
6765124
port - network tests require accept testing enabled
karlskewes Dec 23, 2020
f7893fc
port - default network test requires network exists
karlskewes Dec 23, 2020
2b2ae01
port - use previous libvirt connect behaviour for tests (blind URI)
karlskewes Dec 23, 2020
673c671
Merge branch 'pure-go' of github.com:dmacvicar/terraform-provider-lib…
MalloZup Dec 29, 2020
592b03b
port - record/capture io close error
karlskewes Jan 3, 2021
08641cd
port - close our new second connection too
karlskewes Jan 3, 2021
ca153e4
port - pipe in goroutine so can close - TBC pipe required
karlskewes Jan 8, 2021
6001aed
port - download via buffer - review/revise
karlskewes Jan 8, 2021
3b78009
Merge branch 'pure-go' of github.com:dmacvicar/terraform-provider-lib…
MalloZup Jan 12, 2021
c8e14c5
Fix helper
MalloZup Jan 12, 2021
02a9482
Use new exported error from digital ocean library
MalloZup Apr 15, 2021
51dfb96
port - reinstate error checks with new upstream error code
karlskewes May 20, 2021
c549f79
port - missed removing old if
karlskewes May 20, 2021
26360cc
port - fix domain acceptance tests - uuid handling
karlskewes May 21, 2021
7a75979
port - missed removing old if now test back
karlskewes May 21, 2021
5f56ff6
port - fix most network acceptance tests - active handling
karlskewes May 21, 2021
8b19625
port - fix network lookup uuid usage
karlskewes May 27, 2021
bec3fcd
port - NetworkUpdate params are now swapped
karlskewes May 28, 2021
bcb5520
port - fix template test - missing nvram undefine flag
karlskewes May 28, 2021
e830316
port - some missing libvirtc uses
karlskewes Jun 6, 2021
870e532
Fix tests crashing due to client setup
dmacvicar Jun 6, 2021
b59a407
port - update mock parameters to upstream type
karlskewes Jun 6, 2021
d922fb7
No need to return terraform.ResourceProvider
dmacvicar Jun 10, 2021
90a9f82
Basic support for libvirt URIs
dmacvicar Jun 10, 2021
b4e8ec6
Remove acceptance tests not using the resource test framework.
dmacvicar Jun 10, 2021
1a28169
Revert "No need to return terraform.ResourceProvider"
dmacvicar Jun 10, 2021
9199cf6
Remove libvirt bindings
dmacvicar Jun 10, 2021
1a86985
Support for libvirt connection URIs
dmacvicar Jun 22, 2021
bfe1699
Add github workflow
dmacvicar Jun 23, 2021
68dd458
Install xsltproc before running testsuite
dmacvicar Jun 23, 2021
75f0215
Build on all platforms
dmacvicar Jun 23, 2021
829fbf5
Setup terraform before terraform fmt
dmacvicar Jun 23, 2021
7a2f260
Setup xsltproc for different OS
dmacvicar Jun 23, 2021
ad4bda3
Improve skipping acceptance tests
dmacvicar Jun 23, 2021
d59e6b6
Fix URL handling on Windows
dmacvicar Jun 23, 2021
e9348a2
Fix temporary directory on Windows
dmacvicar Jun 23, 2021
1642492
Fix URL handling on Windows
dmacvicar Jun 23, 2021
617b48c
Remove unused import
dmacvicar Jun 23, 2021
31a1b6e
Simplify test file server with httptest
dmacvicar Jun 23, 2021
0806c34
Fix tests on Windows
dmacvicar Jun 26, 2021
171c384
Make sure we build a valid OS path
dmacvicar Jun 27, 2021
cf78708
Fix Windows tests by using simple paths
dmacvicar Jun 27, 2021
07facfd
Fix image URL handling on Windows
dmacvicar Jun 28, 2021
6252344
go vet
dmacvicar Jun 28, 2021
7acb4f6
Include Windows artifact
dmacvicar Jun 28, 2021
df5d176
Windows is slower than I thought
dmacvicar Jun 28, 2021
fccf009
Start server so that URI is not empty
dmacvicar Jun 28, 2021
992883f
Use t.TempDir()
dmacvicar Jun 28, 2021
d9b7d22
Revert creating tmp file in private tmp dir
dmacvicar Jun 28, 2021
8ca6e00
Check for chmod error
dmacvicar Jun 28, 2021
22df5a2
Workaround for bug in NetworkUpdate reversed parameters
dmacvicar Jun 28, 2021
274df11
Add releaser in order to publish to registry
dmacvicar Jun 28, 2021
f4e6208
Add goreleaser in order to publish to registry
dmacvicar Jun 28, 2021
5537d35
Update README
dmacvicar Jun 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2.3.4
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Import GPG key
id: import_gpg
uses: hashicorp/ghaction-import-gpg@v2.1.0
env:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.5.0
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests
on:
pull_request:
paths-ignore:
- '*.md'
- 'website/*'
push:
branches:
- main
paths-ignore:
- '*.md'
- 'website/*'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- {os: ubuntu-latest, go: 1.16}
- {os: windows-latest, go: 1.16}
- {os: macos-latest, go: 1.16}
timeout-minutes: 10
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Setup terraform
uses: hashicorp/setup-terraform@v1
- name: Terraform fmt
run: |
make tf-check
- name: Build
run: |
make
- name: Test pre-requisites (Linux)
run: sudo apt-get -y install xsltproc
if: runner.os == 'Linux'
- name: Test pre-requisites (MacOS)
run: brew install libxslt
if: runner.os == 'MacOS'
- name: Test pre-requisites (Windows)
run: choco install xsltproc
if: runner.os == 'Windows'
- name: Test
run: |
make test
- uses: actions/upload-artifact@v2
with:
name: terraform-provider-libvirt-${{ matrix.os }}
path: ${{ github.workspace }}/terraform-provider-libvirt*
54 changes: 54 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
51 changes: 7 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,18 @@ 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.

## Downloading

Builds for openSUSE, CentOS, Ubuntu, Fedora are created with openSUSE's [OBS](https://build.opensuse.org). The build definitions are available for both the [stable](https://build.opensuse.org/package/show/systemsmanagement:terraform/terraform-provider-libvirt) and [master](https://build.opensuse.org/package/show/systemsmanagement:terraform:unstable/terraform-provider-libvirt) branches.

## Using published binaries/builds

* *Stable releases*: Head to the [releases section](https://github.com/dmacvicar/terraform-provider-libvirt/releases) and download the latest stable release build for your distribution.
* *git master builds*: Head to the [download area of the OBS project](https://download.opensuse.org/repositories/systemsmanagement:/terraform:/unstable/) and download the build for your distribution.

## Using packages
## Getting the libvirt provider

Follow the instructions for your distribution:
The provide is available via the [Terraform Registry](https://registry.terraform.io/providers/dmacvicar/libvirt/latest).

* [Packages for stable releases](https://software.opensuse.org/download/package?project=systemsmanagement:terraform&package=terraform-provider-libvirt)
* [Packages for current git master](https://software.opensuse.org/download/package?project=systemsmanagement:terraform:unstable&package=terraform-provider-libvirt)
You can also manually download it from the [releases section](https://github.com/dmacvicar/terraform-provider-libvirt/releases) on Github

## Building from source

### Requirements

- [Terraform](https://www.terraform.io/downloads.html)
- [Go](https://golang.org/doc/install) (to build the provider plugin)
- [libvirt](https://libvirt.org/downloads.html) 1.2.14 or newer development headers
- `cgo` is required by the [libvirt-go](https://github.com/libvirt/libvirt-go) package. `export CGO_ENABLED="1"`


This project uses [go modules](https://github.com/golang/go/wiki/Modules) to declare its dependencies.

Ensure you have the latest version of Go installed on your system, terraform usually
takes advantage of features available only inside of the latest stable release.

You need also need libvirt-dev(el) package installed.
- [Go](https://golang.org/doc/install) is required for building.

### Building The Provider

Expand All @@ -86,28 +65,12 @@ make

The binary will be called `terraform-provider-libvirt`.

#### Windows

To build it on Windows (64bit) one can use MinGW64 (http://www.msys2.org/)

Install Golang on Windows
Clone terraform-provider-libvirt repository
Open MinGW64 Console
```console
pacman -S mingw-w64-x86_64-libvirt
export PATH=$PATH:/c/Go/bin
pacman -S mingw-w64-x86_64-pkg-config
pacman -S mingw-w64-x86_64-glib2
pacman -S mingw-w64-x86_64-dbus-glib
pacman -S mingw-w64-x86_64-libssh
pacman -S mingw-w64-x86_64-yajl
go install
```

# Installing

* Check that libvirt daemon 1.2.14 or newer is running on the hypervisor (`virsh version --daemon`)
* [Terraform](https://www.terraform.io/downloads.html)
* `mkisofs` is required to use the [CloudInit](website/docs/r/cloudinit.html.markdown)
* `xsltproc` is required to transform generated libvirt XML

[Copied from the Terraform documentation](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins):

Expand Down Expand Up @@ -197,7 +160,7 @@ Be aware that this variables may be subject to change again in future versions.

## Authors

* Duncan Mac-Vicar P. <dmacvicar@suse.de>
* Duncan Mac-Vicar P. <duncan@mac-vicar.eu>

See also the list of [contributors](https://github.com/dmacvicar/terraform-provider-libvirt/graphs/contributors) who participated in this project.

Expand Down
13 changes: 9 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ module github.com/dmacvicar/terraform-provider-libvirt

require (
github.com/c4milo/gotoolkit v0.0.0-20170704181456-e37eeabad07e // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1
github.com/digitalocean/go-libvirt v0.0.0-20210524223541-696696fc24e0
github.com/fatih/color v1.10.0 // indirect
github.com/google/uuid v1.1.2
github.com/hashicorp/terraform-plugin-sdk v1.4.0
github.com/hashicorp/terraform-plugin-sdk v1.9.0
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
github.com/hooklift/iso9660 v1.0.0
github.com/libvirt/libvirt-go v5.10.0+incompatible
github.com/libvirt/libvirt-go-xml v5.10.0+incompatible
github.com/mattn/goveralls v0.0.2
github.com/pborman/uuid v1.2.0 // indirect
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.7.0
github.com/terraform-providers/terraform-provider-ignition v1.2.1
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
golang.org/x/crypto v0.0.0-20191202143827-86a70503ff7e
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
Expand Down