Skip to content

Commit

Permalink
migrate imports from localstack_ext to localstack.pro.core (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrashed authored Jul 17, 2024
1 parent 794cf6a commit ea21a52
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 14 deletions.
2 changes: 2 additions & 0 deletions aws-replicator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ localstack extensions install "git+https://github.com/localstack/localstack-exte

## Change Log

* `0.1.16`: Update imports for localstack >=3.6 compatibility
* `0.1.15`: Move localstack dependency installation to extra since it's provided at runtime
* `0.1.14`: Install missing dependencies into proxy container for localstack >=3.4 compatibility
* `0.1.13`: Add compatibility with localstack >=3.4; add http2-server; migrate to localstack auth login
* `0.1.12`: Modify aws credentials text field type to password
Expand Down
13 changes: 12 additions & 1 deletion aws-replicator/aws_replicator/client/auth_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from localstack.utils.net import get_docker_host_from_container, get_free_tcp_port
from localstack.utils.serving import Server
from localstack.utils.strings import short_uid, to_bytes, to_str, truncate
from localstack_ext.bootstrap.licensingv2 import ENV_LOCALSTACK_API_KEY, ENV_LOCALSTACK_AUTH_TOKEN
from requests import Response

from aws_replicator import config as repl_config
Expand All @@ -38,6 +37,18 @@

from .http2_server import run_server

try:
from localstack.pro.core.bootstrap.licensingv2 import (
ENV_LOCALSTACK_API_KEY,
ENV_LOCALSTACK_AUTH_TOKEN,
)
except ImportError:
# TODO remove once we don't need compatibility with <3.6 anymore
from localstack_ext.bootstrap.licensingv2 import (
ENV_LOCALSTACK_API_KEY,
ENV_LOCALSTACK_AUTH_TOKEN,
)

LOG = logging.getLogger(__name__)
LOG.setLevel(logging.INFO)
if config.DEBUG:
Expand Down
13 changes: 10 additions & 3 deletions aws-replicator/aws_replicator/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
from localstack.cli import LocalstackCli, LocalstackCliPlugin, console
from localstack.logging.setup import setup_logging
from localstack.utils.files import load_file
from localstack_ext.bootstrap.auth import get_auth_headers
from localstack_ext.cli.aws import aws
from localstack_ext.config import is_api_key_configured

from aws_replicator.shared.models import ProxyConfig, ProxyServiceConfig

try:
from localstack.pro.core.bootstrap.auth import get_auth_headers
from localstack.pro.core.cli.aws import aws
from localstack.pro.core.config import is_api_key_configured
except ImportError:
# TODO remove once we don't need compatibility with <3.6 anymore
from localstack_ext.bootstrap.auth import get_auth_headers
from localstack_ext.cli.aws import aws
from localstack_ext.config import is_api_key_configured


class AwsReplicatorPlugin(LocalstackCliPlugin):
name = "aws-replicator"
Expand Down
12 changes: 9 additions & 3 deletions aws-replicator/aws_replicator/server/resource_replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ def _get_cf_model_class(self, resource: Dict) -> Optional[Type]:

def _load_resource_models(self):
if not hasattr(template_deployer, "_ls_patch_applied"):
from localstack_ext.services.cloudformation.cloudformation_extended import (
patch_cloudformation,
)
try:
from localstack.pro.core.services.cloudformation.cloudformation_extended import (
patch_cloudformation,
)
except ImportError:
# TODO remove once we don't need compatibility with <3.6 anymore
from localstack_ext.services.cloudformation.cloudformation_extended import (
patch_cloudformation,
)

patch_cloudformation()
template_deployer._ls_patch_applied = True
Expand Down
2 changes: 1 addition & 1 deletion aws-replicator/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = localstack-extension-aws-replicator
version = 0.1.14
version = 0.1.16
summary = LocalStack Extension: AWS replicator
description = Replicate AWS resources into your LocalStack instance
long_description = file: README.md
Expand Down
15 changes: 10 additions & 5 deletions mailhog/mailhog/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

from localstack import config, constants
from localstack.extensions.api import Extension, http
from localstack_ext import config as config_ext

try:
from localstack.pro.core import config as config_pro
except ImportError:
# TODO remove once we don't need compatibility with <3.6 anymore
from localstack_ext import config as config_pro

if TYPE_CHECKING:
# conditional import for type checking during development. the actual import is deferred to plugin loading
Expand Down Expand Up @@ -57,10 +62,10 @@ def on_platform_start(self):
LOG.info("starting mailhog server")
self.server.start()

if not config_ext.SMTP_HOST:
config_ext.SMTP_HOST = f"localhost:{self.server.smtp_port}"
os.environ["SMTP_HOST"] = config_ext.SMTP_HOST
LOG.info("configuring SMTP host to internal mailhog smtp: %s", config_ext.SMTP_HOST)
if not config_pro.SMTP_HOST:
config_pro.SMTP_HOST = f"localhost:{self.server.smtp_port}"
os.environ["SMTP_HOST"] = config_pro.SMTP_HOST
LOG.info("configuring SMTP host to internal mailhog smtp: %s", config_pro.SMTP_HOST)

def on_platform_ready(self):
# FIXME: reconcile with LOCALSTACK_HOST. the URL should be reachable from the host (the idea is
Expand Down
1 change: 1 addition & 0 deletions mailhog/mailhog/package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Package for mailhog that downloads the mailhog binary from https://github.com/mailhog/MailHog.
"""

import os
from functools import lru_cache

Expand Down
1 change: 1 addition & 0 deletions mailhog/mailhog/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tools to run the mailhog service.
"""

import logging
import os

Expand Down
2 changes: 1 addition & 1 deletion mailhog/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = localstack-extension-mailhog
version = 0.1.0
version = 0.1.2
url = https://github.com/localstack/localstack-extensions/tree/main/mailhog
author = LocalStack
author_email = [email protected]
Expand Down

0 comments on commit ea21a52

Please sign in to comment.