forked from aws-controllers-k8s/s3-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
54 lines (46 loc) · 1.78 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
import pytest
from typing import Dict, Any
from pathlib import Path
from acktest.k8s.resource import load_and_create_resource
from acktest.resources import load_resource_file
SERVICE_NAME = "s3"
CRD_GROUP = "s3.services.k8s.aws"
CRD_VERSION = "v1alpha1"
# PyTest marker for the current service
service_marker = pytest.mark.service(arg=SERVICE_NAME)
bootstrap_directory = Path(__file__).parent
resource_directory = Path(__file__).parent / "resources"
def load_s3_resource(resource_name: str, additional_replacements: Dict[str, Any] = {}):
""" Overrides the default `load_resource_file` to access the specific resources
directory for the current service.
"""
return load_resource_file(resource_directory, resource_name, additional_replacements=additional_replacements)
def create_s3_resource(
resource_plural, resource_name, spec_file, replacements, namespace="default"
):
"""
Wrapper around k8s.load_and_create_resource to create an S3 resource
"""
reference, spec, resource = load_and_create_resource(
resource_directory,
CRD_GROUP,
CRD_VERSION,
resource_plural,
resource_name,
spec_file,
replacements,
namespace,
)
return reference, spec, resource