mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-16 06:08:40 +00:00
Handle deployment apply error
This commit is contained in:
@@ -312,7 +312,7 @@ func isDecodeError(err error) bool {
|
||||
// isUnhandledError is to check if the error returned from resourceapply is due to that no typed
|
||||
// client can handle the object
|
||||
func isUnhandledError(err error) bool {
|
||||
return err != nil && strings.HasPrefix(err.Error(), "cannot decode")
|
||||
return err != nil && strings.HasPrefix(err.Error(), "unhandled type")
|
||||
}
|
||||
|
||||
// isSameUnstructured compares the two unstructured object.
|
||||
|
||||
@@ -125,6 +125,20 @@ func newFakeMapper() *resource.Mapper {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Group: metav1.APIGroup{
|
||||
Name: "apps",
|
||||
Versions: []metav1.GroupVersionForDiscovery{
|
||||
{Version: "v1", GroupVersion: "apps/v1"},
|
||||
},
|
||||
PreferredVersion: metav1.GroupVersionForDiscovery{Version: "v1", GroupVersion: "apps/v1"},
|
||||
},
|
||||
VersionedResources: map[string][]metav1.APIResource{
|
||||
"v1": {
|
||||
{Name: "deployments", Group: "apps", Namespaced: true, Kind: "Deployment"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return &resource.Mapper{
|
||||
Mapper: restmapper.NewDiscoveryRESTMapper(resources),
|
||||
@@ -309,6 +323,11 @@ func TestSync(t *testing.T) {
|
||||
withExpectedWorkAction("get", "update").
|
||||
withExpectedKubeAction("get", "create").
|
||||
withExpectedCondition(expectedCondition{string(workapiv1.ManifestApplied), metav1.ConditionTrue}),
|
||||
newTestCase("create single deployment resource").
|
||||
withWorkManifest(newUnstructured("apps/v1", "Deployment", "ns1", "test")).
|
||||
withExpectedWorkAction("get", "update").
|
||||
withExpectedDynamicAction("get", "create").
|
||||
withExpectedCondition(expectedCondition{string(workapiv1.ManifestApplied), metav1.ConditionTrue}),
|
||||
newTestCase("update single resource").
|
||||
withWorkManifest(newUnstructured("v1", "Secret", "ns1", "test")).
|
||||
withSpokeObject(newSecret("test", "ns1", "value2")).
|
||||
|
||||
Reference in New Issue
Block a user