Skip to content

Commit

Permalink
fix: move notFoundError to notExistError (#2213)
Browse files Browse the repository at this point in the history
Signed-off-by: fungaren <[email protected]>
  • Loading branch information
fungaren authored Dec 2, 2024
1 parent 09078b4 commit 192ee6e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
6 changes: 5 additions & 1 deletion pkg/yurtmanager/webhook/util/writer/certwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ func updateIfNotExists(ch certReadWriter) (*generator.Artifacts, bool, error) {
certs, err := ch.read()
if isNotExist(err) {
// Create if not exists
certs, err = ch.overwrite(certs.ResourceVersion)
var resourceVersion string
if certs != nil {
resourceVersion = certs.ResourceVersion
}
certs, err = ch.overwrite(resourceVersion)
return certs, true, err
}
return certs, false, err
Expand Down
8 changes: 0 additions & 8 deletions pkg/yurtmanager/webhook/util/writer/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ limitations under the License.

package writer

type notFoundError struct {
err error
}

func (e notFoundError) Error() string {
return e.err.Error()
}

type alreadyExistError struct {
err error
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/yurtmanager/webhook/util/writer/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func ensureExist(dir string) error {
case err == nil:
continue
case os.IsNotExist(err):
return notFoundError{err}
return notExistError{err}
default:
return err
}
Expand Down

0 comments on commit 192ee6e

Please sign in to comment.