Don't return an empty resource if there was an apiErr (#294)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-20 17:31:38 -04:00
1 parent b24fc185a7
commit 627a353ccb
11 files changed
+198 -66

No files matched your search

+24 -8
View File
@@ -58,7 +58,9 @@ func (c *HostSetsClient) Create(ctx context.Context, hostCatalogId string, opt .
if err != nil {
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
}
if apiErr != nil {
return nil, apiErr, nil
}
return target, apiErr, nil
}
@@ -92,7 +94,9 @@ func (c *HostSetsClient) Read(ctx context.Context, hostCatalogId string, hostSet
if err != nil {
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
}
if apiErr != nil {
return nil, apiErr, nil
}
return target, apiErr, nil
}
@@ -143,7 +147,9 @@ func (c *HostSetsClient) Update(ctx context.Context, hostCatalogId string, hostS
if err != nil {
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
}
if apiErr != nil {
return nil, apiErr, nil
}
return target, apiErr, nil
}
@@ -180,7 +186,9 @@ func (c *HostSetsClient) Delete(ctx context.Context, hostCatalogId string, hostS
if err != nil {
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
}
if apiErr != nil {
return false, apiErr, nil
}
return target.Existed, apiErr, nil
}
@@ -213,7 +221,9 @@ func (c *HostSetsClient) List(ctx context.Context, hostCatalogId string, opt ...
if err != nil {
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
}
if apiErr != nil {
return nil, apiErr, nil
}
return target.Items, apiErr, nil
}
@@ -268,7 +278,9 @@ func (c *HostSetsClient) AddHosts(ctx context.Context, hostCatalogId string, hos
if err != nil {
return nil, nil, fmt.Errorf("error decoding AddHosts response: %w", err)
}
if apiErr != nil {
return nil, apiErr, nil
}
return target, apiErr, nil
}
@@ -326,7 +338,9 @@ func (c *HostSetsClient) SetHosts(ctx context.Context, hostCatalogId string, hos
if err != nil {
return nil, nil, fmt.Errorf("error decoding SetHosts response: %w", err)
}
if apiErr != nil {
return nil, apiErr, nil
}
return target, apiErr, nil
}
@@ -381,6 +395,8 @@ func (c *HostSetsClient) RemoveHosts(ctx context.Context, hostCatalogId string,
if err != nil {
return nil, nil, fmt.Errorf("error decoding RemoveHosts response: %w", err)
}
if apiErr != nil {
return nil, apiErr, nil
}
return target, apiErr, nil
}