-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate success and failure flows in asoctl resource importing (#4452)
* Change interface report to minimize coupling * Create import_error.go * Separate success and failure information flows * Tweak error production * Simplify interfaces * Fix merge
- Loading branch information
1 parent
c39cf82
commit bc42335
Showing
6 changed files
with
155 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
*/ | ||
|
||
package importresources | ||
|
||
import ( | ||
"fmt" | ||
|
||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
type ImportError struct { | ||
err error // The error that caused the import to fail | ||
gk schema.GroupKind // The GroupKind of the resource that failed to import | ||
name string // The name of the resource that failed to import | ||
} | ||
|
||
var _ error = &ImportError{} | ||
|
||
func MakeImportError(err error, gk schema.GroupKind, name string) ImportError { | ||
return ImportError{ | ||
err: err, | ||
gk: gk, | ||
name: name, | ||
} | ||
} | ||
|
||
func (ie *ImportError) Error() string { | ||
return fmt.Sprintf("failed to import %s %s: %s", ie.gk, ie.name, ie.err.Error()) | ||
} | ||
|
||
func (ie *ImportError) Unwrap() error { | ||
return ie.err | ||
} |
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
Oops, something went wrong.