Skip to content

Commit

Permalink
added credentials verification
Browse files Browse the repository at this point in the history
  • Loading branch information
A3a3e1 committed Feb 4, 2019
1 parent 83e3820 commit fe16cc0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion ensure-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,7 @@ function delayAndCreateReposForNotExistingComponents() {

createDummyRepoIfNotExist()
.then(delayAndCreateReposForNotExistingComponents())
.catch(error => console.log(`${error}`));
.catch((error) => {
console.log(`${error}`);
process.exit(1);
});
1 change: 1 addition & 0 deletions flint/component-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
configuration-component master git@github.com:elasticio/configuration-component.git
8 changes: 8 additions & 0 deletions flint/export.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export API_URL="https://api.elastic.io"
export TEAM_NAME="comp_pusher_team"
export TEAM_ID="5bed5ee6dd0f9e00128113b1"
export CONTRACT_ID="5b927ae5830b0e0012139294"
export EMAIL="pavel.voropaiev@elastic.io"
export API_KEY="1345442c-03b3-43f9-8eec-a63a72eb4bb2"
export GIT_CLONE_KEY="PATH/TO/THE/KEY"
export SSH_ALIAS="flint-garry"
6 changes: 2 additions & 4 deletions getComponentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ async function readTeamCompIds() {
async function getAllComponentIds() {
const { data } = (await request.get(`/v2/teams/${TEAM_ID}`)).data;
const contractId = data.relationships.contract.data.id;
const { data: allContractComponents } = (await request.get(`/v2/components?contract_id=${contractId}`)).data;
const { data: allContractComponents } = (await request.get(`/v2/components?contract_id=${contractId}&filter[access]=private`)).data;
return Object.values(allContractComponents);
}

// Reads the list of components from the 'component-list.txt' file
function readComponentsList() {
const text = fs.readFileSync(`${process.argv[2]}/component-list.txt`).toString();
const lines = text.split('\n').filter(l => !!l);
Expand All @@ -44,13 +45,10 @@ function readComponentsList() {

async function findCommonComponents() {
const componentsToPush = await readComponentsList();
// console.log(JSON.stringify(componentsToPush, null, 2));
const allComps = await getAllComponentIds();
// console.log(JSON.stringify(allComps, null, 2));
for (const allComp of allComps) {
for (const componentToPush of componentsToPush) {
if (allComp.attributes.name === componentToPush.component) {
// console.log(allComp.id);
console.log(`${allComp.id}:${allComp.attributes.name}`);
}
}
Expand Down
5 changes: 3 additions & 2 deletions push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function process_tenant() {
echo "Check if environment variables are OK..."
auth_response=$(
curl https://api.elastic.io/v2/teams/${TEAM_ID} \
-u ${API_KEY}:${EMAIL} \
-u ${EMAIL}:${API_KEY} \
-H 'Accept: application/json' \
--write-out %{http_code} \
--silent \
Expand All @@ -35,6 +35,7 @@ function process_tenant() {
echo "Environment variables in 'export.vars' file are incorrect. Check it and try again. Exit..."
exit 1
fi
echo "Environment variables are OK"

# Deleting blank lines in components list file. There will be errors when trying to create
# an empty git repository
Expand Down Expand Up @@ -66,7 +67,7 @@ function process_tenant() {
comp_head_rev="$(git rev-parse HEAD)"
echo "Current component version: ${comp_head_rev}"
echo "About to push the component..."
PUSH_RESULT="$(git push "${git_remote_name}" "$version":master 2>&1)"
PUSH_RESULT="$(git push -f "${git_remote_name}" "$version":master 2>&1)"
echo "${PUSH_RESULT}"
PUSH_RESULT_LAST_LINE=$(echo "${PUSH_RESULT}" | tail -n 1 )
PUSH_RESULT_THIRD_LINE_FROM_END=$(echo "${PUSH_RESULT}" | tail -n 3 | head -n 1 )
Expand Down

0 comments on commit fe16cc0

Please sign in to comment.