Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli): store material info in crafting state #1714

Merged
merged 10 commits into from
Jan 9, 2025

Conversation

migmartri
Copy link
Member

This PR is part of some refactoring that could simplify the implementation of #1686

The main change is that attestation add cmd now has available structured information of the material that was added, so then it can be rendered as part of #1686

To achieve that, we needed to update the underlying crafting state so the materials now can contain all its properties, as well as the identifier, as well as factoring out the material stateAPI->action translation code so it can be used outside of status command.

cc/ @Horiodino

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
@migmartri migmartri requested review from jiparis and javirln January 8, 2025 20:40
@@ -89,7 +89,9 @@ func newAttestationAddCmd() *cobra.Command {
// optimistic locking. We retry the operation if the state has changed since we last read it.
return runWithBackoffRetry(
func() error {
if err := a.Run(cmd.Context(), attestationID, name, value, kind, annotations); err != nil {
// TODO: take the material output and show render it
_, err := a.Run(cmd.Context(), attestationID, name, value, kind, annotations)
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the entrypoint that can help with implementing showing the material in the CLI

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
app/cli/internal/action/attestation_add.go Outdated Show resolved Hide resolved
@@ -206,7 +206,7 @@ func (m *Attestation_Material) CraftingStateToIntotoDescriptor(name string) (*in

// string materials don't have an artifact nor container, so a name is not available.
Copy link
Member

Choose a reason for hiding this comment

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

This probably is not true anymore. If the ID is outside the artifact, string materials would have an ID as well, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure, since it's taking about name, ... let me double check

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
@migmartri migmartri merged commit 7dfb5c9 into chainloop-dev:main Jan 9, 2025
11 of 12 checks passed
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.

2 participants