Fix nits error messages

This commit is contained in:
AkiraFukushima 2024-02-26 00:05:31 +09:00
parent c83698be10
commit bd9cf4a3dc
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
5 changed files with 87 additions and 9 deletions

View File

@ -1,7 +1,24 @@
/*
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 model
import (
"fmt"
"path/filepath"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
@ -19,7 +36,7 @@ func (b *CrictlBuilder) Build(c *fi.NodeupModelBuilderContext) error {
assetPath := ""
asset, err := b.Assets.Find(assetName, assetPath)
if err != nil {
return fmt.Errorf("unable to locate asset %q", err)
return fmt.Errorf("unable to locate asset %q: %w", assetName, err)
}
c.AddTask(&nodetasks.File{
@ -44,5 +61,5 @@ func (b *CrictlBuilder) binaryPath() string {
}
func (b *CrictlBuilder) crictlPath() string {
return b.binaryPath() + "/crictl"
return filepath.Join(b.binaryPath(), "crictl")
}

View File

@ -1,7 +1,24 @@
/*
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 model
import (
"fmt"
"path/filepath"
"k8s.io/klog/v2"
"k8s.io/kops/upup/pkg/fi"
@ -17,7 +34,7 @@ var _ fi.NodeupModelBuilder = &NerdctlBuilder{}
func (b *NerdctlBuilder) Build(c *fi.NodeupModelBuilderContext) error {
if b.skipInstall() {
klog.Info("SkipInstall is set to true; won't install nerdctl")
klog.Info("containerd.skipInstall is set to true; won't install nerdctl")
return nil
}
@ -25,7 +42,7 @@ func (b *NerdctlBuilder) Build(c *fi.NodeupModelBuilderContext) error {
assetPath := ""
asset, err := b.Assets.Find(assetName, assetPath)
if err != nil {
return fmt.Errorf("unable to locate asset %q", assetName)
return fmt.Errorf("unable to locate asset %q: %w", assetName, err)
}
c.AddTask(&nodetasks.File{
@ -51,7 +68,7 @@ func (b *NerdctlBuilder) binaryPath() string {
}
func (b *NerdctlBuilder) nerdctlPath() string {
return b.binaryPath() + "/nerdctl"
return filepath.Join(b.binaryPath(), "nerdctl")
}
func (b *NerdctlBuilder) skipInstall() bool {

View File

@ -1,3 +1,19 @@
/*
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 cloudup
import (

View File

@ -1,3 +1,19 @@
/*
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 cloudup
import (

View File

@ -1,3 +1,19 @@
/*
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 cloudup
import (
@ -18,10 +34,6 @@ const (
)
func findNerdctlAsset(c *kops.Cluster, assetBuilder *assets.AssetBuilder, arch architectures.Architecture) (*url.URL, *hashing.Hash, error) {
if c.Spec.Containerd == nil {
return nil, nil, fmt.Errorf("unable to find containerd config")
}
var assetURL, assetHash string
switch arch {
case architectures.ArchitectureAmd64: