Skip to content
Draft
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
6 changes: 6 additions & 0 deletions .github/workflows/utils/bump-chart-and-dagger-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ sed -i "s/tag: .*/tag: \"${semVer}\"/g" "${values_yaml}"
## Update Dagger version
sed -i "s/chainloopVersion = \"v.*\"/chainloopVersion = \"${semVer}\"/" "${dagger_main}"

## Update platform (enterprise) CLI version from infoz endpoint
platform_version=$(curl -sf https://api.app.chainloop.dev/infoz | jq -r '.version')
if [[ -n "${platform_version}" && "${platform_version}" != "null" ]]; then
sed -i "s/platformVersion = \"v.*\"/platformVersion = \"${platform_version}\"/" "${dagger_main}"
fi

40 changes: 35 additions & 5 deletions extras/dagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

const (
chainloopVersion = "v1.98.4"
platformVersion = "v1.77.8"
)

var execOpts = dagger.ContainerWithExecOpts{
Expand All @@ -20,6 +21,25 @@ var execOpts = dagger.ContainerWithExecOpts{
type Chainloop struct {
// +private
Instance InstanceInfo
// +private
Enterprise bool
// +private
CLIVersion string
}

// New creates a new Chainloop module client.
func New(
// Use the enterprise CLI image (ghcr.io/chainloop-dev/platform/cli)
// +optional
enterprise bool,
// Pin a specific CLI version (overrides the built-in default)
// +optional
cliVersion string,
) *Chainloop {
return &Chainloop{
Enterprise: enterprise,
CLIVersion: cliVersion,
}
}

// A Chainloop attestation
Expand Down Expand Up @@ -515,11 +535,21 @@ func (att *Attestation) Debug() *dagger.Container {
return att.Container(0).Terminal()
}

func cliContainer(ttl int, token *dagger.Secret, instance InstanceInfo, parentCI *ParentCIContext, githubEventFile *dagger.File) *dagger.Container {
func cliContainer(ttl int, token *dagger.Secret, instance InstanceInfo, parentCI *ParentCIContext, githubEventFile *dagger.File, enterprise bool, cliVersionOverride string) *dagger.Container {
image := "ghcr.io/chainloop-dev/chainloop/cli"
version := chainloopVersion
if enterprise {
image = "ghcr.io/chainloop-dev/platform/cli"
version = platformVersion
}
if cliVersionOverride != "" {
version = cliVersionOverride
}

ctr := dag.Container().
From(fmt.Sprintf("ghcr.io/chainloop-dev/chainloop/cli:%s", chainloopVersion)).
From(fmt.Sprintf("%s:%s", image, version)).
WithEntrypoint([]string{"/chainloop"}). // Be explicit to prepare for possible API change
WithEnvVariable("CHAINLOOP_DAGGER_CLIENT", chainloopVersion).
WithEnvVariable("CHAINLOOP_DAGGER_CLIENT", version).
WithUser(""). // Our images come with pre-defined user set, so we need to reset it
WithEnvVariable("DAGGER_CACHE_KEY", time.Now().Truncate(time.Duration(ttl)*time.Second).String()) // Cache TTL

Expand Down Expand Up @@ -631,7 +661,7 @@ func (att *Attestation) Container(
// +default=0
ttl int,
) *dagger.Container {
ctr := cliContainer(ttl, att.Token, att.Client.Instance, att.parentCIContext, att.githubEventFile)
ctr := cliContainer(ttl, att.Token, att.Client.Instance, att.parentCIContext, att.githubEventFile, att.Client.Enterprise, att.Client.CLIVersion)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Id not make the CLI version configurable

if att.repository != nil {
ctr = ctr.WithDirectory(".", att.repository)
}
Expand Down Expand Up @@ -778,7 +808,7 @@ func (m *Chainloop) WorkflowCreate(
// +optional
skipIfExists bool,
) (string, error) {
return cliContainer(0, token, m.Instance, nil, nil).
return cliContainer(0, token, m.Instance, nil, nil, m.Enterprise, m.CLIVersion).
WithExec([]string{
"workflow", "create",
"--name", name,
Expand Down
Loading