Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
Avoid adding public keys if no secrets present
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Johansson committed Dec 15, 2015
1 parent 6fc3595 commit 3ecb212
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lighter/secretary.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def apply(document, config):
if not url:
return config

# Avoid adding public keys if no secrets present
if not [value for value in config.get('env', {}).itervalues() if isEnvelope(value)]:
return config

result = deepcopy(config)
masterKey = decodePublicKey(util.rget(document, 'secretary', 'master', 'publickey'))

Expand Down
7 changes: 7 additions & 0 deletions src/lighter/test/secretary_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ def testRedeployWithoutChange(self):

self.assertNotEqual(service1.config['env']['DEPLOY_PUBLIC_KEY'], service2.config['env']['DEPLOY_PUBLIC_KEY'])
self.assertNotEqual(service1.config['env']['DEPLOY_PRIVATE_KEY'], service2.config['env']['DEPLOY_PRIVATE_KEY'])

def testServiceWithoutSecrets(self):
service = lighter.parse_service('src/resources/yaml/staging/myservice-nosecret.yml')
self.assertFalse('SECRETARY_URL' in service.config['env'])
self.assertFalse('MASTER_PRIVATE_KEY' in service.config['env'])
self.assertFalse('DEPLOY_PUBLIC_KEY' in service.config['env'])
self.assertFalse('DEPLOY_PRIVATE_KEY' in service.config['env'])
11 changes: 11 additions & 0 deletions src/resources/yaml/staging/myservice-nosecret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
maven:
groupid: 'com.meltwater'
artifactid: 'myservice'
version: '1.0.0'
override:
env:
DATABASE: 'database:3306'
variables:
avar: '123'
bvar: '%{avar}'
cvar: '%{avar}'

0 comments on commit 3ecb212

Please sign in to comment.