Skip to content

Commit

Permalink
fix: Cloudery service methods noop without cloudery
Browse files Browse the repository at this point in the history
  When no cloudery is configured for the given instance context,
  cloudery service methods should not attempt to build a client and make
  an API call resulting in an error.
  They should return a noop result instead.
  • Loading branch information
taratatach committed Nov 20, 2024
1 parent 965f5f8 commit 7da91ff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions model/cloudery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type SaveCmd struct {
// SaveInstance data into the cloudery matching the instance context.
func (s *ClouderyService) SaveInstance(inst *instance.Instance, cmd *SaveCmd) error {
client := instance.APIManagerClient(inst)
if client == nil {
return nil
}

url := fmt.Sprintf("/api/v1/instances/%s?source=stack", url.PathEscape(inst.UUID))
if err := client.Put(url, map[string]interface{}{
Expand All @@ -57,6 +60,9 @@ type BlockingSubscription struct {

func (s *ClouderyService) BlockingSubscription(inst *instance.Instance) (*BlockingSubscription, error) {
client := instance.APIManagerClient(inst)
if client == nil {
return nil, nil
}

url := fmt.Sprintf("/api/v1/instances/%s", url.PathEscape(inst.UUID))
res, err := client.Get(url)
Expand Down

0 comments on commit 7da91ff

Please sign in to comment.