Skip to content

Commit 12bdbbd

Browse files
committed
[feat] declarative TUF
1 parent 777b2eb commit 12bdbbd

40 files changed

Lines changed: 2026 additions & 1694 deletions

‎.github/workflows/main.yml‎

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -181,32 +181,6 @@ jobs:
181181
podman build ${{ env.OCP_VERSION }}/rhtas-operator -f catalog.Dockerfile -t $CATALOG_IMG
182182
podman push $CATALOG_IMG
183183
184-
build-tufcli:
185-
name: Build-tufcli
186-
runs-on: ubuntu-24.04
187-
steps:
188-
- name: Checkout tufcli source
189-
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
190-
with:
191-
repository: "securesign/tufcli"
192-
path: tufcli
193-
194-
- name: Install Go
195-
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
196-
with:
197-
go-version: ${{ env.GO_VERSION }}
198-
199-
- name: Build
200-
run: cd tufcli && CGO_ENABLED=0 go build -o /tmp/tufcli .
201-
202-
- name: Upload artifact
203-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
204-
with:
205-
name: tufcli
206-
path: /tmp/tufcli
207-
retention-days: 1
208-
if-no-files-found: error
209-
210184
test-kind:
211185
name: Test kind deployment
212186
runs-on: ubuntu-24.04
@@ -215,7 +189,6 @@ jobs:
215189
packages: read
216190
needs:
217191
- build-operator
218-
- build-tufcli
219192
steps:
220193
- name: Checkout source
221194
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
@@ -225,17 +198,6 @@ jobs:
225198
with:
226199
go-version: ${{ env.GO_VERSION }}
227200

228-
- name: Download tufcli
229-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
230-
with:
231-
name: tufcli
232-
path: /tmp/tufcli
233-
234-
- name: Make tufcli executable
235-
run: chmod +x /tmp/tufcli/tufcli
236-
237-
- run: echo "/tmp/tufcli" >> $GITHUB_PATH
238-
239201
- name: Log in to GitHub Container Registry
240202
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
241203
with:
@@ -730,6 +692,7 @@ jobs:
730692
kubectl create -f config/samples/rhtas_v1_securesign.yaml -n ${{ env.TEST_NAMESPACE }}
731693
sleep 1
732694
kubectl wait --for=condition=Ready securesign/securesign-sample --timeout=5m -n ${{ env.TEST_NAMESPACE }}
695+
kubectl wait --for=condition=trustroot-synced tuf/securesign-sample --timeout=5m -n ${{ env.TEST_NAMESPACE }}
733696
734697
- name: Run tests
735698
env:
@@ -794,7 +757,6 @@ jobs:
794757
id-token: write
795758
needs:
796759
- build-operator-coverage
797-
- build-tufcli
798760
steps:
799761
- name: Checkout source
800762
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
@@ -809,17 +771,6 @@ jobs:
809771
go install github.com/konflux-ci/coverport/cli@latest
810772
mv "$(go env GOPATH)/bin/cli" "$(go env GOPATH)/bin/coverport"
811773
812-
- name: Download tufcli
813-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
814-
with:
815-
name: tufcli
816-
path: /tmp/tufcli
817-
818-
- name: Make tufcli executable
819-
run: chmod +x /tmp/tufcli/tufcli
820-
821-
- run: echo "/tmp/tufcli" >> $GITHUB_PATH
822-
823774
- name: Log in to GitHub Container Registry
824775
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
825776
with:

‎config/default/images.env‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RELATED_IMAGE_REKOR_REDIS=registry.redhat.io/rhtas/trillian-redis-rhel9@sha256:6
2626
RELATED_IMAGE_BACKFILL_REDIS=registry.redhat.io/rhtas/rekor-backfill-redis-rhel9@sha256:65c5fea1211077ebd8aad7b67eef5dbbe8b94900149067623b7fd4b56346b1b4
2727

2828
# TUF - Init TUF repository
29-
RELATED_IMAGE_TUF=registry.redhat.io/rhtas/tufcli-init-rhel9@sha256:4b8e775300736d260b5f427d898d2dc73b1cbee89a5ba904c222d14a34bec272
29+
RELATED_IMAGE_TUF=quay.io/jbouska/securesign-controller:tuf-init3
3030

3131
# CTlog - Server
3232
RELATED_IMAGE_CTLOG=registry.redhat.io/rhtas/certificate-transparency-rhel9@sha256:7b59935489352231f55457861353e70adc7484f0ac1ff89c7c8c454047a9fa98

‎config/rbac/role.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ rules:
2222
- ""
2323
resources:
2424
- namespaces
25+
- pods
2526
verbs:
2627
- get
2728
- list

‎internal/controller/tuf/actions/fips_validation.go‎

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package actions
33
import (
44
"context"
55
"fmt"
6+
"maps"
7+
"slices"
68

79
rhtasv1 "github.com/securesign/operator/api/v1"
810
"github.com/securesign/operator/internal/action"
911
fipsAction "github.com/securesign/operator/internal/action/fips"
1012
tufConstants "github.com/securesign/operator/internal/controller/tuf/constants"
11-
"github.com/securesign/operator/internal/controller/tuf/trustroot"
1213
fipsutil "github.com/securesign/operator/internal/utils/fips"
1314
"sigs.k8s.io/controller-runtime/pkg/client"
1415
)
@@ -25,22 +26,40 @@ func NewFIPSValidationAction() action.Action[*rhtasv1.Tuf] {
2526

2627
func tufCryptoMaterial(ctx context.Context, i *rhtasv1.Tuf, c client.Client) ([]fipsAction.CryptoRef, error) {
2728
var refs []fipsAction.CryptoRef
28-
29-
specHasRef := make(map[string]bool)
30-
for _, key := range trustroot.ActiveKeys(i) {
31-
secretRef := trustroot.Binding(i, key).SecretRef
32-
if secretRef == nil {
33-
continue
29+
asTrustRootBindings := func(bindings []rhtasv1.TrustRootBindingWithOIDC) []rhtasv1.TrustRootBinding {
30+
b := make([]rhtasv1.TrustRootBinding, len(bindings))
31+
for i, binding := range bindings {
32+
b[i] = binding.TrustRootBinding
3433
}
35-
specHasRef[key.String()] = true
36-
if err := fipsAction.AppendSecretRef(ctx, c, i.Namespace, secretRef,
37-
fmt.Sprintf("spec.%s[0].secretRef", key), fipsutil.ValidateCryptoMaterialPEM, &refs); err != nil {
38-
return nil, err
34+
return b
35+
}
36+
37+
components := map[string][]rhtasv1.TrustRootBinding{
38+
"ctlog": i.Spec.Ctlog,
39+
"fulcio": asTrustRootBindings(i.Spec.Fulcio),
40+
"rekor": i.Spec.Rekor,
41+
"tsa": i.Spec.Tsa,
42+
}
43+
for component, array := range components {
44+
for _, key := range array {
45+
46+
if key.SecretRef == nil {
47+
continue
48+
}
49+
if err := fipsAction.AppendSecretRef(ctx, c, i.Namespace, key.SecretRef,
50+
fmt.Sprintf("spec.%s[0].secretRef", component), fipsutil.ValidateCryptoMaterialPEM, &refs); err != nil {
51+
return nil, err
52+
}
3953
}
4054
}
4155

4256
for _, ks := range i.Status.Keys {
43-
if ks.SecretRef == nil || specHasRef[ks.Name] {
57+
if ks.SecretRef == nil {
58+
continue
59+
}
60+
if slices.ContainsFunc(slices.Concat(slices.Collect(maps.Values(components))...), func(key rhtasv1.TrustRootBinding) bool {
61+
return key.SecretRef != nil && key.SecretRef.Name == ks.SecretRef.Name
62+
}) {
4463
continue
4564
}
4665
if err := fipsAction.AppendSecretRef(ctx, c, i.Namespace, ks.SecretRef,

‎internal/controller/tuf/actions/migration_job.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/securesign/operator/internal/constants"
1212
"github.com/securesign/operator/internal/controller/traits"
1313
tufConstants "github.com/securesign/operator/internal/controller/tuf/constants"
14+
"github.com/securesign/operator/internal/controller/tuf/trustroot"
1415
"github.com/securesign/operator/internal/controller/tuf/utils"
1516
"github.com/securesign/operator/internal/labels"
1617
"github.com/securesign/operator/internal/state"
@@ -133,7 +134,7 @@ func (i migrationJobAction) ensureMigrationJob(ctx context.Context, labels map[s
133134
),
134135
)
135136
if err != nil {
136-
if errors.Is(err, utils.ErrorResolveServiceUrl) {
137+
if errors.Is(err, trustroot.ErrorResolveServiceUrl) {
137138
return i.Error(ctx, err, instance,
138139
metav1.Condition{
139140
Type: constants.ReadyCondition,

‎internal/controller/tuf/actions/migration_job_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package actions
22

33
import (
4+
_ "embed"
45
"testing"
56
"time"
67

@@ -25,6 +26,9 @@ import (
2526
"sigs.k8s.io/controller-runtime/pkg/client/fake"
2627
)
2728

29+
//go:embed testdata/public_key.pem
30+
var testPEM string
31+
2832
func setupMigrateAction() migrationJobAction {
2933
scheme := runtime.NewScheme()
3034
utilruntime.Must(corev1.AddToScheme(scheme))

‎internal/controller/tuf/actions/resolve_keys.go‎

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

0 commit comments

Comments
 (0)