Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .CreateFile(j.FileOutput)
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
commit d1816fc2b3d88cc668123e7af2151c0a0ce39638 (HEAD -> main, origin/main, origin/HEAD)
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:36:03 2023 +0300

Update encoding.go

commit 02513509f43783ad431670400d095c8691f00998
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:35:16 2023 +0300

Delete precode directory

commit 1aa823fde11a7293c54ab999e26a0903c9d359ec
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:34:29 2023 +0300

Update encoding.go

commit d08c877b39da5c385ccd31f1992d7482c1f2fe1c
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:32:42 2023 +0300

Delete encoding/encoding_test.go

commit b5618c94a0ce72a6f4785d35dc833a15bd34b26b
Merge: 3054315 4ba88b5
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:30:35 2023 +0300

Merge pull request #1 from Yandex-Practicum/prototype

prototype

commit 3054315f478524943e0a4f75bd2ad99a50c92323
Author: bbrodriges <bender.rodriges@gmail.com>
Date: Wed Nov 22 16:27:41 2023 +0300

add autotests

commit 4ba88b56f7b67cfe1dfb9c8d2d26583bf2ce9b27
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Thu Nov 2 18:15:01 2023 +0300

test and precode added

commit 4b3729fe73dd1852872b8315fa53c05ff5975171
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:37:42 2023 +0300

changing example data

commit 1d65c20524dd92f164bc6953079798e1877ecdec
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:36:53 2023 +0300

changing data

commit b2df37c98e02a93dc7052c00ce8baf377543023a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 21:11:43 2023 +0300

prototype

commit 3f1c4d6fa9b36fd888eaa3515d558e591731012a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 20:54:27 2023 +0300

init commit
68 changes: 68 additions & 0 deletions .DecodeJSON(inputJSON, &j.DockerCompose)
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
commit d1816fc2b3d88cc668123e7af2151c0a0ce39638 (HEAD -> main, origin/main, origin/HEAD)
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:36:03 2023 +0300

Update encoding.go

commit 02513509f43783ad431670400d095c8691f00998
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:35:16 2023 +0300

Delete precode directory

commit 1aa823fde11a7293c54ab999e26a0903c9d359ec
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:34:29 2023 +0300

Update encoding.go

commit d08c877b39da5c385ccd31f1992d7482c1f2fe1c
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:32:42 2023 +0300

Delete encoding/encoding_test.go

commit b5618c94a0ce72a6f4785d35dc833a15bd34b26b
Merge: 3054315 4ba88b5
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:30:35 2023 +0300

Merge pull request #1 from Yandex-Practicum/prototype

prototype

commit 3054315f478524943e0a4f75bd2ad99a50c92323
Author: bbrodriges <bender.rodriges@gmail.com>
Date: Wed Nov 22 16:27:41 2023 +0300

add autotests

commit 4ba88b56f7b67cfe1dfb9c8d2d26583bf2ce9b27
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Thu Nov 2 18:15:01 2023 +0300

test and precode added

commit 4b3729fe73dd1852872b8315fa53c05ff5975171
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:37:42 2023 +0300

changing example data

commit 1d65c20524dd92f164bc6953079798e1877ecdec
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:36:53 2023 +0300

changing data

commit b2df37c98e02a93dc7052c00ce8baf377543023a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 21:11:43 2023 +0300

prototype

commit 3f1c4d6fa9b36fd888eaa3515d558e591731012a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 20:54:27 2023 +0300

init commit
68 changes: 68 additions & 0 deletions .ReadFile(j.FileInput)
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
commit d1816fc2b3d88cc668123e7af2151c0a0ce39638 (HEAD -> main, origin/main, origin/HEAD)
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:36:03 2023 +0300

Update encoding.go

commit 02513509f43783ad431670400d095c8691f00998
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:35:16 2023 +0300

Delete precode directory
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вот все такие файлы лишние надо удалить, чтобы их не было в репозитории


commit 1aa823fde11a7293c54ab999e26a0903c9d359ec
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:34:29 2023 +0300

Update encoding.go

commit d08c877b39da5c385ccd31f1992d7482c1f2fe1c
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:32:42 2023 +0300

Delete encoding/encoding_test.go

commit b5618c94a0ce72a6f4785d35dc833a15bd34b26b
Merge: 3054315 4ba88b5
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:30:35 2023 +0300

Merge pull request #1 from Yandex-Practicum/prototype

prototype

commit 3054315f478524943e0a4f75bd2ad99a50c92323
Author: bbrodriges <bender.rodriges@gmail.com>
Date: Wed Nov 22 16:27:41 2023 +0300

add autotests

commit 4ba88b56f7b67cfe1dfb9c8d2d26583bf2ce9b27
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Thu Nov 2 18:15:01 2023 +0300

test and precode added

commit 4b3729fe73dd1852872b8315fa53c05ff5975171
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:37:42 2023 +0300

changing example data

commit 1d65c20524dd92f164bc6953079798e1877ecdec
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:36:53 2023 +0300

changing data

commit b2df37c98e02a93dc7052c00ce8baf377543023a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 21:11:43 2023 +0300

prototype

commit 3f1c4d6fa9b36fd888eaa3515d558e591731012a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 20:54:27 2023 +0300

init commit
68 changes: 68 additions & 0 deletions e()
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
commit d1816fc2b3d88cc668123e7af2151c0a0ce39638 (HEAD -> main, origin/main, origin/HEAD)
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:36:03 2023 +0300

Update encoding.go

commit 02513509f43783ad431670400d095c8691f00998
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:35:16 2023 +0300

Delete precode directory

commit 1aa823fde11a7293c54ab999e26a0903c9d359ec
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:34:29 2023 +0300

Update encoding.go

commit d08c877b39da5c385ccd31f1992d7482c1f2fe1c
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:32:42 2023 +0300

Delete encoding/encoding_test.go

commit b5618c94a0ce72a6f4785d35dc833a15bd34b26b
Merge: 3054315 4ba88b5
Author: supppppppbro <113025477+supppppppbro@users.noreply.github.com>
Date: Wed Nov 22 17:30:35 2023 +0300

Merge pull request #1 from Yandex-Practicum/prototype

prototype

commit 3054315f478524943e0a4f75bd2ad99a50c92323
Author: bbrodriges <bender.rodriges@gmail.com>
Date: Wed Nov 22 16:27:41 2023 +0300

add autotests

commit 4ba88b56f7b67cfe1dfb9c8d2d26583bf2ce9b27
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Thu Nov 2 18:15:01 2023 +0300

test and precode added

commit 4b3729fe73dd1852872b8315fa53c05ff5975171
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:37:42 2023 +0300

changing example data

commit 1d65c20524dd92f164bc6953079798e1877ecdec
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Wed Nov 1 19:36:53 2023 +0300

changing data

commit b2df37c98e02a93dc7052c00ce8baf377543023a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 21:11:43 2023 +0300

prototype

commit 3f1c4d6fa9b36fd888eaa3515d558e591731012a
Author: Владислав Попов <lekanl3k4n@yandex.ru>
Date: Tue Oct 31 20:54:27 2023 +0300

init commit
71 changes: 67 additions & 4 deletions encoding/encoding.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package encoding

import (
"encoding/json"
"fmt"
"io"
"os"

"github.com/Yandex-Practicum/final-project-encoding-go/models"
"gopkg.in/yaml.v3"
)

// JSONData тип для перекодирования из JSON в YAML
Expand All @@ -25,16 +31,73 @@ type MyEncoder interface {

// Encoding перекодирует файл из JSON в YAML
func (j *JSONData) Encoding() error {
// ниже реализуйте метод
// ...

jsonFile, err := os.Open(j.FileInput)
if err != nil {
return fmt.Errorf("open file: %w", err)
Comment thread
Rarik88 marked this conversation as resolved.
}
defer jsonFile.Close()
Comment thread
Rarik88 marked this conversation as resolved.

jsonData, err := io.ReadAll(jsonFile)
if err != nil {
return fmt.Errorf("read file: %w", err)
}

if err = json.Unmarshal(jsonData, &j.DockerCompose); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}

yamlData, err := yaml.Marshal(&j.DockerCompose)
if err != nil {
return fmt.Errorf("marshal: %w", err)
}

yamlFile, err := os.Create(j.FileOutput)
if err != nil {
return fmt.Errorf("create file: %w", err)
}
defer yamlFile.Close()

_, err = yamlFile.Write(yamlData)
if err != nil {
return fmt.Errorf("write file: %w", err)
}

return nil
}

// Encoding перекодирует файл из YAML в JSON
func (y *YAMLData) Encoding() error {
// Ниже реализуйте метод
// ...

yamlFile, err := os.Open(y.FileInput)
if err != nil {
return fmt.Errorf("open file: %w", err)
}
defer yamlFile.Close()
yamlData, err := io.ReadAll(yamlFile)
if err != nil {
return fmt.Errorf("read file: %w", err)
}

if err = yaml.Unmarshal(yamlData, &y.DockerCompose); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}

jsonData, err := json.Marshal(&y.DockerCompose)
if err != nil {
return fmt.Errorf("marshal: %w", err)
}

jsonFile, err := os.Create(y.FileOutput)
if err != nil {
return fmt.Errorf("create file: %w", err)
}
defer jsonFile.Close()
Comment thread
Rarik88 marked this conversation as resolved.

_, err = jsonFile.Write(jsonData)
if err != nil {
return fmt.Errorf("write file: %w", err)
}

return nil
}
1 change: 1 addition & 0 deletions jsonInput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"3","services":{"web":{"build":".","ports":["5000:5000"],"volumes":["/usercode/:/code"],"links":["database:backenddb"]},"database":{"image":"mysql/mysql-server:5.7","environment":["MYSQL_ROOT_PASSWORD=root","MYSQL_USER=testuser","MYSQL_PASSWORD=admin123","MYSQL_DATABASE=backend"],"volumes":["/usercode/db/init.sql:/docker-entrypoint-initdb.d/init.sql"]}}}
1 change: 1 addition & 0 deletions jsonOutput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"3","services":{"web":{"build":".","ports":["5000:5000"],"volumes":["/usercode/:/code"],"links":["database:backenddb"]},"database":{"image":"mysql/mysql-server:5.7","environment":["MYSQL_ROOT_PASSWORD=root","MYSQL_USER=testuser","MYSQL_PASSWORD=admin123","MYSQL_DATABASE=backend"],"volumes":["/usercode/db/init.sql:/docker-entrypoint-initdb.d/init.sql"]}}}
Comment thread
Rarik88 marked this conversation as resolved.
19 changes: 19 additions & 0 deletions yamlInput.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"
services:
web:
build: .
ports:
- 5000:5000
volumes:
- /usercode/:/code
links:
- database:backenddb
database:
image: mysql/mysql-server:5.7
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=testuser
- MYSQL_PASSWORD=admin123
- MYSQL_DATABASE=backend
volumes:
- /usercode/db/init.sql:/docker-entrypoint-initdb.d/init.sql
Loading