Skip to content

Commit

Permalink
0.0.90
Browse files Browse the repository at this point in the history
- Fixed issue where generated code was retruning correct version via api /ping
- Updated README
  • Loading branch information
shammishailaj committed Dec 15, 2022
1 parent d051311 commit ec3290b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 25 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.89
0.0.90
17 changes: 10 additions & 7 deletions templates/README.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,27 @@ The generated structure has been further modified as per the [Golang Standards P

|Requirements Grid||
|---|---|
|Software|Version|
|Docker| >= 19.03.13|
|Software|Version |
|Docker| >= 22.06.0-beta.0 |
|---|---|
|Docker Compose| >= 2.0.0|
|Ubuntu `build-essential` package||
|Docker Compose| >= 2.0.0 |
|Ubuntu `build-essential` package | Docker Image: shammishailaj/gobuilder:0.0.6 |

The default app can be run/built using the following `make` targets.

#### C. `make` targets

---

`run` - Builds and runs the default app using the `docker` image `shammishailaj/gobuilder:0.0.3`
`run` - Builds and runs the default app using the `docker` image `shammishailaj/gobuilder:0.0.6`

`build` - Builds the project using the `docker` image `shammishailaj/gobuilder:0.0.3` first and then copies all the required project files into a `scratch` image. The resultant is a docker image and not an executable.
`build` - Builds the project using the `docker` image `shammishailaj/gobuilder:0.0.6` first and then copies all the required project files into a `scratch` image. The resultant is a docker image and not an executable.

`cli` - Builds and outputs the binary file into the `bin` directory

All `make` targets accept the parameters `os=<os-name>` and `arch=<arch-name>`. The valid values for `os-name` and `arch-name` can be found out by running the go command `go tool dist list`.

#### D. Included Applications

---

- {{.Name}} CLI and Web server
Expand All @@ -70,6 +71,8 @@ go mod init {{.Name}}
go mod tidy
go mod vendor
git init
git config user.name "Firstname Lastname"
git config user.email "firstname.lastname@hostname.tld"
git add .gitignore
git commit -m"Initial commit #1 Ignoring files"
git add .
Expand Down
15 changes: 0 additions & 15 deletions templates/root.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ var (
}
logger = log.New()
u *utils.Utils
SEMVER *schemas.SemanticVersion
GitBranch string
GitState string
GitSummary string
BuildDate string
Version string
GitCommit string
)

// Execute adds all child commands to the root command and sets flags appropriately.
Expand All @@ -71,14 +64,6 @@ func init() {
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")

SEMVER = new(schemas.SemanticVersion)
SEMVER.GitBranch = GitBranch
SEMVER.GitState = GitState
SEMVER.GitSummary = GitSummary
SEMVER.BuildDate = BuildDate
SEMVER.Version = Version
SEMVER.GitCommit = GitCommit
}

// initConfig reads in config file and ENV variables if set.
Expand Down
11 changes: 10 additions & 1 deletion templates/serve.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,17 @@ var serveCmd = &cobra.Command{
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGINT)

semVer = &schemas.SemanticVersion{
GitBranch: GitBranch,
GitState: GitState,
GitSummary: GitSummary,
BuildDate: BuildDate,
Version: Version,
GitCommit: GitCommit,
}

r := routes.GetRoutesList(logger, router.NewRouter(), middleware.NewLog(logger, true))
r.Add("/ping", "GET", handlers.NewPing(logger, SEMVER).Handler)
r.Add("/ping", "GET", handlers.NewPing(logger, semVer).Handler)
r.Parse()

httpErr := make(chan error, 1)
Expand Down
20 changes: 19 additions & 1 deletion templates/version.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,31 @@ import (
"github.com/spf13/cobra"
)

var (
semVer *schemas.SemanticVersion
GitBranch string
GitState string
GitSummary string
BuildDate string
Version string
GitCommit string
)

// cleanCmd represents the cleanCmd command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Displays version information",
Long: `Displays version information for the App`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(SEMVER.String())
semVer = &schemas.SemanticVersion{
GitBranch: GitBranch,
GitState: GitState,
GitSummary: GitSummary,
BuildDate: BuildDate,
Version: Version,
GitCommit: GitCommit,
}
fmt.Println(semVer.String())
},
}

Expand Down

0 comments on commit ec3290b

Please sign in to comment.