Skip to content

Commit

Permalink
Fixed compile problems
Browse files Browse the repository at this point in the history
  • Loading branch information
fd committed May 3, 2016
1 parent b3ae7e8 commit 49dedd8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions cmd/k8s/gen_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func genConfigMap(app *kingpin.Application, configDir, configMapName string) {
if name == ".DS_Store" {
continue
}
if len(name) > 253 || !nameRE.MatchString(name) {
app.Fatalf("%q must have at most 253 characters and match regex %s", name, nameRE.String())
if len(name) > 253 || !nameConfigMapRE.MatchString(name) {
app.Fatalf("%q must have at most 253 characters and match regex %s", name, nameConfigMapRE.String())
}

data, err := ioutil.ReadFile(path)
Expand All @@ -57,33 +57,33 @@ func genConfigMap(app *kingpin.Application, configDir, configMapName string) {
app.FatalIfError(err, "%v", err)
}

configMap.Files = append(configMap.Files, File{
configMap.Files = append(configMap.Files, ConfigMapFile{
Name: name,
Value: string(data),
})
}

err = configMap.WriteTo(os.Stdout)
err = configMap.writeTo(os.Stdout)
if err != nil {
app.FatalIfError(err, "%v", err)
}
}

type ConfigMap struct {
Name string
Files []File
Files []ConfigMapFile
}

type File struct {
type ConfigMapFile struct {
Name string
Value string
}

func (c *ConfigMap) WriteTo(w io.Writer) error {
return tmpl.Execute(w, c)
func (c *ConfigMap) writeTo(w io.Writer) error {
return configMapTmpl.Execute(w, c)
}

var nameRE = regexp.MustCompile(`^\.?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
var nameConfigMapRE = regexp.MustCompile(`^\.?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)

// kind: ConfigMap
// apiVersion: v1
Expand All @@ -96,7 +96,7 @@ var nameRE = regexp.MustCompile(`^\.?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-
// property.1=value-1
// property.2=value-2
// property.3=value-3
var tmpl = template.Must(template.New("").Funcs(template.FuncMap{
var configMapTmpl = template.Must(template.New("").Funcs(template.FuncMap{
"indent": indent,
}).Parse(`kind: ConfigMap
apiVersion: v1
Expand Down
20 changes: 10 additions & 10 deletions cmd/k8s/gen_secretmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func genSecretMap(app *kingpin.Application, secretDir, secretMapName string) {
if name == ".DS_Store" {
continue
}
if len(name) > 253 || !nameRE.MatchString(name) {
app.Fatalf("%q must have at most 253 characters and match regex %s", name, nameRE.String())
if len(name) > 253 || !nameSecretMapRE.MatchString(name) {
app.Fatalf("%q must have at most 253 characters and match regex %s", name, nameSecretMapRE.String())
}

data, err := ioutil.ReadFile(path)
Expand All @@ -57,33 +57,33 @@ func genSecretMap(app *kingpin.Application, secretDir, secretMapName string) {
app.FatalIfError(err, "%v", err)
}

secretMap.Files = append(secretMap.Files, File{
secretMap.Files = append(secretMap.Files, SecretMapFile{
Name: name,
Value: string(data),
})
}

err = secretMap.WriteTo(os.Stdout)
err = secretMap.writeTo(os.Stdout)
if err != nil {
app.FatalIfError(err, "%v", err)
}
}

type SecretMap struct {
Name string
Files []File
Files []SecretMapFile
}

type File struct {
type SecretMapFile struct {
Name string
Value string
}

func (c *SecretMap) WriteTo(w io.Writer) error {
return tmpl.Execute(w, c)
func (c *SecretMap) writeTo(w io.Writer) error {
return secretMapTmpl.Execute(w, c)
}

var nameRE = regexp.MustCompile(`^\.?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
var nameSecretMapRE = regexp.MustCompile(`^\.?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)

// kind: SecretMap
// apiVersion: v1
Expand All @@ -96,7 +96,7 @@ var nameRE = regexp.MustCompile(`^\.?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-
// property.1=value-1
// property.2=value-2
// property.3=value-3
var tmpl = template.Must(template.New("").Funcs(template.FuncMap{
var secretMapTmpl = template.Must(template.New("").Funcs(template.FuncMap{
"b64": b64,
}).Parse(`kind: Secret
apiVersion: v1
Expand Down

0 comments on commit 49dedd8

Please sign in to comment.