-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.example.yaml
More file actions
1372 lines (1366 loc) · 40.3 KB
/
Copy pathButton.example.yaml
File metadata and controls
1372 lines (1366 loc) · 40.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Action not found
# Target: ensure the widget correctly handles missing action definition within "actions".
# Expected behavior: clicking the button triggers an error notification ("The widget definition does not include an action ...").
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-no-action
namespace: krateo-system
spec:
widgetData:
label: Click
icon: fa-trash
type: primary
clickActionId: click
actions: {}
resourcesRefs:
items: []
---
# Default button with label only
# Target: verify correct rendering of text label with default shape and size.
# Expected behavior: displays a standard button labeled “Run”.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-basic
namespace: krateo-system
spec:
widgetData:
label: Run
type: primary
shape: default
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# Primary button with icon and label
# Target: confirm correct layout of icon + label combination.
# Expected behavior: icon appears to the left of the text with correct spacing.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-with-icon
namespace: krateo-system
spec:
widgetData:
label: Deploy
icon: fa-rocket
type: primary
shape: default
size: middle
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# Circle-shaped button with icon only
# Target: verify proper sizing and centering of circular icon-only button.
# Expected behavior: renders compact circle button showing only the icon.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-icon-circle
namespace: krateo-system
spec:
widgetData:
icon: fa-trash
shape: circle
type: primary
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# Default rounded button with custom color
# Target: ensure color token and rounded shape are correctly applied.
# Expected behavior: button has smooth rounded corners and red color variant.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rounded-red
namespace: krateo-system
spec:
widgetData:
label: Restart
backgroundColor: red
type: primary
size: middle
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# Large primary button
# Target: verify consistent scaling for “large” size.
# Expected behavior: increased padding and text size; alignment preserved.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-large-primary
namespace: krateo-system
spec:
widgetData:
label: Approve
type: primary
size: large
shape: default
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# Small dashed button
# Target: confirm rendering of alternative visual “dashed” style.
# Expected behavior: smaller text and dotted outline.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-small-dashed
namespace: krateo-system
spec:
widgetData:
label: Details
type: dashed
size: small
shape: default
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# Link-style button
# Target: verify inline link appearance (no background or border).
# Expected behavior: visually rendered as a text hyperlink.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-link
namespace: krateo-system
spec:
widgetData:
label: View Logs
type: link
size: middle
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# Text-only button
# Target: confirm flat minimal variant without border or background.
# Expected behavior: renders as simple text element, aligned with other inline elements.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-text
namespace: krateo-system
spec:
widgetData:
label: Edit
type: text
shape: default
clickActionId: navigate-example-button-page
actions:
navigate:
- id: navigate-example-button-page
path: /button
type: navigate
resourcesRefs:
items:
- id: navigate-example-button-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-button-page
namespace: krateo-system
resource: pages
verb: GET
---
# navigate - Navigation to another page using `path`
# Target: trigger navigation to a static route (`/barchart`) when the button is clicked.
# Expected behavior: clicking the button redirects the user to `/barchart`.
# No confirmation or loading state are required.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-navigate-path
namespace: krateo-system
spec:
widgetData:
label: Navigate to Bar Chart
type: primary
shape: default
clickActionId: navigate-to-barchart
actions:
navigate:
- id: navigate-to-barchart
path: /barchart
type: navigate
resourcesRefs:
items: []
---
# navigate - Navigation to another resource using `resourceRefId`
# Target: navigate to another dashboard resource (identified by its ref ID).
# Expected behavior: clicking the button triggers navigation to the target resource page.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-navigate-resource
namespace: krateo-system
spec:
widgetData:
label: Navigate to Dashboard
type: primary
clickActionId: navigate-to-dashboard
actions:
navigate:
- id: navigate-to-dashboard
type: navigate
resourceRefId: dashboard-page
resourcesRefs:
items:
- id: dashboard-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: dashboard-page
namespace: krateo-system
resource: pages
verb: GET
---
# navigate - Navigation to another resource using `resourceRefId` with URL path extension
# Target: navigate to another resource identified by its ref ID, setting a custom URL path prefix.
# Expected behavior: clicking the panel triggers navigation to the target resource page. The specified URL path prefix is displayed in the URL.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-navigate-resource-url-path-extension
namespace: krateo-system
spec:
widgetData:
label: Navigate to Dashboard
type: primary
clickActionId: navigate-to-dashboard
actions:
navigate:
- id: navigate-to-dashboard
type: navigate
resourceRefId: dashboard-page
resourceURLPathExtension: button-dashboard
resourcesRefs:
items:
- id: dashboard-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: dashboard-page
namespace: krateo-system
resource: pages
verb: GET
---
# navigate - Navigation with confirmation prompt (`requireConfirmation: true`)
# Target: prevent accidental navigation by requiring explicit user confirmation.
# Expected behavior: before navigating, a confirmation dialog is shown.
# Only if confirmed does the navigation occur.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-navigate-confirm
namespace: krateo-system
spec:
widgetData:
label: Navigate to Bar Chart
type: primary
size: middle
clickActionId: navigate-to-barchart
actions:
navigate:
- id: navigate-to-barchart
path: /barchart
type: navigate
requireConfirmation: true
resourcesRefs:
items: []
---
# navigate - Navigation with loading indicator
# Target: provide visual feedback during navigation.
# Expected behavior: the button shows a loading spinner while navigation is being processed.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-navigate-loading
namespace: krateo-system
spec:
widgetData:
label: Navigate to Bar Chart
type: primary
size: middle
clickActionId: navigate-to-barchart
actions:
navigate:
- id: navigate-to-barchart
path: /barchart
type: navigate
loading:
display: true
resourcesRefs:
items: []
---
# openDrawer - default size
# Target: verify that a drawer can be opened using a defined resource reference
# Expected behavior: when triggered, no confirmation is required;
# the drawer opens at the default width and displays the resource contents once loaded.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-open-drawer-default
namespace: krateo-system
spec:
widgetData:
label: Open Drawer Default
type: primary
size: middle
clickActionId: open-drawer-default
actions:
openDrawer:
- id: open-drawer-default
type: openDrawer
resourceRefId: example-markdown-basic
size: default
title: Default Drawer Example
resourcesRefs:
items:
- id: example-markdown-basic
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-markdown-basic
namespace: krateo-system
resource: markdowns
verb: GET
---
# openDrawer - large size
# Target: verify that a drawer can be opened in large mode
# Expected behavior: a large-size drawer opens with the defined title and resource content.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-open-drawer-large
namespace: krateo-system
spec:
widgetData:
label: Open Drawer Large
type: primary
size: middle
clickActionId: open-drawer-large
actions:
openDrawer:
- id: open-drawer-large
type: openDrawer
resourceRefId: example-markdown-basic
size: large
title: Confirmed Large Drawer Example
loading:
display: false
resourcesRefs:
items:
- id: example-markdown-basic
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-markdown-basic
namespace: krateo-system
resource: markdowns
verb: GET
---
# openModal - default size
# Target: ensure that a modal dialog can be opened,
# displaying a standard modal layout with the given title and resource.
# Expected behavior: the modal appears at the default width and loads the referenced resource.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-open-modal-default
namespace: krateo-system
spec:
widgetData:
label: Open Modal Default
type: primary
size: middle
clickActionId: open-modal-default
actions:
openModal:
- id: open-modal-default
type: openModal
resourceRefId: example-yamlviewer-simple-json
title: ${"Default Modal Example:" + " " + .widget.status.widgetData.label}
loading:
display: true
size: default
resourcesRefs:
items:
- id: example-yamlviewer-simple-json
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-yamlviewer-simple-json
namespace: krateo-system
resource: yamlviewers
verb: GET
---
# openModal - large size
# Target: ensure that a modal dialog can be opened,
# displaying a large modal layout with the given title and resource.
# Expected behavior: the modal appears at the large width and loads the referenced resource.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-open-modal-large
namespace: krateo-system
spec:
widgetData:
label: Open Modal Large
type: primary
size: middle
clickActionId: open-modal-large
actions:
openModal:
- id: open-modal-large
type: openModal
resourceRefId: example-yamlviewer-simple-json
title: Large Modal Example
loading:
display: true
size: large
resourcesRefs:
items:
- id: example-yamlviewer-simple-json
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-yamlviewer-simple-json
namespace: krateo-system
resource: yamlviewers
verb: GET
---
# openModal - custom width
# Target: confirm that a modal can be displayed with a custom width,
# ensuring that custom sizing rules are correctly applied by the system.
# Expected behavior: when triggered, no confirmation is required;
# the modal expands to the defined custom width and shows the referenced resource.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-open-modal-custom
namespace: krateo-system
spec:
widgetData:
label: Open Modal Custom Width
color: purple
type: primary
size: middle
clickActionId: open-modal-custom
actions:
openModal:
- id: open-modal-custom
type: openModal
resourceRefId: example-yamlviewer-simple-json
title: Custom Width Modal Example
size: custom
customWidth: 30%
loading:
display: false
resourcesRefs:
items:
- id: example-yamlviewer-simple-json
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-yamlviewer-simple-json
namespace: krateo-system
resource: yamlviewers
verb: GET
---
# openModal - fullscreen mode
# Target: verify that a modal can occupy the full viewport width when configured in fullscreen mode,
# confirming proper rendering and interaction across the available space.
# Expected behavior: the modal opens instantly and expands to fill the entire screen.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-open-modal-fullscreen
namespace: krateo-system
spec:
widgetData:
label: Open Modal Fullscreen
type: primary
size: middle
clickActionId: open-modal-fullscreen
actions:
openModal:
- id: open-modal-fullscreen
type: openModal
resourceRefId: example-yamlviewer-simple-json
title: Fullscreen Modal Example
size: fullscreen
loading:
display: false
resourcesRefs:
items:
- id: example-yamlviewer-simple-json
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-yamlviewer-simple-json
namespace: krateo-system
resource: yamlviewers
verb: GET
---
# rest - Invalid resourceRefId (reference does not exist in resourcesRefs)
# Target: action includes resourceRefId but the reference is not provided in resourcesRefs.
# Expected behavior: error toast indicating that the resource reference is not found; no API call is performed.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-invalid-resource-ref
namespace: krateo-system
spec:
widgetData:
label: Run
clickActionId: rest-invalid-ref
actions:
rest:
- id: rest-invalid-ref
type: rest
resourceRefId: missing-ref
headers: []
resourcesRefs:
items:
- id: some-other-ref
apiVersion: v1
name: whatever
namespace: krateo-system
resource: configs
verb: GET
---
# rest - Headers malformed (not a "key: value" structure)
# Target: one of the headers does not follow the expected textual format.
# Expected behavior: the header is ignored or causes server-side rejection depending on backend behavior; button still tries to execute.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-malformed-headers
namespace: krateo-system
spec:
widgetData:
label: Execute
clickActionId: rest-bad-headers
actions:
rest:
- id: rest-bad-headers
type: rest
resourceRefId: create-pod
headers:
- "Authorization Bearer token"
- "x-custom: valid"
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: create-pod
namespace: krateo-system
verb: POST
---
# rest - Both onSuccessNavigateTo and onEventNavigateTo defined
# Target: mutually exclusive navigation modes are used simultaneously.
# Expected behavior: execution stops immediately with an error toast indicating the conflict; no API call is sent.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-conflicting-navigations
namespace: krateo-system
spec:
widgetData:
label: Run Action
clickActionId: rest-conflict
actions:
rest:
- id: rest-conflict
type: rest
resourceRefId: create-pod
headers: []
onSuccessNavigateTo: "/ok"
onEventNavigateTo:
eventReason: Completed
url: "/event"
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: create-pod
namespace: krateo-system
verb: POST
---
# rest - Static payload
# Target: action payload contains static fields with primitive values.
# Expected behavior: payload is sent as-is; values are not modified or merged.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-static-payload
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-static-payload
actions:
rest:
- id: rest-static-payload
type: rest
resourceRefId: create-pod
headers:
- "Content-Type: application/json"
payload:
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-sample-nginx-pod"
labels:
app: "my-sample-nginx"
spec:
containers:
- name: "nginx"
image: "nginx:latest"
ports:
- containerPort: 80
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: my-sample-nginx-pod
namespace: krateo-system
verb: POST
---
# rest - Merged payload with resource payload
# Target: action payload is merged with the referenced resource payload.
# Expected behavior: resulting payload contains all fields from both action and resource; action payload values override resource payload in case of conflict.
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-merged-payload
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-merged-payload
actions:
rest:
- id: rest-merged-payload
type: rest
resourceRefId: create-pod
headers:
- "Content-Type: application/json"
payload:
apiVersion: v1
kind: "Pod"
metadata:
name: "my-sample-nginx-pod"
labels:
app: "my-sample-nginx"
spec:
containers:
- name: "nginx"
image: "nginx:latest"
ports:
- containerPort: 80
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: different-name
namespace: krateo-system
verb: POST
---
# rest - Payload overrides with static values (not applied)
# Target: payloadToOverride specifies fields and static values to replace in the merged payload.
# Expected behavior: specified fields in payloadToOverride are not applied after merge since
# it does not make sense for Button to define a custom payload as a Form would do
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-payload-overrides-static
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-overrides-static
actions:
rest:
- id: rest-overrides-static
type: rest
resourceRefId: create-pod
headers:
- "Content-Type: application/json"
payload:
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-sample-nginx-pod"
labels:
app: "my-sample-nginx"
spec:
containers:
- name: "nginx"
image: "nginx:latest"
ports:
- containerPort: 80
payloadToOverride:
- name: apiVersion
value: v2
- name: metadata.name
value: overriden-name
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: create-pod
namespace: krateo-system
verb: POST
---
# rest - Payload overrides with JQ expression (not applied)
# Target: payloadToOverride values are JQ expressions referencing the customPayload.
# Expected behavior: specified fields in payloadToOverride are not applied after merge since
# it does not make sense for Button to define a custom payload as a Form would do
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-payload-overrides-jq
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-overrides-jq
actions:
rest:
- id: rest-overrides-jq
type: rest
resourceRefId: create-pod
headers:
- "Content-Type: application/json"
payload:
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-sample-nginx-pod"
labels:
app: "my-sample-nginx"
spec:
containers:
- name: "nginx"
image: "nginx:latest"
ports:
- containerPort: 80
payloadToOverride:
- name: apiVersion
value: ${ .json.apiVersion }
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: create-pod
namespace: krateo-system
verb: POST
---
# rest - Customized success message
# Target: correct request -> successMessage is displayed
# Expected behavior: after the request succeeds a customized success message is displayed
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-success-message
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-success-message
actions:
rest:
- id: rest-success-message
type: rest
resourceRefId: create-pod
successMessage: 'This is a customized message: successful request!'
headers:
- "Content-Type: application/json"
payload:
apiVersion: "v1"
kind: "Pod"
metadata:
name: "success-message-pod"
labels:
app: "my-sample-nginx"
spec:
containers:
- name: "nginx"
image: "nginx:latest"
ports:
- containerPort: 80
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: success-message-pod
namespace: krateo-system
verb: POST
---
# rest - Customized success message with JQ expression
# Target: correct request -> successMessage with JQ expression is displayed
# Expected behavior: after the request succeeds a customized success message is displayed
# The message interpolates a variable using JQ
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-success-message-jq
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-success-message-jq
actions:
rest:
- id: rest-success-message-jq
type: rest
resourceRefId: create-pod
successMessage: '${ "Success on resource: " + .json.metadata.name }'
headers:
- "Content-Type: application/json"
payload:
apiVersion: "v1"
kind: "Pod"
metadata:
name: "success-message-jq-pod"
labels:
app: "my-sample-nginx"
spec:
containers:
- name: "nginx"
image: "nginx:latest"
ports:
- containerPort: 80
resourcesRefs:
items:
- id: create-pod
apiVersion: v1
resource: pods
name: success-message-jq-pod
namespace: krateo-system
verb: POST
---
### rest - Customized error message
# Target: malformed request -> errorMessage is displayed
# Expected behavior: after the request fails a customized error message is displayed
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-error-message
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-error-message
actions:
rest:
- id: rest-error-message
type: rest
resourceRefId: get-default-ns
errorMessage: 'This is a customized message: malformed request'
headers:
- 'Accept: application/json'
resourcesRefs:
items:
- id: get-default-ns
apiVersion: v1
resource: namespaces
name: default
verb: GET
---
### rest - Customized error message with JQ expression
# Target: malformed request -> errorMessage with JQ expression is displayed
# Expected behavior: after the request fails a customized error message is displayed
# The message interpolates a variable using JQ
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-error-message-jq
namespace: krateo-system
spec:
widgetData:
label: Submit
clickActionId: rest-error-message-jq
actions:
rest:
- id: rest-error-message-jq
type: rest
resourceRefId: get-default-ns
errorMessage: '${"Error while executing action on resource: " + .response.message }'
headers:
- 'Accept: application/json'
resourcesRefs:
items:
- id: get-default-ns
apiVersion: v1
resource: namespaces
name: default
verb: GET
---
### rest - Navigation on success
### Target: correct request -> redirect to another page (onSuccessNavigateTo)
### Expected behaviour: after the request is successfully executed, there is a redirect to a specified page
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-button-rest-success-redirect
namespace: krateo-system
spec:
widgetData:
label: Execute and navigate
clickActionId: rest-success-redirect
actions:
rest:
- id: rest-success-redirect
type: rest
resourceRefId: create-pod
onSuccessNavigateTo: /barchart
headers:
- "Content-Type: application/json"