1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

chore(code): clean up the code EE-5719 (#9183)

This commit is contained in:
andres-portainer 2023-07-10 23:26:54 -03:00 committed by GitHub
parent 979af5301e
commit 64b227b2e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 93 additions and 87 deletions

View file

@ -6,15 +6,15 @@ import (
"encoding/pem"
"errors"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"github.com/gofrs/uuid"
portainer "github.com/portainer/portainer/api"
"github.com/rs/zerolog/log"
"io"
"os"
"github.com/gofrs/uuid"
"github.com/rs/zerolog/log"
)
const (
@ -327,7 +327,7 @@ func (service *Service) GetEdgeStackProjectPathByVersion(edgeStackIdentifier str
}
if commitHash != "" {
versionStr = fmt.Sprintf("%s", commitHash)
versionStr = commitHash
}
return JoinPaths(service.wrapFileStore(EdgeStackStorePath), edgeStackIdentifier, versionStr)
@ -367,7 +367,7 @@ func (service *Service) FormProjectPathByVersion(path string, version int, commi
}
if commitHash != "" {
versionStr = fmt.Sprintf("%s", commitHash)
versionStr = commitHash
}
return JoinPaths(path, versionStr)

View file

@ -8,6 +8,8 @@ import (
"github.com/stretchr/testify/assert"
)
var content = []byte("content")
func Test_movePath_shouldFailIfSourceDirDoesNotExist(t *testing.T) {
sourceDir := "missing"
destinationDir := t.TempDir()
@ -52,8 +54,6 @@ func Test_movePath_successWhenSourceExistsAndDestinationIsMissing(t *testing.T)
assertFileContent(t, path.Join(destinationDir, "dir", "file"))
}
var content []byte = []byte("content")
func addFile(fileParts ...string) (filepath string) {
if len(fileParts) > 2 {
dir := path.Join(fileParts[:len(fileParts)-1]...)
@ -62,6 +62,7 @@ func addFile(fileParts ...string) (filepath string) {
p := path.Join(fileParts...)
os.WriteFile(p, content, 0766)
return p
}