(ttl int, token *dagger.Secret, instance InstanceInfo, parentCI *ParentCIContext, githubEventFile *dagger.File, enterprise bool)
| 561 | } |
| 562 | |
| 563 | func cliContainer(ttl int, token *dagger.Secret, instance InstanceInfo, parentCI *ParentCIContext, githubEventFile *dagger.File, enterprise bool) *dagger.Container { |
| 564 | image := "ghcr.io/chainloop-dev/chainloop/cli" |
| 565 | version := chainloopVersion |
| 566 | if enterprise { |
| 567 | image = "ghcr.io/chainloop-dev/platform/cli" |
| 568 | version = platformVersion |
| 569 | } |
| 570 | |
| 571 | ctr := dag.Container(). |
| 572 | From(fmt.Sprintf("%s:%s", image, version)). |
| 573 | WithEntrypoint([]string{"/chainloop"}). // Be explicit to prepare for possible API change |
| 574 | WithEnvVariable("CHAINLOOP_DAGGER_CLIENT", version). |
| 575 | WithUser(""). // Our images come with pre-defined user set, so we need to reset it |
| 576 | WithEnvVariable("DAGGER_CACHE_KEY", time.Now().Truncate(time.Duration(ttl)*time.Second).String()) // Cache TTL |
| 577 | |
| 578 | // Inject parent CI context if provided |
| 579 | if parentCI != nil { |
| 580 | // Github Actions context |
| 581 | if parentCI.GithubRepository != "" { |
| 582 | ctr = ctr.WithEnvVariable("GITHUB_REPOSITORY", parentCI.GithubRepository) |
| 583 | } |
| 584 | if parentCI.GithubRunID != "" { |
| 585 | ctr = ctr.WithEnvVariable("GITHUB_RUN_ID", parentCI.GithubRunID) |
| 586 | } |
| 587 | if parentCI.GithubEventName != "" { |
| 588 | ctr = ctr.WithEnvVariable("GITHUB_EVENT_NAME", parentCI.GithubEventName) |
| 589 | } |
| 590 | if parentCI.GithubHeadRef != "" { |
| 591 | ctr = ctr.WithEnvVariable("GITHUB_HEAD_REF", parentCI.GithubHeadRef) |
| 592 | } |
| 593 | if parentCI.GithubBaseRef != "" { |
| 594 | ctr = ctr.WithEnvVariable("GITHUB_BASE_REF", parentCI.GithubBaseRef) |
| 595 | } |
| 596 | if parentCI.GithubToken != nil { |
| 597 | ctr = ctr.WithSecretVariable("GITHUB_TOKEN", parentCI.GithubToken) |
| 598 | } |
| 599 | |
| 600 | // Handle Github event file (passed as separate parameter for CLI convenience) |
| 601 | if githubEventFile != nil { |
| 602 | ctr = ctr.WithFile("/tmp/github_event.json", githubEventFile). |
| 603 | WithEnvVariable("GITHUB_EVENT_PATH", "/tmp/github_event.json") |
| 604 | } |
| 605 | |
| 606 | // Gitlab CI context |
| 607 | if parentCI.GitlabCI != "" { |
| 608 | ctr = ctr.WithEnvVariable("GITLAB_CI", parentCI.GitlabCI) |
| 609 | } |
| 610 | if parentCI.GitlabServerURL != "" { |
| 611 | ctr = ctr.WithEnvVariable("CI_SERVER_URL", parentCI.GitlabServerURL) |
| 612 | } |
| 613 | if parentCI.GitlabProjectPath != "" { |
| 614 | ctr = ctr.WithEnvVariable("CI_PROJECT_PATH", parentCI.GitlabProjectPath) |
| 615 | } |
| 616 | if parentCI.GitlabJobURL != "" { |
| 617 | ctr = ctr.WithEnvVariable("CI_JOB_URL", parentCI.GitlabJobURL) |
| 618 | } |
| 619 | if parentCI.GitlabPipelineSource != "" { |
| 620 | ctr = ctr.WithEnvVariable("CI_PIPELINE_SOURCE", parentCI.GitlabPipelineSource) |
no test coverage detected