@@ -57,13 +57,8 @@ var addDeployTargetConfigCmd = &cobra.Command{
5757 & token ,
5858 debug )
5959
60- project , err := lagoon .GetMinimalProjectByName (context .TODO (), cmdProjectName , lc )
61- if err != nil {
62- return err
63- }
6460 addDeployTargetConfig := & schema.AddDeployTargetConfigInput {
65- Project : project .ID ,
66- Weight : weight ,
61+ Weight : weight ,
6762 }
6863 if branches != "" {
6964 addDeployTargetConfig .Branches = branches
@@ -75,9 +70,9 @@ var addDeployTargetConfigCmd = &cobra.Command{
7570 addDeployTargetConfig .DeployTarget = deploytarget
7671 }
7772 if yesNo (fmt .Sprintf ("You are attempting to add a deploytarget configuration to project '%s', are you sure?" , cmdProjectName )) {
78- deployTargetConfig , err := lagoon .AddDeployTargetConfiguration (context .TODO (), addDeployTargetConfig , lc )
73+ deployTargetConfig , err := lagoon .AddDeployTargetConfigurationByProjectName (context .TODO (), cmdProjectName , addDeployTargetConfig , lc )
7974 if err != nil {
80- return err
75+ return fmt . Errorf ( "%v: check if the project exists" , err . Error ())
8176 }
8277 data := []output.Data {}
8378 data = append (data , []string {
@@ -234,18 +229,10 @@ var deleteDeployTargetConfigCmd = &cobra.Command{
234229 & token ,
235230 debug )
236231
237- project , err := lagoon .GetMinimalProjectByName (context .TODO (), cmdProjectName , lc )
238- if err != nil {
239- return err
240- }
241- if project .Name == "" {
242- return handleNilResults ("Project '%s' not found\n " , cmd , cmdProjectName )
243- }
244-
245232 if yesNo (fmt .Sprintf ("You are attempting to delete deploytarget configuration with id '%d' from project '%s', are you sure?" , id , cmdProjectName )) {
246- result , err := lagoon .DeleteDeployTargetConfiguration (context .TODO (), int ( id ), int ( project . ID ) , lc )
233+ result , err := lagoon .DeleteDeployTargetConfigurationByIDAndProjectName (context .TODO (), id , cmdProjectName , lc )
247234 if err != nil {
248- return err
235+ return fmt . Errorf ( "%v: check if the project exists" , err . Error ())
249236 }
250237 resultData := output.Result {
251238 Result : result .DeleteDeployTargetConfig ,
@@ -284,16 +271,9 @@ var listDeployTargetConfigsCmd = &cobra.Command{
284271 & token ,
285272 debug )
286273
287- project , err := lagoon .GetMinimalProjectByName (context .TODO (), cmdProjectName , lc )
288- if err != nil {
289- return err
290- }
291- if project .Name == "" {
292- return handleNilResults ("Project '%s' not found\n " , cmd , cmdProjectName )
293- }
294- deployTargetConfigs , err := lagoon .GetDeployTargetConfigs (context .TODO (), int (project .ID ), lc )
274+ deployTargetConfigs , err := lagoon .GetDeployTargetConfigsByProjectName (context .TODO (), cmdProjectName , lc )
295275 if err != nil {
296- return err
276+ return fmt . Errorf ( "%v: check if the project exists" , err . Error ())
297277 }
298278 if len (* deployTargetConfigs ) == 0 {
299279 return handleNilResults ("No deploytarget-configs for project '%s'\n " , cmd , cmdProjectName )
0 commit comments