From ac117c51694b41972226572be41bdee7c27882cf Mon Sep 17 00:00:00 2001 From: "Zak B. Elep" Date: Wed, 13 Oct 2021 22:44:04 +0800 Subject: [PATCH] awslimitchecker: init at 12.0.0 --- pkgs/tools/admin/awslimitchecker/default.nix | 58 +++++++++++++++++++ .../tools/admin/awslimitchecker/version.patch | 35 +++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 95 insertions(+) create mode 100644 pkgs/tools/admin/awslimitchecker/default.nix create mode 100644 pkgs/tools/admin/awslimitchecker/version.patch diff --git a/pkgs/tools/admin/awslimitchecker/default.nix b/pkgs/tools/admin/awslimitchecker/default.nix new file mode 100644 index 000000000000..54cf59942233 --- /dev/null +++ b/pkgs/tools/admin/awslimitchecker/default.nix @@ -0,0 +1,58 @@ +{ lib, python3Packages, fetchFromGitHub }: + +python3Packages.buildPythonApplication rec { + pname = "awslimitchecker"; + version = "12.0.0"; + + src = fetchFromGitHub { + owner = "jantman"; + repo = "awslimitchecker"; + rev = version; + sha256 = "1p6n4kziyl6sfq7vgga9v88ddwh3sgnfb1m1cx6q25n0wyl7phgv"; + }; + + propagatedBuildInputs = with python3Packages; [ + boto3 + botocore + pytz + termcolor + versionfinder + ]; + + checkInputs = with python3Packages; [ + freezegun + onetimepass + pytestCheckHook + pyotp + testfixtures + ]; + + patches = [ + # Fix the version lookup to use only the hardcoded version in the source package + ./version.patch + ]; + + pytestFlagsArray = [ + "awslimitchecker/tests" + ]; + + disabledTestPaths = [ + # AWS tests that use the network + "awslimitchecker/tests/services" + "awslimitchecker/tests/test_checker.py" + "awslimitchecker/tests/test_runner.py" + + # the version lookup tests as patched above + "awslimitchecker/tests/test_version.py" + ]; + + pythonImportsCheck = [ "awslimitchecker.checker" ]; + + meta = with lib; { + homepage = "http://awslimitchecker.readthedocs.org"; + changelog = "https://github.com/jantman/awslimitchecker/blob/${version}/CHANGES.rst"; + description = "A script and python package to check your AWS service limits and usage via boto3"; + license = licenses.agpl3Plus; + maintainers = with maintainers; [ zakame ]; + }; +} diff --git a/pkgs/tools/admin/awslimitchecker/version.patch b/pkgs/tools/admin/awslimitchecker/version.patch new file mode 100644 index 000000000000..6556fb39a5f2 --- /dev/null +++ b/pkgs/tools/admin/awslimitchecker/version.patch @@ -0,0 +1,35 @@ +--- a/awslimitchecker/version.py ++++ b/awslimitchecker/version.py +@@ -111,32 +106,5 @@ def _get_version_info(): + :returns: awslimitchecker version + :rtype: str + """ +- if os.environ.get('VERSIONCHECK_DEBUG', '') != 'true': +- for lname in ['versionfinder', 'pip', 'git']: +- l = logging.getLogger(lname) +- l.setLevel(logging.CRITICAL) +- l.propagate = True +- try: +- vinfo = find_version('awslimitchecker') +- dirty = '' +- if vinfo.git_is_dirty: +- dirty = '*' +- tag = vinfo.git_tag +- if tag is not None: +- tag += dirty +- commit = vinfo.git_commit +- if commit is not None: +- if len(commit) > 7: +- commit = commit[:8] +- commit += dirty +- return AWSLimitCheckerVersion( +- vinfo.version, +- vinfo.url, +- tag=tag, +- commit=commit +- ) +- except Exception: +- logger.exception("Error checking installed version; this installation " +- "may not be in compliance with the AGPLv3 license:") + # fall back to returning just the hard-coded release information + return AWSLimitCheckerVersion(_VERSION, _PROJECT_URL) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e2f6f1763e06..61f76936c0b5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1312,6 +1312,8 @@ with pkgs; awsebcli = callPackage ../tools/virtualization/awsebcli {}; + awslimitchecker = callPackage ../tools/admin/awslimitchecker { }; + awslogs = callPackage ../tools/admin/awslogs { }; aws-lambda-rie = callPackage ../tools/admin/aws-lambda-runtime-interface-emulator { };