Skip to content

Commit 7f57a9e

Browse files
authored
updated GitOps lab (#83)
* added ds deploy command * added comments to scripts
1 parent ac2de79 commit 7f57a9e

File tree

92 files changed

+1802
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1802
-79
lines changed

.ds/commands/applications/list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
# "ds applications list" queries the Res-Edge data service and displays a list of Applications
4+
35
KIC_RES_EDGE_ENTITYNAME="applications" "$CLI_CMD_DIR/res-edge/entity-list" "$@"

.ds/commands/applications/show

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
# "ds applications show --id <id>" displays a json object from the Res-Edge data service
4+
35
KIC_RES_EDGE_ENTITYNAME="applications" "$CLI_CMD_DIR/res-edge/entity-show" "$@"

.ds/commands/cicd

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,17 @@
11
#!/bin/bash
22

3-
RESEDGE_AUTOMATION_DOCKER_IMAGE="ghcr.io/cse-labs/res-edge-automation:0.9"
3+
# "ds cicd" use the Res-Edge Automation docker image and the Res-Edge Data Service
4+
# to generate GitOps manifest files for each Cluster
45

5-
usage() {
6-
echo "Usage: kic cicd [--show]"
7-
exit 1
8-
}
6+
# Run "git status" to see the repo changes
97

10-
# check the number of parameters
11-
if [ $# -gt 1 ]; then
12-
usage
13-
fi
14-
15-
# extract the first parameter into a variable
16-
param="$1"
17-
18-
# check if the parameter is valid
19-
if [ $# -eq 1 ]; then
20-
if [[ $param == "--show" ]]; then
21-
show_flag=1
22-
else
23-
usage
24-
fi
25-
fi
26-
27-
# If the flag is set, show a message
28-
if [[ $show_flag -eq 1 ]]; then
29-
cat << EOF
30-
Default Script
31-
32-
#!/bin/bash
33-
34-
# The following command will execute the ghcr.io/cse-labs/res-edge-automation image in docker
35-
# and will mount the current directory into a working directory inside the container.
36-
# The container will retrieve all required information from the dataservice
37-
# and validate, create and/or update (as necessary) the clusters gitops manifest files
38-
# in the working directory without pushing changes to remote repository.
39-
40-
docker run -it --rm \\
41-
--net host \\
42-
-v \$(pwd):/goa \\
43-
${RESEDGE_AUTOMATION_DOCKER_IMAGE} \\
44-
-s "${DS_URL}"
45-
EOF
46-
exit
47-
fi
8+
# The changes are not pushed to GitHub
9+
# use "ds deploy" to push any GitOps changes
4810

4911
echo "Running ci-cd locally ..."
5012

51-
# The following command will execute the ghcr.io/cse-labs/res-edge-automation image in docker
52-
# and will mount the current directory into a working directory inside the container.
53-
# The container will retrieve all required information from the dataservice
54-
# and validate, create and/or update (as necessary) the clusters gitops manifest files
55-
# in the working directory without pushing changes to remote repository.
5613
docker run -it --rm \
5714
--net host \
58-
-v "$(pwd)":/goa \
59-
${RESEDGE_AUTOMATION_DOCKER_IMAGE} \
15+
-v "$KIC_BASE":/goa \
16+
ghcr.io/cse-labs/res-edge-automation:0.9 \
6017
-s "${DS_URL}"

.ds/commands/clusters/list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
# "ds clusters list" queries the Res-Edge data service and displays a list of Clusters
4+
35
KIC_RES_EDGE_ENTITYNAME="clusters" "$CLI_CMD_DIR/res-edge/entity-list" "$@"

.ds/commands/clusters/show

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
# "ds clusters show --id <id>" displays a json object from the Res-Edge data service
4+
35
KIC_RES_EDGE_ENTITYNAME="clusters" "$CLI_CMD_DIR/res-edge/entity-show" "$@"

.ds/commands/deploy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# "ds cicd" uses Res-Edge Automation to update the Cluster manifests in the "clusters" directory
4+
# "ds deploy" will commit and push any changes to the "clusters" directory tree to GitHub
5+
# It will not push changes outside the clusters directory
6+
7+
if [[ $(git status "$KIC_BASE/clusters" --porcelain | wc -l ) = 0 ]]; then
8+
echo "No updates to deploy"
9+
exit 0
10+
fi
11+
12+
git add "$KIC_BASE/clusters"
13+
git commit -m "Res-Edge Automation via ds cicd"
14+
git push

.ds/commands/env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3-
env | grep -e "^DS_" -e "^CLI_" -e "^KIC_" | sort
3+
# "ds env" will display a sorted list of environment variables used by the CLIs
4+
5+
env | grep -e "^CLI_" -e "^DS_" -e "^KIC_" | sort

.ds/commands/groups/list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
# "ds groups list" queries the Res-Edge data service and displays a list of Groups
4+
35
KIC_RES_EDGE_ENTITYNAME="groups" "$CLI_CMD_DIR/res-edge/entity-list" "$@"

.ds/commands/groups/show

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
# "ds groups show --id <id>" displays a json object from the Res-Edge data service
4+
35
KIC_RES_EDGE_ENTITYNAME="groups" "$CLI_CMD_DIR/res-edge/entity-show" "$@"

.ds/commands/namespaces/list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
# "ds namespaces list" queries the Res-Edge data service and displays a list of Namespaces
4+
35
KIC_RES_EDGE_ENTITYNAME="namespaces" "$CLI_CMD_DIR/res-edge/entity-list" "$@"

0 commit comments

Comments
 (0)