Skip to content

Commit d73b062

Browse files
authored
feat(dagger): support explicit OCI credentials (#514)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent be941a7 commit d73b062

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

extras/dagger/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,21 @@ dagger call -m github.com/chainloop-dev/chainloop/extras/dagger \
5555
--token env:CHAINLOOP_TOKEN attestation-add \
5656
--attestation-id $ATTESTATION_ID \
5757
--name my-container-image \
58-
--value ghcr.io/chainloop-dev/chainloop
58+
--value ghcr.io/chainloop-dev/chainloop/control-plane
59+
```
60+
61+
In some cases, you might be providing a private container image as a piece of evidence. In this case, you'll also need to provide the container registry credentials.
62+
63+
```sh
64+
# Or one with a raw value such as a container image reference
65+
dagger call -m github.com/chainloop-dev/chainloop/extras/dagger \
66+
--token env:CHAINLOOP_TOKEN attestation-add \
67+
--attestation-id $ATTESTATION_ID \
68+
--name my-container-image \
69+
--value ghcr.io/chainloop-dev/chainloop/control-plane
70+
--registry ghcr.io \
71+
--registry-username my-username \
72+
--registry-password MY_PAT_TOKEN
5973
```
6074

6175
### Sign and push ([docs](https://docs.chainloop.dev/getting-started/attestation-crafting#encode-sign-and-push-attestation))

extras/dagger/main.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88
)
99

10-
const chainloopVersion = "v0.60.0"
10+
const chainloopVersion = "v0.65.0"
1111

1212
type Chainloop struct {
1313
Token *Secret
@@ -70,6 +70,7 @@ func (m *Chainloop) AttestationStatus(ctx context.Context, attestationID string)
7070
// The file type is required for materials of kind ARTIFACT that are uploaded to the CAS
7171
func (m *Chainloop) AttestationAdd(
7272
ctx context.Context,
73+
attestationID string,
7374
// material name
7475
name string,
7576
// path to the file to be added
@@ -78,12 +79,28 @@ func (m *Chainloop) AttestationAdd(
7879
// raw value to be added
7980
// +optional
8081
value string,
81-
attestationID string) (string, error) {
82+
// Container Registry Credentials for Container image-based materials
83+
// i.e docker.io, ghcr.io, etc
84+
// +optional
85+
registry string,
86+
// +optional
87+
registryUsername string,
88+
// +optional
89+
registryPassword *Secret,
90+
) (string, error) {
91+
// Validate that either the path or the raw value is provided
8292
if value != "" && path != nil {
8393
return "", fmt.Errorf("only one of material path or value can be provided")
8494
}
8595

8696
c := m.cliImage()
97+
// These OCI credentials are used to resolve materials of type CONTAINER_IMAGE
98+
if registry != "" {
99+
c = c.WithEnvVariable("CHAINLOOP_REGISTRY_SERVER", registry).
100+
WithEnvVariable("CHAINLOOP_REGISTRY_USERNAME", registryUsername).
101+
WithSecretVariable("CHAINLOOP_REGISTRY_PASSWORD", registryPassword)
102+
}
103+
87104
// if the value is provided in a file we need to upload it to the container
88105
if path != nil {
89106
fileName, err := path.Name(ctx)

0 commit comments

Comments
 (0)