Skip to content

Commit c67fbde

Browse files
author
Dan Wilson
authored
Merge pull request #600 from normal-coder/patch-1
Fix documentation errors
2 parents 9c9efb3 + 3c4d8d5 commit c67fbde

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

content/plugins/adaptive_cards.md

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,71 +20,79 @@ Here is an example of what a card for the Docker plugin looks like :
2020

2121
![Card](/screenshots/card.png)
2222

23-
This card allows you to see, at a glance, all of the important information pertaining to the image generated during the execution of the docker plugin.
23+
This card allows you to see, at a glance, all of the important information pertaining to the image generated during the execution of the docker plugin.
2424

2525
## Supported Versions
26-
- Drone Server - v2.6.0+
27-
- Drone Runner Docker - v1.8.0+ / Drone Kubernetes Runner - latest
28-
## Supported plugins:
29-
- Drone-docker
30-
- Snyk
31-
- Gitleaks
26+
27+
- Drone Server - v2.6.0+
28+
- Drone Runner Docker - v1.8.0+ / Drone Kubernetes Runner - latest
29+
30+
## Supported plugins
31+
32+
- Drone-docker
33+
- Snyk
34+
- Gitleaks
3235

3336
# How do I add adaptive cards support to my plugin?
3437

3538
Plugin Cards are built upon the open adaptive cards format . This makes it much easier for a plugin developer to add enhanced output functionality without requiring any changes to the Drone Server.
3639

3740
A card is made up of a template (what the user sees) and output from a plugin (raw data from the build). These are combined by Drone to display the card in the Drone UI.
3841

39-
During the plugin’s execution, Drone downloads the plugin template. An example of what a template looks like can be found here and it is downloaded when rendering the card.
42+
During the plugin’s execution, Drone downloads the plugin template. An example of what a template looks like can be found here and it is downloaded when rendering the card.
4043

4144
Below is the JSON payload that is generated by the docker plugin. This is the raw information that appears on the card:
4245

43-
{{< highlight yaml "linenos=table" >}}
46+
```yaml {linenos=table}
4447
{
45-
"Id": "sha256:d9437eae98f2787931b0fae86cc79c3993cd3ed031f84f67a41fdff5bcb436c9",
46-
"RepoTags": ["drone-test:latest", "5699c94024237b8b4838717f4f7a55d55cab66bb:latest"],
47-
"RepoDigests": ["drone-test@sha256:2ab4cd8ec41a0f7d68c34289a52dffa4d483abbdd10bcd68fd4da3e904a81f76"],
48-
"Parent": "sha256:bdca5d527305e375f37d177e745224d0d7fce56eb1454210d9a6f2441a40d31b",
49-
"Comment": "",
50-
"Created": "2022-01-05T12:04:34.3483105Z",
51-
"Container": "eafafc780d73493be11f546777ff303341b2094671b244ed804eff49a722d40a",
52-
"DockerVersion": "20.10.9",
53-
"Author": "",
54-
"Architecture": "amd64",
55-
"Os": "linux",
56-
"Size": 186298129,
57-
"VirtualSize": 186298129,
58-
"Metadata": {
59-
"LastTagTime": "2022-01-05T12:04:34.392555Z"
60-
}
48+
"Id": "sha256:d9437eae98f2787931b0fae86cc79c3993cd3ed031f84f67a41fdff5bcb436c9",
49+
"RepoTags": ["drone-test:latest", "5699c94024237b8b4838717f4f7a55d55cab66bb:latest"],
50+
"RepoDigests": ["drone-test@sha256:2ab4cd8ec41a0f7d68c34289a52dffa4d483abbdd10bcd68fd4da3e904a81f76"],
51+
"Parent": "sha256:bdca5d527305e375f37d177e745224d0d7fce56eb1454210d9a6f2441a40d31b",
52+
"Comment": "",
53+
"Created": "2022-01-05T12:04:34.3483105Z",
54+
"Container": "eafafc780d73493be11f546777ff303341b2094671b244ed804eff49a722d40a",
55+
"DockerVersion": "20.10.9",
56+
"Author": "",
57+
"Architecture": "amd64",
58+
"Os": "linux",
59+
"Size": 186298129,
60+
"VirtualSize": 186298129,
61+
"Metadata": {
62+
"LastTagTime": "2022-01-05T12:04:34.392555Z"
63+
}
6164
}
62-
{{< / highlight >}}
65+
```
6366

6467
# Adding Drone card functionality to a plugin
6568

6669
## Creating a template
70+
6771
To get started you first want to think about the information you wish to display on-screen & how it should look. This becomes the card template. The easiest way to create it is by using this adaptive cards designer.
6872

6973
The docker template in this example is hosted and served using Github pages.
74+
7075
Mention the directory structure of the plugin
71-
- /docs/template.json
72-
- /docs/sample_data.json
76+
77+
- /docs/template.json
78+
- /docs/sample_data.json
7379

7480
## Card Input
81+
7582
This assumes that your plugin has been written in Golang but it could be written in any other language. As long as the JSON output is created correctly.
7683

7784
The structure of a card struct is as follows. This is what is written to the logs for the runner to extract and publish information to the Drone server.
7885

79-
{{< highlight golang "linenos=table" >}}
86+
```go {linenos=table}
8087
CardInput struct {
8188
Schema string `json:"schema"` // template url
8289
Data json.RawMessage `json:"data"` // template data
8390
}
84-
{{< / highlight >}}
91+
```
8592

8693
The following encodes the card data in order for the runner to extract it from the logs:
87-
{{< highlight go "linenos=table" >}}
94+
95+
```go {linenos=table}
8896
func writeCardTo(out io.Writer, data []byte) {
8997
encoded := base64.StdEncoding.EncodeToString(data)
9098
io.WriteString(out, "\u001B]1338;")
@@ -93,11 +101,11 @@ func writeCardTo(out io.Writer, data []byte) {
93101
io.WriteString(out, "\n")
94102
}
95103
}
96-
{{< / highlight >}}
104+
```
97105

98-
This code allows the plugin to support both CI & Drone. Once the card input struct has been created, it must be written to “dev/stdout”.
106+
This code allows the plugin to support both CI & Drone. Once the card input struct has been created, it must be written to “dev/stdout”.
99107

100-
{{< highlight go "linenos=table" >}}
108+
```go {linenos=table}
101109
func writeCard(path string, card interface{}) {
102110
data, _ := json.Marshal(card)
103111
switch {
@@ -109,6 +117,6 @@ func writeCard(path string, card interface{}) {
109117
ioutil.WriteFile(path, data, 0644)
110118
}
111119
}
112-
{{< / highlight >}}
120+
```
113121

114-
Once the input data is written, the runner & Drone server will do the rest and in the build screen, a card should appear.
122+
Once the input data is written, the runner & Drone server will do the rest and in the build screen, a card should appear.

0 commit comments

Comments
 (0)