openalm / Extension-UtilitiesPack

Release Management utility tasks
Other
34 stars 38 forks source link

Feature Request: Allow Json file tokens to be replaced before transforming #92

Open deadlydog opened 6 years ago

deadlydog commented 6 years ago

The Tokenizer task allows secrets to be replaced with Release Management variable values. It also allows a Json file to be used to specify more complex replacements to the configuration file (e.g. web.config file). The problem today is that most developers won't have SomeVariable in their web.config file when they check it into source control; they'll likely have a actual value in the field that corresponds to the Dev environment.

e.g. ApiKey = 123456 instead of ApiKey = __ApiKeySecret__

The json file allows us to replace that 123456 value with __ApiKeySecret__, but that won't be enough to get __ApiKeySecret__ to actually get replaced with the real secret value that's stored in Release Management.

What I've done to work around this is, define my Json file like:

{
    "DansSandbox": {
        "CustomVariables": {
            "ApiKeySecret": "__ApiKeySecretToken__"
        },
        "ConfigChanges": [
            {
                "KeyName": "/configuration/appSettings/add[@key='ApiKeySecret']",
                "Attribute": "value",
                "Value": "__ApiKeySecret__"
            }
        ]
    }
}

And then I run the Tokenizer task twice. The first time I run it on the Json file to replace the ApiKeySecretToken variable with the value of the Release Management ApiKeySecretToken variable value. image

I then run the Tokenizer task again using the Json file (that now contains the actual secret to insert into the config file). image

This workaround works, but it would be more convenient to have a checkbox that allows the Json file to be token-replaced before being applied against the configuration file (i.e. web.config), as then we would not need to call the tokenizer task twice; just once.

I imagine this wouldn't be too hard to implement, since all of the functionality is already present in the task, but I haven't looked into the code yet. This would be a nice little feature to make the task easily cover more real-world scenarios.

TheBeardedLlama commented 6 years ago

I agree. It doesn't make sense that the json cannot use variables