Skip to content

Commit

Permalink
networkglue fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
toddnni committed Sep 16, 2024
1 parent 1f9119e commit 62d8219
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ First, generate a GitHub personal access token (PAT) with minimal permissions fo

- https://github.com/settings/personal-access-tokens/
- limit to the specific repository
- contents (read)
- contents (write, needs for branches)
- PRs (write)

Install (token will be needed here)
Expand Down
2 changes: 1 addition & 1 deletion network-glue/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/flant/shell-operator:latest
RUN apk add git
RUN apk add git curl
ADD hooks /hooks

2 changes: 1 addition & 1 deletion network-glue/hooks/bin/clone-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
# Clone the repository using the GitHub token
echo "Cloning the repository..."
rm -rf "$REPO_DIR"
git clone https://"${GIT_TOKEN}":x-oauth-basic@"$REPO_URL" "$REPO_DIR"
git clone https://"${GIT_TOKEN}":x-oauth-basic@"${REPO_URL#https://}" "$REPO_DIR"
cd "$REPO_DIR"

# Create a new branch for the changes
Expand Down
9 changes: 7 additions & 2 deletions network-glue/hooks/bin/create-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set -u
# BRANCH_NAME
# FILE_TO_UPDATE
# Configuration
GIT_USER="shell-operator"
GIT_EMAIL="shell-operator@example.com"
COMMIT_MESSAGE="Update configuration file"
PR_TITLE="Proposal: Update Configuration $FILE_TO_UPDATE"
PR_BODY="This PR proposes updates to the configuration file."
Expand All @@ -23,8 +25,11 @@ if [ -z "$GIT_TOKEN" ]; then
fi

# Add and commit the changes
cd "$REPO_DIR"
git add "$FILE_TO_UPDATE"
echo "Committing the changes..."
echo "Committing the changes with $GIT_USER <$GIT_EMAIL>..."
git config --global user.name "$GIT_USER"
git config --global user.email "$GIT_EMAIL"
git commit -m "$COMMIT_MESSAGE"

# Push the changes to the new branch
Expand All @@ -40,7 +45,7 @@ echo "Resolved repo owner and name: $REPO_OWNER, $REPO_NAME"

echo "Creating a pull request..."
curl -X POST \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Authorization: token ${GIT_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
--fail
-d @- \
Expand Down
2 changes: 1 addition & 1 deletion network-glue/hooks/hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ else
target=$(jq -r '.[0].object.spec.target.networkCIDR' "${BINDING_CONTEXT_PATH}")
targetPort=$(jq -r '.[0].object.spec.target.port' "${BINDING_CONTEXT_PATH}")

export REPO_URL="$REPO_URL"
export REPO_URL="$(echo $REPO_URL | tr -d '\n ')" # strip newlines
export REPO_DIR=/git
export BRANCH_NAME="feature/update-config-$(date +%Y%m%d-%H%M%S)"
export FILE_TO_UPDATE="$REPO_DIR/$namespace-$name.json"
Expand Down

0 comments on commit 62d8219

Please sign in to comment.