cdean
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Cari's brain on ytt Note: This is a working doc meant for writing down concepts as I see them. Please see the [docs](https://carvel.dev/ytt) for official definitions. Input --- Users: - Configuration Authors: Authors of templates and data values. In Kubernetes world, these are often application developers, devops, or PAs. The authors then distribute the templates to those that want to install/use them. - Configuration Consumers: Consumers of the templates that the Configuration Authors wrote. In k8s world, they use the templates to install the applications onto their clusters. Types: - NewBulkFilesSource: Used to process JSON input, from the ytt playground - NewRegularFilesSource: Primary input source. Processes files input with `-f` and accepts other flags. - Directory Structure / file system contract: - Libraries: - Like a virtual file system built from the relative file path of the inputs. Some libraries can be 'private'. - Private library: - is one that is in the `_ytt_lib` directory. - Other libraries cannot access a private library. - It can be thought of as a separate ytt invocation. - File Marks: Used to override the default behavior of ytt file processing. Can override the file extension. - Data Values: Provide a way to inject input data into a template via parameterized variables. Concepts --- - Overlays: - Additional templates that are merged with the previous templates. Templates and data values are merged separately. - Left: being modified - Right: the overlay describing the modification. - Single unit template: Each yaml document is its own single unit. One unit can overlay another, and does not relate to scope. For other file types, a file may be a single unit of configuration. Strive for: --- - Readability: - Important for new maintainers - Descriptive & consistent variable names - Extract code to functions when it's not helpful to have the context at the current level. - Don't extract code to function when it does not add to complexity. - Refactors are necessary to get here but should be done separate from features. - "Single Point Of Truth": Goal is to not have duplicate code to reduce inconsistency and organization. Don't pay the 'complexity cost' twice. - Compactness: the property that a design can fit inside a human being's head. - Be different when we have a reason to be. / Dont conform to patterns when it doesn't fit - Order test variables consistently across tests. - If I remove one line/thing in the code only ONE test should fail. In other words, test only one unit per test. :bee: :bee: :bee: Go patterns --- - Explicit error checks - Discourage use of named returns generally - generally, yes, adds work to the reader to determine what's being returned. - when small, might be nice to use to trim - no reason can't "document" return values with named returns (don't have to use them) - Keep methods private by default - this makes sense in general, however it may be worth considering what the package 'api' should expose. Could the package be imported by other tools? - Function names plurality match what they return (ie: return list, name is plural) - Constructors start with 'New' When reviewing think about: --- - Does an if make more sense as a switch (and viceversa) - When you want to return a boolean to indicate something to the parent method, consider combining the two methods instead - Understand the contributers intention, be a guide to them to find the right spot or with what is already there - begin with the tests, agree on the ux first - When building Starlark builtin functions, you must return Starlark values, not nil or golang values. See ip patched PR for details. When Patching --- For unreleased code, dont have to make just the minimal code change, do it right. Doc opportunities --- How to write a builtin function - mention that you must return starlark values. Intentional ytt 'patterns' --- - library patterns - A file (schema or data value) uses it's `libRef` to indicate what library it belongs to. No libRef? Then it's intented for the current library. - A private library is mostly 'self contained' and can be thought of as a separate ytt invocation. - Many of data value and schema code follows a similar pattern.. Is this the goal or an intermediate stage? - Factory - LibraryExecutionFactory - Envelope - DocumentSchemaEnvelope - Parameterized tests - yamltemplate package: tests that can be in a single file. Similar to e2e tests, asserts on output. (used for overlays, ytt starlark addtions, file positions via `--output`) - TestSchema_With_fuzzed_inputs ? - schema (recent changes & intentional choices) - Prototypes - Helped unexport internals of nodes and prefer mutation thru getters and setters. It behaves as an intermediate type to decouple yamlmeta and schema packages. - `func NewDocumentSet(val *DocumentSetProto)` - Change Node `type` to `meta` `map[string]interface{}`. Allows the schema package to set this info rather than yamlmeta - Do all typing and checking in schema package - previously `TypeWithValues` is now a `yamlmeta.Node` that contains `schema/type` meta - Data Values and Schema are separate packages. Schema package contains typing and validations, and logic to connect dv and schema, and send it to libraries. - Data values is renamed Envelope. It contains and addresses dvs - dvpp and dvSpp are mirrors - AST Structures --- What is it? * Composite of the node * tree structure * A scalar isn't a Node, it's the value of a Node * Abbreviation for "Abstract Syntax Tree" How're they created? * how do they go from bytes to ast? * Scalar types are parsed using our forked yamlv2 parser * workspace package templateloader.go -> ParseYAML() * yamlmeta package document_set.go -> NewDocumentSetFromBytes() unstructured data becomes structured data * parser.go -> ParseBytes() -> parseBytes() * Decode() yields raw yaml structures (no annotations yet) * yaml.v2 package yaml.go unmarshals the data * yaml.v2 defines a struct that represents the structure of the type and the decoder parses based on that * out is what we write the value to * n is the data we're decoding * yamlmeta package parser.go -> parser() * output is either a map, with map items or array with array items * we use a mapSlice instead of a map to preserve map ordering * assignMetas() takes yaml comments and converts to metas * comments directly to the left of a node OR comments directly after a node are added to the node as meta * We check that a map items' value is null if it is followed by #@ value * Since yaml.v2 does not set the position of maps, we manually set the position of a map to the position of its parent Do they contain scalars? * Yes, but not as a separate node. * They are stored in the value of where they are contained, (ie. Document, MapItem, and ArrayItem)this is where they get their position as well. * Scalars implement the TypeWithValues interface, which has a GetPosition() function. What do they store? * Positions * GetValues returns the children * metas How are they output? * template.replace * ### Representation of a computed node value: ```yaml= --- foo: - { a: null } #@ 41+1 ``` ``` doc -> map -> mapitem("foo") -> array [0] map -> mapitem("bar") value: null meta: "@ 41+1" ``` skills knowledge and ability know code coverage, modular design ... if you saw this error message can you find where it is? with the code in front of you, can you talk thru the layers/packages? what problems are you interested in? Have you had an idea of a new improvement in ytt? End goal: to be an appendix to contributer models john and cari together ## template.replace() What: It is a built in starlark module

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully