Esempio n. 1
0
 def test_docker_file_exists(self):
     current_path = os.path.dirname(os.path.abspath(__file__))
     os.environ[environment.PROJECT_ROOT] = os.path.join(
         current_path, '../data')
     fis = FromImageStep()
     result = fis.get_from_line()
     self.assertEqual("FROM redis", result)
Esempio n. 2
0
 def test_inform_if_change_image(self):
     data = {
         pipeline_data.IMAGE_NAME: "my-app",
         pipeline_data.IMAGE_VERSION: "1.2.3_abcdef"
     }
     self.assertIsNotNone(FromImageStep().get_change_image_message(
         "kth-nodejs-api", data))
     self.assertIsNotNone(FromImageStep().get_change_image_message(
         "kth-nodejs-web", data))
Esempio n. 3
0
 def test_inform_if_change_image_is_empty(self):
     data = {
         pipeline_data.IMAGE_NAME: "my-app",
         pipeline_data.IMAGE_VERSION: "1.2.3_abcdef"
     }
     self.assertIsNone(FromImageStep().get_change_image_message(
         "should-not-return-a-message", data))
Esempio n. 4
0
    def __init__(self):
        self.log = logging.getLogger(__name__)

        self.pipeline_steps = pipeline.create_pipeline_from_array([
            # Print Docker version
            DockerVersion(),
            # Configure pipeline
            SetupStep(),
            # Login to docker registry
            DockerLoginStep(),
            # Check the content of docker.conf
            ReadConfFileStep(
                'docker.conf',
                [environment.IMAGE_NAME, pipeline_data.IMAGE_VERSION]),
            # Create new image version major.minor.path_githash
            ImageVersionStep(),
            # Check old dependencies
            DependenciesCheckStep(),
            # Check Dockerfile exists
            DockerFileStep(),
            # Check Dockerfiles FROM statement
            FromImageStep(),
            # Check that ENTRYPOINT is not used
            # InstructionStep()
            # Write information about the current build to a json-file.
            BuildEnvironmentToFileStep(),
            # Scan the repo for passwords, tokens or other suspicious looking strings
            RepoSupervisorStep(),
            # Create docker --build-arg
            DockerCreateBuildArgStep(),
            # Build the image to local registry
            BuildLocalStep(),
            # It never to late to party
            CelebrateStep(),
            # Test run the image
            DryRunStep(),
            # Run unit tests
            UnitTestStep(),
            # Run integration tests
            IntegrationTestStep(),
            # Do something (leftover?)
            TestImageStep(),
            # EXPERIMENTAL ONLY: Docker-slim
            DockerSlimStep(),
            # Tag the built image with image version
            TagImageStep(),
            # Push the tagged image to a repository
            PushPublicImageStep(),
            PushAzureImageStep(),
            PushImageStep(),
            DoneStep()
        ])
Esempio n. 5
0
 def test_get_base_image_name_2(self):
     self.assertEqual(
         FromImageStep(self.TEST_ALLOWED_IMAGES).get_base_image_name(
             'FROM mongo/mongodb:latest'), 'mongodb')
Esempio n. 6
0
 def test_get_base_image_name(self):
     self.assertEqual(
         FromImageStep(self.TEST_ALLOWED_IMAGES).get_base_image_name(
             'FROM kthse/kth-nodejs:10.14.1'), 'kth-nodejs')
Esempio n. 7
0
 def test_allow_all_versions(self):
     self.assertTrue(
         FromImageStep(self.TEST_ALLOWED_IMAGES).validate(
             "FROM docker.io/redis:13.37", "kth-azure-app:13.37.0_abcdef"))
Esempio n. 8
0
 def test_all_versions_invalid(self):
     self.assertFalse(
         FromImageStep(self.TEST_ALLOWED_IMAGES).validate(
             "FROM docker.io/oracle:11.1", "kth-azure-app:13.37.0_abcdef"))
Esempio n. 9
0
 def test_allow_all_unknown_images(self):
     self.assertTrue(
         FromImageStep(self.TEST_ALLOWED_IMAGES).validate(
             "FROM docker.io/someimage:latest",
             "kth-azure-app:13.37.0_abcdef"))
Esempio n. 10
0
 def test_other_app_image(self):
     self.assertTrue(
         FromImageStep(self.TEST_ALLOWED_IMAGES).validate(
             "FROM docker.io/other-app:latest",
             "kth-azure-app:13.37.0_abcdef"))
Esempio n. 11
0
 def test_more_supported_kth_image(self):
     self.assertTrue(
         FromImageStep(self.TEST_ALLOWED_IMAGES).validate(
             "FROM kthse/kth-nodejs:9.11.0",
             "kth-azure-app:13.37.0_abcdef"))
Esempio n. 12
0
 def test_not_supported_kth_image(self):
     self.assertFalse(
         FromImageStep(self.TEST_ALLOWED_IMAGES).validate(
             "FROM kthreg/kth-app:0.0", "kth-azure-app:13.37.0_abcdef"))