diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3938a79..559c701 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -45,16 +45,17 @@ jobs: # current version VERSION=`hatch version` if [[ $VERSION == *dev* ]]; then - echo "This is a dev version: $VERSION" - hatch version dev + echo "This is a dev version: $VERSION" + hatch version dev elif [[ $VERSION == *rc* ]]; then - echo "This is a RC version: $VERSION,\n only use dev and release ones" - exit 1 + echo "This is a RC version: $VERSION,\n only use dev and release ones" + exit 1 else - # simple version are created manually from code edits. - echo "This is a simple version: $VERSION, we have released it, converting into next dev." - hatch version patch - hatch version dev + # simple version are created manually from code edits. + echo "This is a simple version: $VERSION, we have released it, converting into next dev." + #hatch version patch + hatch version minor # TODO: we are using MINOR and increasing minor versions until v1.0 + hatch version dev fi NEW_VERSION=`hatch version` git add src/hckr/__about__.py diff --git a/pyproject.toml b/pyproject.toml index b89351e..28d54f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,10 @@ dependencies = [ "psycopg2-binary", # for Postgres "pymysql", # for MySQL # "sqlite", # for SQLITE - "snowflake-sqlalchemy", # For Snowflake + "snowflake-sqlalchemy", # For Snowflake, + + # Error and debugging + "sentry-sdk" ] [project.urls] diff --git a/src/hckr/__about__.py b/src/hckr/__about__.py index 2d1040c..f3dc93f 100644 --- a/src/hckr/__about__.py +++ b/src/hckr/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2024-present Ashish Patel # # SPDX-License-Identifier: MIT -__version__ = "0.4.1.dev0" +__version__ = "0.5.0.dev0" diff --git a/src/hckr/cli/__init__.py b/src/hckr/cli/__init__.py index 84fc654..0575694 100644 --- a/src/hckr/cli/__init__.py +++ b/src/hckr/cli/__init__.py @@ -13,6 +13,7 @@ from hckr.cli.k8s.context import context from hckr.cli.k8s.namespace import namespace from hckr.cli.k8s.pod import pod +from hckr.utils import CliUtils from .crypto.fernet import fernet from .data import data from .info import info @@ -22,26 +23,12 @@ from ..cli.cron import cron from ..cli.crypto import crypto from ..cli.hash import hash -from ..utils.CliUtils import check_update +from ..utils.CliUtils import check_update, Info, LOGGING_LEVELS from ..utils.MessageUtils import warning -LOGGING_LEVELS = { - 0: logging.NOTSET, - # 1: logging.ERROR, - # 2: logging.WARN, - 1: logging.INFO, - 2: logging.DEBUG, -} #: a mapping of `verbose` option counts to logging levels - - -# Define a format for the console handler -class Info: - """An information object to pass data between CLI functions.""" - - def __init__(self): # Note: This object must have an empty constructor. - """Create a new instance.""" - self.verbose: int = 0 +# sentry logging and monitoring +CliUtils.sentry_init() # pass_info is a decorator for functions that pass 'Info' objects. pass_info = click.make_pass_decorator(Info, ensure=True) diff --git a/src/hckr/cli/env.py b/src/hckr/cli/env.py index b831694..3005d63 100644 --- a/src/hckr/cli/env.py +++ b/src/hckr/cli/env.py @@ -3,7 +3,7 @@ import click from ..utils import MessageUtils -from ..utils.EnvUtils import list_env, set_env +from ..utils.EnvUtils import list_env, set_env, DEFAULT_PATTERN from ..utils.MessageUtils import PSuccess, PError @@ -84,7 +84,7 @@ def get(variable): @env.command("list") -@click.option("-p", "--pattern", required=False, default=".*") +@click.option("-p", "--pattern", required=False, default=DEFAULT_PATTERN) @click.option("-i", "--ignore-case", is_flag=True, help="Ignore case distinctions.") def env_list(pattern, ignore_case): """ @@ -113,5 +113,10 @@ def env_list(pattern, ignore_case): **Command Reference**: """ - MessageUtils.info("Listing all environment variables") + if pattern == DEFAULT_PATTERN: + MessageUtils.info("Listing all environment variables") + else: + MessageUtils.info( + f"Listing environment variables, filtering with regex pattern '[green]{pattern}[/green]'" + ) list_env(pattern, ignore_case) diff --git a/src/hckr/utils/CliUtils.py b/src/hckr/utils/CliUtils.py index 388e854..ba4ccd2 100644 --- a/src/hckr/utils/CliUtils.py +++ b/src/hckr/utils/CliUtils.py @@ -6,10 +6,29 @@ from rich.panel import Panel from .MessageUtils import colored, success, warning +from .config.Constants import SENTRY_DSN from ..__about__ import __version__ import platform +LOGGING_LEVELS = { + 0: logging.NOTSET, + # 1: logging.ERROR, + # 2: logging.WARN, + 1: logging.INFO, + 2: logging.DEBUG, +} #: a mapping of `verbose` option counts to logging levels + + +# Define a format for the console handler +class Info: + """An information object to pass data between CLI functions.""" + + def __init__(self): # Note: This object must have an empty constructor. + """Create a new instance.""" + self.verbose: int = 0 + + def check_latest_version(): current_version = __version__ try: @@ -57,3 +76,18 @@ def check_update(show_no_update=False): success( f"Success: You are using latest version {colored(__version__, 'magenta')}" ) + + +def sentry_init(): + import sentry_sdk + + sentry_sdk.init( + dsn=SENTRY_DSN, + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for tracing. + traces_sample_rate=1.0, + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + profiles_sample_rate=1.0, + ) diff --git a/src/hckr/utils/EnvUtils.py b/src/hckr/utils/EnvUtils.py index a70b3ea..dac902c 100644 --- a/src/hckr/utils/EnvUtils.py +++ b/src/hckr/utils/EnvUtils.py @@ -5,6 +5,8 @@ from . import MessageUtils from .MessageUtils import PError, PSuccess, PWarn +DEFAULT_PATTERN = ".*" + def list_env(pattern, ignore_case): """List all environment variables, optionally filtering by a pattern.""" diff --git a/src/hckr/utils/config/Constants.py b/src/hckr/utils/config/Constants.py index 699348e..0ad59c5 100644 --- a/src/hckr/utils/config/Constants.py +++ b/src/hckr/utils/config/Constants.py @@ -47,3 +47,6 @@ def __str__(self): DB_ACCOUNT = "account" DB_ROLE = "role" DB_WAREHOUSE = "warehouse" + +# SENTRY +SENTRY_DSN = "https://b549c324ba6054fc68c4e3cd3bb146e4@o4507910058213376.ingest.us.sentry.io/4507910060572672"