Skip to content

Commit

Permalink
Merge pull request #4 from rsharifnasab/main
Browse files Browse the repository at this point in the history
Sync readme and default yaml flie path
  • Loading branch information
1995parham authored Oct 31, 2024
2 parents 7dad8eb + e3c0455 commit ef6938e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.yaml
*.yml
/helmfig
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Release workflow](https://github.com/snapp-incubator/helmfig/actions/workflows/release.yaml/badge.svg)

Are you tired of writing `values.yaml` for `configmap` of your project when you are helmifying them? Helmfig is a handy
Are you tired of writing `values.yaml` for `configmap` of your project when you are helmifying them? Helmfig is a handy
tool that can generate the content of your `configmap` object and its parameters for `values.yaml` based on a config
example file.

Expand Down Expand Up @@ -95,7 +95,7 @@ cd helmfig
go build .
```

3. Put your ```config.example.yml``` near the compiled binary and run it via:
3. Put your ```config.example.yaml``` near the compiled binary and run it via:

```bash
./helmfig yaml
Expand Down
10 changes: 5 additions & 5 deletions cmd/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var yamlCMD = &cobra.Command{
func init() {
rootCMD.AddCommand(yamlCMD)

yamlCMD.PersistentFlags().StringVarP(&inputPath, "example-config", "x", "config.example.yml", "Path to example yaml config file")
yamlCMD.PersistentFlags().StringVarP(&inputPath, "example-config", "x", "config.example.yaml", "Path to example yaml config file")
yamlCMD.PersistentFlags().StringVar(&configMapPath, "configmap", "configmap.yaml", "Path to configmap file output")
yamlCMD.PersistentFlags().StringVar(&valuesPath, "values", "values.yaml", "Path to values file output")
}
Expand All @@ -38,8 +38,8 @@ func yamlFunc(_ *cobra.Command, _ []string) {
log.WithError(err).Fatal("error in unmarshalling the file with YAML format")
}

var configMap = map[interface{}]interface{}{}
var values = map[interface{}]interface{}{}
configMap := map[interface{}]interface{}{}
values := map[interface{}]interface{}{}
traverse(parsedConfig, configMap, values, "")

rawConfigMap, err := yaml.Marshal(configMap)
Expand Down Expand Up @@ -74,8 +74,8 @@ func traverse(m, configMap, values map[interface{}]interface{}, valuesPath strin
for k, v := range m {
lowerCamelKey := strcase.ToLowerCamel(k.(string))
if reflect.TypeOf(v).Kind() == reflect.Map {
var localConfigMap = map[interface{}]interface{}{}
var localValues = map[interface{}]interface{}{}
localConfigMap := map[interface{}]interface{}{}
localValues := map[interface{}]interface{}{}
traverse(v.(map[interface{}]interface{}), localConfigMap, localValues, valuesPath+lowerCamelKey+".")
configMap[k] = localConfigMap
values[lowerCamelKey] = localValues
Expand Down

0 comments on commit ef6938e

Please sign in to comment.