Skip to content

Commit 24e981c

Browse files
authored
Merge pull request #179 from alexeldeib/ace/windows
🐛 fix windows filepath compatibility
2 parents af0a811 + 66e11c3 commit 24e981c

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

pkg/crd/generator/generator.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"log"
2222
"os"
2323
"path"
24+
"path/filepath"
2425
"strings"
2526

2627
"github.com/ghodss/yaml"
@@ -95,7 +96,7 @@ func (c *Generator) ValidateAndInitFields() error {
9596

9697
// Init output directory
9798
if c.OutputDir == "" {
98-
c.OutputDir = path.Join(c.RootPath, "config/crds")
99+
c.OutputDir = filepath.Join(c.RootPath, "config/crds")
99100
}
100101

101102
return nil
@@ -148,7 +149,7 @@ func (c *Generator) writeCRDs(crds map[string][]byte) error {
148149
}
149150

150151
for file, crd := range crds {
151-
outFile := path.Join(c.OutputDir, file)
152+
outFile := filepath.Join(c.OutputDir, file)
152153
if err := (&util.FileWriter{Fs: c.OutFs}).WriteFile(outFile, crd); err != nil {
153154
return err
154155
}
@@ -206,7 +207,7 @@ func (c *Generator) setAPIsPkg() error {
206207
c.apisPkg = c.APIsPkg
207208
if c.apisPkg == "" {
208209
// Validate apis directory exists under working path
209-
apisPath := path.Join(c.RootPath, c.APIsPath)
210+
apisPath := filepath.Join(c.RootPath, c.APIsPath)
210211
if _, err := os.Stat(apisPath); err != nil {
211212
return fmt.Errorf("error validating apis path %s: %v", apisPath, err)
212213
}

pkg/crd/util/util.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ import (
2222
gobuild "go/build"
2323
"log"
2424
"os"
25-
"path"
2625
"path/filepath"
2726
"strings"
2827
)
2928

3029
// IsGoSrcPath validate if given path is of path $GOPATH/src.
3130
func IsGoSrcPath(filePath string) bool {
3231
for _, gopath := range getGoPaths() {
33-
goSrc := path.Join(gopath, "src")
32+
goSrc := filepath.Join(gopath, "src")
3433
if filePath == goSrc {
3534
return true
3635
}
@@ -42,7 +41,7 @@ func IsGoSrcPath(filePath string) bool {
4241
// IsUnderGoSrcPath validate if given path is under path $GOPATH/src.
4342
func IsUnderGoSrcPath(filePath string) bool {
4443
for _, gopath := range getGoPaths() {
45-
goSrc := path.Join(gopath, "src")
44+
goSrc := filepath.Join(gopath, "src")
4645
if strings.HasPrefix(filepath.Dir(filePath), goSrc) {
4746
return true
4847
}
@@ -57,7 +56,7 @@ func IsUnderGoSrcPath(filePath string) bool {
5756
func DirToGoPkg(dir string) (pkg string, err error) {
5857
goPaths := getGoPaths()
5958
for _, gopath := range goPaths {
60-
goSrc := path.Join(gopath, "src")
59+
goSrc := filepath.Join(gopath, "src")
6160
if !strings.HasPrefix(dir, goSrc) {
6261
continue
6362
}
@@ -80,7 +79,7 @@ func getGoPaths() []string {
8079

8180
// PathHasProjectFile validate if PROJECT file exists under the path.
8281
func PathHasProjectFile(filePath string) bool {
83-
if _, err := os.Stat(path.Join(filePath, "PROJECT")); os.IsNotExist(err) {
82+
if _, err := os.Stat(filepath.Join(filePath, "PROJECT")); os.IsNotExist(err) {
8483
return false
8584
}
8685

@@ -101,7 +100,7 @@ func GetRepoFromProject(rootPath string) string {
101100
func GetFieldFromProject(fieldKey string, rootPath string) string {
102101
var fieldVal string
103102

104-
file, err := os.Open(path.Join(rootPath, "PROJECT"))
103+
file, err := os.Open(filepath.Join(rootPath, "PROJECT"))
105104
if err != nil {
106105
log.Fatal(err)
107106
}

pkg/webhook/generator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"log"
2323
"net"
2424
"net/url"
25-
"path"
25+
"path/filepath"
2626
"sort"
2727
"strconv"
2828

@@ -87,7 +87,7 @@ func (o *generatorOptions) setDefaults() {
8787
o.port = 443
8888
}
8989
if len(o.certDir) == 0 {
90-
o.certDir = path.Join("/tmp", "k8s-webhook-server", "serving-certs")
90+
o.certDir = filepath.Join("/tmp", "k8s-webhook-server", "serving-certs")
9191
}
9292

9393
if len(o.mutatingWebhookConfigName) == 0 {

pkg/webhook/manifests.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package webhook
1919
import (
2020
"bytes"
2121
"fmt"
22-
"path"
22+
"path/filepath"
2323
"strings"
2424
"text/template"
2525

@@ -121,7 +121,7 @@ spec:
121121
if err := temp.Execute(buf, p); err != nil {
122122
return err
123123
}
124-
return afero.WriteFile(o.outFs, path.Join(o.PatchOutputDir, "manager_patch.yaml"), buf.Bytes(), 0644)
124+
return afero.WriteFile(o.outFs, filepath.Join(o.PatchOutputDir, "manager_patch.yaml"), buf.Bytes(), 0644)
125125
}
126126

127127
func toYAML(m map[string]string) (string, error) {

pkg/webhook/writer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package webhook
33
import (
44
"bytes"
55
"fmt"
6-
"path"
76
"path/filepath"
87

98
"github.com/ghodss/yaml"
@@ -84,7 +83,7 @@ func (o *WriterOptions) WriteObjectsToDisk(objects ...runtime.Object) error {
8483
}
8584
isFirstObject = false
8685
}
87-
err = afero.WriteFile(o.outFs, path.Join(o.OutputDir, "webhookmanifests.yaml"), buf.Bytes(), 0644)
86+
err = afero.WriteFile(o.outFs, filepath.Join(o.OutputDir, "webhookmanifests.yaml"), buf.Bytes(), 0644)
8887
if err != nil {
8988
return err
9089
}

0 commit comments

Comments
 (0)