Skip to content

Commit

Permalink
Merge pull request #999 from 24sama/v2.0.0
Browse files Browse the repository at this point in the history
modify MD5 file name and artifact directory tree.
  • Loading branch information
ks-ci-bot committed Jan 12, 2022
2 parents a45560c + b3caa8e commit ec38774
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
18 changes: 3 additions & 15 deletions pkg/artifact/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ type ArchiveDependencies struct {

func (a *ArchiveDependencies) Execute(runtime connector.Runtime) error {
src := filepath.Join(runtime.GetWorkDir(), common.Artifact)
if err := coreutil.Tar(src, a.Manifest.Arg.Output, runtime.GetWorkDir()); err != nil {
if err := coreutil.Tar(src, a.Manifest.Arg.Output, src); err != nil {
return errors.Wrapf(errors.WithStack(err), "archive %s failed", src)
}
return nil
Expand All @@ -268,18 +268,6 @@ func (u *UnArchive) Execute(runtime connector.Runtime) error {
if err := coreutil.Untar(u.KubeConf.Arg.Artifact, runtime.GetWorkDir()); err != nil {
return errors.Wrapf(errors.WithStack(err), "unArchive %s failed", u.KubeConf.Arg.Artifact)
}

// copy k8s binaries ("./kubekey/artifact/v1.21.5" tp "./kubekey/v1.21.5 .e.g")
src := filepath.Join(runtime.GetWorkDir(), "artifact", u.KubeConf.Cluster.Kubernetes.Version)
if err := exec.Command("/bin/sh", "-c", fmt.Sprintf("cp -r -f %s %s", src, runtime.GetWorkDir())).Run(); err != nil {
return errors.Wrapf(errors.WithStack(err), "copy %s to %s failed", src, runtime.GetWorkDir())
}

// copy registry binaries ("./kubekey/artifact/registry" tp "./kubekey/registry .e.g")
rSrc := filepath.Join(runtime.GetWorkDir(), "artifact", "registry")
if err := exec.Command("/bin/sh", "-c", fmt.Sprintf("cp -r -f %s %s", rSrc, runtime.GetWorkDir())).Run(); err != nil {
return errors.Wrapf(errors.WithStack(err), "copy %s to %s failed", src, runtime.GetWorkDir())
}
return nil
}

Expand All @@ -291,7 +279,7 @@ func (m *Md5Check) Execute(runtime connector.Runtime) error {
m.ModuleCache.Set("md5AreEqual", false)

// check if there is a md5.sum file. This file's content contains the last artifact md5 value.
oldFile := filepath.Join(runtime.GetWorkDir(), "md5.sum")
oldFile := filepath.Join(runtime.GetWorkDir(), "artifact.md5")
if exist := coreutil.IsExist(oldFile); !exist {
return nil
}
Expand All @@ -314,7 +302,7 @@ type CreateMd5File struct {
}

func (c *CreateMd5File) Execute(runtime connector.Runtime) error {
oldFile := filepath.Join(runtime.GetWorkDir(), "md5.sum")
oldFile := filepath.Join(runtime.GetWorkDir(), "artifact.md5")
newMd5 := coreutil.LocalMd5Sum(c.KubeConf.Arg.Artifact)
f, err := os.Create(oldFile)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/os/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (s *SyncRepositoryFile) Execute(runtime connector.Runtime) error {
r := release.(*osrelease.Data)

fileName := fmt.Sprintf("%s-%s-%s.iso", r.ID, r.VersionID, host.GetArch())
src := filepath.Join(runtime.GetWorkDir(), common.Artifact, "repository", host.GetArch(), r.ID, r.VersionID, fileName)
src := filepath.Join(runtime.GetWorkDir(), "repository", host.GetArch(), r.ID, r.VersionID, fileName)
dst := filepath.Join(common.TmpDir, fileName)
if err := runtime.GetRunner().Scp(src, dst); err != nil {
return errors.Wrapf(errors.WithStack(err), "scp %s to %s failed", src, dst)
Expand Down
2 changes: 1 addition & 1 deletion pkg/images/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ type PushImage struct {
}

func (p *PushImage) Execute(runtime connector.Runtime) error {
imagesPath := filepath.Join(runtime.GetWorkDir(), common.Artifact, "images")
imagesPath := filepath.Join(runtime.GetWorkDir(), "images")
files, err := ioutil.ReadDir(imagesPath)
if err != nil {
return errors.Wrapf(errors.WithStack(err), "read %s dir faied", imagesPath)
Expand Down

0 comments on commit ec38774

Please sign in to comment.