Skip to content

Commit

Permalink
chore(boilerplate): Fix FileMode
Browse files Browse the repository at this point in the history
  • Loading branch information
vaerh committed Sep 24, 2024
1 parent d86a9ba commit bfd85d5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tools/boilerplate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func main() {

// if !*isDS {
fName := fmt.Sprintf("%v_%v", Resource.HCL(), strings.TrimPrefix(resName, "routeros_"))
f, err := os.OpenFile(filepath.Join("routeros", fName+".go"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm)
f, err := os.OpenFile(filepath.Join("routeros", fName+".go"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
panic(err)
}
Expand All @@ -109,13 +109,14 @@ func main() {
GoResourceName string
System bool
Schema string
}{Resource.String() + goName, *isSystem, Schema})
ResourcePath string
}{Resource.String() + goName, *isSystem, Schema, strings.ReplaceAll(strings.TrimPrefix(resName, "routeros_"), "_", "/")})
if err != nil {
panic(err)
}
f.Close()

f, err = os.OpenFile(filepath.Join("routeros", fName+"_test.go"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm)
f, err = os.OpenFile(filepath.Join("routeros", fName+"_test.go"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
panic(err)
}
Expand All @@ -136,7 +137,7 @@ func main() {

os.MkdirAll(filepath.Join("examples", "resources", resName), os.ModePerm)

f, err = os.OpenFile(filepath.Join("examples", "resources", resName, "import.sh"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm)
f, err = os.OpenFile(filepath.Join("examples", "resources", resName, "import.sh"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
panic(err)
}
Expand All @@ -153,7 +154,7 @@ func main() {
}
f.Close()

f, err = os.OpenFile(filepath.Join("examples", "resources", resName, "resource.tf"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm)
f, err = os.OpenFile(filepath.Join("examples", "resources", resName, "resource.tf"), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
panic(err)
}
Expand All @@ -174,7 +175,7 @@ func main() {
flags |= os.O_CREATE
}

f, err = os.OpenFile(filepath.Join("routeros", "provider.go"), flags, os.ModePerm)
f, err = os.OpenFile(filepath.Join("routeros", "provider.go"), flags, 0644)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -259,7 +260,7 @@ REST JSON
// https://help.mikrotik.com/docs/display/ROS/
func {{.GoResourceName}}() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/"),
MetaResourcePath: PropResourcePath("/{{.ResourcePath}}"),
MetaId: PropId(Id),
{{.Schema}}
Expand Down

0 comments on commit bfd85d5

Please sign in to comment.