Skip to content

Commit 76e9765

Browse files
committed
cmd&build: Push ORCs to Oasis ROFL registry by default
1 parent d75f12c commit 76e9765

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

build/rofl/oci.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"maps"
7+
"net/http"
78
"os"
89
"path/filepath"
910
"slices"
@@ -27,6 +28,9 @@ const (
2728
ociTypeOrcArtifact = "application/vnd.oasis.orc"
2829
)
2930

31+
// DefaultOCIRegistry is the default OCI registry.
32+
const DefaultOCIRegistry = "rofl-orc-registry.prd.oasis.io"
33+
3034
// PushBundleToOciRepository pushes an ORC bundle to the given remote OCI repository.
3135
//
3236
// Returns the OCI manifest digest and the ORC manifest hash.
@@ -118,11 +122,17 @@ func PushBundleToOciRepository(bundleFn, dst string) (string, hash.Hash, error)
118122
if err != nil {
119123
return "", hash.Hash{}, fmt.Errorf("failed to init OCI credential store: %w", err)
120124
}
121-
repo.Client = &auth.Client{
125+
client := &auth.Client{
122126
Client: retry.DefaultClient,
123127
Cache: auth.NewCache(),
124128
Credential: credentials.Credential(creds),
125129
}
130+
if strings.Contains(dst, DefaultOCIRegistry) {
131+
client.Header = http.Header{
132+
"X-Rofl-Registry-Caller": []string{"cli"},
133+
}
134+
}
135+
repo.Client = client
126136

127137
// Push to remote repository.
128138
if _, err = oras.Copy(ctx, store, tag, repo, tag, oras.DefaultCopyOptions); err != nil {

cmd/rofl/deploy.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"github.com/google/uuid"
78
"maps"
89
"os"
10+
"time"
911

1012
"github.com/spf13/cobra"
1113
flag "github.com/spf13/pflag"
@@ -114,8 +116,10 @@ var (
114116

115117
// Push ORC to OCI repository.
116118
if deployment.OCIRepository == "" {
117-
// TODO: Support default OCI repository.
118-
cobra.CheckErr(fmt.Sprintf("Missing OCI repository for deployment '%s'.", deploymentName))
119+
// Use default OCI repository with random name and timestamp tag.
120+
deployment.OCIRepository = fmt.Sprintf(
121+
"%s/%s:%d", buildRofl.DefaultOCIRegistry, uuid.New(), time.Now().Unix(),
122+
)
119123
}
120124
fmt.Printf("Pushing ROFL app to OCI repository '%s'...\n", deployment.OCIRepository)
121125

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
github.com/ethereum/go-ethereum v1.15.0
1919
github.com/foxboron/go-uefi v0.0.0-20241017190036-fab4fdf2f2f3
2020
github.com/github/go-spdx/v2 v2.3.2
21+
github.com/google/uuid v1.6.0
2122
github.com/miguelmota/go-ethereum-hdwallet v0.1.2
2223
github.com/mitchellh/mapstructure v1.5.0
2324
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a

0 commit comments

Comments
 (0)