Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move notFoundError to notExistError #2213

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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

Check warning on line 82 in pkg/yurtmanager/webhook/util/writer/certwriter.go

View check run for this annotation

Codecov / codecov/patch

pkg/yurtmanager/webhook/util/writer/certwriter.go#L80-L82

Added lines #L80 - L82 were not covered by tests
}
certs, err = ch.overwrite(resourceVersion)

Check warning on line 84 in pkg/yurtmanager/webhook/util/writer/certwriter.go

View check run for this annotation

Codecov / codecov/patch

pkg/yurtmanager/webhook/util/writer/certwriter.go#L84

Added line #L84 was not covered by tests
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 @@
case err == nil:
continue
case os.IsNotExist(err):
return notFoundError{err}
return notExistError{err}

Check warning on line 191 in pkg/yurtmanager/webhook/util/writer/fs.go

View check run for this annotation

Codecov / codecov/patch

pkg/yurtmanager/webhook/util/writer/fs.go#L191

Added line #L191 was not covered by tests
default:
return err
}
Expand Down
Loading