Skip to content

Commit

Permalink
Clean up (#24)
Browse files Browse the repository at this point in the history
* cleaned up readme

* added another test for props

* adds a simple example
  • Loading branch information
mtintes authored Oct 1, 2024
1 parent e746f05 commit 0fd0056
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# configamajig
# <img src="configamajig_icon.png" width="50px"/> configamajig

You know when you have 20 apps and they all are basically configured the same way, but not 100% the same? This is for that problem.

Expand All @@ -13,9 +13,34 @@ You need to sometimes use one value vs another in an env depending on another de

Confused why something doesn't seem to template like you expect? configamajig has full value tracing so you can see which file changed what value super easy!

## Install

`brew install mtintes/configamajig/configamajig`

Or `brew tap mtintes/configamajig` and then `brew install configamajig`.

Or find latest build under [releases](https://github.com/mtintes/configamajig/releases)

## Tips
"configamajig" is a lot for anyone to type out. We recommend setting up an alias!

## Commands

### Generate Config
To generate a basic config file:
```configamajig generate config >> config.json```

### Replace:
Feed in an template file + a config and out comes a fully filled out file

```configamajig replace -c <CONFIG.json> -i <INPUT> -o <OUTPUT>```

### Read Key:
For finding the value of a specific key

```configamajig read key -c <CONFIG.json> -o <OUTPUT>", "some.key"```


## Contributing

Wow, um that is super cool if you do want to help. I guess to start read through the current issue and if you think you can solve something or want to take a shot then post something on said issue. I guess we will figure it out from there.
32 changes: 32 additions & 0 deletions cli/actions/memoryMap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,3 +666,35 @@ func TestMemoryMapWithIntPropsIsOutlawed(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, fmt.Sprint(expectedMemoryMap), fmt.Sprint(memoryMap))
}

func TestMemoryMapWithMappedProps(t *testing.T) {

Config := ConfigurationMap{
Configs: []Config{
{
Props: map[string]interface{}{
"key": map[string]interface{}{
"key1": "value",
},
},
Mappings: []Mapping{
{
InPath: "key",
ToPath: "newKey",
},
},
},
},
}

expectedMemoryMap := map[string]interface{}{
"newKey": map[string]interface{}{
"key1": "value",
},
}

memoryMap, _, err := ReadMemoryMap(&Config)

assert.Nil(t, err)
assert.Equal(t, fmt.Sprint(expectedMemoryMap), fmt.Sprint(memoryMap))
}
Binary file added configamajig_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions example-files/replaceCmdExamples/simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To Run:

```configamajig replace -c config.json -i input1.txt -o output.txt```

or with trace

```configamajig replace -c config.json -i input1.txt -o output.txt -t trace.md```
33 changes: 33 additions & 0 deletions example-files/replaceCmdExamples/simple/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"configs": [
{
"path": "global.json",
"mappings": [
{
"inPath": "globalAppConfigs",
"toPath": "globals"
},
{
"inPath": "deploymentConfigs",
"toPath": "deploymentValues"
}
],
"applyFile": "after"
},
{
"path": "regional.json",
"mappings": [
{
"inPath": "globalAppConfigs",
"toPath": "globals"
},
{
"inPath": "deploymentConfigs",
"toPath": "deploymentValues"
}
],
"applyFile": "later"
}
],
"version": "1.0.0"
}
11 changes: 11 additions & 0 deletions example-files/replaceCmdExamples/simple/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"globalAppConfigs":{
"dbConfigs": "someGlobalConnectionString",
"someAPIKey": "someAPIKey",
"someOtherGlobalConfigs": "someOtherGlobalConfigs"
},
"deploymentConfigs":{
"stage": "development",
"someOtherConfigs": "someOtherConfigs"
}
}
3 changes: 3 additions & 0 deletions example-files/replaceCmdExamples/simple/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global.dbConfigs: {{ .globals.dbConfigs }}

deploymentValues.stage: {{ .deploymentValues.stage }}
10 changes: 10 additions & 0 deletions example-files/replaceCmdExamples/simple/regional.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"globalAppConfigs":{
"dbConfigs": "someRegionalConnectionString",
"someAPIKey": "someAPIKey"
},
"deploymentConfigs":{
"stage": "integration",
"someOtherConfigs": "someOtherConfigs"
}
}

0 comments on commit 0fd0056

Please sign in to comment.