pulumi-kubernetes-cert-manager 0.2.0a1736827123__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,327 @@
1
+ # coding=utf-8
2
+ # *** WARNING: this file was generated by pulumi-language-python. ***
3
+ # *** Do not edit by hand unless you're certain you know what you are doing! ***
4
+
5
+
6
+ import asyncio
7
+ import functools
8
+ import importlib.metadata
9
+ import importlib.util
10
+ import inspect
11
+ import json
12
+ import os
13
+ import sys
14
+ import typing
15
+ import warnings
16
+ import base64
17
+
18
+ import pulumi
19
+ import pulumi.runtime
20
+ from pulumi.runtime.sync_await import _sync_await
21
+ from pulumi.runtime.proto import resource_pb2
22
+
23
+ from semver import VersionInfo as SemverVersion
24
+ from parver import Version as PEP440Version
25
+
26
+ C = typing.TypeVar("C", bound=typing.Callable)
27
+
28
+
29
+ def get_env(*args):
30
+ for v in args:
31
+ value = os.getenv(v)
32
+ if value is not None:
33
+ return value
34
+ return None
35
+
36
+
37
+ def get_env_bool(*args):
38
+ str = get_env(*args)
39
+ if str is not None:
40
+ # NOTE: these values are taken from https://golang.org/src/strconv/atob.go?s=351:391#L1, which is what
41
+ # Terraform uses internally when parsing boolean values.
42
+ if str in ["1", "t", "T", "true", "TRUE", "True"]:
43
+ return True
44
+ if str in ["0", "f", "F", "false", "FALSE", "False"]:
45
+ return False
46
+ return None
47
+
48
+
49
+ def get_env_int(*args):
50
+ str = get_env(*args)
51
+ if str is not None:
52
+ try:
53
+ return int(str)
54
+ except:
55
+ return None
56
+ return None
57
+
58
+
59
+ def get_env_float(*args):
60
+ str = get_env(*args)
61
+ if str is not None:
62
+ try:
63
+ return float(str)
64
+ except:
65
+ return None
66
+ return None
67
+
68
+
69
+ def _get_semver_version():
70
+ # __name__ is set to the fully-qualified name of the current module, In our case, it will be
71
+ # <some module>._utilities. <some module> is the module we want to query the version for.
72
+ root_package, *rest = __name__.split('.')
73
+
74
+ # pkg_resources uses setuptools to inspect the set of installed packages. We use it here to ask
75
+ # for the currently installed version of the root package (i.e. us) and get its version.
76
+
77
+ # Unfortunately, PEP440 and semver differ slightly in incompatible ways. The Pulumi engine expects
78
+ # to receive a valid semver string when receiving requests from the language host, so it's our
79
+ # responsibility as the library to convert our own PEP440 version into a valid semver string.
80
+
81
+ pep440_version_string = importlib.metadata.version(root_package)
82
+ pep440_version = PEP440Version.parse(pep440_version_string)
83
+ (major, minor, patch) = pep440_version.release
84
+ prerelease = None
85
+ if pep440_version.pre_tag == 'a':
86
+ prerelease = f"alpha.{pep440_version.pre}"
87
+ elif pep440_version.pre_tag == 'b':
88
+ prerelease = f"beta.{pep440_version.pre}"
89
+ elif pep440_version.pre_tag == 'rc':
90
+ prerelease = f"rc.{pep440_version.pre}"
91
+ elif pep440_version.dev is not None:
92
+ prerelease = f"dev.{pep440_version.dev}"
93
+
94
+ # The only significant difference between PEP440 and semver as it pertains to us is that PEP440 has explicit support
95
+ # for dev builds, while semver encodes them as "prerelease" versions. In order to bridge between the two, we convert
96
+ # our dev build version into a prerelease tag. This matches what all of our other packages do when constructing
97
+ # their own semver string.
98
+ return SemverVersion(major=major, minor=minor, patch=patch, prerelease=prerelease)
99
+
100
+
101
+ # Determine the version once and cache the value, which measurably improves program performance.
102
+ _version = _get_semver_version()
103
+ _version_str = str(_version)
104
+
105
+ def get_resource_opts_defaults() -> pulumi.ResourceOptions:
106
+ return pulumi.ResourceOptions(
107
+ version=get_version(),
108
+ plugin_download_url=get_plugin_download_url(),
109
+ )
110
+
111
+ def get_invoke_opts_defaults() -> pulumi.InvokeOptions:
112
+ return pulumi.InvokeOptions(
113
+ version=get_version(),
114
+ plugin_download_url=get_plugin_download_url(),
115
+ )
116
+
117
+ def get_resource_args_opts(resource_args_type, resource_options_type, *args, **kwargs):
118
+ """
119
+ Return the resource args and options given the *args and **kwargs of a resource's
120
+ __init__ method.
121
+ """
122
+
123
+ resource_args, opts = None, None
124
+
125
+ # If the first item is the resource args type, save it and remove it from the args list.
126
+ if args and isinstance(args[0], resource_args_type):
127
+ resource_args, args = args[0], args[1:]
128
+
129
+ # Now look at the first item in the args list again.
130
+ # If the first item is the resource options class, save it.
131
+ if args and isinstance(args[0], resource_options_type):
132
+ opts = args[0]
133
+
134
+ # If resource_args is None, see if "args" is in kwargs, and, if so, if it's typed as the
135
+ # the resource args type.
136
+ if resource_args is None:
137
+ a = kwargs.get("args")
138
+ if isinstance(a, resource_args_type):
139
+ resource_args = a
140
+
141
+ # If opts is None, look it up in kwargs.
142
+ if opts is None:
143
+ opts = kwargs.get("opts")
144
+
145
+ return resource_args, opts
146
+
147
+
148
+ # Temporary: just use pulumi._utils.lazy_import once everyone upgrades.
149
+ def lazy_import(fullname):
150
+
151
+ import pulumi._utils as u
152
+ f = getattr(u, 'lazy_import', None)
153
+ if f is None:
154
+ f = _lazy_import_temp
155
+
156
+ return f(fullname)
157
+
158
+
159
+ # Copied from pulumi._utils.lazy_import, see comments there.
160
+ def _lazy_import_temp(fullname):
161
+ m = sys.modules.get(fullname, None)
162
+ if m is not None:
163
+ return m
164
+
165
+ spec = importlib.util.find_spec(fullname)
166
+
167
+ m = sys.modules.get(fullname, None)
168
+ if m is not None:
169
+ return m
170
+
171
+ loader = importlib.util.LazyLoader(spec.loader)
172
+ spec.loader = loader
173
+ module = importlib.util.module_from_spec(spec)
174
+
175
+ m = sys.modules.get(fullname, None)
176
+ if m is not None:
177
+ return m
178
+
179
+ sys.modules[fullname] = module
180
+ loader.exec_module(module)
181
+ return module
182
+
183
+
184
+ class Package(pulumi.runtime.ResourcePackage):
185
+ def __init__(self, pkg_info):
186
+ super().__init__()
187
+ self.pkg_info = pkg_info
188
+
189
+ def version(self):
190
+ return _version
191
+
192
+ def construct_provider(self, name: str, typ: str, urn: str) -> pulumi.ProviderResource:
193
+ if typ != self.pkg_info['token']:
194
+ raise Exception(f"unknown provider type {typ}")
195
+ Provider = getattr(lazy_import(self.pkg_info['fqn']), self.pkg_info['class'])
196
+ return Provider(name, pulumi.ResourceOptions(urn=urn))
197
+
198
+
199
+ class Module(pulumi.runtime.ResourceModule):
200
+ def __init__(self, mod_info):
201
+ super().__init__()
202
+ self.mod_info = mod_info
203
+
204
+ def version(self):
205
+ return _version
206
+
207
+ def construct(self, name: str, typ: str, urn: str) -> pulumi.Resource:
208
+ class_name = self.mod_info['classes'].get(typ, None)
209
+
210
+ if class_name is None:
211
+ raise Exception(f"unknown resource type {typ}")
212
+
213
+ TheClass = getattr(lazy_import(self.mod_info['fqn']), class_name)
214
+ return TheClass(name, pulumi.ResourceOptions(urn=urn))
215
+
216
+
217
+ def register(resource_modules, resource_packages):
218
+ resource_modules = json.loads(resource_modules)
219
+ resource_packages = json.loads(resource_packages)
220
+
221
+ for pkg_info in resource_packages:
222
+ pulumi.runtime.register_resource_package(pkg_info['pkg'], Package(pkg_info))
223
+
224
+ for mod_info in resource_modules:
225
+ pulumi.runtime.register_resource_module(
226
+ mod_info['pkg'],
227
+ mod_info['mod'],
228
+ Module(mod_info))
229
+
230
+
231
+ _F = typing.TypeVar('_F', bound=typing.Callable[..., typing.Any])
232
+
233
+
234
+ def lift_output_func(func: typing.Any) -> typing.Callable[[_F], _F]:
235
+ """Decorator internally used on {fn}_output lifted function versions
236
+ to implement them automatically from the un-lifted function."""
237
+
238
+ func_sig = inspect.signature(func)
239
+
240
+ def lifted_func(*args, opts=None, **kwargs):
241
+ bound_args = func_sig.bind(*args, **kwargs)
242
+ # Convert tuple to list, see pulumi/pulumi#8172
243
+ args_list = list(bound_args.args)
244
+ return pulumi.Output.from_input({
245
+ 'args': args_list,
246
+ 'kwargs': bound_args.kwargs
247
+ }).apply(lambda resolved_args: func(*resolved_args['args'],
248
+ opts=opts,
249
+ **resolved_args['kwargs']))
250
+
251
+ return (lambda _: lifted_func)
252
+
253
+
254
+ def call_plain(
255
+ tok: str,
256
+ props: pulumi.Inputs,
257
+ res: typing.Optional[pulumi.Resource] = None,
258
+ typ: typing.Optional[type] = None,
259
+ ) -> typing.Any:
260
+ """
261
+ Wraps pulumi.runtime.plain to force the output and return it plainly.
262
+ """
263
+
264
+ output = pulumi.runtime.call(tok, props, res, typ)
265
+
266
+ # Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency.
267
+ result, known, secret, _ = _sync_await(asyncio.create_task(_await_output(output)))
268
+
269
+ problem = None
270
+ if not known:
271
+ problem = ' an unknown value'
272
+ elif secret:
273
+ problem = ' a secret value'
274
+
275
+ if problem:
276
+ raise AssertionError(
277
+ f"Plain resource method '{tok}' incorrectly returned {problem}. "
278
+ + "This is an error in the provider, please report this to the provider developer."
279
+ )
280
+
281
+ return result
282
+
283
+
284
+ async def _await_output(o: pulumi.Output[typing.Any]) -> typing.Tuple[object, bool, bool, set]:
285
+ return (
286
+ await o._future,
287
+ await o._is_known,
288
+ await o._is_secret,
289
+ await o._resources,
290
+ )
291
+
292
+
293
+ # This is included to provide an upgrade path for users who are using a version
294
+ # of the Pulumi SDK (<3.121.0) that does not include the `deprecated` decorator.
295
+ def deprecated(message: str) -> typing.Callable[[C], C]:
296
+ """
297
+ Decorator to indicate a function is deprecated.
298
+
299
+ As well as inserting appropriate statements to indicate that the function is
300
+ deprecated, this decorator also tags the function with a special attribute
301
+ so that Pulumi code can detect that it is deprecated and react appropriately
302
+ in certain situations.
303
+
304
+ message is the deprecation message that should be printed if the function is called.
305
+ """
306
+
307
+ def decorator(fn: C) -> C:
308
+ if not callable(fn):
309
+ raise TypeError("Expected fn to be callable")
310
+
311
+ @functools.wraps(fn)
312
+ def deprecated_fn(*args, **kwargs):
313
+ warnings.warn(message)
314
+ pulumi.warn(f"{fn.__name__} is deprecated: {message}")
315
+
316
+ return fn(*args, **kwargs)
317
+
318
+ deprecated_fn.__dict__["_pulumi_deprecated_callable"] = fn
319
+ return typing.cast(C, deprecated_fn)
320
+
321
+ return decorator
322
+
323
+ def get_plugin_download_url():
324
+ return None
325
+
326
+ def get_version():
327
+ return _version_str