Skip to content

Commit

Permalink
Fix issue with tink template update using stdin (#588)
Browse files Browse the repository at this point in the history
## Description

Fixes an issue with `tink template update` using stdin, follow up to #587 

## Why is this needed

#587 didn't fully add support for sdin with `tink template update`, it still threw an error if content wasn't provided using the `--path` argument.

## How Has This Been Tested?
Tested manually against a Tinkerbell environment created using HEAD of sandbox

## How are existing users impacted? What migration steps/scripts do we need?

Existing users not impacted
  • Loading branch information
mergify[bot] authored Feb 9, 2022
2 parents 03a3d54 + f0988a2 commit f704d1c
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions cmd/tink-cli/cmd/template/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,21 @@ $ tink template update 614168df-45a5-11eb-b13d-0242ac120003 --path /tmp/example.

func updateTemplate(id string) {
req := template.WorkflowTemplate{Id: id}
if filePath != "" {
data, err := readTemplateData()
if err != nil {
log.Fatalf("readTemplateData: %v", err)
}
data, err := readTemplateData()
if err != nil {
log.Fatalf("readTemplateData: %v", err)
}

if data != "" {
wf, err := workflow.Parse([]byte(data))
if err != nil {
log.Fatal(err)
}
req.Name = wf.Name
req.Data = data
if data != "" {
wf, err := workflow.Parse([]byte(data))
if err != nil {
log.Fatal(err)
}
} else {
log.Fatal("Nothing is provided in the file path")
req.Name = wf.Name
req.Data = data
}

_, err := client.TemplateClient.UpdateTemplate(context.Background(), &req)
if err != nil {
if _, err := client.TemplateClient.UpdateTemplate(context.Background(), &req); err != nil {
log.Fatal(err)
}
fmt.Println("Updated Template: ", id)
Expand Down

0 comments on commit f704d1c

Please sign in to comment.