Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Some nicer way to base64decode and jsondecode #263

Open
wryun opened this issue Mar 21, 2018 · 1 comment
Open

Some nicer way to base64decode and jsondecode #263

wryun opened this issue Mar 21, 2018 · 1 comment

Comments

@wryun
Copy link
Contributor

wryun commented Mar 21, 2018

If we reference into ConfigMaps and Secrets, it can be useful to parse JSON and base 64 decode (so complex configuration can be passed around safely).

Lack of json decoding means all ConfigMap/Secret references are shallow (i.e. top level k/v), and that we automatically base 64 decode secret references (since Go does - but this is not a good strategy in many cases when we want to put them in JSON as the output).

Possible ways to fix this:

  1. fork kubernetes jsonpath into voyager codebase (https://github.com/kubernetes/client-go/tree/master/util/jsonpath) and add these functions as 'identifiers' (cf range/end) - code looks straightforward. However, this will probably require us to remove the magic 'add {$.}' currently in the smith reference code.
  2. use jmespath instead of jsonpath and define custom functions. Unfortunately, looks like Go jmespath doesn't allow one to define custom functions in the current interface, unlike other jmespath implementations, but it's trivial to add and we may be able to upstream.
  3. add a 'subReference' (name?) to the top level references (cf Refactor dependsOn into References #262 ) like:
  subReference:
    Path: 'inside.secret.path'
    Operations: [base64decode, jsondecode]

I'm in favour of Option 1 for now

@wryun
Copy link
Contributor Author

wryun commented Mar 21, 2018

I now think (1) would not be straightforward having looked more deeply into how the kubernetes hacked on identifier processing works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants