Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions internal/client/connections/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,24 @@ func Create(name string, content []byte, serviceAccountName string, serviceAccou
operationId := filepath.Base(o.Name)
clilog.Info.Printf("Checking connection status for %s in %d seconds\n", operationId, interval)

var lroError error
stop := apiclient.Every(interval*time.Second, func(time.Time) bool {
var respBody []byte
lroError = nil

if respBody, err = GetOperation(operationId); err != nil {
lroError = err
return false
}

if err = json.Unmarshal(respBody, &o); err != nil {
lroError = err
return false
}

if o.Done {
if o.Error != nil {
lroError = errors.New(o.Error.Message)
clilog.Error.Printf("Connection completed with error: %s\n", o.Error.Message)
} else {
clilog.Info.Println("Connection completed successfully!")
Expand All @@ -314,6 +319,11 @@ func Create(name string, content []byte, serviceAccountName string, serviceAccou
})

<-stop

if isBubbleLROErrorsEnabled() {
err = lroError
}

}

return respBody, err
Expand Down Expand Up @@ -1118,19 +1128,24 @@ func RepairEvent(name string, wait bool) (err error) {
operationId := filepath.Base(o.Name)
clilog.Info.Printf("Checking connection repair status for %s in %d seconds\n", operationId, interval)

var lroError error
stop := apiclient.Every(interval*time.Second, func(time.Time) bool {
var respBody []byte
lroError = nil

if respBody, err = GetOperation(operationId); err != nil {
lroError = err
return false
}

if err = json.Unmarshal(respBody, &o); err != nil {
lroError = err
return false
}

if o.Done {
if o.Error != nil {
lroError = errors.New(o.Error.Message)
clilog.Error.Printf("Connection completed with error: %s\n", o.Error.Message)
} else {
clilog.Info.Println("Connection repair completed successfully!")
Expand All @@ -1143,6 +1158,10 @@ func RepairEvent(name string, wait bool) (err error) {
})

<-stop

if isBubbleLROErrorsEnabled() {
err = lroError
}
}
return err
}
Expand Down Expand Up @@ -1176,3 +1195,7 @@ func isGoogleConnection(connectionName string) bool {
}
return false
}

func isBubbleLROErrorsEnabled() bool {
return os.Getenv("INTEGRATIONCLI_BUBBLE_LRO_ERRORS") == "1"
}
13 changes: 12 additions & 1 deletion internal/client/connections/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package connections

import (
"encoding/json"
"errors"
"fmt"
"internal/apiclient"
"internal/clilog"
Expand Down Expand Up @@ -80,19 +81,24 @@ func CreateEndpoint(name string, serviceAttachment string, description string, w
operationId := filepath.Base(o.Name)
clilog.Info.Printf("Checking connection status for %s in %d seconds\n", operationId, interval)

var lroError error
stop := apiclient.Every(interval*time.Second, func(time.Time) bool {
var respBody []byte
lroError = nil

if respBody, err = GetOperation(operationId); err != nil {
lroError = err
return false
}

if err = json.Unmarshal(respBody, &o); err != nil {
lroError = err
return false
}

if o.Done {
if o.Error != nil {
lroError = errors.New(o.Error.Message)
clilog.Error.Printf("Connection completed with error: %s\n", o.Error.Message)
} else {
clilog.Info.Println("Connection completed successfully!")
Expand All @@ -105,8 +111,13 @@ func CreateEndpoint(name string, serviceAttachment string, description string, w
})

<-stop

if isBubbleLROErrorsEnabled() {
err = lroError
}
}
return

return respBody, err
}

// GetEndpoint
Expand Down
Loading