github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/examples/0002/02/notes.md (about) 1 ### Notes 2 3 Demo the basic structure to config scope and execute a mock call to create an app stack by send a post api call 4 5 ### Incremental Improvement 6 7 #### Add an interactive encryption/decryption util 8 9 ``` 10 11 Ξ 0002/02 git:(master) ▶ up ngo Utils_crypt_interactive -i dev 12 loading [Config]: ./upconfig.yml 13 Main config: 14 Version -> 1.0.0 15 RefDir -> ./ups 16 WorkDir -> cwd 17 AbsWorkDir -> /up-project/up/examples/0002/02 18 TaskFile -> up.yml 19 Verbose -> v 20 ModuleName -> self 21 ShellType -> /bin/sh 22 MaxCallLayers -> 8 23 Timeout -> 3600000 24 MaxModuelCallLayers -> 256 25 EntryTask -> Utils_crypt_interactive 26 work dir: /up-project/up/examples/0002/02 27 -exec task: Utils_crypt_interactive 28 loading [Task]: ./up.yml 29 module: [self], instance id: [dev], exec profile: [] 30 loading [./main.yml]: ./ups/./main.yml 31 loading [./utils/encrypt.yml]: ./ups/./utils/encrypt.yml 32 Task2: [Utils_crypt_interactive ==> Utils_crypt_interactive: ] 33 -Step1: 34 Enter Value For [choice]: 35 choose 1 to encrypt or anyting else to decrypt 36 1 37 =Task3: [Utils_crypt_interactive ==> encrypt: ] 38 --Step1: 39 Enter Value For [raw]: 40 This will be saved as raw's value 41 api_username 42 ~~SubStep1: [print: ] 43 api_username 44 ~~SubStep2: [print: ] 45 ixAvykgdH73SafoaGEGB+WiPH/zwZzYQnDMUrIig7lc= 46 ~~SubStep3: [print: ] 47 api_username 48 49 ``` 50 51 #### Move core business task to sit under ./ups/myapp/create.yml 52 53 #### Move the Main task to: ./ups/main.yml 54 55 #### Use secret username/password instead of plain text in post call 56 57 #### Save the encrypted config vars in up.yml in its own scope 58 59 So, you can have one common password for prod/nonprod, or dev/staging individually for nonprod env. Just put them into the scope 60 61 62 ### list 63 64 ``` 65 Ξ 0002/02 git:(master) ▶ up list 66 loading [Config]: ./upconfig.yml 67 Main config: 68 Version -> 1.0.0 69 RefDir -> ./ups 70 WorkDir -> cwd 71 AbsWorkDir -> /up-project/up/examples/0002/02 72 TaskFile -> up.yml 73 Verbose -> v 74 ModuleName -> self 75 ShellType -> /bin/sh 76 MaxCallLayers -> 8 77 Timeout -> 3600000 78 MaxModuelCallLayers -> 256 79 EntryTask -> 80 work dir: /up-project/up/examples/0002/02 81 loading [Task]: ./up.yml 82 module: [self], instance id: [nonamed], exec profile: [] 83 WARN: [*be aware*] - [both instance id and exec profile are not set] 84 loading [./main.yml]: ./ups/./main.yml 85 loading [./utils/encrypt.yml]: ./ups/./utils/encrypt.yml 86 loading [./myapp/create.yml]: ./ups/./myapp/create.yml 87 -task list 88 1 | Main | public| 89 2 | Utils_crypt_interactive | public| 90 3 | encrypt |protected| 91 4 | decrypt |protected| 92 5 | CreateMyAppStack | public| 93 ``` 94 95 #### exec 96 97 ``` 98 99 Ξ 0002/02 git:(master) ▶ up ngo CreateMyAppStack -i dev 100 loading [Config]: ./upconfig.yml 101 Main config: 102 Version -> 1.0.0 103 RefDir -> ./ups 104 WorkDir -> cwd 105 AbsWorkDir -> /up-project/up/examples/0002/02 106 TaskFile -> up.yml 107 Verbose -> v 108 ModuleName -> self 109 ShellType -> /bin/sh 110 MaxCallLayers -> 8 111 Timeout -> 3600000 112 MaxModuelCallLayers -> 256 113 EntryTask -> CreateMyAppStack 114 work dir: /up-project/up/examples/0002/02 115 -exec task: CreateMyAppStack 116 loading [Task]: ./up.yml 117 module: [self], instance id: [dev], exec profile: [] 118 loading [./main.yml]: ./ups/./main.yml 119 loading [./utils/encrypt.yml]: ./ups/./utils/encrypt.yml 120 loading [./myapp/create.yml]: ./ups/./myapp/create.yml 121 Task5: [CreateMyAppStack ==> CreateMyAppStack: ] 122 -Step1: [create_my_application: fake mock up only ] 123 cmd( 1): 124 - 125 { 126 "args": {}, 127 "data": "", 128 "files": {}, 129 "form": { 130 "\n{\n \"name\": \"tom\",\n \"class\": \"year12-k\",\n \"school\": \"SG\"\n \"username\": \"api_username\"\n \"password\": \"the_api_password\"\n}": "" 131 }, 132 "headers": { 133 "Accept": "application/json", 134 "Content-Length": "123", 135 "Content-Type": "application/x-www-form-urlencoded", 136 "Host": "httpbin.org", 137 "User-Agent": "curl/7.54.0", 138 "X-Amzn-Trace-Id": "Root=1-5f578ccc-a88a77be8fb07696fb993f3e" 139 }, 140 "json": null, 141 "origin": "118.211.180.66", 142 "url": "http://httpbin.org/post" 143 } 144 145 - 146 .. ok 147 . ok 148 149 ```