cleanup: remove kubekey/artifact dir after exporting an artifact

Signed-off-by: 24sama <jacksama@foxmail.com>
This commit is contained in:
24sama 2022-06-07 12:58:39 +08:00
parent f7036b0b7a
commit b6d0fb191c

View File

@ -18,17 +18,19 @@ package artifact
import (
"fmt"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/connector"
"github.com/kubesphere/kubekey/pkg/core/logger"
coreutil "github.com/kubesphere/kubekey/pkg/core/util"
"github.com/pkg/errors"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/pkg/errors"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/connector"
"github.com/kubesphere/kubekey/pkg/core/logger"
coreutil "github.com/kubesphere/kubekey/pkg/core/util"
)
type DownloadISOFile struct {
@ -107,6 +109,11 @@ func (a *ArchiveDependencies) Execute(runtime connector.Runtime) error {
if err := coreutil.Tar(src, a.Manifest.Arg.Output, src); err != nil {
return errors.Wrapf(errors.WithStack(err), "archive %s failed", src)
}
// remove the src directory
if err := os.RemoveAll(src); err != nil {
return errors.Wrapf(errors.WithStack(err), "remove %s failed", src)
}
return nil
}