Skip to content

Commit bfa63ce

Browse files
alexander-demicevk8s-infra-cherrypick-robot
authored andcommitted
Pin book dependecies
Signed-off-by: alexander-demicev <[email protected]>
1 parent 155b6c9 commit bfa63ce

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.24.4
55
require (
66
github.com/MakeNowJust/heredoc v1.0.0
77
github.com/Masterminds/goutils v1.1.1
8+
github.com/distribution/reference v0.6.0
89
github.com/evanphx/json-patch/v5 v5.9.11
910
github.com/go-errors/errors v1.5.1
1011
github.com/go-logr/logr v1.4.3
@@ -40,7 +41,6 @@ require (
4041
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4142
github.com/cloudflare/circl v1.6.1 // indirect
4243
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
43-
github.com/distribution/reference v0.6.0 // indirect
4444
github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46 // indirect
4545
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
4646
github.com/felixge/httpsnoop v1.0.4 // indirect

internal/controller/image_overrides.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package controller
1818

1919
import (
20+
"errors"
2021
"fmt"
21-
"strings"
2222

23+
"github.com/distribution/reference"
2324
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2425
"k8s.io/client-go/kubernetes/scheme"
2526

@@ -63,16 +64,9 @@ func alterImage(component, imageString string, imageMeta configclient.ImageMetaC
6364
return result, nil
6465
}
6566

66-
// isCanonicalError checks if error is about non nanonical image format.
67+
// isCanonicalError checks if error is about non canonical image format.
6768
func isCanonicalError(err error) bool {
68-
if err == nil {
69-
return false
70-
}
71-
72-
msg := err.Error()
73-
74-
return strings.Contains(msg, "repository name must be canonical") ||
75-
strings.Contains(msg, "couldn't parse image name")
69+
return errors.Is(err, reference.ErrNameNotCanonical)
7670
}
7771

7872
// fixImages alters images using the give alter func

internal/controller/image_overrides_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"testing"
2222

23+
"github.com/distribution/reference"
2324
. "github.com/onsi/gomega"
2425
appsv1 "k8s.io/api/apps/v1"
2526
corev1 "k8s.io/api/core/v1"
@@ -203,7 +204,7 @@ func TestAlterImage(t *testing.T) {
203204
component: "cluster-api",
204205
image: "example.com/controller:v1.0.0",
205206
mockFunc: func(component, image string) (string, error) {
206-
return "", fmt.Errorf("couldn't parse image name: repository name must be canonical")
207+
return "", reference.ErrNameNotCanonical
207208
},
208209
want: "example.com/controller:v1.0.0",
209210
wantErr: false,
@@ -250,20 +251,25 @@ func TestIsCanonicalError(t *testing.T) {
250251
want: false,
251252
},
252253
{
253-
name: "canonical error with 'repository name must be canonical'",
254-
err: fmt.Errorf("repository name must be canonical"),
254+
name: "ErrNameNotCanonical returns true",
255+
err: reference.ErrNameNotCanonical,
255256
want: true,
256257
},
257258
{
258-
name: "canonical error with 'couldn't parse image name'",
259-
err: fmt.Errorf("couldn't parse image name: invalid format"),
259+
name: "wrapped ErrNameNotCanonical returns true",
260+
err: fmt.Errorf("parse error: %w", reference.ErrNameNotCanonical),
260261
want: true,
261262
},
262263
{
263264
name: "other error returns false",
264265
err: fmt.Errorf("test"),
265266
want: false,
266267
},
268+
{
269+
name: "couldn't parse image name error returns false",
270+
err: fmt.Errorf("couldn't parse image name: invalid format"),
271+
want: false,
272+
},
267273
{
268274
name: "empty error message returns false",
269275
err: fmt.Errorf(""),

scripts/ci-install-mdbook.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y
3030

3131
# Install mdbook and dependencies
3232
cargo install mdbook --version "$VERSION" --root "$OUTPUT_PATH"
33-
cargo install mdbook-fs-summary --root "$OUTPUT_PATH"
34-
cargo install mdbook-toc --root "$OUTPUT_PATH"
33+
cargo install mdbook-fs-summary --version "=0.2.0" --root "$OUTPUT_PATH"
34+
cargo install mdbook-toc --version "=0.14.2" --root "$OUTPUT_PATH"

0 commit comments

Comments
 (0)