Skip to content

TNZ-32337 - Add expiring licenses check script and configuration #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
33 changes: 33 additions & 0 deletions tasks/expiring-licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# code_snippet expiring-licenses-script start bash

cat /var/version && echo ""
set -eux

# Build the command with optional flags
cmd="om --env env/"${ENV_FILE}" expiring-licenses --format json"

if [ -n "${EXPIRES_WITHIN:-}" ]; then
cmd="${cmd} --expires-within ${EXPIRES_WITHIN}"
fi

if [ "${STAGED:-false}" = "true" ]; then
cmd="${cmd} --staged"
fi

if [ "${DEPLOYED:-false}" = "true" ]; then
cmd="${cmd} --deployed"
fi

# Run the command and capture the output
output=$(${cmd})

# Check if there are any expiring licenses (empty array means no licenses)
if [ "$output" != "[]" ]; then
echo "Found expiring licenses:"
echo "$output"
exit 1
fi

echo "No expiring licenses found within ${EXPIRES_WITHIN:-3m}"
# code_snippet expiring-licenses-script end
42 changes: 42 additions & 0 deletions tasks/expiring-licenses.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# The inputs, outputs, params, filename, and filepath
# of this task file are part of its semantically versioned API.
# See our documentation for a detailed discussion of our semver API.
# See www.semver.org for an explanation of semantic versioning.

# code_snippet expiring-licenses start yaml
---
platform: linux

inputs:
- name: platform-automation-tasks
- name: env # contains the env file with target OpsMan Information

params:
ENV_FILE: env.yml
# - Required
# - Filepath of the env config YAML
# - The path is relative to root of the `env` input

EXPIRES_WITHIN:
# - Optional
# - Example: "3m" is 3 months
# - Check for licenses expiring within the defined time period
# - Supports a time period defined with a suffix of:
# days(d), weeks(w), months(m) and years(y)
# - Defaults to "3m" if not specified

STAGED:
# - Optional
# - Boolean flag
# - Include staged products in the check
# - Defaults to false if not specified

DEPLOYED:
# - Optional
# - Boolean flag
# - Include deployed products in the check
# - Defaults to false if not specified

run:
path: platform-automation-tasks/tasks/expiring-licenses.sh
# code_snippet expiring-licenses end