Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
  • Loading branch information
lubronzhan committed Jan 30, 2024
1 parent 539ad9c commit 01c5966
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
27 changes: 27 additions & 0 deletions exp/runtime/topologymutation/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package topologymutation

import (
patchvariables "sigs.k8s.io/cluster-api/internal/controllers/topology/cluster/patches/variables"
)

// IsNotFoundError checks if the passed error is a notFoundError.
// It expose same function in internal package so that user can directly call

Check failure on line 24 in exp/runtime/topologymutation/errors.go

View workflow job for this annotation

GitHub Actions / lint

Comment should end in a period (godot)

Check failure on line 24 in exp/runtime/topologymutation/errors.go

View workflow job for this annotation

GitHub Actions / lint

Comment should end in a period (godot)
func IsNotFoundError(err error) bool {
return patchvariables.IsNotFoundError(err)
}
7 changes: 1 addition & 6 deletions exp/runtime/topologymutation/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,8 @@ func GetBoolVariable(templateVariables map[string]apiextensionsv1.JSON, variable
return false, err
}

// Unquote the JSON string.
stringValue, err := strconv.Unquote(string(value.Raw))
if err != nil {
return false, err
}
// Parse the JSON bool.
boolValue, err := strconv.ParseBool(stringValue)
boolValue, err := strconv.ParseBool(string(value.Raw))
if err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion exp/runtime/topologymutation/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func Test_GetStringTemplateVariable(t *testing.T) {
func Test_GetBoolVariable(t *testing.T) {
g := NewWithT(t)

varA := apiextensionsv1.JSON{Raw: toJSON("true")}
varA := apiextensionsv1.JSON{Raw: []byte(`true`)}
tests := []struct {
name string
variables map[string]apiextensionsv1.JSON
Expand Down

0 comments on commit 01c5966

Please sign in to comment.