@@ -15,7 +15,7 @@ import (
15
15
16
16
const templateExt = ".tmpl"
17
17
18
- func RenderDir (templatePath , root , plugin , pluginGithubUrl , pgVersion string ) {
18
+ func RenderDir (templatePath , root , plugin , pluginGithubUrl , pluginVersion , pgVersion string ) {
19
19
var targetFilePath string
20
20
err := filepath .Walk (templatePath , func (filePath string , info os.FileInfo , err error ) error {
21
21
if err != nil {
@@ -64,10 +64,12 @@ func RenderDir(templatePath, root, plugin, pluginGithubUrl, pgVersion string) {
64
64
data := struct {
65
65
Plugin string
66
66
PluginGithubUrl string
67
+ PluginVersion string
67
68
PgVersion string
68
69
}{
69
70
plugin ,
70
71
pluginGithubUrl ,
72
+ pluginVersion ,
71
73
pgVersion ,
72
74
}
73
75
@@ -95,25 +97,35 @@ func RenderDir(templatePath, root, plugin, pluginGithubUrl, pgVersion string) {
95
97
func main () {
96
98
// Check if the correct number of command-line arguments are provided
97
99
if len (os .Args ) < 4 {
98
- fmt .Println ("Usage: go run generator.go <templatePath> <root> <plugin> [pluginGithubUrl]" )
100
+ fmt .Println ("Usage: go run generator.go <templatePath> <root> <plugin> [plugin_version] [ pluginGithubUrl]" )
99
101
return
100
102
}
101
103
102
104
templatePath := os .Args [1 ]
103
105
root := os .Args [2 ]
104
106
plugin := os .Args [3 ]
107
+ var pluginVersion string
105
108
var pluginGithubUrl string
106
109
107
- fmt .Println (len (os .Args ))
110
+ // Check if pluginVersion is provided as a command-line argument
111
+ if len (os .Args ) >= 5 {
112
+ pluginVersion = os .Args [4 ]
113
+ }
108
114
109
115
// Check if PluginGithubUrl is provided as a command-line argument
110
- if len (os .Args ) == 5 {
111
- pluginGithubUrl = os .Args [4 ]
116
+ if len (os .Args ) >= 6 {
117
+ pluginGithubUrl = os .Args [5 ]
112
118
} else {
113
119
// If PluginGithubUrl is not provided, generate it based on PluginAlias
114
120
pluginGithubUrl = "github.com/turbot/steampipe-plugin-" + plugin
115
121
}
116
122
123
+ // If pluginVersion is provided but pluginGithubUrl is not, error out
124
+ if pluginVersion != "" && pluginGithubUrl == "" {
125
+ fmt .Println ("Error: plugin_github_url is required when plugin_version is specified" )
126
+ return
127
+ }
128
+
117
129
// Convert relative paths to absolute paths
118
130
absTemplatePath , err := filepath .Abs (templatePath )
119
131
if err != nil {
@@ -130,7 +142,7 @@ func main() {
130
142
// get the postgres version used
131
143
pgVersion := getPostgreSQLVersion ()
132
144
133
- RenderDir (absTemplatePath , absRoot , plugin , pluginGithubUrl , pgVersion )
145
+ RenderDir (absTemplatePath , absRoot , plugin , pluginGithubUrl , pluginVersion , pgVersion )
134
146
}
135
147
136
148
func getPostgreSQLVersion () string {
0 commit comments