-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error handling for List resources (#2493)
List resources are included in the SDK for compatibility with various YAML manifests and Helm charts. These resources are not currently able to be created directly, but the failure condition was not handled explicitly. Instead, users would get an error when the provider failed to determine if the resource was namespaced. This is fixed with the following changes: 1. Create a lookup table for known List resources 2. Return an error during Check for List resources with a descriptive error message This change also adds a few missing kinds to the Namespaced lookup table that have been added since the table was created initially.
- Loading branch information
1 parent
c628a79
commit a160f74
Showing
8 changed files
with
254 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package kinds | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestKind_Namespaced(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
k Kind | ||
wantKnown bool | ||
wantNamespaced bool | ||
}{ | ||
{ | ||
"Standard kind", | ||
Deployment, | ||
true, | ||
true, | ||
}, | ||
{ | ||
"List kind", | ||
DeploymentList, | ||
true, | ||
true, | ||
}, | ||
{ | ||
"Unknown kind", | ||
Kind("TokenReview"), | ||
false, | ||
false, | ||
}, | ||
{ | ||
"Unknown list kind", | ||
Kind("TokenReviewList"), | ||
false, | ||
false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotKnown, gotNamespaced := tt.k.Namespaced() | ||
if gotKnown != tt.wantKnown { | ||
t.Errorf("Namespaced() gotKnown = %v, want %v", gotKnown, tt.wantKnown) | ||
} | ||
if gotNamespaced != tt.wantNamespaced { | ||
t.Errorf("Namespaced() gotNamespaced = %v, want %v", gotNamespaced, tt.wantNamespaced) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters