Skip to content

Commit

Permalink
Merge dev into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DinisCruz committed Nov 23, 2024
2 parents 1690c17 + 1470ba9 commit 6c46801
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Repo details

![Current Release](https://img.shields.io/badge/release-v0.3.0-blue)
![Current Release](https://img.shields.io/badge/release-v0.3.1-blue)
11 changes: 8 additions & 3 deletions osbot_local_stack/local_stack/Local_Stack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from osbot_aws.aws.s3.S3 import S3
from osbot_aws.AWS_Config import ENV_NAME__AWS_ENDPOINT_URL
from osbot_local_stack.local_stack.Local_Stack__Internal import Local_Stack__Internal, DEFAULT__LOCAL_STACK__TARGET_SERVER
from osbot_utils.utils.Env import get_env, set_env, del_env
from osbot_utils.base_classes.Type_Safe import Type_Safe

class Local_Stack(Type_Safe):
Expand All @@ -18,12 +15,18 @@ def __exit__(self, exc_type, exc_val, exc_tb):


def activate(self):
from osbot_aws.AWS_Config import ENV_NAME__AWS_ENDPOINT_URL
from osbot_utils.utils.Env import get_env, set_env

endpoint_url = self.local_stack__internal.endpoint_url
self.endpoint_url__saved = get_env(ENV_NAME__AWS_ENDPOINT_URL)
set_env(ENV_NAME__AWS_ENDPOINT_URL, endpoint_url)
return self

def deactivate(self):
from osbot_aws.AWS_Config import ENV_NAME__AWS_ENDPOINT_URL
from osbot_utils.utils.Env import set_env, del_env

if self.endpoint_url__saved is None:
del_env(ENV_NAME__AWS_ENDPOINT_URL)
else:
Expand All @@ -34,6 +37,8 @@ def check__local_stack__health(self):
return self.local_stack__internal.get__internal_health() != {}

def check__local_stack__boto3_setup(self):
from osbot_aws.aws.s3.S3 import S3

return S3().client().meta.endpoint_url == DEFAULT__LOCAL_STACK__TARGET_SERVER # use S3 since this is the one that is currently working correctly

def is_local_stack_configured_and_available(self):
Expand Down
23 changes: 13 additions & 10 deletions osbot_local_stack/local_stack/Local_Stack__Internal.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import requests
from requests import RequestException

from osbot_utils.utils.Objects import dict_to_obj

from osbot_utils.utils.Http import url_join_safe

from osbot_utils.utils.Env import get_env

from osbot_utils.base_classes.Type_Safe import Type_Safe

ENV_NAME__LOCAL_STACK__TARGET_SERVER = 'LOCAL_STACK__TARGET_SERVER'
DEFAULT__LOCAL_STACK__TARGET_SERVER = 'http://localhost:4566'

# see full list at https://docs.localstack.cloud/references/internal-endpoints/

class Local_Stack__Internal(Type_Safe):
endpoint_url: str = get_env(ENV_NAME__LOCAL_STACK__TARGET_SERVER, DEFAULT__LOCAL_STACK__TARGET_SERVER)
endpoint_url: str = None

def __init__(self, **kwargs):
from osbot_utils.utils.Env import get_env

super().__init__(**kwargs)
self.endpoint_url = get_env(ENV_NAME__LOCAL_STACK__TARGET_SERVER, DEFAULT__LOCAL_STACK__TARGET_SERVER)

def get__aws_lambda_runtimes(self):
return self.requests__aws__get('lambda/runtimes')
Expand All @@ -40,6 +38,11 @@ def requests__internal__get(self, action):
return self.requests__get(path)

def requests__get(self, path):
import requests
from requests import RequestException
from osbot_utils.utils.Objects import dict_to_obj
from osbot_utils.utils.Http import url_join_safe

try:
url = url_join_safe(self.endpoint_url, path)
json_data = requests.get(url).json()
Expand Down
2 changes: 1 addition & 1 deletion osbot_local_stack/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.3.0
v0.3.1
32 changes: 16 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "osbot_local_stack"
version = "v0.3.0"
version = "v0.3.1"
description = "OWASP Security Bot - LLM"
authors = ["Dinis Cruz <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/local_stack/test_Local_Stack__Internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def test_get__internal_health(self):
assert getattr(health.services, 'resource-groups') == 'disabled' # name has a - in it
for service_name in expected_available_services:
assert getattr(health.services,service_name) in ['available', 'running']
assert health.version.startswith('3.8.') is True

#assert health.version.startswith('3.8.') is True

# skipping this since there were a couple inconsistencies in the data when running this in GH Actions
#delattr(obj_data.services, 'lambda' )
#delattr(obj_data.services, 'resource-groups')
Expand Down

0 comments on commit 6c46801

Please sign in to comment.