Skip to content

Conversation

@Denzol
Copy link
Collaborator

@Denzol Denzol commented Nov 27, 2022

Реализовано хранилище s3(minio).
Для тестового запуска и проверки работоспособности создал файл /app/main.go, в котором необходимо будет вписать ключи хранилища. Также в папке app добавлены два файла: шаблон и сертификат для теста хранилища.

return buffer, nil
}

func (m minioStorage) GetCertificate(certificateName string) ([]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это не очень хорошо - должна быть функция GetFile(path) ([]byte, error) у имплементации s3, и к ней GetCertificate(certificateName string) ([]byte, error) и GetTemplate(certificateName string) ([]byte, error)
как обёртки. Но дучше пока оставить как есть.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ок...пока оставляем как есть, потом правим на GetFile.

"log"
)

func main() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это должно быть в тесте

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Завтра займусь тестом.

app/main.go Outdated

func main() {
endpoint := "localhost:9000"
accessKey := "..." //необходимо вписать для проверки
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так даже в тесте нельзя делать - os.Getenv()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил пока в файл main.go применение переменных окружения. В корень проекта добавил файл .env.
В main.go применена библиотека godotenv.

@@ -1 +1,164 @@
package s3

import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Импорты мы любим сортировать по блокам (встроенные, сторонние, свои)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подправил.


obj, err := m.client.GetObject(ctx, bucketName, objectName, minio.GetObjectOptions{})
if err != nil {
return nil, fmt.Errorf("Template not getted!")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to get - неправильный глагол.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подправил.

"github.com/minio/minio-go/v7/pkg/credentials"
"gus_certificates/utils/storage"
"io"
"log"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логгер мы же взяли сторонний

@Denzol
Copy link
Collaborator Author

Denzol commented Nov 28, 2022

Добавил .env файл с переменными окружения и включил их пока в файл main.go (завтра если не втуплю где-нибудь заменю файл main на тесты).
Поправил порядок в импортах.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants