Skip to content

Commit 40764cb

Browse files
DanNiEShclaude
andcommitted
Add HostLease controller with Ironic power management
Implement a controller that watches HostLease CR (from osac-operator) and reconciles spec.poweredOn to Ironic power on/off. Filters on spec.hostClass == "openstack" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6cfb356 commit 40764cb

36 files changed

Lines changed: 2320 additions & 395 deletions

.devcontainer/devcontainer.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

.devcontainer/post-install.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/internal/api/** linguist-generated=true

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,14 @@ updates:
77
schedule:
88
# Check for updates to GitHub Actions every week
99
interval: "weekly"
10+
- package-ecosystem: "gomod"
11+
directory: "/"
12+
schedule:
13+
# Check for updates to Go modules every week
14+
interval: "weekly"
15+
groups:
16+
go-dependencies:
17+
patterns:
18+
- "*"
19+
commit-message:
20+
prefix: "NO-ISSUE"

.github/workflows/build-image.yaml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: Build container image
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
# Use docker.io for Docker Hub if empty
16+
REGISTRY: ghcr.io
17+
# github.repository as <account>/<repo>
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
21+
jobs:
22+
test:
23+
name: Run Tests
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v6
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v6
31+
with:
32+
go-version-file: 'go.mod'
33+
34+
- name: Install kind
35+
uses: helm/kind-action@v1
36+
with:
37+
install_only: true
38+
39+
- name: Run all tests
40+
run: make test
41+
42+
build:
43+
needs: test
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: read
47+
packages: write
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v6
52+
53+
# Login against a Docker registry except on PR
54+
# https://github.com/docker/login-action
55+
- name: Log into registry ${{ env.REGISTRY }}
56+
if: github.event_name != 'pull_request'
57+
uses: docker/login-action@v4
58+
with:
59+
registry: ${{ env.REGISTRY }}
60+
username: ${{ github.actor }}
61+
password: ${{ secrets.GITHUB_TOKEN }}
62+
63+
# Extract metadata (tags, labels) for Docker
64+
# https://github.com/docker/metadata-action
65+
- name: Extract Docker metadata
66+
id: meta
67+
uses: docker/metadata-action@v6
68+
with:
69+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
70+
tags: |
71+
type=semver,pattern=v{{version}}
72+
type=semver,pattern=v{{major}}.{{minor}}
73+
type=semver,pattern=v{{major}}
74+
type=ref,event=branch
75+
type=ref,event=pr
76+
type=ref,event=tag
77+
type=sha
78+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
79+
80+
81+
# Build and push Docker image with Buildx (don't push on PR)
82+
# https://github.com/docker/build-push-action
83+
- name: Build and push Docker image
84+
id: build-operator
85+
uses: docker/build-push-action@v7
86+
with:
87+
context: .
88+
file: Containerfile
89+
push: ${{ github.event_name != 'pull_request' }}
90+
tags: ${{ steps.meta.outputs.tags }}
91+
labels: ${{ steps.meta.outputs.labels }}
92+
93+
# Extract the commit SHA tag for manifest generation
94+
- name: Extract commit SHA tag
95+
id: sha-tag
96+
if: github.event_name != 'pull_request'
97+
run: |
98+
# Extract the sha tag from the metadata output
99+
FULL_SHA_TAG=$(echo "${{ steps.meta.outputs.tags }}" | grep -E "sha-[0-9a-f]{7}" | head -n1)
100+
SHA_TAG=$(echo "$FULL_SHA_TAG" | sed "s/.*://")
101+
echo "sha-tag=$SHA_TAG" >> $GITHUB_OUTPUT
102+
echo "full-sha-tag=$FULL_SHA_TAG" >> $GITHUB_OUTPUT
103+
echo "manifest-tag=$SHA_TAG-manifests" >> $GITHUB_OUTPUT
104+
echo "Using SHA tag: $SHA_TAG"
105+
echo "Full SHA tag: $FULL_SHA_TAG"
106+
echo "Manifest tag: $SHA_TAG-manifests"
107+
108+
# Set up Go for kustomize operations
109+
- name: Set up Go for manifest generation
110+
if: github.event_name != 'pull_request'
111+
uses: actions/setup-go@v6
112+
with:
113+
go-version-file: 'go.mod'
114+
115+
# Generate manifests with kustomize pointing to the SHA-tagged image
116+
- name: Generate manifests with kustomize
117+
if: github.event_name != 'pull_request'
118+
run: |
119+
# Install kustomize
120+
make kustomize
121+
122+
# Create dist directory
123+
mkdir -p dist
124+
125+
# Set the manager image to the SHA-tagged version
126+
cd config/manager && ../../bin/kustomize edit set image controller=${{ steps.sha-tag.outputs.full-sha-tag }}
127+
128+
# Generate the complete manifest
129+
cd ../..
130+
./bin/kustomize build config/default > dist/install.yaml
131+
132+
echo "Generated manifest with image: ${{ steps.sha-tag.outputs.full-sha-tag }}"
133+
echo "Manifest content preview:"
134+
head -20 dist/install.yaml
135+
136+
# Create Dockerfile for manifest container
137+
- name: Create manifest container Dockerfile
138+
if: github.event_name != 'pull_request'
139+
run: |
140+
cat > Dockerfile.manifests << 'EOF'
141+
FROM scratch
142+
COPY dist/install.yaml /manifests/install.yaml
143+
EOF
144+
145+
echo "Created Dockerfile.manifests:"
146+
cat Dockerfile.manifests
147+
148+
# Extract metadata for manifest container
149+
- name: Extract manifest container metadata
150+
id: meta-manifests
151+
if: github.event_name != 'pull_request'
152+
uses: docker/metadata-action@v6
153+
with:
154+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
155+
tags: |
156+
type=raw,value=${{ steps.sha-tag.outputs.manifest-tag }}
157+
158+
# Build and push manifest container
159+
- name: Build and push manifest container
160+
if: github.event_name != 'pull_request'
161+
uses: docker/build-push-action@v7
162+
with:
163+
context: .
164+
file: Dockerfile.manifests
165+
push: true
166+
tags: ${{ steps.meta-manifests.outputs.tags }}
167+
labels: ${{ steps.meta-manifests.outputs.labels }}

.github/workflows/lint.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/pre-commit.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@ jobs:
1212
with:
1313
python-version: "3.13"
1414
- uses: pre-commit/action@v3.0.1
15+
with:
16+
extra_args: -c .pre-commit-config-ci.yaml
17+
18+
golangci-lint:
19+
name: lint
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v6
23+
- uses: actions/setup-go@v6
24+
with:
25+
go-version: stable
26+
- name: golangci-lint
27+
uses: golangci/golangci-lint-action@v9

.github/workflows/test-e2e.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
*.so
66
*.dylib
77
bin/*
8+
main
89
Dockerfile.cross
10+
Dockerfile.manifests
11+
dist/
912

1013
# Test binary, built with `go test -c`
1114
*.test
@@ -25,3 +28,9 @@ go.work
2528
*.swp
2629
*.swo
2730
*~
31+
32+
# Development memory/notes (local only)
33+
MEMORY.md
34+
35+
# Claude notes
36+
CLAUDE.md

0 commit comments

Comments
 (0)