├── .gcloudignore ├── .gitignore ├── README.md ├── cloudbuild_breakout.yaml ├── cloudbuild_expanded_a.yaml ├── cloudbuild_expanded_b.yaml ├── cloudbuild_simple.yaml ├── firebase ├── .firebaserc ├── .gcloudignore ├── .gitignore ├── README.md ├── firebase.json └── public │ ├── 404.html │ └── index.html ├── functions ├── README.md └── index.js └── tools └── curl-test.sh /.gcloudignore: -------------------------------------------------------------------------------- 1 | # This file specifies files that are *not* uploaded to Google Cloud Platform 2 | # using gcloud. It follows the same syntax as .gitignore, with the addition of 3 | # "#!include" directives (which insert the entries of the given .gitignore-style 4 | # file at that point). 5 | # 6 | # For more information, run: 7 | # $ gcloud topic gcloudignore 8 | # 9 | .gcloudignore 10 | # If you would like to upload your .git directory, .gitignore file or files 11 | # from your .gitignore file, remove the corresponding line 12 | # below: 13 | .git 14 | .gitignore 15 | 16 | node_modules 17 | #!include:.gitignore 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gcb-syntax-blog 2 | Example code used in blog post about Google Cloud Build syntax 3 | -------------------------------------------------------------------------------- /cloudbuild_breakout.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/curl' 3 | entrypoint: 'bash' 4 | args: 5 | - '-c' 6 | - | 7 | PET="$$(curl -s https://pets.doingdevops.com/pet_flaky --max-time 10)" 8 | while [ "$$PET" == "ERROR" ] ; do 9 | echo "Error: API failed to respond with a pet! Try again..." 10 | PET="$$(curl -s https://pets.doingdevops.com/pet_flaky --max-time 10)" 11 | done 12 | echo "Success! $${PET}" -------------------------------------------------------------------------------- /cloudbuild_expanded_a.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: "gcr.io/cloud-builders/curl" 3 | args: 4 | - 'https://pets.doingdevops.com/pet' 5 | - '-s' 6 | - '--max-time' 7 | - '10' -------------------------------------------------------------------------------- /cloudbuild_expanded_b.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: "gcr.io/cloud-builders/curl" 3 | args: 4 | [ 5 | 'https://pets.doingdevops.com/pet', 6 | '-s', 7 | '--max-time', '10', # related arguments are grouped on one line 8 | ] -------------------------------------------------------------------------------- /cloudbuild_simple.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: "gcr.io/cloud-builders/curl" 3 | args: ['https://pets.doingdevops.com/pet','-s','--max-time','10'] -------------------------------------------------------------------------------- /firebase/.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "sandbox": "gcb-sandbox" 4 | } 5 | } -------------------------------------------------------------------------------- /firebase/.gcloudignore: -------------------------------------------------------------------------------- 1 | # This file specifies files that are *not* uploaded to Google Cloud Platform 2 | # using gcloud. It follows the same syntax as .gitignore, with the addition of 3 | # "#!include" directives (which insert the entries of the given .gitignore-style 4 | # file at that point). 5 | # 6 | # For more information, run: 7 | # $ gcloud topic gcloudignore 8 | # 9 | .gcloudignore 10 | # If you would like to upload your .git directory, .gitignore file or files 11 | # from your .gitignore file, remove the corresponding line 12 | # below: 13 | .git 14 | .gitignore 15 | 16 | node_modules 17 | #!include:.gitignore 18 | -------------------------------------------------------------------------------- /firebase/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | firebase-debug.log* 8 | 9 | # Firebase cache 10 | .firebase/ 11 | 12 | # Firebase config 13 | 14 | # Uncomment this if you'd like others to create their own Firebase project. 15 | # For a team working on the same Firebase project(s), it is recommended to leave 16 | # it commented so all members can deploy to the same project(s) in .firebaserc. 17 | # .firebaserc 18 | 19 | # Runtime data 20 | pids 21 | *.pid 22 | *.seed 23 | *.pid.lock 24 | 25 | # Directory for instrumented libs generated by jscoverage/JSCover 26 | lib-cov 27 | 28 | # Coverage directory used by tools like istanbul 29 | coverage 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (http://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | 49 | # Optional npm cache directory 50 | .npm 51 | 52 | # Optional eslint cache 53 | .eslintcache 54 | 55 | # Optional REPL history 56 | .node_repl_history 57 | 58 | # Output of 'npm pack' 59 | *.tgz 60 | 61 | # Yarn Integrity file 62 | .yarn-integrity 63 | 64 | # dotenv environment variables file 65 | .env 66 | -------------------------------------------------------------------------------- /firebase/README.md: -------------------------------------------------------------------------------- 1 | Firebase is used to establish a custom domain front end for GCF. The only really important bit here is firebase.json -------------------------------------------------------------------------------- /firebase/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "public", 4 | "rewrites": [ 5 | { 6 | "source": "/pet", "function": "pet" 7 | }, 8 | { 9 | "source": "/pet_flaky", "function": "pet_flaky" 10 | } 11 | ], 12 | "ignore": [ 13 | "firebase.json", 14 | "**/.*", 15 | "**/node_modules/**" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /firebase/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Page Not Found 7 | 8 | 23 | 24 | 25 |
26 |

404

27 |

Page Not Found

28 |

The specified file was not found on this website. Please check the URL for mistakes and try again.

29 |

Why am I seeing this?

30 |

This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.

31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /firebase/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to Firebase Hosting 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 32 | 33 | 34 |
35 |

Welcome

36 |

Firebase Hosting Setup Complete

37 |

You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!

38 | Open Hosting Documentation 39 |
40 |

Firebase SDK Loading…

41 | 42 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /functions/README.md: -------------------------------------------------------------------------------- 1 | These functions are published to GCF via 2 | `gcloud functions deploy pet[_flaky] --runtime nodejs8 --trigger-http` -------------------------------------------------------------------------------- /functions/index.js: -------------------------------------------------------------------------------- 1 | var dog = ` 2 | .o8 3 | "888 4 | .oooo888 .ooooo. .oooooooo 5 | d88' '888 d88' '88b 888' '8b 6 | 888 888 888 888 888 888 7 | 888 888 888 888 '88bod8P' 8 | 'Y8bod88P" 'Y8bod8P' '8oooooo. 9 | d" YD 10 | "Y88888P' 11 | 12 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 13 | @@@@@@@@@@@@@@@@@@@@@@@***,@@@@@@@@@@@@ 14 | @@@@@@@@@@@@/,,,...,,////**...,@@@@@@@@ 15 | @@@@@@@@#... ... *(/*,,.@&(**,,,@@@@@@@ 16 | @@@@@@@@ . . .../(///*,.,&@#*...@@@@@@@ 17 | @@@@@@@@@@... ..(///*,. %&/ @@@@@@@ 18 | @@@@@@@@@@.... .,/,. * . ,&&(,.@@@@@@@ 19 | @@@@@@,&@#(/.,,.,/*,,...,&&., . &@@@@@@ 20 | @@@@%..@@#(/*(/*///*,.*(@@&&&**.&&@@@@@ 21 | @%/(@.,&@@%(&@///(*,..,(@@@@&*,./&@@@@@ 22 | //@@@,.,/@@&@&&*., ..,*&&&@%.. ,#@@@@@ 23 | */@@@@,,.,&@@@%&%* , ,(&@@&*##%##@@@@@@ 24 | //(@@@@@.,..*@@&&%#*,,..//%&%#%%%@@@@@@ 25 | ///#&@@@@@.,....(%%%#*..##%#,%(%@@@@@@@ 26 | /(//#@@@@@@@@# . .@@@@@@@@@@@@@@@@@ 27 | //((#@@@@@@@@&@&%%#(##@@@@@@@@@@@@@@@@@ 28 | /(/((@@@@@@@@&&&&%###%@@@@@@@@@@@@@@@@@ 29 | //(/(&@@@@@@&&%#%####%@@@@@@@@@@@@@@@@@ 30 | ///(((@@@@@@&&%%%%##%#@@@@@@@@@@@@@@@@@ 31 | //(/((((@@&&&%#%&%###%@@@@@@@@@@@@@@@@@ 32 | `; 33 | 34 | var cat = ` 35 | . 36 | .o8 37 | .ooooo. .oooo. .o888oo 38 | d88' '"Y8 'P )88b 888 39 | 888 .oP"888 888 40 | 888 .o8 d8( 888 888 . 41 | 'Y8bod8P' 'Y888""8o "888" 42 | 43 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 44 | @@@@@@@@@@@@@@@@@@@@@*,*@@@@@@,*/@@@@@@ 45 | @@@@@@@@@@@@@@@@@@@@@...,*##(*...@@@@@@ 46 | @@@@@@@@@@@@@@@@@@@@@. * ,,/, ., @@@@@@ 47 | @@@@@@@@@@@@@@@@@@@@@#/,***./***(@@@@@@ 48 | @@@@@@@@@@@@@@@@@@@@@(/,,., ..,*(@@@@@@ 49 | @@@@@@@@@@@@@@@@@@@@@@/,.,,,*,.,%@@@@@@ 50 | @@@@@@@@@@@@@@@@@@@@@.**,,....,*,(@@@@@ 51 | @@@@@@@@@@@@@@@@@@@,,,,,,.. ./@@@@@ 52 | @@@@@@@@@@@@@@@@@@..,*,,, . ,*#@@@@ 53 | @@@@@@@@@@@@@@@@@*,..*/*.. .,/#@@@@ 54 | @@@@@@@@@@@@@@@@. *,..(*,,.,. . /&@@@@ 55 | @@@@@@@@@@@@@@@. /.. */...,, ../(@@@@@ 56 | @@@@@@@@@@@@@@ *,*, .(/..,* .*(@@@@@ 57 | @@@@@@@@@@@@. .*,,,..,(*,*(,..,(@@@@@ 58 | @@@@@@@@@@ ..,/,.,,,../*,*(* ,*&@@@@@ 59 | @@@@@@*. ....@@@/, ,@* ,*,*(*.,*@@@@@@ 60 | @@@,,....@@@@@@@/,.@@@ ./,*(,.*(@@@@@@ 61 | @@@@@@@@@@@@@@@@(, ,@@@. *(,/.,/@@@@@@@ 62 | @@@@@@@@@@@@@@@@@*./@@@@ *..*/@@@@@@@ 63 | @@@@@@@@@@@@@@@@@@@@@@@@@@@*.,*/@@@@@@@ 64 | @@@@@@@@@@@@@@@@@@@@@@@@@@@&.,/@@@@@@@@ 65 | ` 66 | // flakiness is a float between 0 and 1; higher values create a flakier API 67 | function getPet(flakiness) { 68 | if(Math.random() < flakiness) { 69 | return "ERROR\n"; 70 | } 71 | 72 | if(Math.random() > 0.5) { 73 | return dog; 74 | } else { 75 | return cat; 76 | } 77 | } 78 | 79 | // unflaky API 80 | exports.pet = (req, res) => { 81 | res.send(getPet(0)); 82 | }; 83 | 84 | // flaky API 85 | exports.pet_flaky = (req, res) => { 86 | res.send(getPet(0.8)); 87 | }; -------------------------------------------------------------------------------- /tools/curl-test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # curl "https://qrng.anu.edu.au/API/jsonI.php?length=1&type=uint16" -o random.json 4 | 5 | # if [ $(( $(curl -s "https://xrand.org/ints?count=1&start=1&end=11&radix=10") % 2 )) == 0 ]; then echo "even"; else echo "odd"; fi 6 | 7 | #PET=$(curl -s "https://gcb-sandbox.firebaseapp.com/pet_flaky" --max-time 10); 8 | 9 | PET="$(curl -s https://gcb-sandbox.firebaseapp.com/pet_flaky --max-time 10)"; 10 | while [ "$PET" == "ERROR" ] ; do 11 | echo "Error: no pet! Try again..."; 12 | PET="$(curl -s https://gcb-sandbox.firebaseapp.com/pet_flaky --max-time 10)"; 13 | done; 14 | echo "Success! ${PET}"; --------------------------------------------------------------------------------