Skip to content

Commit dc80967

Browse files
Merge pull request intelops#190 from intelops/change-folder-for-generated-project
enhancement: changed the folder for generated project and fixed the g…
2 parents 8ef2545 + 1ff6ef0 commit dc80967

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

.github/workflows/release.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ on:
44
tags:
55
- "v*.*.*"
66
permissions:
7-
contents: write
7+
contents: write # needed to write releases
8+
id-token: write # needed for keyless signing
9+
packages: write # needed for ghcr access
10+
811
jobs:
912
push_to_registry:
1013
name: Build and push Docker image github container registry.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ git clone https://github.com/intelops/compage.git
134134
cd compage
135135
go build -o compage .
136136
## initialize the config.yaml file
137-
./compage init
137+
./compage init --serverType grpc
138138
## edit the config.yaml file as per your requirement
139139
## generate the code. Below command accepts serverType [rest, grpc and rest-grpc]
140-
./compage generate grpc
140+
./compage generate
141141
```
142142

143143
## Contributing

cmd/generate.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/intelops/compage/internal/utils"
88
log "github.com/sirupsen/logrus"
99
"github.com/spf13/cobra"
10+
"os"
1011
)
1112

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

2425
func init() {
2526
rootCmd.AddCommand(generateCmd)
26-
27+
wD, err := os.Getwd()
28+
if err != nil {
29+
log.Errorf("error while getting the current directory [" + err.Error() + "]")
30+
return
31+
}
32+
// set the project folder environment variable, if this is set, then the project will be generated in this folder
33+
err = os.Setenv("COMPAGE_GENERATED_PROJECT_FOLDER", wD)
34+
if err != nil {
35+
log.Errorf("error while setting the project folder [" + err.Error() + "]")
36+
return
37+
}
2738
// Here you will define your flags and configuration settings.
2839

2940
// Cobra supports Persistent Flags which will work for this command

cmd/init.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func createOrUpdateDefaultConfigFile() {
3939
log.Infof("skipping config file creation")
4040
return
4141
}
42+
log.Infof("overwriting the config file")
4243
err = os.Remove(configFilePath)
4344
if err != nil {
4445
log.Warnf("error while removing the config file %s", err)

internal/utils/fileUtils.go

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import (
1111

1212
// GetProjectDirectoryName returns tarFile parent path
1313
func GetProjectDirectoryName(name string) string {
14+
projectDirectoryName := os.Getenv("COMPAGE_GENERATED_PROJECT_FOLDER")
15+
if projectDirectoryName != "" {
16+
return projectDirectoryName + "/" + name
17+
}
18+
1419
userHomeDir, err := os.UserHomeDir()
1520
if err != nil {
1621
log.Debugf("Error getting user home directory: %s", err)

0 commit comments

Comments
 (0)