feat(cli): extend workflow contract with apply#2469
feat(cli): extend workflow contract with apply#2469Piskoo merged 7 commits intochainloop-dev:mainfrom
Conversation
| # Apply to a specific project | ||
| chainloop workflow contract apply --contract my-contract.yaml --project my-project`, | ||
| PreRunE: func(_ *cobra.Command, _ []string) error { | ||
| if filePath == "" && name == "" { |
There was a problem hiding this comment.
it would make more sense if this validates that either the explicit name or a name in the spec is available, this new helper can probably be made generically as you did in the middleware
| } | ||
|
|
||
| // extractContractNameFromContent tries to extract the contract name from the contract file content | ||
| func extractContractNameFromRawSchema(content []byte) (string, error) { |
There was a problem hiding this comment.
this function could be made generically by marshalling to anything with meta and run from cmd as part of the validation as mentioned above.
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
| } | ||
|
|
||
| cmd.Flags().StringVarP(&filePath, "contract", "f", "", "workflow contract file path (optional)") | ||
| cmd.Flags().StringVar(&name, "name", "", "contract name (required if no contract file provided)") |
There was a problem hiding this comment.
This doesn't match with the command description nor the examples (Apply a contract from a file. This command will create the contract if it doesn't exist). How would it work then? I would expect that the file was mandatory.
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
|
I've decided to remove support for schema v2 from this PR, all schema v2 related code will be a part of #2467. Here we have |
This PR adds apply command that combines create and update functionality into one.
Example