예제 #1
0
    def test_find_required_key_error_missing_key(self):
        invalid_properties_dict = {'name': 'some-lambda-function'}
        test_key = 'taskDefinition'

        with self.assertRaises(MissingPropertyError):
            find_required_key('task definition', invalid_properties_dict,
                              test_key)
예제 #2
0
    def test_find_required_key_error_missing_key(self):
        invalid_properties_dict = {
            'name': 'some-lambda-function'
        }
        test_key = 'taskDefinition'

        with self.assertRaises(MissingPropertyError):
            find_required_key('task definition', invalid_properties_dict, test_key)
예제 #3
0
파일: deploy.py 프로젝트: Cuteo1000/AWS-CLI
    def update_task_def_arn(self, new_arn):
        """
        Inserts the ARN of the previously created ECS task definition
        into the provided appspec.

        Expected format of ECS appspec (YAML) is:
            version: 0.0
            resources:
              - <service-name>:
                  type: AWS::ECS::Service
                  properties:
                    taskDefinition: <value>  # replace this
                    loadBalancerInfo:
                      containerName: <value>
                      containerPort: <value>
        """
        appspec_obj = self._appspec_dict

        resources_key = filehelpers.find_required_key('codedeploy-appspec',
                                                      appspec_obj, 'resources')
        updated_resources = []

        # 'resources' is a list of string:obj dictionaries
        for resource in appspec_obj[resources_key]:
            for name in resource:
                # get content of resource
                resource_content = resource[name]
                # get resource properties
                properties_key = filehelpers.find_required_key(
                    name, resource_content, 'properties')
                properties_content = resource_content[properties_key]
                # find task definition property
                task_def_key = filehelpers.find_required_key(
                    properties_key, properties_content, 'taskDefinition')

                # insert new task def ARN into resource
                properties_content[task_def_key] = new_arn

            updated_resources.append(resource)

        appspec_obj[resources_key] = updated_resources
        self._appspec_dict = appspec_obj
예제 #4
0
파일: deploy.py 프로젝트: aws/aws-cli
    def update_task_def_arn(self, new_arn):
        """
        Inserts the ARN of the previously created ECS task definition
        into the provided appspec.

        Expected format of ECS appspec (YAML) is:
            version: 0.0
            resources:
              - <service-name>:
                  type: AWS::ECS::Service
                  properties:
                    taskDefinition: <value>  # replace this
                    loadBalancerInfo:
                      containerName: <value>
                      containerPort: <value>
        """
        appspec_obj = self._appspec_dict

        resources_key = filehelpers.find_required_key(
            'codedeploy-appspec', appspec_obj, 'resources')
        updated_resources = []

        # 'resources' is a list of string:obj dictionaries
        for resource in appspec_obj[resources_key]:
            for name in resource:
                # get content of resource
                resource_content = resource[name]
                # get resource properties
                properties_key = filehelpers.find_required_key(
                    name, resource_content, 'properties')
                properties_content = resource_content[properties_key]
                # find task definition property
                task_def_key = filehelpers.find_required_key(
                    properties_key, properties_content, 'taskDefinition')

                # insert new task def ARN into resource
                properties_content[task_def_key] = new_arn

            updated_resources.append(resource)

        appspec_obj[resources_key] = updated_resources
        self._appspec_dict = appspec_obj
예제 #5
0
    def test_find_required_key(self):
        test_properties_dict = {
            "TaskDefinition": "arn:aws:ecs:::task-definition/test:1",
            "loadbalancerInfo": {
                    "containerName": "web",
                    "containerPort": 80
                } 
        }
        test_key = 'taskDefinition'
        expected_result = 'TaskDefinition'

        result = find_required_key(
            'task definition', test_properties_dict, test_key)
        self.assertEqual(result, expected_result)
예제 #6
0
    def test_find_required_key(self):
        test_properties_dict = {
            "TaskDefinition": "arn:aws:ecs:::task-definition/test:1",
            "loadbalancerInfo": {
                "containerName": "web",
                "containerPort": 80
            }
        }
        test_key = 'taskDefinition'
        expected_result = 'TaskDefinition'

        result = find_required_key('task definition', test_properties_dict,
                                   test_key)
        self.assertEqual(result, expected_result)
예제 #7
0
    def test_find_required_key_error_empty_object(self):
        test_key = 'taskDefinition'

        with self.assertRaises(MissingPropertyError):
            find_required_key('task definition', dict(), test_key)
예제 #8
0
    def test_find_required_key_error_empty_object(self):
        test_key = 'taskDefinition'

        with self.assertRaises(MissingPropertyError):
            find_required_key('task definition', dict(), test_key)