Ejemplo n.º 1
0
def create_default_deployer(session, config, ui):
    # type: (Session, Config, UI) -> Deployer
    client = TypedAWSClient(session)
    osutils = OSUtils()
    pip_runner = PipRunner(pip=SubprocessPip(osutils=osutils), osutils=osutils)
    dependency_builder = PipDependencyBuilder(osutils=osutils,
                                              pip_runner=pip_runner)
    return Deployer(
        application_builder=ApplicationGraphBuilder(),
        deps_builder=DependencyBuilder(),
        build_stage=BuildStage(steps=[
            InjectDefaults(),
            DeploymentPackager(packager=LambdaDeploymentPackager(
                osutils=osutils,
                dependency_builder=dependency_builder,
                ui=UI(),
            ), ),
            PolicyGenerator(policy_gen=AppPolicyGenerator(osutils=osutils), ),
            SwaggerBuilder(swagger_generator=TemplatedSwaggerGenerator(), )
        ], ),
        plan_stage=PlanStage(
            osutils=osutils,
            remote_state=RemoteState(
                client, config.deployed_resources(config.chalice_stage)),
        ),
        sweeper=UnreferencedResourcePlanner(),
        executor=Executor(client, ui),
        recorder=ResultsRecorder(osutils=osutils),
    )
Ejemplo n.º 2
0
def create_build_stage(osutils, ui, swagger_gen):
    # type: (OSUtils, UI, SwaggerGenerator) -> BuildStage
    pip_runner = PipRunner(pip=SubprocessPip(osutils=osutils),
                           osutils=osutils)
    dependency_builder = PipDependencyBuilder(
        osutils=osutils,
        pip_runner=pip_runner
    )
    build_stage = BuildStage(
        steps=[
            InjectDefaults(),
            DeploymentPackager(
                packager=LambdaDeploymentPackager(
                    osutils=osutils,
                    dependency_builder=dependency_builder,
                    ui=ui,
                ),
            ),
            PolicyGenerator(
                policy_gen=AppPolicyGenerator(
                    osutils=osutils
                ),
                osutils=osutils,
            ),
            SwaggerBuilder(
                swagger_generator=swagger_gen,
            ),
            LambdaEventSourcePolicyInjector(),
            WebsocketPolicyInjector()
        ],
    )
    return build_stage
Ejemplo n.º 3
0
def create_build_stage(osutils, ui, swagger_gen, config):
    # type: (OSUtils, UI, SwaggerGenerator, Config) -> BuildStage
    pip_runner = PipRunner(pip=SubprocessPip(osutils=osutils), osutils=osutils)
    dependency_builder = PipDependencyBuilder(osutils=osutils,
                                              pip_runner=pip_runner)
    deployment_packager = cast(BaseDeployStep, None)
    if config.automatic_layer:
        deployment_packager = ManagedLayerDeploymentPackager(
            lambda_packager=AppOnlyDeploymentPackager(
                osutils=osutils,
                dependency_builder=dependency_builder,
                ui=ui,
            ),
            layer_packager=LayerDeploymentPackager(
                osutils=osutils,
                dependency_builder=dependency_builder,
                ui=ui,
            ))
    else:
        deployment_packager = DeploymentPackager(
            packager=LambdaDeploymentPackager(
                osutils=osutils,
                dependency_builder=dependency_builder,
                ui=ui,
            ))
    build_stage = BuildStage(steps=[
        InjectDefaults(), deployment_packager,
        PolicyGenerator(
            policy_gen=AppPolicyGenerator(osutils=osutils),
            osutils=osutils,
        ),
        SwaggerBuilder(swagger_generator=swagger_gen, ),
        LambdaEventSourcePolicyInjector(),
        WebsocketPolicyInjector()
    ], )
    return build_stage
Ejemplo n.º 4
0
    def package(self):
        pip_runner = PipRunner(
            pip=SubprocessPip(osutils=self._osutils),
            osutils=self._osutils
        )

        dependency_builder = PipDependencyBuilder(
            osutils=self._osutils,
            pip_runner=pip_runner
        )

        packager = ChaliceLambdaDeploymentPackager(
            osutils=self._osutils,
            dependency_builder=dependency_builder,
            ui=self._ui,
        )

        self.package_path = packager.create_deployment_package(
            self.source_code_path,
            'python3.6'
        )
        package_content = self.load_package()
        self.cleanup()
        return package_content