Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12 add api documentation #7

Open
wants to merge 87 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
4d7a7dd
remove core limitation
matheuspolitano Dec 23, 2024
6c29e2f
fix main bugs
matheuspolitano Dec 24, 2024
1601264
fix main bugs
matheuspolitano Dec 24, 2024
1310b7b
down go version
matheuspolitano Dec 24, 2024
aa08816
add release file
matheuspolitano Dec 24, 2024
8e08e34
add release info in readme
matheuspolitano Dec 24, 2024
70f5b75
Merge pull request #1 from matheuspolitano/1-fix-main-bugs
matheuspolitano Dec 24, 2024
0982ac0
add new pipeline
matheuspolitano Dec 24, 2024
011b3a8
Merge pull request #2 from matheuspolitano/1-fix-main-bugs-1
matheuspolitano Dec 24, 2024
fee950d
fix pipeline
matheuspolitano Dec 24, 2024
6df7c14
Merge pull request #3 from matheuspolitano/1-fix-main-bugs-2
matheuspolitano Dec 24, 2024
3690243
Add new release file release_20241224104515.toml
github-actions[bot] Dec 24, 2024
4285907
improve the pipeline
matheuspolitano Dec 24, 2024
015183f
update release
matheuspolitano Dec 24, 2024
9a12574
Merge pull request #4 from matheuspolitano/2-improve-the-pipeline
matheuspolitano Dec 24, 2024
e8914ac
Add new release file release_20241224105329.toml
github-actions[bot] Dec 24, 2024
a363d78
pipeline adjust
matheuspolitano Dec 24, 2024
c9c86ad
Merge pull request #5 from matheuspolitano/3-remove-release-file
matheuspolitano Dec 24, 2024
d51f15e
Add new release file release_20241224111005.toml
github-actions[bot] Dec 24, 2024
d766a84
improve errors messages
matheuspolitano Dec 24, 2024
375a284
ädd local env and extras check in config
matheuspolitano Dec 24, 2024
a4e8ec9
change main go file
matheuspolitano Dec 24, 2024
497f3c8
add config
matheuspolitano Dec 24, 2024
4b0ed73
add config test
matheuspolitano Dec 24, 2024
e904542
run in sequence de config test and improve the config
matheuspolitano Dec 24, 2024
29e68c4
fix type error in port
matheuspolitano Dec 24, 2024
314338f
add note in release
matheuspolitano Dec 24, 2024
90991ca
improve task detail
matheuspolitano Dec 24, 2024
858c708
Merge pull request #6 from matheuspolitano/5-improve-config
matheuspolitano Dec 24, 2024
55ba43f
Add new release file release_20241224141902.toml
github-actions[bot] Dec 24, 2024
8a9556d
update readme
matheuspolitano Dec 24, 2024
049a9af
update readme
matheuspolitano Dec 24, 2024
0a5b0ce
update readme
matheuspolitano Dec 24, 2024
be3a5b7
update readme
matheuspolitano Dec 24, 2024
76b5c7f
add myduration
matheuspolitano Dec 25, 2024
6fc90b0
add test
matheuspolitano Dec 25, 2024
29092dc
add release
matheuspolitano Dec 25, 2024
ecb6071
Merge pull request #8 from matheuspolitano/7-improve-time-alive
matheuspolitano Dec 25, 2024
3e48f98
Add new release file release_20241225114904.toml
github-actions[bot] Dec 25, 2024
650acee
improve main.go and server start and shutdown
matheuspolitano Dec 25, 2024
dadf977
improve readme
matheuspolitano Dec 25, 2024
37eecea
Merge pull request #9 from matheuspolitano/6-improve-main.go
matheuspolitano Dec 25, 2024
81a767c
Add new release file release_20241225141728.toml
github-actions[bot] Dec 25, 2024
f6d55be
add env as type
matheuspolitano Dec 25, 2024
c99942f
add new pacakge and set new test
matheuspolitano Dec 25, 2024
d7b3d96
add production mod
matheuspolitano Dec 25, 2024
a94b47f
remove useless comments
matheuspolitano Dec 25, 2024
798ec5a
add max age
matheuspolitano Dec 25, 2024
e2dfaa5
improve response
matheuspolitano Dec 25, 2024
aa4a2f6
improve config and add new config
matheuspolitano Dec 25, 2024
1e16f01
update dockerimage
matheuspolitano Dec 25, 2024
4c3e893
add in readme
matheuspolitano Dec 25, 2024
2ad6d1f
add release
matheuspolitano Dec 25, 2024
aa6389b
update go version
matheuspolitano Dec 25, 2024
d355e9b
update pipeline and go version
matheuspolitano Dec 25, 2024
e1b534d
ignore scripts
matheuspolitano Dec 26, 2024
57f302b
improve release pipeline
matheuspolitano Dec 26, 2024
215b9c5
add ignore
matheuspolitano Dec 26, 2024
6a874e9
improve the validate release
matheuspolitano Dec 26, 2024
088cedf
improve release
matheuspolitano Dec 26, 2024
da84809
add response
matheuspolitano Dec 26, 2024
bdc9bbe
improve format
matheuspolitano Dec 26, 2024
49429e7
update release
matheuspolitano Dec 26, 2024
79b53c0
fix test
matheuspolitano Dec 26, 2024
c2db65b
Merge pull request #10 from matheuspolitano/7-improve-gin-api
matheuspolitano Dec 26, 2024
0b2c8a2
Add new release file release_20241226171013.toml
github-actions[bot] Dec 26, 2024
f203a84
improve memdb
matheuspolitano Dec 26, 2024
1cea555
Merge pull request #11 from matheuspolitano/8-improve-repository
matheuspolitano Dec 26, 2024
a8acdba
Add new release file release_20241226174317.toml
github-actions[bot] Dec 26, 2024
caa30ad
add docker
matheuspolitano Dec 26, 2024
69069d6
add release
matheuspolitano Dec 26, 2024
aad42e9
add release
matheuspolitano Dec 26, 2024
80eccc2
Merge pull request #12 from matheuspolitano/9-setup-docker
matheuspolitano Dec 27, 2024
c245e41
Release: Add release_20241227000208.toml
github-actions[bot] Dec 27, 2024
64c930a
cicd adjust
matheuspolitano Dec 27, 2024
ebc0cf5
Merge pull request #13 from matheuspolitano/10-migrate-deploy-file
matheuspolitano Dec 27, 2024
dedcac4
Release: Add release_20241227122723.toml
github-actions[bot] Dec 27, 2024
5166895
11 improve service #major (#14)
matheuspolitano Dec 27, 2024
06ac48a
Release: Add release_20241227124702.toml
github-actions[bot] Dec 27, 2024
cde0067
add doc
matheuspolitano Dec 27, 2024
e5c9e4b
improve readme
matheuspolitano Dec 27, 2024
9fa2a51
improve readme
matheuspolitano Dec 27, 2024
12d5bb3
improve readme
matheuspolitano Dec 27, 2024
10af987
improve readme
matheuspolitano Dec 27, 2024
89cbe2a
improve readme
matheuspolitano Dec 27, 2024
94d8b9a
add latest push in docker
matheuspolitano Dec 27, 2024
5704f8e
go mod tidy
matheuspolitano Dec 27, 2024
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
Prev Previous commit
Next Next commit
fix main bugs
  • Loading branch information
matheuspolitano committed Dec 24, 2024
commit 1601264d45a8527b6a9c3cae1f3b4b0af919749d
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Validate Release

on:
pull_request:
branches:
- main

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20

- name: Install dependencies
run: go mod tidy

- name: Validate release.toml
run: go run scripts/validate_release.go

merge:
needs: validate
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Move release.toml
run: |
mv release.toml releases/$(date +%s)_release.toml
File renamed without changes.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Schwarz IT Code Review Repository

This repository is meant to be used in the onboarding process of Go developers
applying to Schwarz IT.

Code smells and security issues are made on purpose. All the code to be reviewed is
in the [review](review) directory.

# Overview

This repository was created from the repository at https://github.com/SchwarzIT/go-code-review to make corrections and improvements
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions review/go.mod → go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.1 // indirect
Expand Down
3 changes: 3 additions & 0 deletions review/go.sum → go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY=
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand All @@ -75,6 +77,7 @@ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Metadata]

Author = "Matheus Politano"
Release_file_version = "2.1"

[Description]

Notes = """
This is the first Merge request
"""


[[Digest.Bugs]]
Name = "Fix main bugs"
Issue = 1
Description = """

"""
108 changes: 108 additions & 0 deletions scripts/validate_release.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package main

import (
"fmt"
"os"
"strings"

"github.com/pelletier/go-toml"
)

type Release struct {
Metadata struct {
Author string `toml:"Author"`
ReleaseFileVersion string `toml:"Release_file_version"`
} `toml:"Metadata"`

Description struct {
Notes string `toml:"Notes"`
} `toml:"Description"`

Digest struct {
Features []Section `toml:"Features"`
Improvements []Section `toml:"Improvements"`
Bugs []Section `toml:"Bugs"`
} `toml:"Digest"`
}

type Section struct {
Name string `toml:"Name"`
Issue int `toml:"Issue"`
Description string `toml:"Description"`
}

func validateRelease(filePath string) error {
content, err := os.ReadFile(filePath)
if err != nil {
return fmt.Errorf("failed to read file: %v", err)
}

// Basic format check
if !strings.HasPrefix(string(content), "[Metadata]") {
return fmt.Errorf("file must start with [Metadata] section")
}

// Parse TOML
var release Release
err = toml.Unmarshal(content, &release)
if err != nil {
return fmt.Errorf("invalid TOML format: %v", err)
}

// Check required fields in Metadata
if release.Metadata.Author == "" || release.Metadata.ReleaseFileVersion == "" {
return fmt.Errorf("missing required fields in Metadata")
}

// Check Notes in Description
if release.Description.Notes == "" {
return fmt.Errorf("Notes in Description must not be empty")
}

// Check Digest sections
if len(release.Digest.Features) == 0 && len(release.Digest.Improvements) == 0 && len(release.Digest.Bugs) == 0 {
return fmt.Errorf("at least one Digest section (Features, Improvements, Bugs) must be provided")
}

// Ensure every entry in Digest has required fields
validateSection := func(sections []Section) error {
for _, section := range sections {
if section.Name == "" || section.Issue == 0 || section.Description == "" {
return fmt.Errorf("Digest entries must have Name, Issue, and Description filled out")
}
}
return nil
}

if err := validateSection(release.Digest.Features); err != nil {
return err
}
if err := validateSection(release.Digest.Improvements); err != nil {
return err
}
if err := validateSection(release.Digest.Bugs); err != nil {
return err
}

return nil
}

func main() {
releaseFile := "./release.toml"
// Check if file exists

fmt.Println("Checking if release file exists")
if _, err := os.Stat(releaseFile); os.IsNotExist(err) {
fmt.Println("release.toml file not found")
os.Exit(1)
}

// Validate file
fmt.Println("Validating release file")
err := validateRelease(releaseFile)
if err != nil {
fmt.Printf("Validation failed: %v\n", err)
os.Exit(1)
}

}