Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ jobs:
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 patch
hatch version minor # TODO: we are using MINOR and increasing minor versions until v1.0
hatch version dev
fi
NEW_VERSION=`hatch version`
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/hckr/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present Ashish Patel <ashishpatel0720@gmail.com>
#
# SPDX-License-Identifier: MIT
__version__ = "0.4.1.dev0"
__version__ = "0.5.0"
21 changes: 4 additions & 17 deletions src/hckr/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions src/hckr/cli/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
34 changes: 34 additions & 0 deletions src/hckr/utils/CliUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
)
Comment thread
pateash marked this conversation as resolved.
2 changes: 2 additions & 0 deletions src/hckr/utils/EnvUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 3 additions & 0 deletions src/hckr/utils/config/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
pateash marked this conversation as resolved.