Groovy web console

subscribe to the feed Subscribe
to this
site
test (via #groovywebconsole)
tweet this snippet Tweet
this
script

test

Published 5 months ago by test with tags test
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.JsonSlurper
import groovy.json.JsonBuilder


def ecrRepo="my.web.site"
def configJSON = new JsonSlurper().parseText('{"auths": {"https://my.web.site":"some.replacement"}}')
def dockercfgJSON = new JsonSlurper().parseText('{"url":"my.web.site"}')
//copy the specific ecrRepo key on         
dockercfgJSON."${ecrRepo}" = configJSON.auths."https://${ecrRepo}"       
def dockercfgContent = new JsonBuilder(dockercfgJSON).toPrettyString() 

println "${dockercfgContent}"