-
Notifications
You must be signed in to change notification settings - Fork 2
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
V0.6 | AWS & File functions #16
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
44e042f
Added function for IAM policy creation
sandy724 1233743
Added a function to create role
sandy724 d3633a0
Added function to validate if IAM policy exists or not
sandy724 1613794
Added function to get AWS account id
sandy724 a930397
Added function to validate if a role exists
sandy724 96476f6
Added functions for finding a line in a file
sandy724 8454fcd
Updated code to find entities of Dockerfile path
sandy724 d88bbcd
Fixed issue
sandy724 b30c667
Added function to find clonflicting files
sandy724 a7854ef
Added function to get committer of files in a certain branch
sandy724 f0e98ea
done shellcheck suggestions
Cpriyanshi77 28567cd
done shellcheck suggestions
Cpriyanshi77 1186258
done shellcheck suggestions
Cpriyanshi77 a881de6
done shellcheck suggestions
Cpriyanshi77 130a357
Merge branch 'main' into v0.6
sandy724 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,60 @@ | ||
#!/bin/bash | ||
|
||
function bucketExist() { | ||
BUCKET=$1 | ||
BUCKET="$1" | ||
|
||
BUCKET_EXISTS=$(aws s3api head-bucket --bucket $BUCKET 2>&1 || true) | ||
BUCKET_EXISTS=$(aws s3api head-bucket --bucket "$BUCKET" 2>&1 || true) | ||
if [ -z "$BUCKET_EXISTS" ]; then | ||
echo 0 | ||
else | ||
echo 1 | ||
fi | ||
} | ||
|
||
function getAccountId() { | ||
aws sts get-caller-identity --query "Account" --output text | ||
} | ||
|
||
function copyFileToS3() { | ||
SOURCE_FILE=$1 | ||
S3_BUCKET=$2 | ||
KEY_NAME=$3 | ||
SOURCE_FILE="$1" | ||
S3_BUCKET="$2" | ||
KEY_NAME="$3" | ||
|
||
aws s3 cp ${SOURCE_FILE} s3://${S3_BUCKET}/${KEY_NAME} | ||
aws s3 cp "${SOURCE_FILE}" "s3://${S3_BUCKET}/${KEY_NAME}" | ||
} | ||
|
||
function copyFileFromS3() { | ||
S3_BUCKET=$1 | ||
FILE_KEY=$2 | ||
FILE_PATH=$3 | ||
aws s3 cp s3://${S3_BUCKET}/${FILE_KEY} ${FILE_PATH} | ||
S3_BUCKET="$1" | ||
FILE_KEY="$2" | ||
FILE_PATH="$3" | ||
aws s3 cp "s3://${S3_BUCKET}/${FILE_KEY}" "${FILE_PATH}" | ||
} | ||
|
||
function policyExists() { | ||
POLICY_ARN="$1" | ||
|
||
aws iam get-policy --policy-arn "${POLICY_ARN}" >/dev/null 2>&1 | ||
echo $? | ||
} | ||
|
||
function createPolicy() { | ||
POLICY_NAME="$1" | ||
POLICY_FILE_PATH="$2" | ||
|
||
aws iam create-policy \ | ||
--policy-name "${POLICY_NAME}" --no-paginate \ | ||
--policy-document "file://${POLICY_FILE_PATH}" | ||
} | ||
|
||
function roleExists() { | ||
ROLE_NAME="$1" | ||
|
||
aws iam get-role --role-name "${ROLE_NAME}" >/dev/null 2>&1 | ||
echo $? | ||
} | ||
|
||
function createRole() { | ||
ROLE_NAME="$1" | ||
POLICY_DOCUMENT="$2" | ||
aws iam create-role --role-name "${ROLE_NAME}" --no-paginate --assume-role-policy-document "file://${POLICY_DOCUMENT}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/bash | ||
|
||
function isFileExist() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
FILEPATH=$1 | ||
FILEPATH="$1" | ||
|
||
if [ -f "$FILEPATH" ]; then | ||
echo 0 | ||
|
@@ -9,8 +11,21 @@ function isFileExist() { | |
} | ||
|
||
function fileContainsString() { | ||
FILEPATH=$1 | ||
FILEPATH="$1" | ||
TEXT="$2" | ||
grep -q ${TEXT} ${FILEPATH} | ||
grep -q "${TEXT}" "${FILEPATH}" | ||
echo $? | ||
} | ||
|
||
function getLineForAString() { | ||
FILEPATH="$1" | ||
TEXT="$2" | ||
grep "${TEXT}" "${FILEPATH}" | ||
} | ||
|
||
function textExistsInALine(){ | ||
LINE="$1" | ||
TEXT="$2" | ||
echo "${LINE}" | grep -q "${TEXT}" | ||
echo "$?" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
function switchBranch() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
TGT_BRANCH="$1" | ||
|
||
git checkout "$TGT_BRANCH" | ||
} | ||
|
||
function showStatusInShortFormat() { | ||
git status -s | ||
} | ||
|
||
function findConflictingFiles() { | ||
SRC_BRANCH="$1" | ||
TGT_BRANCH="$2" | ||
|
||
git checkout -q "${TGT_BRANCH}" | ||
# git pull origin "${TGT_BRANCH}" | ||
|
||
git checkout -q -b temp_merge_branch | ||
git merge -q "$SRC_BRANCH" 1> /dev/null | ||
|
||
conflicts=$(git diff --name-only --diff-filter=U) | ||
git merge --abort | ||
git checkout -q "${TGT_BRANCH}" | ||
git branch -q -D temp_merge_branch | ||
echo "$conflicts" | ||
} | ||
|
||
function getLastAuthorOfFile() { | ||
BRANCH="$1" | ||
FILE="$2" | ||
|
||
git checkout -q "$BRANCH" | ||
|
||
git log -1 --pretty=format:"%an" "${FILE}" | ||
} | ||
|
||
function getLastAuthorOfFiles() { | ||
BRANCH="$1" | ||
FILES="$2" | ||
for FILE in "${FILES[@]}" | ||
do | ||
author=$(getLastAuthorOfFile "$BRANCH" "$FILE") | ||
echo "${FILE}: ${author}" | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
#!/bin/bash | ||
|
||
function isStrNonEmpty() { | ||
STR=$1 | ||
STR="$1" | ||
if [ -z "$STR" ]; then | ||
echo 1 | ||
else | ||
echo 0 | ||
fi | ||
} | ||
} | ||
|
||
function getNthTextInALine() { | ||
LINE="$1" | ||
SEPARATOR="$2" | ||
POSITION="$3" | ||
|
||
echo "${LINE}" | awk -F "${SEPARATOR}" -v POS="${POSITION}" "{print $POS}" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [shellcheck] reported by reviewdog 🐶
Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. SC2148