Skip to content

Commit

Permalink
fixed forced path style logic, using path style as default (#174)
Browse files Browse the repository at this point in the history
Signed-off-by: Min Min <[email protected]>

Co-authored-by: Min Min <[email protected]>
  • Loading branch information
jamsman94 and Min Min authored Aug 13, 2021
1 parent f1bcf1c commit 639fa73
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 95 deletions.
6 changes: 3 additions & 3 deletions pkg/microservice/aslan/core/common/service/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func DownloadService(base, serviceName string) error {
filePath := fmt.Sprintf("%s.tar.gz", serviceName)
tarFilePath := path.Join(base, filePath)
objectKey := s3Storage.GetObjectPath(filePath)
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/aslan/core/common/service/it_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func GetLocalTestSuite(pipelineName, serviceName, testType string, taskID int64,
log.Errorf("GetLocalTestSuite GenerateTmpFile err:%v", err)
}
objectKey := s3Storage.GetObjectPath(fmt.Sprintf("%s/%d/%s/%s", pipelineName, taskID, "test", testJobName))
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ func downloadReport(taskInfo *task.Task, fileName, testName string, logger *zap.
}()

objectKey := store.GetObjectPath(fileName)
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/microservice/aslan/core/log/service/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func getContainerLogFromS3(pipelineName, filenamePrefix string, taskID int64, lo
} else {
storage.Subfolder = fmt.Sprintf("%s/%d/%s", pipelineName, taskID, "log")
}
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down Expand Up @@ -135,7 +135,7 @@ func GetCurrentContainerLogs(podName, containerName, envName, productName string
}

buf := new(bytes.Buffer)
err = containerlog.GetContainerLogs(envName,podName,containerName,false,tail,buf,clientSet)
err = containerlog.GetContainerLogs(envName, podName, containerName, false, tail, buf, clientSet)
if err != nil {
log.Errorf("containerlog.GetContainerLogs error: %v", err)
return "", err
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/aslan/core/service/service/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,9 @@ func uploadService(base, serviceName, filePath string) error {
log.Errorf("获取默认的s3配置失败 err:%v", err)
return err
}
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/aslan/core/service/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ func DeleteServiceTemplate(serviceName, serviceType, productName, isEnvTemplate,
} else {
s3Storage.Subfolder = fmt.Sprintf("%s/%s", subFolderName, "service")
}
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err == nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/aslan/core/system/service/capacity.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ func cleanStaleTasks(tasks []*task.Task, s3Server *s3.S3, dryRun bool) []string
ids[i] = task.ID.Hex()
paths[i] = fmt.Sprintf("%s/%d/", task.PipelineName, task.TaskID)
}
forcedPathStyle := false
if s3Server.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Server.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(s3Server.Endpoint, s3Server.Ak, s3Server.Sk, s3Server.Insecure, forcedPathStyle)
if err == nil {
Expand Down
12 changes: 6 additions & 6 deletions pkg/microservice/aslan/core/system/service/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (

func UpdateS3Storage(updateBy, id string, storage *commonmodels.S3Storage, logger *zap.SugaredLogger) error {
s3Storage := &s3.S3{S3Storage: storage}
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err != nil {
Expand All @@ -49,9 +49,9 @@ func UpdateS3Storage(updateBy, id string, storage *commonmodels.S3Storage, logge

func CreateS3Storage(updateBy string, storage *commonmodels.S3Storage, logger *zap.SugaredLogger) error {
s3Storage := &s3.S3{S3Storage: storage}
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ func (h *TaskAckHandler) uploadTaskData(pt *task.Task) error {
testJobName := strings.Replace(strings.ToLower(fmt.Sprintf("%s-%s-%d-%s-%s",
config.WorkflowType, pt.PipelineName, pt.TaskID, config.TaskTestingV2, testInfo.TestModuleName)), "_", "-", -1)
fileSrc := fmt.Sprintf("%s/%d/%s/%s", pt.PipelineName, pt.TaskID, "test", testJobName)
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
objectKey := storage.GetObjectPath(fileSrc)
Expand Down Expand Up @@ -614,9 +614,9 @@ func (h *TaskAckHandler) uploadTaskData(pt *task.Task) error {
testJobName := strings.Replace(strings.ToLower(fmt.Sprintf("%s-%s-%d-%s-%s",
config.TestType, pipelineName, pt.TaskID, config.TaskTestingV2, testInfo.TestModuleName)), "_", "-", -1)
fileSrc := fmt.Sprintf("%s/%d/%s/%s", pipelineName, pt.TaskID, "test", testJobName)
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
objectKey := storage.GetObjectPath(fileSrc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,9 @@ func GePackageFileContent(pipelineName string, taskID int64, log *zap.SugaredLog
defer func() {
_ = os.Remove(tmpfile.Name())
}()
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
if err != nil {
Expand All @@ -927,9 +927,9 @@ func GetArtifactFileContent(pipelineName string, taskID int64, log *zap.SugaredL
if _, err := os.Stat(sourcePath); os.IsNotExist(err) {
_ = os.MkdirAll(sourcePath, 0777)
}
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down Expand Up @@ -986,9 +986,9 @@ func GetTestArtifactInfo(pipelineName, dir string, taskID int64, log *zap.Sugare
} else {
storage.Subfolder = fmt.Sprintf("%s/%d/%s", pipelineName, taskID, "artifact")
}
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func GetTestLocalTestSuite(serviceName string, log *zap.SugaredLogger) (*commonm
if err != nil {
log.Errorf("GetTestLocalTestSuite GenerateTmpFile err:%v", err)
}
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ func GetHTMLTestReport(pipelineName, pipelineType, taskIDStr, testName string, l
defer func() {
_ = os.Remove(tmpFilename)
}()
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func GetTestArtifactInfo(pipelineName, dir string, taskID int64, log *zap.Sugare
} else {
storage.Subfolder = fmt.Sprintf("%s/%d/%s", pipelineName, taskID, "artifact")
}
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/reaper/core/service/archive/file_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ func (c *WorkspaceAchiever) Achieve(target string) error {
//}

if store, err := s3.NewS3StorageFromEncryptedURI(c.StorageURI); err == nil {
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions pkg/microservice/reaper/core/service/reaper/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (r *Reaper) archiveS3Files() (err error) {
} else {
store.Subfolder = fmt.Sprintf("%s/%d/%s", r.Ctx.PipelineName, r.Ctx.TaskID, "file")
}
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down Expand Up @@ -100,9 +100,9 @@ func (r *Reaper) archiveTestFiles() error {
//log.Warningf("upload filepath not exist")
return nil
}
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down Expand Up @@ -152,9 +152,9 @@ func (r *Reaper) archiveHTMLTestReportFile() error {
}

fileName := filepath.Base(r.Ctx.Archive.TestReportFile)
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/reaper/core/service/reaper/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func artifactsUpload(ctx *meta.Context, activeWorkspace string) error {
}

if store != nil {
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions pkg/microservice/reaper/core/service/reaper/cachemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ func (gcm *TarCacheManager) Archive(source, dest string) error {
//}

if store, err := gcm.getS3Storage(); err == nil {
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand All @@ -139,9 +139,9 @@ func (gcm *TarCacheManager) Archive(source, dest string) error {

func (gcm *TarCacheManager) Unarchive(source, dest string) error {
if store, err := gcm.getS3Storage(); err == nil {
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/reaper/core/service/reaper/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func (r *Reaper) runIntallationScripts() error {
filepath := strings.Split(install.Download, "/")
fileName := filepath[len(filepath)-1]
tmpPath = path.Join(os.TempDir(), fileName)
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func getCheckStatus(status config.Status) github.CIStatus {
case config.StatusSkipped:
return github.CIStatusCancelled
case config.StatusCancelled:
return github.CIStatusCancelled
return github.CIStatusCancelled
default:
return github.CIStatusError
}
Expand Down Expand Up @@ -483,9 +483,9 @@ func downloadReport(taskInfo *task.Task, fileName, testName string, logger *zap.
logger.Errorf("failed to create s3 storage %s", taskInfo.StorageURI)
return nil, err
}
forcedPathStyle := false
if store.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if store.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(store.Endpoint, store.Ak, store.Sk, store.Insecure, forcedPathStyle)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/microservice/warpdrive/core/service/taskplugin/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,9 @@ func (p *DeployTaskPlugin) downloadService(pipelineTask *task.Task, serviceName,

filePath := fmt.Sprintf("%s.tar.gz", serviceName)
tarFilePath := path.Join(base, filePath)
forcedPathStyle := false
if s3Storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if s3Storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(s3Storage.Endpoint, s3Storage.Ak, s3Storage.Sk, s3Storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func upload(ctx context.Context, log *zap.SugaredLogger, storage *s3.S3, localfi

return err
}
forcedPathStyle := false
if storage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if storage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
client, err := s3tool.NewClient(storage.Endpoint, storage.Ak, storage.Sk, storage.Insecure, forcedPathStyle)
if err != nil {
Expand Down Expand Up @@ -160,9 +160,9 @@ func (p *Distribute2S3TaskPlugin) Run(ctx context.Context, pipelineTask *task.Ta
defer func() {
_ = os.Remove(tmpFile.Name())
}()
forcedPathStyle := false
if srcStorage.Provider == setting.ProviderSourceSystemDefault {
forcedPathStyle = true
forcedPathStyle := true
if srcStorage.Provider == setting.ProviderSourceAli {
forcedPathStyle = false
}
s3client, err := s3tool.NewClient(srcStorage.Endpoint, srcStorage.Ak, srcStorage.Sk, srcStorage.Insecure, forcedPathStyle)
if err != nil {
Expand Down
Loading

0 comments on commit 639fa73

Please sign in to comment.