Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement UI element to annotate YAML files #976

Merged
merged 7 commits into from
Jul 15, 2024

Conversation

niallthomson
Copy link
Contributor

@niallthomson niallthomson commented Jun 22, 2024

What this PR does / why we need it:

This PR adds a new markdown UI element that can be used to break down YAML snippets with annotations to call out each important section and what its doing. This is currently being done in several labs but without much consistency and in generally still requiring a lot of effort for the user to pick through the YAML to match the explanations with parts of the file.

This is an example of the markdown used:

::yaml{file="manifests/modules/autoscaling/compute/karpenter/scale/deployment.yaml" paths="spec.replicas,spec.template.spec.nodeSelector,spec.template.spec.containers.0.image,spec.template.spec.containers.0.resources"}

1. Initially specifies 0 replicas to run, we'll scale it up later
2. Requires the pods to be scheduled to capacity provisioned by Karpenter by using a node selector that matches our NodePool
3. Uses a simple `pause` container image
4. Requests `1Gi` of memory for each pod

Things to note:

  1. File is referenced by path
  2. The "paths" attribute accepts a comma-separated list of paths to highlight in a similar format to jq. You can reference specific fields (metadata.name), whole blocks/multiple lines (spec.template) and specific items in arrays using numbers (spec.template.spec.containers.0) as well as fields of them (spec.template.spec.containers.0.name).
  3. Optionally you can include a markdown ordered list as the next markdown element and it will correlate these in the order that the "paths" attribute was specified. So item (1) will match the first entry in "paths", (2) will match the second etc.

The above example will render like this:

Screenshot 2024-06-22 at 7 43 45 PM

Which issue(s) this PR fixes:

N/A

Quality checks

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@niallthomson niallthomson added this to the Release 06/28 milestone Jun 22, 2024
@niallthomson niallthomson requested a review from a team as a code owner June 22, 2024 04:53
Copy link

netlify bot commented Jun 22, 2024

Deploy Preview for eks-workshop canceled.

Name Link
🔨 Latest commit 4822157
🔍 Latest deploy log https://app.netlify.com/sites/eks-workshop/deploys/668bfd417c96a80008e24213

@svennam92
Copy link
Contributor

@niallthomson I like this particularly being able to use markdown formatting like code blocks in the descriptor text. Can we add your blurb above to the style guide? https://github.com/aws-samples/eks-workshop-v2/blob/main/docs/style_guide.md

@niallthomson
Copy link
Contributor Author

@svennam92 based on some feedback I changed the annotations from numbers to letters to better distinguish from the line numbers. Updated the style guide and UI components docs.

@niallthomson niallthomson merged commit 7b576ba into main Jul 15, 2024
9 checks passed
@niallthomson niallthomson deleted the yaml-annotations branch July 15, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants