|
| 1 | +print("These macros are from parser_test.go --------------") |
| 2 | + |
| 3 | +# basic |
| 4 | +print("@@{calm_random}@@") |
| 5 | +print("@@{calm_unique}@@") |
| 6 | +print("@@{AZ_RANDOM}@@") |
| 7 | +print("@@{AZ_UNIQUE}@@") |
| 8 | +print("@@{calm_random_hash}@@") |
| 9 | +print("@@{calm_random_hex}@@") |
| 10 | +print("@@{AZ_RANDOM_HASH}@@") |
| 11 | +print("@@{AZ_RANDOM_HEX}@@") |
| 12 | + |
| 13 | +print("@@{AZ_B64ENCODE(calm_unique)}@@") |
| 14 | +print("@@{calm_b64encode(calm_unique)}@@") |
| 15 | + |
| 16 | +# Base64 Decode |
| 17 | +print("@@{AZ_B64ENCODE(calm_b64encode(calm_random))}@@") |
| 18 | +print("@@{calm_b64decode(calm_b64encode(calm_random))}@@") |
| 19 | +print('@@{calm_b64decode(calm_b64encode("日本語"))}@@') |
| 20 | + |
| 21 | +# calm_random |
| 22 | +print("@@{calm_random_hash(2)}@@") |
| 23 | +print("@@{calm_random_hash}@@") |
| 24 | +print("@@{calm_random_hex(2)}@@") |
| 25 | +print("@@{calm_random_hex}@@") |
| 26 | +print("@@{AZ_RANDOM_HASH(2)}@@") |
| 27 | +print("@@{AZ_RANDOM_HASH}@@") |
| 28 | +print("@@{AZ_RANDOM_HEX(2)}@@") |
| 29 | +print("@@{AZ_RANDOM_HEX}@@") |
| 30 | + |
| 31 | +# calm_int |
| 32 | +print("@@{calm_int(2)}@@") |
| 33 | +print("@@{calm_int(AZ_INT(-3.6))}@@") |
| 34 | +print("@@{calm_int(calm_float(4.5))}@@") |
| 35 | + |
| 36 | +# calm_float |
| 37 | +print("@@{calm_float(2.5)}@@") |
| 38 | +print('@@{AZ_FLOAT("-4")}@@') |
| 39 | +print("@@{calm_float(calm_int(1.5))}@@") |
| 40 | + |
| 41 | +# calm_string |
| 42 | +print("@@{calm_string(2.505)}@@") |
| 43 | +print("@@{calm_string(calm_int(1))}@@") |
| 44 | +print('@@{AZ_STRING("string")}@@') |
| 45 | +print('@@{calm_string(calm_int(calm_string("123")))}@@') |
| 46 | +print("""@@{calm_string(AZ_JSON_LOAD('{"value": false}').get('value'))}@@""") |
| 47 | + |
| 48 | +# AZ_LEN with split |
| 49 | +print('@@{AZ_LEN("hello,world,now,forever,moon,sun", ",")}@@') |
| 50 | +print('@@{AZ_LEN("hello,world你好!你好吗notbeforecomma,now,forever,moon,sun", ",")}@@') |
| 51 | + |
| 52 | +# AZ_LEN without split |
| 53 | +print('@@{AZ_LEN("Hello")}@@') |
| 54 | +print('@@{AZ_LEN("€")}@@') |
| 55 | + |
| 56 | +# JSONLoadAndDumpBasic |
| 57 | +print("""@@{AZ_JSON_DUMP(AZ_JSON_LOAD('{"strs":["a","b"],"hello":{"1":true}}'))}@@""") |
| 58 | +print('@@{AZ_JSON_DUMP(AZ_JSON_LOAD("1"))}@@') |
| 59 | + |
| 60 | +# JSONRelationalBasic |
| 61 | +print("""@@{AZ_JSON_LOAD('{"Name":"Platypus","Order":"Monotremata"}').get('Name')}@@""") |
| 62 | + |
| 63 | +# JSON Relational Nested |
| 64 | +print( |
| 65 | + """@@{AZ_JSON_LOAD('{"num":6.13,"strs":["a","b"],"hello":{"1":"2"}}').get('hello').get('1')}@@""" |
| 66 | +) |
| 67 | + |
| 68 | +# AZ_TIME |
| 69 | +print("@@{calm_time}@@") |
| 70 | +print("@@{AZ_TIME('%y%m%d-%H%M%S')}@@") |
| 71 | +print("@@{AZ_TIME('%y%m%d-%H%M%S', 'gmt')}@@") |
| 72 | + |
| 73 | +# AZ_SPLIT |
| 74 | +print('@@{AZ_SPLIT("hello,world你好!你好吗notbeforecomma,now,forever,moon,sun", ",")}@@') |
| 75 | + |
| 76 | +# AZ_DAY |
| 77 | +print("@@{AZ_DAY('month','gmt')}@@") |
| 78 | +print("@@{AZ_DAY('year','utc')}@@") |
| 79 | +print("@@{calm_day('month','gmt')}@@") |
| 80 | +print("@@{calm_day('year')}@@") |
| 81 | +print("@@{calm_day('year', 'utc')}@@") |
| 82 | + |
| 83 | +# AzMonthShort |
| 84 | +print("@@{AZ_MONTH('short')}@@") |
| 85 | +print("@@{AZ_MONTH('short','gmt')}@@") |
| 86 | +print("@@{calm_month('short','utc')}@@") |
| 87 | + |
| 88 | +# AZ_REPLACE |
| 89 | +print('@@{AZ_REPLACE("x(p*)y", "B", "xy--xpppyxxppxy-")}@@') |
| 90 | +print('@@{AZ_REPLACE("x(p*)y", "$1P", "xy--xpppyxxppxy-")}@@') |
| 91 | +print('@@{AZ_REPLACE("x(p*)y", "${1}Q", "xy--xpppyxxppxy-")}@@') |
| 92 | + |
| 93 | +# AZ_MONTH LONG |
| 94 | +print("@@{AZ_MONTH('long','gmt')}@@") |
| 95 | +print("@@{calm_month('long')}@@") |
| 96 | +print("@@{calm_month('long','gmt')}@@") |
| 97 | + |
| 98 | +# AZ_MONTH |
| 99 | +print("@@{AZ_MONTH('mm')}@@") |
| 100 | +print("@@{AZ_MONTH('mm','utc')}@@") |
| 101 | +print("@@{calm_month('mm','gmt')}@@") |
| 102 | + |
| 103 | +# AZ_JOIN |
| 104 | +print("""@@{AZ_JOIN(AZ_JSON_LOAD('["a", "b", "c"]') , ',')}@@""") |
| 105 | + |
| 106 | +# AzYearFormat |
| 107 | +print("@@{AZ_YEAR('yy')}@@") |
| 108 | +print("@@{calm_year('yy','gmt')}@@") |
| 109 | +print("@@{calm_year('yy','utc')}@@") |
| 110 | + |
| 111 | +# AzYear |
| 112 | +print("@@{AZ_YEAR('yyyy')}@@") |
| 113 | +print("@@{calm_year('yyyy','gmt')}@@") |
| 114 | +print("@@{calm_year('yyyy','utc')}@@") |
| 115 | + |
| 116 | +# AzWeekdayShort |
| 117 | +print("@@{AZ_WEEKDAY('name_short')}@@") |
| 118 | +print("@@{calm_weekday('name_short','gmt')}@@") |
| 119 | +print("@@{calm_weekday('name_short','utc')}@@") |
| 120 | + |
| 121 | + |
| 122 | +# TestAzWeekdayLong |
| 123 | +print("@@{AZ_WEEKDAY('name_long')}@@") |
| 124 | +print("@@{calm_weekday('name_long','gmt')}@@") |
| 125 | +print("@@{calm_weekday('name_long','utc')}@@") |
| 126 | + |
| 127 | +# TestAzIsWeekday |
| 128 | +print("@@{AZ_IS_WEEKDAY()}@@") |
| 129 | +print("@@{calm_is_weekday()}@@") |
| 130 | +print("@@{AZ_IS_LONG_WEEKDAY()}@@") |
| 131 | +print("@@{calm_is_long_weekday()}@@") |
| 132 | +print("@@{AZ_IS_WEEKDAY('gmt')}@@") |
| 133 | +print("@@{AZ_IS_WEEKDAY('utc')}@@") |
| 134 | +print("@@{calm_is_weekday('gmt')}@@") |
| 135 | +print("@@{calm_is_weekday('utc')}@@") |
| 136 | +print("@@{AZ_IS_LONG_WEEKDAY('gmt')}@@") |
| 137 | +print("@@{AZ_IS_LONG_WEEKDAY('utc')}@@") |
| 138 | +print("@@{calm_is_long_weekday('gmt')}@@") |
| 139 | +print("@@{calm_is_long_weekday('utc')}@@") |
| 140 | + |
| 141 | +# TestAzWeekNumber |
| 142 | +print("@@{AZ_WEEKNUMBER}@@") |
| 143 | +print("@@{AZ_WEEKNUMBER('gmt')}@@") |
| 144 | +print("@@{AZ_WEEKNUMBER('utc')}@@") |
| 145 | +print("@@{AZ_WEEKNUMBER('gmt','iso')}@@") |
| 146 | +print("@@{calm_weeknumber()}@@") |
| 147 | +print("@@{calm_weeknumber('iso')}@@") |
| 148 | +print("@@{calm_weeknumber('iso','gmt')}@@") |
| 149 | +print("@@{calm_weeknumber('utc','iso')}@@") |
| 150 | + |
| 151 | +# TestAzMinute |
| 152 | +print("@@{AZ_MINUTE()}@@") |
| 153 | +print("@@{AZ_MINUTE('gmt')}@@") |
| 154 | +print("@@{calm_minute()}@@") |
| 155 | +print("@@{calm_minute('utc')}@@") |
| 156 | + |
| 157 | +# TestAzSecond |
| 158 | +print("@@{AZ_SECOND()}@@") |
| 159 | +print("@@{AZ_SECOND('gmt')}@@") |
| 160 | +print("@@{calm_second}@@") |
| 161 | +print("@@{calm_second('utc')}@@") |
| 162 | + |
| 163 | +# TestAzHour |
| 164 | +print("@@{AZ_HOUR('am_pm')}@@") |
| 165 | +print("@@{AZ_HOUR('12')}@@") |
| 166 | +print("@@{AZ_HOUR('am_pm','utc')}@@") |
| 167 | +print("@@{calm_hour('am_pm','gmt')}@@") |
| 168 | +print("@@{calm_hour('12','gmt')}@@") |
| 169 | +print("@@{calm_hour('12','utc')}@@") |
| 170 | + |
| 171 | +# TestAzNow |
| 172 | +print("@@{calm_now()}@@") |
| 173 | +print("@@{calm_now}@@") |
| 174 | +print("@@{calm_today}@@") |
| 175 | +print("@@{AZ_TODAY()}@@") |
| 176 | +print("@@{AZ_TODAY('gmt')}@@") |
| 177 | + |
| 178 | +# calm_hour |
| 179 | +print("@@{AZ_HOUR('24')}@@") |
| 180 | +print("@@{calm_hour('24','gmt')}@@") |
| 181 | +print("@@{calm_hour('24','utc')}@@") |
| 182 | + |
| 183 | +# TestAzRunID |
| 184 | +print("@@{AZ_RUN_ID()}@@") |
| 185 | +print("@@{AZ_ID()}@@") |
| 186 | + |
| 187 | +# TestAzNoOp |
| 188 | +print("@@{AZ_NOOP()}@@") |
| 189 | + |
| 190 | +# TestAzEntityMachineCredentialShort |
| 191 | +print("@@{AZ_ENTITY('machine-ids')}@@") |
| 192 | +print("@@{AZ_ENTITY('machine-uuids')}@@") |
| 193 | +print("@@{AZ_MACHINE('machine-uuids')}@@") |
| 194 | +print("@@{AZ_MACHINE('credential-uids')}@@") |
| 195 | +print("@@{AZ_CREDENTIAL('credential-uids')}@@") |
| 196 | +print("@@{AZ_ENTITY('credential-uids')}@@") |
| 197 | + |
| 198 | +# AZ_Task |
| 199 | +print("@@{AZ_TASK('trlid')}@@") |
| 200 | +print("@@{AZ_TASK('status')}@@") |
| 201 | +print("@@{AZ_TASK('exitcode')}@@") |
| 202 | +print("@@{AZ_TASK('reason')}@@") |
| 203 | + |
| 204 | +# These macros are from parser_cp_test.go |
| 205 | +print("These macros are from parser_cp_test.go --------------") |
| 206 | + |
| 207 | +# TestAzList |
| 208 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Machine('name')))}@@""") |
| 209 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Credential('name')))}@@""") |
| 210 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Machine('name')),delimiter=';')}@@""") |
| 211 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Credential('name')),delimiter=';')}@@""") |
| 212 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Machine('address')))}@@""") |
| 213 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Credential('uid')))}@@""") |
| 214 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Machine('address')),delimiter=';')}@@""") |
| 215 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Credential('uid')),delimiter=';')}@@""") |
| 216 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Machine('ssh_port')))}@@""") |
| 217 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Credential('secret')))}@@""") |
| 218 | +print("""@@{AZ_LIST(Entity(id=entity_id).get(Machine('ssh_port')), delimiter=';')}@@""") |
| 219 | +print( |
| 220 | + """@@{AZ_LIST(Entity(id=entity_id).get(Credential('secret')), delimiter=';')}@@""" |
| 221 | +) |
| 222 | + |
| 223 | +# TestAzListProperty |
| 224 | +print("""@@{AZ_LIST(Machine(id=machine_id).get(Property("error_detail")))}@@""") |
| 225 | +print("""@@{AZ_LIST(Credential(name="cred1").get(Property("passphrase")))}@@""") |
| 226 | +print("""@@{AZ_LIST(Entity(name="macro-entity").get(Property("prop1")))}@@""") |
| 227 | +print( |
| 228 | + """@@{AZ_LIST(Entity(name="macro-entity").get(Property("ALL")), delimiter=' ')}@@""" |
| 229 | +) |
| 230 | + |
| 231 | +# TestAzListPropertyFailure |
| 232 | +print("""@@{AZ_LIST(Machine(id=machine_id).get(Property("does-not-exist")))}@@""") |
| 233 | +print("""@@{AZ_LIST(Credential(name="cred1").get(Property("does-not-exit")))}@@""") |
| 234 | +print("""@@{AZ_LIST(Entity(name="macro-entity").get(Property("does-not-exit")))}@@""") |
| 235 | + |
| 236 | +# calm_jwt |
| 237 | +print("""@@{calm_jwt}@@""") |
0 commit comments