Skip to content

Commit

Permalink
Working version of ChatGPT generator script
Browse files Browse the repository at this point in the history
  • Loading branch information
DGuhr committed Jan 28, 2023
1 parent 5026e3e commit aa6ace8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHATGPT_GENERATOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,16 @@ I actually played around quite a bit with feeding ChatGPT with the schema refere

Off bouldering,
Dom

#Update 1:
Oh, dare you, bash! For sure the variables defined in the script are not made available to the calling script unless you use source! But luckily ChatGPT is a bash magician, so after a little fiddling - or lets say, crying for help...
```
i have the following lines in my calling script that calls the script1.sh beforehand:
echo "Username 1 is set to ${username1}"
user1Uid=$(/opt/keycloak/bin//kcadm.sh get users -r master -q username=$username1 --fields=id | awk -F':' '{print $2}' | grep . | tr -d "\"" | sed -e 's/^[[:space:]]*//')
The ${username1} echo returns an empty result. help
```
it gave me the actual correct response: use `source` you brat!
![q_and_a7](https://github.com/DGuhr/keycloak-spicedb-eventlistener/blob/main/assets/q_and_a7.png?raw=true)

So now it really works :)
Binary file added assets/q_and_a7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions initialize-poc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ echo "Connecting kcadm.sh to local keycloak instance..."
echo "Success! Now adding test-events to master-realm and initializing scheme..."
/opt/keycloak/bin/kcadm.sh update events/config -r master -s 'eventsListeners=["jboss-logging","spicedb-events"]'

sleep 5
echo "Success! Also waited 5 seconds to allow initializing the spiceDB schema."
sleep 4
echo "Success! Also waited 4 seconds to allow initializing the spiceDB schema."
# echo "Now adding users to master-realm including org_id field. Thank you, ChatGPT... :-D"
/opt/keycloak/bin/usergenerator.sh 10
source /opt/keycloak/bin/usergenerator.sh 10

echo "Now adding an org/ tenant id to the admin, needed for creating groups that are tied to an org (we need the orgid of the creating person there)"

Expand All @@ -54,6 +54,7 @@ echo "Now that we simulate an orgs admin, we can let them create a group that sh
/opt/keycloak/bin/kcadm.sh create groups -r master -s name=MyGroup

echo "ok now lets add a user to the previously created group... in order to do that we need the userId and the groupId."
echo "Username 1 is set to ${username1}"
user1Uid=$(/opt/keycloak/bin//kcadm.sh get users -r master -q username=$username1 --fields=id | awk -F':' '{print $2}' | grep . | tr -d "\"" | sed -e 's/^[[:space:]]*//')
myGroupUid=$(/opt/keycloak/bin//kcadm.sh get groups -r master -q name=MyGroup --fields=id | awk -F':' '{print $2}' | grep . | tr -d "\"" | sed -e 's/^[[:space:]]*//')
/opt/keycloak/bin/kcadm.sh update users/$user1Uid/groups/$myGroupUid -r master -s realm=master -s userId=$user1Uid -s groupId=$myGroupUid -n
Expand Down

0 comments on commit aa6ace8

Please sign in to comment.