@colisweb/rescript-toolkit 5.49.3 → 5.49.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.secure_files/{ci-functions-v20.0.3 → ci-functions-v20.6.1-anchor-for_services} +294 -58
- package/.secure_files/{ci-functions-v20.0.0 → ci-functions-v20.6.1-anchor-for_services-beta} +440 -140
- package/.secure_files/{ci-functions-v20.0.1 → ci-functions-v20.7.0} +440 -140
- package/.secure_files/{ci-functions-v20.0.2 → ci-functions-v20.7.1} +443 -140
- package/package.json +1 -1
- package/src/ui/Toolkit__Ui_Timeline.res +1 -1
|
@@ -62,7 +62,7 @@ extract_arg() {
|
|
|
62
62
|
value=$3
|
|
63
63
|
if [ "--$name" != "$passed" ]; then
|
|
64
64
|
echo "missing argument $name"
|
|
65
|
-
|
|
65
|
+
return 1
|
|
66
66
|
fi
|
|
67
67
|
eval $name='$value'
|
|
68
68
|
}
|
|
@@ -481,6 +481,7 @@ database_k8s() {
|
|
|
481
481
|
LocalForward 25551 toutatis-testing-composite-db.ca0rjdmnxf1x.eu-west-1.rds.amazonaws.com:5432
|
|
482
482
|
LocalForward 25431 toutatis-testing-mysql-db.ca0rjdmnxf1x.eu-west-1.rds.amazonaws.com:3306
|
|
483
483
|
LocalForward 25531 testapirds.ca0rjdmnxf1x.eu-west-1.rds.amazonaws.com:3306
|
|
484
|
+
LocalForward 25561 toutatis-testing-oracle-db.ca0rjdmnxf1x.eu-west-1.rds.amazonaws.com:1521
|
|
484
485
|
Host bastion_staging
|
|
485
486
|
HostName 127.0.0.1
|
|
486
487
|
Port 2226
|
|
@@ -868,13 +869,17 @@ function kstatus() {
|
|
|
868
869
|
#!/usr/bin/env bash
|
|
869
870
|
|
|
870
871
|
k8_nodes_stats() {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
872
|
+
ENV=${1:-testing}
|
|
873
|
+
|
|
874
|
+
configure_kubectl_for "${ENV}"
|
|
875
|
+
|
|
876
|
+
kubectl get nodes -o name |
|
|
877
|
+
xargs kubectl describe |
|
|
878
|
+
grep "^Name\|workType\|cpu \|memory " |
|
|
879
|
+
sed -r 's/[ :=]+/\t/g' |
|
|
880
|
+
sed 's/\tworkType\t//g' |
|
|
881
|
+
sed -r 's/^Name/---\nName/g' |
|
|
882
|
+
grep --color "Name\|web\|workers\|cpu\|memory\|---"
|
|
878
883
|
}
|
|
879
884
|
|
|
880
885
|
#!/usr/bin/env bash
|
|
@@ -940,14 +945,14 @@ pod_copy_to() {
|
|
|
940
945
|
|
|
941
946
|
pick_pod() {
|
|
942
947
|
ENV=$1
|
|
943
|
-
POD_FILTER
|
|
948
|
+
POD_FILTER=$2
|
|
944
949
|
configure_kubectl_for $ENV
|
|
945
950
|
|
|
946
951
|
if [ -z "$2" ] ; then
|
|
947
952
|
kubectl -n $ENV get pods | gum filter | cut -f1 -d" "
|
|
948
953
|
else
|
|
949
|
-
if PODS=$(kubectl -n $ENV get pods
|
|
950
|
-
echo $PODS
|
|
954
|
+
if PODS=$(kubectl -n $ENV get pods | grep -m1 "$POD_FILTER" | cut -f1 -d" "); then
|
|
955
|
+
echo $PODS
|
|
951
956
|
else
|
|
952
957
|
echo "no pods found on $ENV matching $POD_FILTER" >&2
|
|
953
958
|
fi
|
|
@@ -1427,6 +1432,182 @@ spec:
|
|
|
1427
1432
|
}
|
|
1428
1433
|
|
|
1429
1434
|
|
|
1435
|
+
#!/usr/bin/env bash
|
|
1436
|
+
|
|
1437
|
+
# Usage info
|
|
1438
|
+
show_help_shell() {
|
|
1439
|
+
local help="""Usage: run_job_k8s -s SCRIPT [-e ENV] [-c CONFIG] [-p POD] [-f FOLDER] [ARGS]
|
|
1440
|
+
Create a k8s job executing a script
|
|
1441
|
+
|
|
1442
|
+
-h display this help and exit
|
|
1443
|
+
-s SCRIPT run script SCRIPT on a pod (SCRIPT must be a .sc file)
|
|
1444
|
+
-e ENV opt. set execution environment (default to testing)
|
|
1445
|
+
-c CONFIG opt. secret file needed for the script (must be a .sc file, not a .secret file)
|
|
1446
|
+
-p POD opt. name of the pod to create (default to $USERNAME)
|
|
1447
|
+
-f FOLDER opt. name of the folder containing the scripts to execute (if SCRIPT needs other files)
|
|
1448
|
+
ARGS opt. additional arguments for SCRIPT
|
|
1449
|
+
|
|
1450
|
+
The organisation of the files must be the same locally as on the pod :
|
|
1451
|
+
- /code containing the script to execute (arg -s) and the other needed files (if the arg -f is used, it must reference this directory)
|
|
1452
|
+
- /conf containing the secret file (arg -c if used)
|
|
1453
|
+
E.g. in the script \"/code/script.sc\", to use a secret file \"/conf/secret.sc\", the import should look like \"import \$file.^.conf.secret.sc\"
|
|
1454
|
+
"""
|
|
1455
|
+
echo "$help"
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
run_shell_k8s() {
|
|
1459
|
+
|
|
1460
|
+
#default values
|
|
1461
|
+
local namespace="testing"
|
|
1462
|
+
local name="$USERNAME"
|
|
1463
|
+
local secret=""
|
|
1464
|
+
local shell_folder=""
|
|
1465
|
+
local script_script=""
|
|
1466
|
+
|
|
1467
|
+
while getopts ":e:c:p:f:s:h" opt; do
|
|
1468
|
+
case $opt in
|
|
1469
|
+
e)
|
|
1470
|
+
namespace="$OPTARG" >&2
|
|
1471
|
+
;;
|
|
1472
|
+
p)
|
|
1473
|
+
name="$OPTARG" >&2
|
|
1474
|
+
;;
|
|
1475
|
+
c)
|
|
1476
|
+
secret="$OPTARG" >&2
|
|
1477
|
+
;;
|
|
1478
|
+
f)
|
|
1479
|
+
shell_folder="$OPTARG" >&2
|
|
1480
|
+
;;
|
|
1481
|
+
s)
|
|
1482
|
+
shell_script="$OPTARG" >&2
|
|
1483
|
+
;;
|
|
1484
|
+
h)
|
|
1485
|
+
show_help_job
|
|
1486
|
+
return 0
|
|
1487
|
+
;;
|
|
1488
|
+
:)
|
|
1489
|
+
echo "Option -$OPTARG requires an argument. Run run_cron_job_k8s -h for help" >&2
|
|
1490
|
+
return 0
|
|
1491
|
+
;;
|
|
1492
|
+
\?)
|
|
1493
|
+
echo "Invalid option: -$OPTARG. Run run_cron_job_k8s -h for help" >&2
|
|
1494
|
+
return 0
|
|
1495
|
+
;;
|
|
1496
|
+
esac
|
|
1497
|
+
done
|
|
1498
|
+
|
|
1499
|
+
if [ -z "$shell_script" ]; then
|
|
1500
|
+
echo 'Missing -s. Run run_job_k8s -h for help' >&2
|
|
1501
|
+
return 0
|
|
1502
|
+
fi
|
|
1503
|
+
|
|
1504
|
+
shift "$((OPTIND-1))"
|
|
1505
|
+
|
|
1506
|
+
local script_args=$(
|
|
1507
|
+
if [ "$#" -gt 0 ] ; then
|
|
1508
|
+
printf '"'
|
|
1509
|
+
join_by '", "' $*
|
|
1510
|
+
printf '"'
|
|
1511
|
+
fi
|
|
1512
|
+
)
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
local IMAGE="949316342391.dkr.ecr.eu-west-1.amazonaws.com/docker-infra-builder:v3.1.0"
|
|
1518
|
+
local JOB_NAME="job-shell-$name"
|
|
1519
|
+
|
|
1520
|
+
if [[ ! -r "$shell_script" ]]; then
|
|
1521
|
+
echo "shell script not found $shell_script"
|
|
1522
|
+
return 2
|
|
1523
|
+
else
|
|
1524
|
+
local CONFIG_MAP="config-$JOB_NAME"
|
|
1525
|
+
local CONFIG_MAP_DIR="$(mktemp -d)"
|
|
1526
|
+
local SECRET_MAP="secret-$JOB_NAME"
|
|
1527
|
+
|
|
1528
|
+
configure_kubectl_for $namespace
|
|
1529
|
+
|
|
1530
|
+
if [[ ! -z $shell_folder && -d $shell_folder ]] ; then
|
|
1531
|
+
cp -r "$shell_folder/" "$CONFIG_MAP_DIR"
|
|
1532
|
+
fi
|
|
1533
|
+
cp "$shell_script" "$CONFIG_MAP_DIR/script.sh"
|
|
1534
|
+
|
|
1535
|
+
kubectl -n $namespace get configmap $CONFIG_MAP && kubectl -n $namespace delete configmap $CONFIG_MAP
|
|
1536
|
+
kubectl -n $namespace create configmap $CONFIG_MAP --from-file="$CONFIG_MAP_DIR"
|
|
1537
|
+
|
|
1538
|
+
kubectl -n $namespace get secret $SECRET_MAP && kubectl -n $namespace delete secret $SECRET_MAP
|
|
1539
|
+
kubectl -n $namespace create secret generic $SECRET_MAP --from-file="$secret"
|
|
1540
|
+
|
|
1541
|
+
kubectl -n $namespace get job $JOB_NAME && kubectl -n $namespace delete job $JOB_NAME
|
|
1542
|
+
|
|
1543
|
+
echo "starting $JOB_NAME with $IMAGE"
|
|
1544
|
+
fi
|
|
1545
|
+
|
|
1546
|
+
JOB_DEFINITION='
|
|
1547
|
+
apiVersion: batch/v1
|
|
1548
|
+
kind: Job
|
|
1549
|
+
metadata:
|
|
1550
|
+
name: '$JOB_NAME'
|
|
1551
|
+
namespace: '$namespace'
|
|
1552
|
+
spec:
|
|
1553
|
+
template:
|
|
1554
|
+
spec:
|
|
1555
|
+
containers:
|
|
1556
|
+
- name: '$JOB_NAME'
|
|
1557
|
+
command: ["bash", "/code/script.sh"]
|
|
1558
|
+
image: '$IMAGE'
|
|
1559
|
+
args: ['$script_args']
|
|
1560
|
+
env:
|
|
1561
|
+
- name: POD_NAME
|
|
1562
|
+
valueFrom:
|
|
1563
|
+
fieldRef:
|
|
1564
|
+
apiVersion: v1
|
|
1565
|
+
fieldPath: metadata.name
|
|
1566
|
+
- name: POD_NAMESPACE
|
|
1567
|
+
valueFrom:
|
|
1568
|
+
fieldRef:
|
|
1569
|
+
apiVersion: v1
|
|
1570
|
+
fieldPath: metadata.namespace
|
|
1571
|
+
- name: HOST_IP
|
|
1572
|
+
valueFrom:
|
|
1573
|
+
fieldRef:
|
|
1574
|
+
apiVersion: v1
|
|
1575
|
+
fieldPath: status.hostIP
|
|
1576
|
+
volumeMounts:
|
|
1577
|
+
- name: config
|
|
1578
|
+
mountPath: /code
|
|
1579
|
+
- name: secret
|
|
1580
|
+
mountPath: /conf
|
|
1581
|
+
readOnly: true
|
|
1582
|
+
resources:
|
|
1583
|
+
requests:
|
|
1584
|
+
cpu: 500m
|
|
1585
|
+
memory: 256Mi
|
|
1586
|
+
limits:
|
|
1587
|
+
cpu: 4000m
|
|
1588
|
+
memory: 1Gi
|
|
1589
|
+
nodeSelector:
|
|
1590
|
+
workType: workers
|
|
1591
|
+
restartPolicy: Never
|
|
1592
|
+
volumes:
|
|
1593
|
+
- name: config
|
|
1594
|
+
configMap:
|
|
1595
|
+
name: '$CONFIG_MAP'
|
|
1596
|
+
- name: secret
|
|
1597
|
+
secret:
|
|
1598
|
+
secretName: '$SECRET_MAP'
|
|
1599
|
+
- name: stockage
|
|
1600
|
+
|
|
1601
|
+
'
|
|
1602
|
+
|
|
1603
|
+
|
|
1604
|
+
echo $JOB_DEFINITION > /tmp/job.yaml
|
|
1605
|
+
|
|
1606
|
+
kubectl -n $namespace apply -f /tmp/job.yaml
|
|
1607
|
+
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
|
|
1430
1611
|
#!/usr/bin/env bash
|
|
1431
1612
|
|
|
1432
1613
|
run_task() {
|
|
@@ -1545,6 +1726,8 @@ jwt_token() {
|
|
|
1545
1726
|
|
|
1546
1727
|
#!/usr/bin/env bash
|
|
1547
1728
|
|
|
1729
|
+
alias update_devtool="git -C ~/.oh-my-zsh/custom/dev-tools/ pull"
|
|
1730
|
+
|
|
1548
1731
|
SCRIPT_PATH=$SCRIPT_FULL_PATH/shell/run
|
|
1549
1732
|
PATH="$PATH:$SCRIPT_PATH/script"
|
|
1550
1733
|
|
|
@@ -1602,13 +1785,23 @@ function bash_array_to_json {
|
|
|
1602
1785
|
}
|
|
1603
1786
|
|
|
1604
1787
|
function get_random_street {
|
|
1605
|
-
local
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1788
|
+
local CODE_POSTAUX_ARG=${1:-59000}
|
|
1789
|
+
IFS=',' read -r -a CODE_POSTAUX <<< "$CODE_POSTAUX_ARG"
|
|
1790
|
+
for CODE_POSTAL in "${CODE_POSTAUX[@]}"; do
|
|
1791
|
+
if [[ ! "$CODE_POSTAL" =~ ^[0-9]{5}$ ]]; then
|
|
1792
|
+
echo "Chaque CODE_POSTAL doit avoir une taille de 5 chiffre : $CODE_POSTAL"
|
|
1793
|
+
exit 1
|
|
1794
|
+
fi
|
|
1795
|
+
done
|
|
1796
|
+
local CODE_POSTAL=$(echo "${CODE_POSTAUX[@]}" | tr " " "\n" | sort -u -R | head -n 1)
|
|
1797
|
+
|
|
1798
|
+
get_random_street_in_cp $CODE_POSTAL
|
|
1799
|
+
}
|
|
1610
1800
|
|
|
1611
|
-
|
|
1801
|
+
function get_random_street_in_cp {
|
|
1802
|
+
local CODE_POSTAL=$1
|
|
1803
|
+
|
|
1804
|
+
FILENAME="rue-$CODE_POSTAL.lst"
|
|
1612
1805
|
if [ ! -f "$FILENAME" ]; then
|
|
1613
1806
|
curl --output tmp1.gz https://adresse.data.gouv.fr/data/ban/adresses/latest/csv/adresses-"${CODE_POSTAL:0:2}".csv.gz
|
|
1614
1807
|
gzip -d tmp1.gz
|
|
@@ -1647,14 +1840,14 @@ function call_create_sfh_order {
|
|
|
1647
1840
|
source "$3"
|
|
1648
1841
|
local POS=$4
|
|
1649
1842
|
local BARCODES="$5"
|
|
1650
|
-
local
|
|
1843
|
+
local CODE_POSTAUX="$6"
|
|
1651
1844
|
local PACKAGES=$(echo "$BARCODES" | jq '[{
|
|
1652
1845
|
"barcode": .[],
|
|
1653
|
-
"length":
|
|
1654
|
-
"height":
|
|
1655
|
-
"width":
|
|
1656
|
-
"weight":
|
|
1657
|
-
"description": "test
|
|
1846
|
+
"length": 20.0,
|
|
1847
|
+
"height": 15.0,
|
|
1848
|
+
"width": 4.0,
|
|
1849
|
+
"weight": 1.5,
|
|
1850
|
+
"description": "test parcel",
|
|
1658
1851
|
"options": [],
|
|
1659
1852
|
"productTypology": "Classical",
|
|
1660
1853
|
"packageType": "Parcel"
|
|
@@ -1670,7 +1863,22 @@ function call_create_sfh_order {
|
|
|
1670
1863
|
done
|
|
1671
1864
|
DELIVERY_OPTIONS_P+=']'
|
|
1672
1865
|
|
|
1673
|
-
IFS=";" read -r nu rue code_postal ville < <(get_random_street "$
|
|
1866
|
+
IFS=";" read -r nu rue code_postal ville < <(get_random_street "$CODE_POSTAUX")
|
|
1867
|
+
|
|
1868
|
+
if [ -n "$PICKUP_STORE_CODE" ]; then
|
|
1869
|
+
PICKUP_LOCATION='{
|
|
1870
|
+
"type": "store",
|
|
1871
|
+
"storeCode": "'"$PICKUP_STORE_CODE"'"
|
|
1872
|
+
}'
|
|
1873
|
+
elif [ -n "$PICKUP_WAREHOUSE_CODE" ]; then
|
|
1874
|
+
PICKUP_LOCATION='{
|
|
1875
|
+
"type": "Warehouse",
|
|
1876
|
+
"warehouseCode": "'"$PICKUP_WAREHOUSE_CODE"'"
|
|
1877
|
+
}'
|
|
1878
|
+
else
|
|
1879
|
+
echo PICKUP_WAREHOUSE_CODE ou PICKUP_STORE_CODE doit être définie dans la "$3"
|
|
1880
|
+
exit 1
|
|
1881
|
+
fi
|
|
1674
1882
|
JSON='{
|
|
1675
1883
|
"primaryOrderReference": "'"${PRIMARY_REF}${POS}"'",
|
|
1676
1884
|
"secondaryOrderReference": null,
|
|
@@ -1678,10 +1886,7 @@ function call_create_sfh_order {
|
|
|
1678
1886
|
{
|
|
1679
1887
|
"type": "Pickup",
|
|
1680
1888
|
"packageBarcodes": '"$BARCODES"',
|
|
1681
|
-
"location":
|
|
1682
|
-
"type": "Warehouse",
|
|
1683
|
-
"warehouseCode": "'"$PICKUP_WAREHOUSE_CODE"'"
|
|
1684
|
-
}
|
|
1889
|
+
"location": '"$PICKUP_LOCATION"'
|
|
1685
1890
|
},
|
|
1686
1891
|
{
|
|
1687
1892
|
"type": "Dropoff",
|
|
@@ -1742,16 +1947,19 @@ function call_register_delivery {
|
|
|
1742
1947
|
|
|
1743
1948
|
local ORDER_ID=$4
|
|
1744
1949
|
local BARCODES="$5"
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
--cookie session="$TOKEN" --data-raw '{
|
|
1950
|
+
|
|
1951
|
+
DATA='{
|
|
1748
1952
|
"slot": '"$(rand_slot "${DELIVERY_DATE}" "$SCENARIO")"',
|
|
1749
1953
|
"storeIdOwner":"'"$STORE_ID_OWNER"'",
|
|
1750
1954
|
"pickup":{"type":"hub","code":"'"$HUB"'"},
|
|
1751
1955
|
"barcodes":'"$BARCODES"',
|
|
1752
1956
|
"price":{"origin":"auto","amount":25.9},
|
|
1753
|
-
"allowCustomerSlotUpdate":false
|
|
1957
|
+
"allowCustomerSlotUpdate":false,
|
|
1958
|
+
"withForcedSlot": false
|
|
1754
1959
|
}'
|
|
1960
|
+
|
|
1961
|
+
curl -X POST https://api.$ENV.colisweb.com/api/v6/order/external/warehouse/orders/"$ORDER_ID"/deliveries \
|
|
1962
|
+
--cookie session="$TOKEN" --data-raw "$DATA"
|
|
1755
1963
|
}
|
|
1756
1964
|
|
|
1757
1965
|
|
|
@@ -1773,14 +1981,15 @@ ACCOUNT_IDENTIFIER="102" # pour la creation de order force utilie
|
|
|
1773
1981
|
HUB="duck" # pour sur l'appel api/v6/order/external/warehouse/orders
|
|
1774
1982
|
# parametre pickup.code (type est a "hub")
|
|
1775
1983
|
STORE_ID_OWNER="184" # parametre pickup.storeIdOwner
|
|
1776
|
-
|
|
1777
|
-
|
|
1984
|
+
# sur l'appel api/v6/order/external/warehouse/orders
|
|
1985
|
+
# PICKUP_STORE_CODE="2" # si non commenté alors départ du magasin
|
|
1986
|
+
PICKUP_WAREHOUSE_CODE="422" # pour un départ d'entrepôt
|
|
1778
1987
|
|
|
1779
1988
|
BARCODES_COUNT=5 # nombres packages
|
|
1780
1989
|
PREF="aaaa" # doit faire 4 caractères utilies pour générer les barecode
|
|
1781
1990
|
# des packtages
|
|
1782
1991
|
|
|
1783
|
-
|
|
1992
|
+
CODE_POSTAUX=("59000", "75001") # liste code postale sur lequelle une addresse aléatoire seras choisi
|
|
1784
1993
|
# (creation de la commade)
|
|
1785
1994
|
DELIVERY_SLOTS=( # liste des horraires de créneau de livraison choisi aléatoirement
|
|
1786
1995
|
"06:00+01:00[Europe/Paris]-08:00+01:00[Europe/Paris]"
|
|
@@ -1790,9 +1999,9 @@ DELIVERY_SLOTS=( # liste des horraires de créne
|
|
|
1790
1999
|
"18:00+01:00[Europe/Paris]-20:00+01:00[Europe/Paris]"
|
|
1791
2000
|
)
|
|
1792
2001
|
|
|
1793
|
-
# DELIVERY_OPTIONS=("skill1" "skill2") # liste des skill - a décommanter
|
|
2002
|
+
# DELIVERY_OPTIONS=("skill1" "skill2") # liste des nom skill - a décommanter
|
|
1794
2003
|
|
|
1795
|
-
# normalement pas bessoin modifer
|
|
2004
|
+
# normalement pas bessoin modifer
|
|
1796
2005
|
ORDER_DATE=$(date '+%Y-%m-%d') # date du jour
|
|
1797
2006
|
RAND=$(date +%y%m%d%H%M%S) # valueur peudo aleadoire (ici basé par date) doit faire 17 caractères
|
|
1798
2007
|
BARCODE_PART=0000$RAND # utiliser pour générer les bare code les barecode sont :
|
|
@@ -1847,7 +2056,7 @@ cleanup_all_ecr_images() {
|
|
|
1847
2056
|
|
|
1848
2057
|
while read -r REPOSITORY; do
|
|
1849
2058
|
echo "processing ECR repository $REPOSITORY before $CLEAN_BEFORE"
|
|
1850
|
-
cleanup_single_ecr_repository $
|
|
2059
|
+
cleanup_single_ecr_repository "$CLEAN_BEFORE" "$REPOSITORY"
|
|
1851
2060
|
done <<< "$REPOSITORIES"
|
|
1852
2061
|
}
|
|
1853
2062
|
|
|
@@ -1855,6 +2064,8 @@ cleanup_single_ecr_repository() {
|
|
|
1855
2064
|
BEFORE=$1
|
|
1856
2065
|
REPOSITORY=$2
|
|
1857
2066
|
|
|
2067
|
+
echo "gettings tags for repository $REPOSITORY before $BEFORE"
|
|
2068
|
+
|
|
1858
2069
|
ALL_TAGS=$(aws ecr describe-images --repository-name "$REPOSITORY" --output json |
|
|
1859
2070
|
jq '.imageDetails' |
|
|
1860
2071
|
jq '. |= sort_by(.imagePushedAt)' |
|
|
@@ -1864,22 +2075,30 @@ cleanup_single_ecr_repository() {
|
|
|
1864
2075
|
jq -r '.imageTags | join(" ")' |
|
|
1865
2076
|
sort -u)
|
|
1866
2077
|
|
|
1867
|
-
|
|
1868
|
-
|
|
2078
|
+
if [ -z "${ALL_TAGS}" ]; then
|
|
2079
|
+
echo "no tag to delete for repository $REPOSITORY"
|
|
2080
|
+
else
|
|
2081
|
+
echo "deleting $(echo $ALL_TAGS | wc -l) tags for $REPOSITORY"
|
|
2082
|
+
|
|
2083
|
+
while read image_tags; do
|
|
2084
|
+
SINGLE_TAG=$(echo $image_tags | grep -o '^\S*')
|
|
1869
2085
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2086
|
+
DIGESTS_TO_DELETE=$(docker buildx imagetools inspect \
|
|
2087
|
+
949316342391.dkr.ecr.eu-west-1.amazonaws.com/$REPOSITORY:$SINGLE_TAG --raw |
|
|
2088
|
+
jq -r '[.manifests | .[].digest] | join(" imageDigest=") | "imageDigest=" + .' ||
|
|
2089
|
+
echo "")
|
|
1873
2090
|
|
|
1874
|
-
|
|
2091
|
+
TAGS_TO_DELETE=$(echo "$image_tags" | sed 's/[^ ]* */imageTag=&/g')
|
|
1875
2092
|
|
|
1876
|
-
|
|
2093
|
+
export AWS_PAGER=""
|
|
1877
2094
|
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
2095
|
+
aws ecr batch-delete-image --repository-name "$REPOSITORY" --image-ids $(echo $TAGS_TO_DELETE) > /dev/null 2>&1
|
|
2096
|
+
test -z $DIGESTS_TO_DELETE ||
|
|
2097
|
+
aws ecr batch-delete-image --repository-name "$REPOSITORY" --image-ids $(echo $DIGESTS_TO_DELETE)> /dev/null 2>&1
|
|
2098
|
+
done <<< $ALL_TAGS
|
|
1881
2099
|
|
|
1882
|
-
|
|
2100
|
+
echo "deleted $(echo $ALL_TAGS | wc -l) tags"
|
|
2101
|
+
fi
|
|
1883
2102
|
|
|
1884
2103
|
}
|
|
1885
2104
|
|
|
@@ -1905,6 +2124,23 @@ cleanup_ci_cache() {
|
|
|
1905
2124
|
done < <(aws s3 ls $CACHE_BUCKET --recursive)
|
|
1906
2125
|
}
|
|
1907
2126
|
|
|
2127
|
+
cleanup_batch_definitions() {
|
|
2128
|
+
DEFINITION_NAME=$1
|
|
2129
|
+
ARNs=($(
|
|
2130
|
+
aws batch describe-job-definitions \
|
|
2131
|
+
--status ACTIVE \
|
|
2132
|
+
--job-definition-name "$DEFINITION_NAME" |
|
|
2133
|
+
jq '.jobDefinitions | sort_by(-.revision)' |
|
|
2134
|
+
jq 'del( .[0])' |
|
|
2135
|
+
jq -r '.[] | .jobDefinitionArn'
|
|
2136
|
+
)
|
|
2137
|
+
)
|
|
2138
|
+
for A in ${ARNs[@]}; do
|
|
2139
|
+
echo "deregister $A"
|
|
2140
|
+
aws batch deregister-job-definition --job-definition $A
|
|
2141
|
+
done
|
|
2142
|
+
echo "cleaned up all definitions except latest"
|
|
2143
|
+
}
|
|
1908
2144
|
#!/usr/bin/env bash
|
|
1909
2145
|
|
|
1910
2146
|
ftp_ikea_k8s() {
|
|
@@ -2360,15 +2596,15 @@ extract_yaml_config_variable() {
|
|
|
2360
2596
|
|
|
2361
2597
|
if [ ! -f ${CONFIGS_PATH}/common.yaml ]; then
|
|
2362
2598
|
echo >&2 "Missing $CONFIGS_PATH/common.yaml configuration file"
|
|
2363
|
-
|
|
2599
|
+
return 1
|
|
2364
2600
|
fi
|
|
2365
2601
|
if [ ! -f ${CONFIGS_PATH}/${ENVIRONMENT}.yaml ]; then
|
|
2366
2602
|
echo >&2 "Missing $CONFIGS_PATH/$ENVIRONMENT.yaml configuration file"
|
|
2367
|
-
|
|
2603
|
+
return 1
|
|
2368
2604
|
fi
|
|
2369
2605
|
if [ ! -f ${CONFIGS_PATH}/${ENVIRONMENT}-secrets.yaml ]; then
|
|
2370
2606
|
echo >&2 "Missing $CONFIGS_PATH/$ENVIRONMENT-secrets.yaml configuration file"
|
|
2371
|
-
|
|
2607
|
+
return 1
|
|
2372
2608
|
fi
|
|
2373
2609
|
|
|
2374
2610
|
result=$(yq -r ${VARIABLE} "$CONFIGS_PATH/$ENVIRONMENT-secrets.yaml")
|
|
@@ -2379,10 +2615,10 @@ extract_yaml_config_variable() {
|
|
|
2379
2615
|
if [ $? -ne 0 ] || [ "$result" = "null" ]; then
|
|
2380
2616
|
if [ $OPTIONAL = true ]; then
|
|
2381
2617
|
echo ""
|
|
2382
|
-
|
|
2618
|
+
return 0
|
|
2383
2619
|
else
|
|
2384
2620
|
echo >&2 "Missing path $VARIABLE in $CONFIGS_PATH/$ENVIRONMENT-secrets.yaml, $CONFIGS_PATH/$ENVIRONMENT.yaml or $CONFIGS_PATH/common.yaml"
|
|
2385
|
-
|
|
2621
|
+
return 1
|
|
2386
2622
|
fi
|
|
2387
2623
|
fi
|
|
2388
2624
|
fi
|
|
@@ -2655,7 +2891,7 @@ deploy_chart() {
|
|
|
2655
2891
|
if [ ! -d ${root_path}/${path_chart} ] || [ ! -f ${root_path}/${path_chart}/Chart.yaml ]; then
|
|
2656
2892
|
echo "Bad Chart $root_path/$path_chart : does not exists or missing Chart.yaml"
|
|
2657
2893
|
print_usage
|
|
2658
|
-
|
|
2894
|
+
return 1
|
|
2659
2895
|
fi
|
|
2660
2896
|
|
|
2661
2897
|
# Unset Kubectl configuration made via the KUBECONFIG env variable
|
|
@@ -2738,7 +2974,7 @@ verify_deployments() {
|
|
|
2738
2974
|
|
|
2739
2975
|
if [ $? -ne 0 ]; then
|
|
2740
2976
|
echo "at least one deployment failed or timed out (after $TIMEOUT)"
|
|
2741
|
-
|
|
2977
|
+
return 1
|
|
2742
2978
|
fi
|
|
2743
2979
|
done
|
|
2744
2980
|
|
|
@@ -2761,7 +2997,7 @@ check_config_file() {
|
|
|
2761
2997
|
if [ ! -f ${filename} ]; then
|
|
2762
2998
|
echo "Missing $filename configuration file"
|
|
2763
2999
|
print_usage
|
|
2764
|
-
|
|
3000
|
+
return 1
|
|
2765
3001
|
fi
|
|
2766
3002
|
}
|
|
2767
3003
|
|
|
@@ -2986,7 +3222,7 @@ emit_datadog_deploy_event() {
|
|
|
2986
3222
|
echo "event successfully created check in datadog UI : $url"
|
|
2987
3223
|
else
|
|
2988
3224
|
echo " failed to create event "
|
|
2989
|
-
|
|
3225
|
+
return 1
|
|
2990
3226
|
fi
|
|
2991
3227
|
}
|
|
2992
3228
|
|