Skip to content

Commit

Permalink
add links command
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Nov 13, 2024
1 parent 941edf2 commit 5da08f5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/ctrlc/root/api/create/release/release.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package release

import (
"encoding/json"
"fmt"
"time"

Expand All @@ -16,8 +17,10 @@ func NewReleaseCmd() *cobra.Command {
var deploymentID string
var metadata map[string]string
var configArray map[string]string
var links map[string]string
var createdAt string
var name string

cmd := &cobra.Command{
Use: "release [flags]",
Short: "Create a new release",
Expand Down Expand Up @@ -46,6 +49,15 @@ func NewReleaseCmd() *cobra.Command {
parsedTime = &t
}

if len(links) > 0 {
linksJSON, err := json.Marshal(links)
if err != nil {
return fmt.Errorf("failed to marshal links: %w", err)
}
metadata["ctrlplane/links"] = string(linksJSON)
}


config := cliutil.ConvertConfigArrayToNestedMap(configArray)
resp, err := client.CreateRelease(cmd.Context(), api.CreateReleaseJSONRequestBody{
Version: versionFlag,
Expand All @@ -68,6 +80,7 @@ func NewReleaseCmd() *cobra.Command {
cmd.Flags().StringVar(&deploymentID, "deployment", "", "ID of the deployment (required)")
cmd.Flags().StringToStringVar(&metadata, "metadata", make(map[string]string), "Metadata key-value pairs (e.g. --metadata key=value)")
cmd.Flags().StringToStringVar(&configArray, "config", make(map[string]string), "Config key-value pairs with nested values (can be specified multiple times)")
cmd.Flags().StringToStringVar(&links, "link", make(map[string]string), "Links key-value pairs (can be specified multiple times)")
cmd.Flags().StringVar(&createdAt, "created-at", "", "Created at timestamp (e.g. --created-at 2024-01-01T00:00:00Z) for the release channel")
cmd.Flags().StringVar(&name, "name", "", "Name of the release channel")

Expand Down

0 comments on commit 5da08f5

Please sign in to comment.