Skip to content

Commit ad9828c

Browse files
committed
refactor: enhance Nerdctl configuration setup and logging mechanics
- Remove unused import of the file package in boot.go. - Add the file package import in install.go. - Integrate file existence checks and directory creation for Nerdctl configuration in install.go. - Update logging message in node.sh for initializing k3s TLS environment. - Include file checks and directory creation for Nerdctl configuration in cluster.go. Signed-off-by: ysicing <[email protected]>
1 parent 7fce443 commit ad9828c

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

Diff for: cmd/boot/boot.go

-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111

1212
"github.com/cockroachdb/errors"
13-
"github.com/ergoapi/util/file"
1413
"github.com/ergoapi/util/zos"
1514

1615
"github.com/easysoft/qcadmin/common"
@@ -28,7 +27,6 @@ var rootDirs = []string{
2827
var qDirs = []string{
2928
common.GetDefaultQuickonPlatformDir(""),
3029
common.GetDefaultQuickonBackupDir(""),
31-
common.DefaultNerdctlDir,
3230
}
3331

3432
func initRootDirectory() error {
@@ -50,9 +48,6 @@ func initRootDirectory() error {
5048
if err := static.StageFiles(); err != nil {
5149
return errors.Errorf("failed to stage files, err: %s", err)
5250
}
53-
if !file.CheckFileExists(common.DefaultNerdctlConfig) {
54-
file.Copy(common.GetCustomFile("hack/manifests/hub/nerdctl.toml"), common.DefaultNerdctlConfig, true)
55-
}
5651
return nil
5752
}
5853

Diff for: cmd/experimental/install.go

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/cockroachdb/errors"
1212
"github.com/ergoapi/util/color"
13+
"github.com/ergoapi/util/file"
1314
"github.com/spf13/cobra"
1415
"k8s.io/kubectl/pkg/util/templates"
1516

@@ -63,6 +64,10 @@ func InstallCommand(f factory.Factory) *cobra.Command {
6364
f.GetLog().Debugf("download %s result: %v", tool, res.Status)
6465
_ = os.Chmod(localURL, common.FileMode0755)
6566
if tool == "nerdctl" {
67+
if !file.CheckFileExists(common.DefaultNerdctlConfig) {
68+
os.MkdirAll(common.DefaultNerdctlDir, common.FileMode0777)
69+
file.Copy(common.GetCustomFile("hack/manifests/hub/nerdctl.toml"), common.DefaultNerdctlConfig, true)
70+
}
6671
docker := fmt.Sprintf("%s/qc-docker", common.GetDefaultBinDir())
6772
_ = os.Remove(docker)
6873
_ = os.Link(localURL, docker)

Diff for: hack/manifests/scripts/node.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ systemd_disable() {
7171
# }
7272

7373
systemd_env() {
74-
info "enabling k3s unit env"
74+
info "init k3s tls env"
7575
cat > /tmp/.k3s.service.env <<EOF
7676
CATTLE_NEW_SIGNED_CERT_EXPIRATION_DAYS=3650
7777
EOF

Diff for: pkg/cluster/cluster.go

+4
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ func (c *Cluster) installNerdctl() error {
347347
if c.OffLine {
348348
return nil
349349
}
350+
if !file.CheckFileExists(common.DefaultNerdctlConfig) {
351+
os.MkdirAll(common.DefaultNerdctlDir, common.FileMode0777)
352+
file.Copy(common.GetCustomFile("hack/manifests/hub/nerdctl.toml"), common.DefaultNerdctlConfig, true)
353+
}
350354
remoteURL := fmt.Sprintf("https://pkg.qucheng.com/qucheng/cli/stable/tools/nerdctl-%s-%s", runtime.GOOS, runtime.GOARCH)
351355
localURL := fmt.Sprintf("%s/qc-nerdctl", common.GetDefaultBinDir())
352356
_, err := downloader.Download(remoteURL, localURL)

0 commit comments

Comments
 (0)