Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name-template: '$NEXT_MINOR_VERSION'
tag-template: '$NEXT_MINOR_VERSION'
version-template: '$COMPLETE'
change-template: '- $TITLE (#$NUMBER)'
change-title-escapes: '\<*_&#@`'
template: |
# Release $NEXT_MINOR_VERSION

$CHANGES
exclude-labels:
- 'kind/skip-release-notes'
34 changes: 34 additions & 0 deletions .github/workflows/check-manifest-generation-diff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check for diff after manifest and generated targets

on:
pull_request: {}

jobs:
check:
name: Check for diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Make manifests && generate
run: |
make manifests && make generate
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Restore Go cache
uses: actions/cache@v3
with:
path: /home/runner/work/_temp/_github_home/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: go mod tidy
run: |
go mod tidy
- name: Check for diff
run: |
git diff --exit-code --shortstat
38 changes: 0 additions & 38 deletions .github/workflows/ghcr.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release Drafter

on:
push:
branches:
- main

permissions:
contents: read
# The release-drafter action adds PR titles to the release notes once these are merged to main.
# A draft release is kept up-to-date listing the changes for the next minor release version.
jobs:
update_release_draft:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105 changes: 105 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release

on:
workflow_dispatch:
inputs:
release_candidate:
type: boolean
description: "Release Candidate"
required: false
default: false

env:
REGISTRY: ghcr.io
DOCKERFILE: ${{ github.workspace }}/goreleaser.dockerfile

jobs:
tests:
uses: ./.github/workflows/tests.yaml
permissions:
contents: read
pull-requests: 'read'
release:
needs: tests
name: Trigger release build
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
pull-requests: 'read'
repository-projects: 'write'
packages: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Cache go-build and mod
uses: actions/cache@v3
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Set release version
run: |
if ${{ inputs.release_candidate }}; then
echo "RELEASE_VERSION=$(go run $GITHUB_WORKSPACE/pkg/version/generate/release_generate.go print-rc-version)" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=$(go run $GITHUB_WORKSPACE/pkg/version/generate/release_generate.go print-version)" >> $GITHUB_ENV
fi
- name: Set release notes file
run: |
echo "RELEASE_NOTES_FILE=docs/release_notes/$(go run $GITHUB_WORKSPACE/pkg/version/generate/release_generate.go print-version).md" >> $GITHUB_ENV
- name: Validate release notes
run: |
if [[ ! -f ${{ env.RELEASE_NOTES_FILE }} ]]; then
>&2 echo "Must have release notes ${{ env.RELEASE_NOTES_FILE }}"
exit 6
fi
- name: Create and push branch
env:
RELEASE_BRANCH: release-${{ env.RELEASE_VERSION }}
run: |
if ! git checkout ${RELEASE_BRANCH} >/dev/null; then
echo "Creating ${RELEASE_BRANCH} from $(git branch --show-current)"
git checkout -b ${RELEASE_BRANCH}
git push origin "$(git branch --show-current)"
else
git checkout ${RELEASE_BRANCH}
git pull --ff-only origin ${RELEASE_BRANCH}
fi
- name: Setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
- name: Create and push tag
run: |
msg="Release ${{ env.RELEASE_VERSION }}"
git tag --annotate --message "${msg}" ${{ env.RELEASE_VERSION }}
git push origin ${{ env.RELEASE_VERSION }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate manifests
run: |
mkdir -p output
kustomize build ./config/default > ./output/install.yaml
- name: Run goreleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean --timeout 60m --skip-validate --config=./.goreleaser.yaml --release-notes=${{ env.RELEASE_NOTES_FILE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ env.RELEASE_VERSION }}
36 changes: 36 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: tests

on:
pull_request:
paths-ignore:
- 'CODE_OF_CONDUCT.md'
- 'README.md'
- 'Contributing.md'
workflow_call:

push:
branches:
- main

permissions:
contents: read # for actions/checkout to fetch code

jobs:
test-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Restore Go cache
uses: actions/cache@v3
with:
path: /home/runner/work/_temp/_github_home/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run tests
run: make test
49 changes: 49 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
- go mod tidy
builds:
- main: main.go
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
archives:
- name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
release:
extra_files:
- glob: output/install.yaml
checksum:
name_template: 'checksums.txt'
extra_files:
- glob: output/install.yaml
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
# for more information on what this target does: https://goreleaser.com/errors/docker-build/
dockers:
- id: linux-build
image_templates:
- "{{ .Env.REGISTRY }}/open-component-model/{{ .ProjectName }}:{{ .Tag }}"
- "{{ .Env.REGISTRY }}/open-component-model/{{ .ProjectName }}:latest"
# GOOS of the built binary that should be used.
goos: linux
# GOARCH of the built binary that should be used.
goarch: amd64
dockerfile: "{{ .Env.DOCKERFILE }}"
build_flag_templates:
- "--platform=linux/amd64"
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.20 as builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -15,6 +15,7 @@ RUN go mod download
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
Expand Down
49 changes: 41 additions & 8 deletions api/v1alpha1/componentsubscription_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package v1alpha1

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -35,28 +37,59 @@ type Signature struct {
PublicKey SecretRef `json:"publicKey"`
}

// OCIRepository defines details for a repository, such as access keys and the url.
type OCIRepository struct {
// OCMRepository defines details for a repository, such as access keys and the url.
type OCMRepository struct {
URL string `json:"url"`
SecretRef Ref `json:"secretRef"`
SecretRef *Ref `json:"secretRef,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍🏻

}

// ComponentSubscriptionSpec defines the desired state of ComponentSubscription
type ComponentSubscriptionSpec struct {
Interval string `json:"interval"`
Source OCIRepository `json:"source"`
Destination OCIRepository `json:"destination"`
// Interval is the reconciliation interval, i.e. at what interval shall a reconciliation happen.
// This is used to requeue objects for reconciliation in case of success as well as already reconciling objects.
// +required
Interval metav1.Duration `json:"interval"`

Source OCMRepository `json:"source"`
Destination OCMRepository `json:"destination"`
Component string `json:"component"`
//+optional
Semver string `json:"semver,omitempty"`
Verify []Signature `json:"verify"`
Verify []Signature `json:"verify,omitempty"`
}

// ComponentSubscriptionStatus defines the observed state of ComponentSubscription
type ComponentSubscriptionStatus struct {
// LatestVersion defines the version that was last reconciled successfully.
LatestVersion string `json:"latestVersion"`

// ObservedGeneration is the last reconciled generation.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

//+optional
ReplicatedVersion string `json:"replicatedVersion,omitempty"`
LatestVersion string `json:"latestVersion"`

// +optional
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// GetConditions returns the conditions of the ComponentVersion.
func (in *ComponentSubscription) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// SetConditions sets the conditions of the ComponentVersion.
func (in *ComponentSubscription) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// GetRequeueAfter returns the duration after which the ComponentVersion must be
// reconciled again.
func (in ComponentSubscription) GetRequeueAfter() time.Duration {
return in.Spec.Interval.Duration
}

//+kubebuilder:object:root=true
Expand Down
Loading