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

enhancement: changed the folder for generated project and fixed the g… #190

Merged
merged 1 commit into from
Nov 28, 2023
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ on:
tags:
- "v*.*.*"
permissions:
contents: write
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access

jobs:
push_to_registry:
name: Build and push Docker image github container registry.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ git clone https://github.com/intelops/compage.git
cd compage
go build -o compage .
## initialize the config.yaml file
./compage init
./compage init --serverType grpc
## edit the config.yaml file as per your requirement
## generate the code. Below command accepts serverType [rest, grpc and rest-grpc]
./compage generate grpc
./compage generate
```

## Contributing
Expand Down
13 changes: 12 additions & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/intelops/compage/internal/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
)

// generateCmd represents the generate command
Expand All @@ -23,7 +24,17 @@ Change the file as per your needs and then run the compage generate command to g

func init() {
rootCmd.AddCommand(generateCmd)

wD, err := os.Getwd()
if err != nil {
log.Errorf("error while getting the current directory [" + err.Error() + "]")
return
}
// set the project folder environment variable, if this is set, then the project will be generated in this folder
err = os.Setenv("COMPAGE_GENERATED_PROJECT_FOLDER", wD)
if err != nil {
log.Errorf("error while setting the project folder [" + err.Error() + "]")
return
}
// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
Expand Down
1 change: 1 addition & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func createOrUpdateDefaultConfigFile() {
log.Infof("skipping config file creation")
return
}
log.Infof("overwriting the config file")
err = os.Remove(configFilePath)
if err != nil {
log.Warnf("error while removing the config file %s", err)
Expand Down
5 changes: 5 additions & 0 deletions internal/utils/fileUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (

// GetProjectDirectoryName returns tarFile parent path
func GetProjectDirectoryName(name string) string {
projectDirectoryName := os.Getenv("COMPAGE_GENERATED_PROJECT_FOLDER")
if projectDirectoryName != "" {
return projectDirectoryName + "/" + name
}

userHomeDir, err := os.UserHomeDir()
if err != nil {
log.Debugf("Error getting user home directory: %s", err)
Expand Down