playground-ls-cli 4.14.1.dev8__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.
Files changed (112) hide show
  1. localstack_cli/__init__.py +0 -0
  2. localstack_cli/cli/__init__.py +10 -0
  3. localstack_cli/cli/console.py +11 -0
  4. localstack_cli/cli/core_plugin.py +12 -0
  5. localstack_cli/cli/exceptions.py +19 -0
  6. localstack_cli/cli/localstack.py +951 -0
  7. localstack_cli/cli/lpm.py +138 -0
  8. localstack_cli/cli/main.py +22 -0
  9. localstack_cli/cli/plugin.py +39 -0
  10. localstack_cli/cli/plugins.py +134 -0
  11. localstack_cli/cli/profiles.py +65 -0
  12. localstack_cli/config.py +1689 -0
  13. localstack_cli/constants.py +165 -0
  14. localstack_cli/logging/__init__.py +0 -0
  15. localstack_cli/logging/format.py +194 -0
  16. localstack_cli/logging/setup.py +142 -0
  17. localstack_cli/packages/__init__.py +25 -0
  18. localstack_cli/packages/api.py +418 -0
  19. localstack_cli/packages/core.py +416 -0
  20. localstack_cli/pro/__init__.py +0 -0
  21. localstack_cli/pro/core/__init__.py +0 -0
  22. localstack_cli/pro/core/bootstrap/__init__.py +1 -0
  23. localstack_cli/pro/core/bootstrap/auth.py +213 -0
  24. localstack_cli/pro/core/bootstrap/dns_utils.py +55 -0
  25. localstack_cli/pro/core/bootstrap/entitlements.py +117 -0
  26. localstack_cli/pro/core/bootstrap/extensions/__init__.py +3 -0
  27. localstack_cli/pro/core/bootstrap/extensions/__main__.py +106 -0
  28. localstack_cli/pro/core/bootstrap/extensions/autoinstall.py +63 -0
  29. localstack_cli/pro/core/bootstrap/extensions/bootstrap.py +97 -0
  30. localstack_cli/pro/core/bootstrap/extensions/repository.py +374 -0
  31. localstack_cli/pro/core/bootstrap/licensingv2.py +1259 -0
  32. localstack_cli/pro/core/bootstrap/pods/__init__.py +0 -0
  33. localstack_cli/pro/core/bootstrap/pods/api_types.py +17 -0
  34. localstack_cli/pro/core/bootstrap/pods/constants.py +26 -0
  35. localstack_cli/pro/core/bootstrap/pods/remotes/__init__.py +0 -0
  36. localstack_cli/pro/core/bootstrap/pods/remotes/api.py +75 -0
  37. localstack_cli/pro/core/bootstrap/pods/remotes/configs.py +69 -0
  38. localstack_cli/pro/core/bootstrap/pods/remotes/params.py +86 -0
  39. localstack_cli/pro/core/bootstrap/pods_client.py +834 -0
  40. localstack_cli/pro/core/cli/__init__.py +0 -0
  41. localstack_cli/pro/core/cli/auth.py +226 -0
  42. localstack_cli/pro/core/cli/aws.py +16 -0
  43. localstack_cli/pro/core/cli/cli.py +99 -0
  44. localstack_cli/pro/core/cli/click_utils.py +21 -0
  45. localstack_cli/pro/core/cli/cloud_pods.py +465 -0
  46. localstack_cli/pro/core/cli/diff_view.py +41 -0
  47. localstack_cli/pro/core/cli/ephemeral.py +199 -0
  48. localstack_cli/pro/core/cli/extensions.py +492 -0
  49. localstack_cli/pro/core/cli/iam.py +180 -0
  50. localstack_cli/pro/core/cli/license.py +90 -0
  51. localstack_cli/pro/core/cli/localstack.py +118 -0
  52. localstack_cli/pro/core/cli/replicator.py +378 -0
  53. localstack_cli/pro/core/cli/state.py +183 -0
  54. localstack_cli/pro/core/cli/tree_view.py +235 -0
  55. localstack_cli/pro/core/config.py +556 -0
  56. localstack_cli/pro/core/constants.py +54 -0
  57. localstack_cli/pro/core/plugins.py +169 -0
  58. localstack_cli/runtime/__init__.py +6 -0
  59. localstack_cli/runtime/exceptions.py +7 -0
  60. localstack_cli/runtime/hooks.py +73 -0
  61. localstack_cli/testing/__init__.py +1 -0
  62. localstack_cli/testing/config.py +4 -0
  63. localstack_cli/utils/__init__.py +0 -0
  64. localstack_cli/utils/analytics/__init__.py +12 -0
  65. localstack_cli/utils/analytics/cli.py +67 -0
  66. localstack_cli/utils/analytics/client.py +111 -0
  67. localstack_cli/utils/analytics/events.py +30 -0
  68. localstack_cli/utils/analytics/logger.py +48 -0
  69. localstack_cli/utils/analytics/metadata.py +250 -0
  70. localstack_cli/utils/analytics/publisher.py +160 -0
  71. localstack_cli/utils/analytics/service_request_aggregator.py +133 -0
  72. localstack_cli/utils/archives.py +271 -0
  73. localstack_cli/utils/batching.py +258 -0
  74. localstack_cli/utils/bootstrap.py +1418 -0
  75. localstack_cli/utils/checksum.py +313 -0
  76. localstack_cli/utils/collections.py +554 -0
  77. localstack_cli/utils/common.py +229 -0
  78. localstack_cli/utils/container_networking.py +142 -0
  79. localstack_cli/utils/container_utils/__init__.py +0 -0
  80. localstack_cli/utils/container_utils/container_client.py +1585 -0
  81. localstack_cli/utils/container_utils/docker_cmd_client.py +987 -0
  82. localstack_cli/utils/container_utils/docker_sdk_client.py +1018 -0
  83. localstack_cli/utils/crypto.py +294 -0
  84. localstack_cli/utils/docker_utils.py +272 -0
  85. localstack_cli/utils/files.py +327 -0
  86. localstack_cli/utils/functions.py +92 -0
  87. localstack_cli/utils/http.py +326 -0
  88. localstack_cli/utils/json.py +219 -0
  89. localstack_cli/utils/net.py +516 -0
  90. localstack_cli/utils/no_exit_argument_parser.py +19 -0
  91. localstack_cli/utils/numbers.py +49 -0
  92. localstack_cli/utils/objects.py +235 -0
  93. localstack_cli/utils/patch.py +260 -0
  94. localstack_cli/utils/platform.py +77 -0
  95. localstack_cli/utils/run.py +514 -0
  96. localstack_cli/utils/server/__init__.py +0 -0
  97. localstack_cli/utils/server/tcp_proxy.py +108 -0
  98. localstack_cli/utils/serving.py +187 -0
  99. localstack_cli/utils/ssl.py +71 -0
  100. localstack_cli/utils/strings.py +245 -0
  101. localstack_cli/utils/sync.py +267 -0
  102. localstack_cli/utils/threads.py +163 -0
  103. localstack_cli/utils/time.py +81 -0
  104. localstack_cli/utils/urls.py +21 -0
  105. localstack_cli/utils/venv.py +100 -0
  106. localstack_cli/utils/xml.py +41 -0
  107. localstack_cli/version.py +34 -0
  108. playground_ls_cli-4.14.1.dev8.dist-info/METADATA +95 -0
  109. playground_ls_cli-4.14.1.dev8.dist-info/RECORD +112 -0
  110. playground_ls_cli-4.14.1.dev8.dist-info/WHEEL +5 -0
  111. playground_ls_cli-4.14.1.dev8.dist-info/entry_points.txt +17 -0
  112. playground_ls_cli-4.14.1.dev8.dist-info/top_level.txt +1 -0
@@ -0,0 +1,229 @@
1
+ from localstack_cli import config
2
+
3
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
4
+ from localstack_cli.utils.archives import get_unzipped_size, is_zip_file, untar, unzip # noqa
5
+
6
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
7
+ from localstack_cli.utils.collections import ( # noqa
8
+ DelSafeDict,
9
+ HashableList,
10
+ PaginatedList,
11
+ ensure_list,
12
+ is_list_or_tuple,
13
+ is_none_or_empty,
14
+ is_sub_dict,
15
+ items_equivalent,
16
+ last_index_of,
17
+ merge_dicts,
18
+ merge_recursive,
19
+ remove_attributes,
20
+ remove_none_values_from_dict,
21
+ rename_attributes,
22
+ select_attributes,
23
+ to_unique_items_list,
24
+ )
25
+
26
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
27
+ from localstack_cli.utils.crypto import ( # noqa
28
+ PEM_CERT_END,
29
+ PEM_CERT_START,
30
+ PEM_KEY_END_REGEX,
31
+ PEM_KEY_START_REGEX,
32
+ generate_ssl_cert,
33
+ )
34
+
35
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
36
+ from localstack_cli.utils.files import ( # noqa
37
+ TMP_FILES,
38
+ chmod_r,
39
+ chown_r,
40
+ cleanup_tmp_files,
41
+ cp_r,
42
+ disk_usage,
43
+ ensure_readable,
44
+ file_exists_not_empty,
45
+ get_or_create_file,
46
+ is_empty_dir,
47
+ load_file,
48
+ mkdir,
49
+ new_tmp_dir,
50
+ new_tmp_file,
51
+ replace_in_file,
52
+ rm_rf,
53
+ save_file,
54
+ )
55
+
56
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
57
+ from localstack_cli.utils.functions import ( # noqa
58
+ call_safe,
59
+ empty_context_manager,
60
+ prevent_stack_overflow,
61
+ run_safe,
62
+ )
63
+
64
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
65
+ from localstack_cli.utils.http import ( # noqa
66
+ NetrcBypassAuth,
67
+ _RequestsSafe,
68
+ download,
69
+ get_proxies,
70
+ make_http_request,
71
+ parse_request_data,
72
+ replace_response_content,
73
+ safe_requests,
74
+ )
75
+
76
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
77
+ from localstack_cli.utils.json import ( # noqa
78
+ CustomEncoder,
79
+ FileMappedDocument,
80
+ assign_to_path,
81
+ canonical_json,
82
+ clone,
83
+ clone_safe,
84
+ extract_from_jsonpointer_path,
85
+ extract_jsonpath,
86
+ fix_json_keys,
87
+ json_safe,
88
+ parse_json_or_yaml,
89
+ try_json,
90
+ )
91
+
92
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
93
+ from localstack_cli.utils.net import ( # noqa
94
+ PortNotAvailableException,
95
+ PortRange,
96
+ get_free_tcp_port,
97
+ is_ip_address,
98
+ is_ipv4_address,
99
+ is_port_open,
100
+ port_can_be_bound,
101
+ resolve_hostname,
102
+ wait_for_port_closed,
103
+ wait_for_port_open,
104
+ wait_for_port_status,
105
+ )
106
+
107
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
108
+ from localstack_cli.utils.numbers import format_bytes, format_number, is_number # noqa
109
+
110
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
111
+ from localstack_cli.utils.objects import ( # noqa
112
+ ArbitraryAccessObj,
113
+ Mock,
114
+ ObjectIdHashComparator,
115
+ SubtypesInstanceManager,
116
+ fully_qualified_class_name,
117
+ get_all_subclasses,
118
+ keys_to_lower,
119
+ not_none_or,
120
+ recurse_object,
121
+ )
122
+
123
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
124
+ from localstack_cli.utils.platform import ( # noqa
125
+ get_arch,
126
+ get_os,
127
+ in_docker,
128
+ is_debian,
129
+ is_linux,
130
+ is_mac_os,
131
+ is_windows,
132
+ )
133
+
134
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
135
+ from localstack_cli.utils.run import ( # noqa
136
+ CaptureOutput,
137
+ ShellCommandThread,
138
+ get_os_user,
139
+ is_command_available,
140
+ is_root,
141
+ kill_process_tree,
142
+ run,
143
+ run_for_max_seconds,
144
+ )
145
+
146
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
147
+ from localstack_cli.utils.strings import ( # noqa
148
+ base64_to_hex,
149
+ camel_to_snake_case,
150
+ canonicalize_bool_to_str,
151
+ convert_to_printable_chars,
152
+ first_char_to_lower,
153
+ first_char_to_upper,
154
+ is_base64,
155
+ is_string,
156
+ is_string_or_bytes,
157
+ long_uid,
158
+ md5,
159
+ short_uid,
160
+ short_uid_from_seed,
161
+ snake_to_camel_case,
162
+ str_insert,
163
+ str_remove,
164
+ str_startswith_ignore_case,
165
+ str_to_bool,
166
+ to_bytes,
167
+ to_str,
168
+ truncate,
169
+ )
170
+
171
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
172
+ from localstack_cli.utils.sync import ( # noqa
173
+ poll_condition,
174
+ retry,
175
+ sleep_forever,
176
+ synchronized,
177
+ wait_until,
178
+ )
179
+
180
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
181
+ from localstack_cli.utils.threads import ( # noqa
182
+ TMP_PROCESSES,
183
+ TMP_THREADS,
184
+ FuncThread,
185
+ cleanup_threads_and_processes,
186
+ parallelize,
187
+ start_thread,
188
+ start_worker_thread,
189
+ )
190
+
191
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
192
+ from localstack_cli.utils.time import ( # noqa
193
+ TIMESTAMP_FORMAT,
194
+ TIMESTAMP_FORMAT_MICROS,
195
+ TIMESTAMP_FORMAT_TZ,
196
+ epoch_timestamp,
197
+ isoformat_milliseconds,
198
+ mktime,
199
+ now,
200
+ now_utc,
201
+ parse_timestamp,
202
+ timestamp,
203
+ timestamp_millis,
204
+ )
205
+
206
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
207
+ from localstack_cli.utils.urls import path_from_url # noqa
208
+
209
+ # TODO: remove imports from here (need to update any client code that imports these from utils.common)
210
+ from localstack_cli.utils.xml import obj_to_xml, strip_xmlns # noqa
211
+
212
+
213
+ # TODO: move somewhere sensible (probably localstack.runtime)
214
+ class ExternalServicePortsManager(PortRange):
215
+ """Manages the ports used for starting external services like ElasticSearch, OpenSearch,..."""
216
+
217
+ def __init__(self):
218
+ super().__init__(config.EXTERNAL_SERVICE_PORTS_START, config.EXTERNAL_SERVICE_PORTS_END)
219
+
220
+
221
+ external_service_ports = ExternalServicePortsManager()
222
+ """The PortRange object of LocalStack's external service port range. This port range is by default exposed by the
223
+ localstack container when starting via the CLI."""
224
+
225
+ # TODO: replace references with config.get_protocol/config.edge_ports_info
226
+ get_service_protocol = config.get_protocol
227
+
228
+ # TODO: replace references to safe_run with localstack.utils.run.run
229
+ safe_run = run
@@ -0,0 +1,142 @@
1
+ import logging
2
+ import os
3
+ import re
4
+ from functools import lru_cache
5
+
6
+ from localstack_cli import config, constants
7
+ from localstack_cli.utils.container_utils.container_client import ContainerException
8
+ from localstack_cli.utils.docker_utils import DOCKER_CLIENT
9
+ from localstack_cli.utils.net import get_docker_host_from_container
10
+
11
+ LOG = logging.getLogger(__name__)
12
+
13
+
14
+ @lru_cache
15
+ def get_main_container_network() -> str | None:
16
+ """
17
+ Gets the main network of the LocalStack container (if we run in one, bridge otherwise)
18
+ If there are multiple networks connected to the LocalStack container, we choose the first as "main" network
19
+
20
+ :return: Network name
21
+ """
22
+ if config.MAIN_DOCKER_NETWORK:
23
+ if config.is_in_docker:
24
+ networks = DOCKER_CLIENT.get_networks(get_main_container_name())
25
+ if config.MAIN_DOCKER_NETWORK not in networks:
26
+ LOG.warning(
27
+ "The specified 'MAIN_DOCKER_NETWORK' is not connected to the LocalStack container! Falling back to %s",
28
+ networks[0],
29
+ )
30
+ return networks[0]
31
+ return config.MAIN_DOCKER_NETWORK
32
+
33
+ # use the default bridge network in case of host mode or if we can't resolve the networks for the main container
34
+ main_container_network = "bridge"
35
+ if config.is_in_docker:
36
+ try:
37
+ networks = DOCKER_CLIENT.get_networks(get_main_container_name())
38
+ main_container_network = networks[0]
39
+ except Exception as e:
40
+ container_name = get_main_container_name()
41
+ LOG.info(
42
+ 'Unable to get network name of main container "%s", falling back to "bridge": %s',
43
+ container_name,
44
+ e,
45
+ )
46
+
47
+ LOG.info("Determined main container network: %s", main_container_network)
48
+ return main_container_network
49
+
50
+
51
+ @lru_cache
52
+ def get_endpoint_for_network(network: str | None = None) -> str:
53
+ """
54
+ Get the LocalStack endpoint (= IP address) on the given network.
55
+ If a network is given, it will return the IP address/hostname of LocalStack on that network
56
+ If omitted, it will return the IP address/hostname of the main container network
57
+ This is a cached call, clear cache if networks might have changed
58
+
59
+ :param network: Network to return the endpoint for
60
+ :return: IP address or hostname of LS on the given network
61
+ """
62
+ container_name = get_main_container_name()
63
+ network = network or get_main_container_network()
64
+ main_container_ip = None
65
+ try:
66
+ if config.is_in_docker:
67
+ main_container_ip = DOCKER_CLIENT.get_container_ipv4_for_network(
68
+ container_name_or_id=container_name,
69
+ container_network=network,
70
+ )
71
+ else:
72
+ # default gateway for the network should be the host
73
+ # In a Linux host-mode environment, the default gateway for the network should be the IP of the host
74
+ if config.is_in_linux:
75
+ main_container_ip = DOCKER_CLIENT.inspect_network(network)["IPAM"]["Config"][0][
76
+ "Gateway"
77
+ ]
78
+ else:
79
+ # In a non-Linux host-mode environment, we need to determine the IP of the host by running a container
80
+ # (basically macOS host mode, i.e. this is a feature to improve the developer experience)
81
+ image_name = constants.DOCKER_IMAGE_NAME_PRO
82
+ out, _ = DOCKER_CLIENT.run_container(
83
+ image_name,
84
+ remove=True,
85
+ entrypoint="",
86
+ command=["ping", "-c", "1", "host.docker.internal"],
87
+ )
88
+ out = out.decode(config.DEFAULT_ENCODING) if isinstance(out, bytes) else out
89
+ ip = re.match(r"PING[^\(]+\(([^\)]+)\).*", out, re.MULTILINE | re.DOTALL)
90
+ ip = ip and ip.group(1)
91
+ if ip:
92
+ main_container_ip = ip
93
+ LOG.info("Determined main container target IP: %s", main_container_ip)
94
+ except Exception as e:
95
+ LOG.info("Unable to get main container IP address: %s", e)
96
+
97
+ if not main_container_ip:
98
+ # fall back to returning the hostname/IP of the Docker host, if we cannot determine the main container IP
99
+ return get_docker_host_from_container()
100
+
101
+ return main_container_ip
102
+
103
+
104
+ def get_main_container_ip():
105
+ """
106
+ Get the container IP address of the LocalStack container.
107
+ Use get_endpoint_for network where possible, as it allows better control about which address to return
108
+
109
+ :return: IP address of LocalStack container
110
+ """
111
+ container_name = get_main_container_name()
112
+ return DOCKER_CLIENT.get_container_ip(container_name)
113
+
114
+
115
+ def get_main_container_id():
116
+ """
117
+ Return the container ID of the LocalStack container
118
+
119
+ :return: container ID
120
+ """
121
+ container_name = get_main_container_name()
122
+ try:
123
+ return DOCKER_CLIENT.get_container_id(container_name)
124
+ except ContainerException:
125
+ return None
126
+
127
+
128
+ @lru_cache
129
+ def get_main_container_name():
130
+ """
131
+ Returns the container name of the LocalStack container
132
+
133
+ :return: LocalStack container name
134
+ """
135
+ hostname = os.environ.get("HOSTNAME")
136
+ if hostname:
137
+ try:
138
+ return DOCKER_CLIENT.get_container_name(hostname)
139
+ except ContainerException:
140
+ return config.MAIN_CONTAINER_NAME
141
+ else:
142
+ return config.MAIN_CONTAINER_NAME
File without changes