Skip to content
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

Optimized bash scripts #119

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

jamallorock
Copy link
Collaborator

Description

In common_utils.sh script:
Key Improvements

✅ Uses kubectl wait instead of an inefficient polling loop with sleep.
✅ Removes redundant kubectl get pods calls, reducing API requests.
✅ Adds set -e to exit immediately on failure, improving script safety.
✅ Uses standard exit codes (1 instead of -1) for better compatibility.
✅ Uses local for variables to avoid polluting the global namespace.

In generate-certs.sh script:
The improvements include:
✅ Better error handling – added error messages.
✅ Variability and flexibility – option to change parameters without editing the code.
✅ Consistency and readability – structured code with clear messages.

Motivation and Context

Closes #

Screenshots (if appropriate):

How Has This Been Tested?

Tested localy.

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have run make generate and checked in the results.
  • I have run make manifests and checked in the results.

For new code releases:

  • I have bumped the appVersion in the Helm chart.

For new Helm chart releases:

  • I have bumped the Helm chart version.

@djkormo djkormo requested a review from aw1cks February 5, 2025 12:27
Comment on lines 16 to 24
# 📍 Setting default values for CA certificate
COUNTRY="US"
STATE="YourState"
CITY="YourCity"
ORG="YourOrganization"
ORG_UNIT="YourOrganizationalUnit"
COMMON_NAME="adcs-issuer Test CA"
KEY_SIZE=4096
DAYS_VALID=3650 # 10 years
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 📍 Setting default values for CA certificate
COUNTRY="US"
STATE="YourState"
CITY="YourCity"
ORG="YourOrganization"
ORG_UNIT="YourOrganizationalUnit"
COMMON_NAME="adcs-issuer Test CA"
KEY_SIZE=4096
DAYS_VALID=3650 # 10 years
# 📍 Setting default values for CA certificate
COUNTRY='US'
STATE='YourState'
CITY='YourCity'
ORG='YourOrganization'
ORG_UNIT='YourOrganizationalUnit'
COMMON_NAME='adcs-issuer Test CA'
KEY_SIZE='4096'
DAYS_VALID='3650' # 10 years

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggests using doubles everywhere. @djkormo


mkdir -pv "${OUTPUT_DIR}/ca"
echo "🔧 Creating directories..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "🔧 Creating directories..."
echo '🔧 Creating directories...'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change without impact. Doesn't understand why it changed to single.

-config "${CA_DIR}/ca.cnf"

# 📍 Copying certificates to test files
echo "📂 Copying certificates..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "📂 Copying certificates..."
echo '📂 Copying certificates...'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change without impact. Doesn't understand why it changed to single,

cp -v "${CA_DIR}/ca.pem" "${OUTPUT_DIR}/pkcs7.pem"
cp -v "${CA_DIR}/ca.pem" "${OUTPUT_DIR}/x509.pem"

echo "✅ Certificates successfully generated!"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "✅ Certificates successfully generated!"
echo '✅ Certificates successfully generated!'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change without impact. Doesn't understand why it changed to single.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants