コード例 #1
0
 def test_h_AddDigestsToImageTags(self):
     print('COMPOSE ADD DIGESTS')
     DockerImageTools.PullImage('nginx')
     TerminalTools.LoadEnvironmentVariables(
         os.path.join(TestTools.TEST_SAMPLE_FOLDER, '.env'))
     yamlData = YamlTools.GetYamlData(
         [os.path.join(TestTools.TEST_SAMPLE_FOLDER, 'docker-compose.yml')],
         replaceEnvironmentVariablesMatches=False)
     DockerComposeTools.AddDigestsToImageTags(yamlData)
     for service in yamlData['services']:
         if 'my.service' in yamlData['services'][service]['image']:
             self.assertEqual('my_repo/my.service:1.0.0',
                              yamlData['services'][service]['image'])
         else:
             self.assertTrue(
                 'nginx@sha256:' in yamlData['services'][service]['image'])
         self.assertTrue(yamlData['services'][service]['environment']
                         ['SOME_VARIABLE'] == '${SOME_ENV_VARIABLE}')
     print('DONE COMPOSE ADD DIGESTS')
コード例 #2
0
def GenerateComposeFileWithDigests(composeFiles, outputComposeFile):
    TerminalTools.LoadDefaultEnvironmentVariablesFile()
    yamlData = YamlTools.GetYamlData(composeFiles, replaceEnvironmentVariablesMatches=False)
    DockerComposeTools.AddDigestsToImageTags(yamlData)
    YamlTools.DumpYamlDataToFile(yamlData, outputComposeFile)