Skip to content

Commit

Permalink
New workflows for raw otel
Browse files Browse the repository at this point in the history
  • Loading branch information
mkelly committed Oct 17, 2023
1 parent ec9f39c commit 05e3175
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/bindplane_deploy_export_raw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: BindPlane OP Deploy and Export Raw
on:
push:
branches:
- main
- dev

jobs:
bindplane:
runs-on: "ubuntu-22.04"
steps:
- name: Check out source code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- run: mkdir download

- name: Install BindPlane CLI
run: |
curl -o bindplane.zip https://storage.googleapis.com/bindplane-op-releases/bindplane/bindplane-ee-v1.30.0-linux-amd64.zip
unzip bindplane.zip
sudo chmod +x bindplane
sudo mv bindplane /usr/local/bin/bindplane
working-directory: download

- name: Create Profile
run: |
bindplane profile set gitflow \
--remote-url https://app.bindplane.com \
--api-key ${{ secrets.BINDPLANE_API_KEY }}
bindplane profile use gitflow
- name: Test CLI
run: bindplane version

- name: Deploy Resources
run: bash ./apply_bindplane_configs.sh

- name: Export and checkin otel
run: bash ./get_bindplane_otel_configs.sh

- name: Commit and Push Changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add -A
git commit -m "Automated changes"
git push
5 changes: 5 additions & 0 deletions .github/workflows/bindplane_deploy_raw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ jobs:
for file in output/*.yaml; do
bindplane apply -f $file
done
- name: Get Raw OTEL using Bindplane CLI
run: |
bash ./get_bindplane_config.sh
7 changes: 7 additions & 0 deletions apply_bindplane_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Directory to start the search; default is the current directory
start_directory="./bindplane"

# Use find command to locate all yaml files and execute bindplane apply on each
find "$start_directory" -name "*.yaml" -type f -exec echo "Applying {}" \; -exec bindplane apply -f {} \;
27 changes: 27 additions & 0 deletions get_bindplane_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Define the template, source, and output directories
SOURCE_DIR="source"
OUTPUT_DIR="bindplane"

# Array of commands to automatically execute
declare -a commands=("configuration" "account" "destination" "user")

for command in "${commands[@]}"; do
# Create a directory for each command's output
mkdir -p "${OUTPUT_DIR}/$command"

# Fetch the list for the current command from bindplane
bindplane_output=$(bindplane get "${command}s") # Appending 's' to get the list

# Parse the NAME field from the output and loop through each one
echo "$bindplane_output" | awk 'NR>1 {print $1}' | while read -r name; do
# Fetch the YAML detail for each NAME
yaml_output=$(bindplane get "$command" "$name" -o yaml)

# Save the YAML detail to a file in the OUTPUT folder
echo "$yaml_output" > "${OUTPUT_DIR}/$command/${name}.yaml"
done
done

echo "Completed exporting all configuration files. Results saved to: $OUTPUT_DIR"
22 changes: 22 additions & 0 deletions get_bindplane_otel_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Define the template, source, and output directories
SOURCE_DIR="source"
OUTPUT_DIR="bindplane_otel"

# Create a directory for each command's output
mkdir -p "${OUTPUT_DIR}"

# Fetch the list for the current command from bindplane
bindplane_output=$(bindplane get configs)

# Parse the NAME field from the output and loop through each one
echo "$bindplane_output" | awk 'NR>1 {print $1}' | while read -r name; do
# Fetch the YAML detail for each NAME
yaml_output=$(bindplane get config "$name" -o raw)

# Save the YAML detail to a file in the OUTPUT folder
echo "$yaml_output" > "${OUTPUT_DIR}/${name}.yaml"
done

echo "Completed exporting all configuration files. Results saved to: $OUTPUT_DIR"

0 comments on commit 05e3175

Please sign in to comment.