Skip to content

Commit 2b321c0

Browse files
committed
chore: initial commit
Signed-off-by: Damien Chomat <[email protected]>
0 parents  commit 2b321c0

Some content is hidden

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

57 files changed

+7260
-0
lines changed

.copywrite.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
project {
2+
license = "MPL-2.0"
3+
copyright_year = 2024
4+
header_ignore = [
5+
".goreleaser.yml"
6+
]
7+
}

.github/renovate.json5

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
extends: [
3+
"config:recommended",
4+
],
5+
dependencyDashboard: true,
6+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Manual release workflow is used for deploying documentation updates
2+
# on the specified branch without making an official plugin release.
3+
name: Notify Integration Release (Manual)
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "The release version (semver)"
9+
default: 1.0.0
10+
required: false
11+
branch:
12+
description: "A branch or SHA"
13+
default: 'main'
14+
required: false
15+
16+
jobs:
17+
notify-release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout this repo
21+
uses: actions/checkout@v4
22+
with:
23+
ref: ${{ github.event.inputs.branch }}
24+
25+
# Ensure that Docs are Compiled
26+
- uses: actions/setup-go@v5
27+
- shell: bash
28+
run: make generate
29+
30+
- shell: bash
31+
run: |
32+
if [[ -z "$(git status -s)" ]]; then
33+
echo "OK"
34+
else
35+
echo "Docs have been updated, but the compiled docs have not been committed."
36+
echo "Run 'make generate', and commit the result to resolve this error."
37+
exit 1
38+
fi
39+
# Perform the Release
40+
- name: Checkout integration-release-action
41+
uses: actions/checkout@v4
42+
with:
43+
repository: hashicorp/integration-release-action
44+
path: ./integration-release-action
45+
- name: Notify Release
46+
uses: ./integration-release-action
47+
with:
48+
# The Packer team will use the integration identifier to register the integration;
49+
# the expected format is packer/<GitHub Org Name>/<plugin-name>
50+
integration_identifier: "packer/pelotech/kubevirt"
51+
release_version: ${{ github.event.inputs.version }}
52+
release_sha: ${{ github.event.inputs.branch }}
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Notify Integration Release (Tag)
2+
on:
3+
push:
4+
tags:
5+
- '*.*.*' # Proper releases
6+
7+
jobs:
8+
strip-version:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
packer-version: ${{ steps.strip.outputs.packer-version }}
12+
steps:
13+
- name: Strip leading v from version tag
14+
id: strip
15+
env:
16+
REF: ${{ github.ref_name }}
17+
run: |
18+
echo "packer-version=$(echo "$REF" | sed -E 's/v?([0-9]+\.[0-9]+\.[0-9]+)/\1/')" >> "$GITHUB_OUTPUT"
19+
20+
notify-release:
21+
needs:
22+
- strip-version
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout this repo
26+
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ github.ref }}
29+
30+
# Ensure that Docs are Compiled
31+
- uses: actions/setup-go@v5
32+
- shell: bash
33+
run: make generate
34+
- shell: bash
35+
run: |
36+
if [[ -z "$(git status -s)" ]]; then
37+
echo "OK"
38+
else
39+
echo "Docs have been updated, but the compiled docs have not been committed."
40+
echo "Run 'make generate', and commit the result to resolve this error."
41+
exit 1
42+
fi
43+
44+
# Perform the Release
45+
- name: Checkout integration-release-action
46+
uses: actions/checkout@v4
47+
with:
48+
repository: hashicorp/integration-release-action
49+
path: ./integration-release-action
50+
- name: Notify Release
51+
# disable release to https://developer.hashicorp.com/packer/integrations until an identifier is assigned.
52+
if: false
53+
uses: ./integration-release-action
54+
with:
55+
# The Packer team will use the integration identifier to register the integration;
56+
# the expected format is packer/<GitHub Org Name>/<plugin-name>
57+
integration_identifier: "packer/pelotech/kubevirt"
58+
release_version: ${{ needs.strip-version.outputs.packer-version }}
59+
release_sha: ${{ github.ref }}
60+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pre-commit.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: pre-commit
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
pre-commit:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: install pre-commit
16+
run: pip install pre-commit
17+
- name: pre-commit
18+
run: pre-commit run --all-files --show-diff-on-failure

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This GitHub action can publish assets for release when a tag is created.
2+
# Currently its setup to run on any tag that matches the pattern "v*" (i.e., v0.1.0).
3+
#
4+
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
5+
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `GPG_PASSPHRASE`
6+
# secret. If you would rather own your own GPG handling, please fork this action
7+
# or use an alternative one for key handling.
8+
#
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
10+
# in `goreleaser` to indicate this is being used in a non-interactive mode.
11+
#
12+
name: release
13+
on:
14+
push:
15+
tags:
16+
- 'v*'
17+
18+
permissions:
19+
contents: write
20+
packages: read
21+
22+
jobs:
23+
go-releaser:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Unshallow
30+
run: git fetch --prune --unshallow
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version-file: 'go.mod'
36+
37+
- name: Describe plugin
38+
id: plugin_describe
39+
run: echo "api_version=$(go run . describe | jq -r '.api_version')" >> $GITHUB_OUTPUT
40+
41+
- name: Import GPG key
42+
id: import_gpg
43+
uses: crazy-max/ghaction-import-gpg@v6
44+
with:
45+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
46+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
47+
48+
- name: Run go-releaser
49+
uses: goreleaser/goreleaser-action@v6
50+
with:
51+
version: "~> v2"
52+
args: release --clean
53+
env:
54+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
API_VERSION: ${{ steps.plugin_describe.outputs.api_version }}

.github/workflows/tests.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# This is a manually triggered action workflow.
2+
# It uses Packer at the latest version to init, validate and build
3+
# an example configuration in a folder.
4+
name: test plugin
5+
6+
on:
7+
push:
8+
9+
env:
10+
PRODUCT_VERSION: "1.11.2"
11+
12+
jobs:
13+
build:
14+
# runs-on: [ "self-hosted", "linux", "x64", "ubuntu-2204" ] # until self-hosted runner is available
15+
runs-on: ubuntu-latest
16+
name: Run Packer
17+
env:
18+
working-directory: ./example
19+
PKR_VAR_destination_aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
20+
PKR_VAR_destination_aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
21+
steps:
22+
- name: repository checkout
23+
uses: actions/checkout@v4
24+
25+
- name: go setup
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version-file: 'go.mod'
29+
30+
- name: Cache build
31+
uses: actions/cache@v4
32+
with:
33+
path: ./packer-plugin-kubevirt
34+
key: build-${{ hashFiles('**/*.go') }}
35+
36+
- name: packer plugin build
37+
if: steps.cache.outputs.cache-hit != 'true'
38+
run: go build .
39+
40+
- name: generate kind config
41+
run: |
42+
cat <<EOF > kind-config.yaml
43+
kind: Cluster
44+
apiVersion: kind.x-k8s.io/v1alpha4
45+
nodes:
46+
- role: control-plane
47+
extraMounts:
48+
- hostPath: /dev/kvm
49+
containerPath: /dev/kvm
50+
EOF
51+
52+
- name: kind setup
53+
uses: helm/kind-action@v1
54+
with:
55+
cluster_name: kind
56+
version: v0.24.0
57+
kubectl_version: v1.30.4
58+
config: kind-config.yaml
59+
60+
- name: kubevirt+cdi install
61+
run: |
62+
export KUBEVIRT_VERSION=$(curl -s https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)
63+
kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml"
64+
kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-cr.yaml"
65+
66+
export CDI_VERSION=$(basename $(curl -s -w %{redirect_url} https://github.com/kubevirt/containerized-data-importer/releases/latest))
67+
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDI_VERSION}/cdi-operator.yaml
68+
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDI_VERSION}/cdi-cr.yaml
69+
70+
kubectl wait --for=jsonpath='{.status.phase}'=Deployed kubevirt/kubevirt --namespace kubevirt --timeout=2m
71+
kubectl wait --for=jsonpath='{.status.phase}'=Deployed cdi/cdi --namespace cdi --timeout=2m
72+
73+
kubectl apply -k "https://github.com/kubevirt/common-instancetypes/VirtualMachineClusterPreferences?ref=v1.1.0"
74+
# to skip '/dev/kvm' requirement - but requires testing with custom node and host volume mounting
75+
# kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}}}}'
76+
77+
- name: display runner node / capabilities
78+
run: |
79+
# Print CPU information
80+
echo "CPU Information:"
81+
echo "----------------"
82+
lscpu | grep -E '^Architecture|^CPU\(s\)|^Model name|^Thread|^Core|^Socket|^Vendor ID'
83+
echo ""
84+
85+
# Print Memory information
86+
echo "Memory Information:"
87+
echo "-------------------"
88+
free -h
89+
echo ""
90+
91+
# Print Disk Space information
92+
echo "Disk Space Information:"
93+
echo "-----------------------"
94+
df -hT | awk '{print $1, $2, $3, $4, $5, $6, $7}'
95+
echo ""
96+
97+
echo "KVM module state:"
98+
echo "-----------------------"
99+
if lsmod | grep -q kvm; then
100+
echo "KVM modules are loaded."
101+
else
102+
echo "KVM modules are not loaded."
103+
fi
104+
echo ""
105+
106+
echo "Kubernetes worker nodes:"
107+
echo "-----------------------"
108+
kubectl get nodes -o jsonpath='{range .items[*]}{"["}{.metadata.name}{"] cpu: "}{.status.capacity.cpu}{"; memory: "}{.status.capacity.memory}{"\n"}{end}'
109+
110+
- name: packer setup
111+
uses: hashicorp/[email protected]
112+
with:
113+
version: ${{ env.PRODUCT_VERSION }}
114+
115+
- name: packer format
116+
run: |
117+
packer fmt -check .
118+
119+
- name: packer init
120+
working-directory: ${{ env.working-directory }}
121+
run: |
122+
packer plugins install --path ../packer-plugin-kubevirt "github.com/pelotech/kubevirt"
123+
packer init .
124+
125+
- name: packer validate
126+
working-directory: ${{ env.working-directory }}
127+
run: |
128+
packer validate .
129+
130+
- name: packer build
131+
if: false # until self-hosted runner is available
132+
working-directory: ${{ env.working-directory }}
133+
run: |
134+
PACKER_LOG=1 packer build .

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.idea
2+
main
3+
packer-plugin-kubevirt
4+
**/packer_log*.txt
5+
**/git_*test.pkr.hcl
6+
crash.log
7+
**/*.pkrvars.hcl
8+
9+
dist/*
10+
.docs/*
11+
docs.zip

0 commit comments

Comments
 (0)