def config(self, request): config = mock.create_autospec(Configuration([]), spec_set=True) config.environment = request.param.get("env") config.usage_reporting_cluster_name = 'cluster_name' config.usage_reporting_operator = 'operator_sdrn' config.usage_reporting_team = request.param.get("team") yield config
def config(self, secrets_mode): generic_enabled, strongbox_enabled, _, _ = secrets_mode config = mock.create_autospec(Configuration([]), spec_set=True) config.secrets_init_container_image = SECRET_IMAGE if generic_enabled else None config.secrets_service_account_name = "secretsmanager" if generic_enabled else None config.strongbox_init_container_image = STRONGBOX_IMAGE if strongbox_enabled else None yield config
def generic_init_secrets(self): config = mock.create_autospec(Configuration([]), spec_set=True) config.secret_init_containers = { "default": "default-image", "some-provider": "some-secret-container-image" } return GenericInitSecrets(config)
def test_legacy_strongbox_secrets(self, deployment, app_spec): config = mock.create_autospec(Configuration([]), spec_set=True) config.strongbox_init_container_image = STRONGBOX_IMAGE app_spec = app_spec._replace( strongbox=StrongboxSpec(enabled=True, iam_role="iam_role", aws_region="eu-west-1", groups=["group1", "group2"])) generic_init_secrets = mock.create_autospec(GenericInitSecrets(config), spec_set=True, instance=True) generic_init_secrets.supports.side_effect = lambda _type: _type == 'strongbox' secrets = Secrets( config, mock.create_autospec(KubernetesSecrets(), spec_set=True, instance=True), generic_init_secrets) expected_spec = SecretsSpec( type="strongbox", parameters={ "AWS_REGION": "eu-west-1", "SECRET_GROUPS": "group1,group2" }, annotations={"iam.amazonaws.com/role": "iam_role"}) secrets.apply(deployment, app_spec) generic_init_secrets.apply.assert_called_once_with( deployment, app_spec, expected_spec)
def test_app_spec_secrets(self, deployment, app_spec): config = mock.create_autospec(Configuration([]), spec_set=True) app_spec = app_spec._replace(secrets=APP_SPEC_SECRETS) generic_init_secrets = mock.create_autospec(GenericInitSecrets(config), spec_set=True, instance=True) secrets = Secrets( config, mock.create_autospec(KubernetesSecrets(), spec_set=True, instance=True), generic_init_secrets) expected_spec = APP_SPEC_SECRETS[0] secrets.apply(deployment, app_spec) generic_init_secrets.apply.assert_called_once_with( deployment, app_spec, expected_spec)
def test_default_secrets(self, deployment, app_spec): config = mock.create_autospec(Configuration([]), spec_set=True) config.secret_init_containers = {"default": DEFAULT_IMAGE} generic_init_secrets = mock.create_autospec(GenericInitSecrets(config), spec_set=True, instance=True) generic_init_secrets.supports.side_effect = lambda _type: _type == 'default' secrets = Secrets( config, mock.create_autospec(KubernetesSecrets(), spec_set=True, instance=True), generic_init_secrets) expected_spec = SecretsSpec(type="default", parameters={}, annotations={}) secrets.apply(deployment, app_spec) generic_init_secrets.apply.assert_called_once_with( deployment, app_spec, expected_spec)
def config(self): config = mock.create_autospec(Configuration([]), spec_set=True) config.datadog_container_image = CONTAINER_IMAGE return config
def factory(self): config = mock.create_autospec(Configuration([]), spec_set=True) return SpecFactory(Factory(), {}, config)
def strongbox_secrets(self): config = mock.create_autospec(Configuration([]), spec_set=True) return StrongboxSecrets(config)
def generic_init_secrets(self, use_in_memory_emptydirs): config = mock.create_autospec(Configuration([]), spec_set=True) config.use_in_memory_emptydirs = use_in_memory_emptydirs return GenericInitSecrets(config)
def config(self): config = create_autospec(Configuration([]), spec_set=True) config.datadog_container_image = None return config
def strongbox_secrets(self): config = mock.create_autospec(Configuration([]), spec_set=True) config.secret_init_containers = {} config.strongbox_init_container_image = "some-strongbox-image" return GenericInitSecrets(config)
def generic_init_secrets(self, use_in_memory_emptydirs): config = mock.create_autospec(Configuration([]), spec_set=True) config.secret_init_containers = {} config.use_in_memory_emptydirs = use_in_memory_emptydirs config.secrets_init_container_image = "some-image" return GenericInitSecrets(config)
def config(self): config = mock.create_autospec(Configuration([]), spec_set=True) config.usage_reporting_endpoint = "http://example.com/usage" return config
def config(self): config = mock.create_autospec(Configuration([]), spec_set=True) config.datadog_container_image = CONTAINER_IMAGE config.datadog_container_memory = "2Gi" config.datadog_global_tags = {"tag": "test"} return config