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

Update workstation scripts to be more broadly useful #64

Merged
merged 25 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 24 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
334 changes: 248 additions & 86 deletions README.md

Large diffs are not rendered by default.

26 changes: 7 additions & 19 deletions assets/capidoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ check_certificate_expirations:
description: Reads YAML files, checks for expired (or premature) certs. Useful for pipeline troubleshooting
location: capi-workspace/bin
group: testing
commit_with_shortlog:
description: Git commit with a staged_shortlog
location: capi-workspace/bin
group: git
compare_db_rows:
description: Compares counts of two db's rows to validate backup & restore
location: capi-workspace/bin
Expand All @@ -50,10 +46,14 @@ fixcommitter:
description: Cleans up committer/author after a rebase
location: capi-workspace/bin
group: git
gcs_to_claimed:
description: Convert bosh-lite environment files stored in gcs to a claimed bosh-lite
generate_integration_config:
description: Create an integration_config.json for running CATS against current bosh target.
location: capi-workspace/bin
group: bosh-lite-pool
group: testing
git-open:
description: Open a git repo in your browser, courtesy of Paul Irish.
location: capi-workspace/bin
group: git
mysql_bosh_lite:
description: Connect to current bosh target's MySQL DB
location: capi-workspace/bin
Expand Down Expand Up @@ -147,14 +147,6 @@ gi:
description: gem install
location: capi-workspace/custom-bash-it-plugins
group: ruby-dev
set_capi_pipeline:
description: Set the capi pipeline to your local config file (fly set-pipeline)
location: capi-workspace/bin
group: ci
watch_cc_units:
description: Watch CAPI CI unit tests. For a specific run, -b build_number (fly watch)
location: capi-workspace/bin
group: ci
cfu:
description: Alias for seed_users
location: capi-workspace/bin
Expand Down Expand Up @@ -200,10 +192,6 @@ attach_debugger:
description: Attaches the rubymine debugger to your bosh lite
location: capi-release/src/cloud_controller_ng/scripts/short-circuit-cc
group: bosh-lite-pool
load-key:
description: Loads the an ssh key in the currently logged in lastpass called "github-private-key". Run eval $(ssh-agent) if it fails
location: capi-workspace/bin
group: auth
capi-workspaces:
description: List and connect to existing K8s CAPI workspaces
location: capi-workspace/bin
Expand Down
7 changes: 7 additions & 0 deletions assets/use-created-capi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- type: replace
path: /releases/name=capi
value:
name: capi
version: create
url: file://((capi_release_dir))
42 changes: 0 additions & 42 deletions bin/can-i-push

This file was deleted.

13 changes: 1 addition & 12 deletions bin/cf_admin_password
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,13 @@ set -e

get_cf_admin_password() {
echo "Getting CF admin password from credhub... "

# Newer bosh-lites use $CREDHUB_SECRET instead of $CREDHUB_PASSWORD
# The credhub cli is aware of $CREDHUB_SECRET so it does not need it passed in
# If there are no bosh-lites around anymore that were created before 01/25/2018
# you can delete the else condition
set +u # $CREDHUB_PASSWORD may be unbound
if [[ -z $CREDHUB_PASSWORD ]]; then
credhub login --skip-tls-validation
else
credhub login -s "$CREDHUB_SERVER" -u "$CREDHUB_USERNAME" -p "$CREDHUB_PASSWORD" --skip-tls-validation
fi
set -u
cf_admin_password=$(credhub get --name '/bosh-lite/cf/cf_admin_password' --output-json | jq -r '.value')
}

main() {
if [ -z "$BOSH_ENVIRONMENT" ]; then
echo "No bosh targeted. Use \"target_bosh\" before getting credhub password"
echo "No bosh targeted. Use \"target_bosh\" before getting admin password."
else
get_cf_admin_password
echo "CF Admin Password: ${cf_admin_password}"
Expand Down
4 changes: 0 additions & 4 deletions bin/commit_with_shortlog

This file was deleted.

20 changes: 13 additions & 7 deletions bin/create_and_deploy
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/bash
set -exu
set -eu

cfd_dir="${CF_DEPLOYMENT_DIR:-$HOME/workspace/cf-deployment}"
capi_ci_dir="${CAPI_CI_DIR:-$HOME/workspace/capi-ci}"

create_and_upload

# deploy to current bosh env
bosh deploy ~/workspace/cf-deployment/cf-deployment.yml \
printf "\nDeploying uploaded release...\n"
echo "bosh deploy cf-deployment.yml -o..."

bosh deploy "${cfd_dir}/cf-deployment.yml" \
-v system_domain=$BOSH_LITE_DOMAIN \
-o ~/workspace/capi-ci/cf-deployment-operations/skip-cert-verify.yml \
-o ~/workspace/cf-deployment/operations/bosh-lite.yml \
-o ~/workspace/cf-deployment/operations/use-compiled-releases.yml \
-o ~/workspace/capi-ci/cf-deployment-operations/use-latest-capi.yml $@
-o "${capi_ci_dir}/cf-deployment-operations/skip-cert-verify.yml" \
-o "${cfd_dir}/operations/bosh-lite.yml" \
-o "${cfd_dir}/operations/use-compiled-releases.yml" \
-o "${capi_ci_dir}/cf-deployment-operations/use-latest-capi.yml" \
$@
27 changes: 23 additions & 4 deletions bin/create_and_upload
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#!/bin/bash
set -eu
set -e

# create and upload a release
pushd ~/workspace/capi-release
if [ -z "$BOSH_ENVIRONMENT" ]; then
echo "No bosh targeted. Use \"target_bosh\" before creating and uploading a release."
exit 1
fi
echo "Uploading new release to $BOSH_ENVIRONMENT."

set -u

capi_release_dir="${CAPI_RELEASE_DIR:-$HOME/workspace/capi-release}"

pushd "${capi_release_dir}" > /dev/null

printf "\nSyncing bosh blobs...\n"
echo "bosh sync-blobs"
bosh sync-blobs

printf "\nCreating bosh release...\n"
echo "create-release --force --name capi"
bosh create-release --force --name capi

printf "\nUploading release to bosh director...\n"
echo "bosh upload-release --rebase"
bosh upload-release --rebase
popd

popd > /dev/null
2 changes: 1 addition & 1 deletion bin/deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -exu
set -e

create_and_deploy $@ -n
22 changes: 14 additions & 8 deletions bin/deploy_only_new_capi
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/usr/bin/env bash

# you provide your own capi-release directory via the first positional argument
if [[ -n "$1" ]] ; then
CAPI_RELEASE_DIR="$1" ; shift
else
CAPI_RELEASE_DIR="$HOME/workspace/capi-release"
set -e

capi_release_dir="${CAPI_RELEASE_DIR:-$HOME/workspace/capi-release}"
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [ -z "$BOSH_ENVIRONMENT" ]; then
echo "No bosh targeted. Use \"target_bosh\" before deploying new CAPI."
exit 1
fi
echo "Building a new CAPI from local filesystem and deploying to $BOSH_ENVIRONMENT."

echo "bosh deploy <(bosh manifest) -o ...use-created-capi.yml ..."

bosh -n deploy <(bosh manifest) \
-o ~/workspace/capi-ci/cf-deployment-operations/use-created-capi.yml \
-v capi_release_dir="${CAPI_RELEASE_DIR}" \
"$@"
-o "${__dir}/../assets/use-created-capi.yml" \
-v capi_release_dir="${capi_release_dir}" \
$@
2 changes: 2 additions & 0 deletions bin/fixcommitter
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

do_fixcommitter ()
{
( committer=$(git show HEAD -s --pretty="tformat:%b" | grep Signed-off | cut -d: -f2);
Expand Down
32 changes: 0 additions & 32 deletions bin/gcs_to_claimed

This file was deleted.

15 changes: 0 additions & 15 deletions bin/load-key

This file was deleted.

14 changes: 7 additions & 7 deletions bin/mysql_bosh_lite
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ set -e
set -o pipefail

get_database_password(){
set +u # $CREDHUB_PASSWORD may be unbound
if [[ -z $CREDHUB_PASSWORD ]]; then
credhub login --skip-tls-validation
else
credhub login -s "$CREDHUB_SERVER" -u "$CREDHUB_USERNAME" -p "$CREDHUB_PASSWORD" --skip-tls-validation
fi
set -u
cc_database_password=$(credhub get -n '/bosh-lite/cf/cc_database_password' --output-json | jq -r '.value')
}

Expand Down Expand Up @@ -45,6 +38,13 @@ kill_tree() {
kill $pid
}

set +u
if [ -z "$BOSH_ENVIRONMENT" ]; then
echo "No bosh targeted. Use \"target_bosh\" before connecting to MySQL."
exit 1
fi
set -u

{
get_database_password &&
ssh_tunnel &&
Expand Down
Loading