Skip to content

feat(cli): allow setting project name in .chainloop.yaml#3065

Open
waveywaves wants to merge 1 commit intochainloop-dev:mainfrom
waveywaves:feat/chainloop-yaml-org-project
Open

feat(cli): allow setting project name in .chainloop.yaml#3065
waveywaves wants to merge 1 commit intochainloop-dev:mainfrom
waveywaves:feat/chainloop-yaml-org-project

Conversation

@waveywaves
Copy link
Copy Markdown
Contributor

Summary

Fixes #3063.

Extends .chainloop.yaml to support a project field, so chainloop attestation init can resolve the project name from config when --project is not provided.

Changes

  • config.go: Added Project and Organization fields to DotChainloopConfig struct
  • attestation_init.go: Extended the PreRunE config loader to populate projectName from config when the CLI flag is empty. Same precedence pattern as projectVersion: CLI flag > .chainloop.yaml > default.
  • Removed MarkFlagRequired("project"): The flag is no longer required by cobra since the value can come from config. The existing deprecation warning at line 156 still fires when neither flag nor config provides a project name.

Example .chainloop.yaml

```yaml
project: my-project
projectVersion: v1.2.0
```

Note on organization

The Organization field is added to the struct for forward-compatibility, but org override is not wired up in this PR. The organization is baked into the gRPC connection credentials during PersistentPreRunE (root.go:169), before att init's PreRunE runs. Supporting org from config requires loading .chainloop.yaml earlier in the command lifecycle — left for follow-up discussion.

Test plan

  • go build ./... passes
  • Commits GPG-signed and DCO signed-off
  • Manual test: att init with --project flag still works as before
  • Manual test: att init without --project reads from .chainloop.yaml

🤖 Generated with Claude Code

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/cli/cmd/config.go">

<violation number="1" location="app/cli/cmd/config.go:165">
P2: Added `.chainloop` `organization` field is unused, causing a silent no-op that can mislead users.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread app/cli/cmd/config.go Outdated
type DotChainloopConfig struct {
ProjectVersion string `yaml:"projectVersion"`
Project string `yaml:"project"`
Organization string `yaml:"organization"`
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 21, 2026

Choose a reason for hiding this comment

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

P2: Added .chainloop organization field is unused, causing a silent no-op that can mislead users.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/cli/cmd/config.go, line 165:

<comment>Added `.chainloop` `organization` field is unused, causing a silent no-op that can mislead users.</comment>

<file context>
@@ -161,4 +161,6 @@ func isDir(filename string) bool {
 type DotChainloopConfig struct {
 	ProjectVersion string `yaml:"projectVersion"`
+	Project        string `yaml:"project"`
+	Organization   string `yaml:"organization"`
 }
</file context>
Fix with Cubic

Extend DotChainloopConfig to support a `project` field so that
`chainloop attestation init` can read the project name from the
config file when the --project flag is not provided.

Precedence: CLI flag > .chainloop.yaml > default.

Example .chainloop.yaml:
  project: my-project
  projectVersion: v1.2.0

Note: organization override from .chainloop.yaml is not included
in this PR because the org is baked into the gRPC connection
credentials during PersistentPreRunE, before att init's PreRunE
runs. Supporting org override requires loading the config earlier
in the command lifecycle — left for follow-up discussion.

Fixes: chainloop-dev#3063

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
@waveywaves waveywaves force-pushed the feat/chainloop-yaml-org-project branch from 2abca03 to 50ce228 Compare April 21, 2026 10:27
@waveywaves waveywaves marked this pull request as ready for review April 21, 2026 16:18
@waveywaves
Copy link
Copy Markdown
Contributor Author

@migmartri @jiparis Ready for review. Extends .chainloop.yaml to support a project field — same precedence pattern as projectVersion (CLI flag > config > default). Organization field left for follow-up due to gRPC connection lifecycle constraints. All commits GPG-signed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: allow to force project and organization in .chainloop.yaml

1 participant