This repository was archived by the owner on Aug 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Add HostLease controller for bare metal management via Ironic #1
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
| # Ignore build and test binaries. | ||
| bin/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /internal/api/** linguist-generated=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| name: Build container image | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| # Use docker.io for Docker Hub if empty | ||
| REGISTRY: ghcr.io | ||
| # github.repository as <account>/<repo> | ||
| IMAGE_NAME: ${{ github.repository }} | ||
|
|
||
|
|
||
| jobs: | ||
| test: | ||
| name: Run Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Install kind | ||
| uses: helm/kind-action@v1 | ||
| with: | ||
| install_only: true | ||
|
|
||
| - name: Run all tests | ||
| run: make test | ||
|
|
||
| build: | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| # Login against a Docker registry except on PR | ||
| # https://github.com/docker/login-action | ||
| - name: Log into registry ${{ env.REGISTRY }} | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # Extract metadata (tags, labels) for Docker | ||
| # https://github.com/docker/metadata-action | ||
| - name: Extract Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v6 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=semver,pattern=v{{version}} | ||
| type=semver,pattern=v{{major}}.{{minor}} | ||
| type=semver,pattern=v{{major}} | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=ref,event=tag | ||
| type=sha | ||
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | ||
|
|
||
|
|
||
| # Build and push Docker image with Buildx (don't push on PR) | ||
| # https://github.com/docker/build-push-action | ||
| - name: Build and push Docker image | ||
| id: build-operator | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: . | ||
| file: Containerfile | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
|
|
||
| # Extract the commit SHA tag for manifest generation | ||
| - name: Extract commit SHA tag | ||
| id: sha-tag | ||
| if: github.event_name != 'pull_request' | ||
| run: | | ||
| # Extract the sha tag from the metadata output | ||
| FULL_SHA_TAG=$(echo "${{ steps.meta.outputs.tags }}" | grep -E "sha-[0-9a-f]{7}" | head -n1) | ||
| SHA_TAG=$(echo "$FULL_SHA_TAG" | sed "s/.*://") | ||
| echo "sha-tag=$SHA_TAG" >> $GITHUB_OUTPUT | ||
| echo "full-sha-tag=$FULL_SHA_TAG" >> $GITHUB_OUTPUT | ||
| echo "manifest-tag=$SHA_TAG-manifests" >> $GITHUB_OUTPUT | ||
| echo "Using SHA tag: $SHA_TAG" | ||
| echo "Full SHA tag: $FULL_SHA_TAG" | ||
| echo "Manifest tag: $SHA_TAG-manifests" | ||
|
|
||
| # Set up Go for kustomize operations | ||
| - name: Set up Go for manifest generation | ||
| if: github.event_name != 'pull_request' | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| # Generate manifests with kustomize pointing to the SHA-tagged image | ||
| - name: Generate manifests with kustomize | ||
| if: github.event_name != 'pull_request' | ||
| run: | | ||
| # Install kustomize | ||
| make kustomize | ||
|
|
||
| # Create dist directory | ||
| mkdir -p dist | ||
|
|
||
| # Set the manager image to the SHA-tagged version | ||
| cd config/manager && ../../bin/kustomize edit set image controller=${{ steps.sha-tag.outputs.full-sha-tag }} | ||
|
|
||
| # Generate the complete manifest | ||
| cd ../.. | ||
| ./bin/kustomize build config/default > dist/install.yaml | ||
|
|
||
| echo "Generated manifest with image: ${{ steps.sha-tag.outputs.full-sha-tag }}" | ||
| echo "Manifest content preview:" | ||
| head -20 dist/install.yaml | ||
|
|
||
| # Create Dockerfile for manifest container | ||
| - name: Create manifest container Dockerfile | ||
| if: github.event_name != 'pull_request' | ||
| run: | | ||
| cat > Dockerfile.manifests << 'EOF' | ||
| FROM scratch | ||
| COPY dist/install.yaml /manifests/install.yaml | ||
| EOF | ||
|
|
||
| echo "Created Dockerfile.manifests:" | ||
| cat Dockerfile.manifests | ||
|
|
||
| # Extract metadata for manifest container | ||
| - name: Extract manifest container metadata | ||
| id: meta-manifests | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/metadata-action@v6 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=raw,value=${{ steps.sha-tag.outputs.manifest-tag }} | ||
|
|
||
| # Build and push manifest container | ||
| - name: Build and push manifest container | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: . | ||
| file: Dockerfile.manifests | ||
| push: true | ||
| tags: ${{ steps.meta-manifests.outputs.tags }} | ||
| labels: ${{ steps.meta-manifests.outputs.labels }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Binaries for programs and plugins | ||
| *.exe | ||
| *.exe~ | ||
| *.dll | ||
| *.so | ||
| *.dylib | ||
| bin/* | ||
| main | ||
| Dockerfile.cross | ||
| Dockerfile.manifests | ||
| dist/ | ||
|
|
||
| # Test binary, built with `go test -c` | ||
| *.test | ||
|
|
||
| # Output of the go coverage tool, specifically when used with LiteIDE | ||
| *.out | ||
|
|
||
| # Go workspace file | ||
| go.work | ||
|
|
||
| # Kubernetes Generated files - skip generated files, except for vendored files | ||
| !vendor/**/zz_generated.* | ||
|
|
||
| # editor and IDE paraphernalia | ||
| .idea | ||
| .vscode | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # Development memory/notes (local only) | ||
| MEMORY.md | ||
|
|
||
| # Claude notes | ||
| CLAUDE.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| version: "2" | ||
| run: | ||
| allow-parallel-runners: true | ||
| linters: | ||
| default: none | ||
| enable: | ||
| - dupl | ||
| - errcheck | ||
| - ginkgolinter | ||
| - goconst | ||
| - gocyclo | ||
| - govet | ||
| - ineffassign | ||
| - lll | ||
| - misspell | ||
| # nakedret | ||
| - prealloc | ||
| - revive | ||
| - staticcheck | ||
| - unconvert | ||
| # unparam | ||
| - unused | ||
| settings: | ||
| revive: | ||
| rules: | ||
| - name: comment-spacings | ||
| staticcheck: | ||
| checks: | ||
| - all | ||
| - '-QF1008' | ||
| exclusions: | ||
| generated: lax | ||
| rules: | ||
| - linters: | ||
| - lll | ||
| path: api/* | ||
| - linters: | ||
| - dupl | ||
| - lll | ||
| path: internal/* | ||
| - linters: | ||
| - dupl | ||
| path: api/v1alpha1/clusterorder_clusterreference.go | ||
| - linters: | ||
| - dupl | ||
| path: api/v1alpha1/computeinstance_virtualmachinereference.go | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
| formatters: | ||
| enable: | ||
| - gofmt | ||
| - goimports | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: check-merge-conflict | ||
| - id: end-of-file-fixer | ||
| - id: check-added-large-files | ||
| - id: check-case-conflict | ||
| - id: check-json | ||
| - id: check-symlinks | ||
| - id: detect-private-key | ||
|
|
||
| - repo: https://github.com/adrienverge/yamllint.git | ||
| rev: v1.35.1 | ||
| hooks: | ||
| - id: yamllint | ||
| exclude: "^config/" | ||
| files: \.(yaml|yml)$ | ||
| types: [file, yaml] | ||
| entry: yamllint --strict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Build the manager binary | ||
| FROM golang:1.25 AS builder | ||
| ARG TARGETOS | ||
| ARG TARGETARCH | ||
|
|
||
| WORKDIR /workspace | ||
| # Copy the Go Modules manifests | ||
| COPY go.mod go.mod | ||
| COPY go.sum go.sum | ||
| # cache deps before building and copying source so that we don't need to re-download as much | ||
| # and so that source changes don't invalidate our downloaded layer | ||
| RUN go mod download | ||
|
|
||
| # Copy the go source | ||
| COPY . ./ | ||
|
|
||
| # Build | ||
| # the GOARCH has not a default value to allow the binary be built according to the host where the command | ||
| # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO | ||
| # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, | ||
| # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. | ||
| RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why provide a default for GOOS? Shouldn't the same logic apply to GOOS that applies to GOARCH?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This Containerfile is generated by |
||
|
|
||
| # Use distroless as minimal base image to package the manager binary | ||
| # Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
| FROM gcr.io/distroless/static:nonroot | ||
| WORKDIR / | ||
| COPY --from=builder /workspace/manager . | ||
| USER 65532:65532 | ||
|
|
||
| ENTRYPOINT ["/manager"] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.