github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/fly/commands/edit_target.go (about) 1 package commands 2 3 import ( 4 "errors" 5 "fmt" 6 7 "github.com/pf-qiu/concourse/v6/fly/rc" 8 ) 9 10 type EditTargetCommand struct { 11 NewName rc.TargetName `long:"target-name" description:"Update target name"` 12 Url string `short:"u" long:"concourse-url" description:"Update concourse URL"` 13 Team string `short:"n" long:"team-name" description:"Update team name"` 14 } 15 16 func (command *EditTargetCommand) Execute([]string) error { 17 _, err := rc.LoadTarget(Fly.Target, Fly.Verbose) 18 if err != nil { 19 return err 20 } 21 22 if command.NewName == "" && command.Url == "" && command.Team == "" { 23 return errors.New("error: no attributes specified to update") 24 } 25 26 targetProps := rc.TargetProps{} 27 targetProps.API = command.Url 28 targetProps.TeamName = command.Team 29 30 if command.Url != "" || command.Team != "" { 31 err = rc.UpdateTargetProps(Fly.Target, targetProps) 32 if err != nil { 33 return err 34 } 35 } 36 37 if command.NewName != "" { 38 err = rc.UpdateTargetName(Fly.Target, command.NewName) 39 if err != nil { 40 return err 41 } 42 } 43 44 fmt.Println("Updated target: " + Fly.Target) 45 46 return nil 47 }