June 16, 2020

1806 words 9 mins read

What is YAML?

What is YAML?

The increasing popularity of Kubernetes means you’ve probably heard of YAML because it’s the format for Kubernetes configuration files.  While it’s not as ubiquitous as JSON, YAML goes far beyond Kubernetes. The human-readable data-serialisation language was first released in 2001,  and it’s used in tools from OpenStack to Ansible playbooks. SEE MORE What is agile development? SEE MORE What is D

evOps? SEE MORE How to develop IoT apps Originally YAML stood for “Yet Another Markup Language,” but it has since been renamed to “YAML Ain’t Markup Language” to make it clear that unlike SGML and HTML, both of which are languages for documents, it’s designed with data in mind.  It’s a text-based format for declarative configuration information or specifications, and for data serialisation (where you convert complex, structured data into a flat-file format you can store or transmit, but still be able to get back to the original structure). Those are the same kinds of things you’d do with XML but unlike XML or JSON, it’s designed to be a format that humans can read and write easily, which is why projects like Ansible picked it over other options. The YAML website is easy to read and it’s also a valid YAML code. How does YAML work? This programming language borrows features and patterns from a host of others to simplify the process of reading and writing code. You may use indentations and new lines to structure code so how the code is displayed on your monitor is how it would work, as in Python for example. You’ll be able to select the degrees of indentation you wish to adopt so you can choose whichever you find the most readable, so long as you maintain consistency. You cannot, however, use the tab character, which avoids a major issue that varying operating systems handle tabs differently - in addition to the ongoing spaces versus tabs debate. Users may also adopt a more compact format where the two main data types, lists and associative arrays (also known as maps) are denoted by the [] and) {} figures. This makes it effectively a superset of JSON, although this is outlined for machines, not humans, to read. Incidentally, YAML also has features that are absent from JSON, including comments, which JSON hasn’t been created to support. There are, however, workarounds. These data types may also be nested to represent more complicated structures based on those present in Perl. Features are lifted from C, HTML, MIME, as well as mail headers, with colons used to denote key: value pairs. The space function is present so users won’t have to put quotation marks around strings and numbers. Simple types such as integers, floats and Booleans are detected by default, and there’s priced-in support for ISO-formatted dates and times, although you can also declare your own data types. Structures let you store multiple documents in a single file or refer to content in one part of the document from elsewhere using an anchor (which also lets you duplicate or inherent properties). That means it’s much more flexible than JSON where the hierarchy is fixed, with each child node having only one parent node and while there’s a similar option in XML the YAML parse automatically expands the references. That way you get a file that’s easier to read and you avoid potential errors copying and pasting parameters where only a handful of things change between different instances, but external systems don’t need to be told about the structure of the YAML file. What are the benefits of YAML? Because the formatting is straightforward and you don’t have to worry about closing tags, brackets or quote marks, you can edit YAML in simple text editing tools, and subsections of YAML files are often valid YAML. But there are also plugins to add YAML support to common IDEs like Visual Studio Code and Atom; these can use the YAML Language Server provide autocomplete and Intellisense, and there are several YAML linters to check code for correctness. You can’t write YAML that validates itself the way XML documents can do, based on schema, but if you need to define a schema for your YAML there are languages that let you do that. The combination of YAML and JSON Schema can be powerful: VS Code, the DocFX static web site generator and even the schema for Microsoft’s Q# Quantum Chemistry library use them together to achieve a more human-readable version of JSON. Using YAML files has advantages over typing in command line options: you can create much more complex structures in YAML and you don’t have to deal with long and unwieldy strings of parameters. And because they’re files, you can check them into source control systems, track versions and changes. Because YAML treats lines as information, it works better with git-based systems for tracking changes than JSON. That makes it easier to treat configuration as code that you manage, test and consume the same way you do all your other code. Are there any downsides to YAML? YAML has its faults, like all programming languages. Because the language was designed specifically to be straightforward to read and write, and because indentation is functional, mistakes are easy to make, and changes to your YAML code can be made by simple errors like adding an extra space. Longer files may also get complex, and it would be difficult to find typos in YAML code. A typing error, for instance, could mean your code might be functionally correct but may not perform as you intend it to. Using a linter won’t help, either, as it’s a declarative language, so the concept of stepping through code, or setting breakpoints to debug, doesn’t apply. Since YAML is more readable than JSON or XML, reading through a YAML file will more likely lead to finding errors than other languages. With the kind of configuration you perform in YAML becoming more relevant to the adoption of DevOps, configurations you’re specifying may become more complex and may demand more expertise - regardless of language you’re writing them in. Arguably, there are better languages, such as TOML, but these haven’t been adopted as widely, so YAML is the language more developers will face. Higher-grade tools will always be easier to work with versus reading and writing YAML files, and there’s a swelling choice of those for Kubernetes. This choice of tools ranges such as Helm, that streamlines installing and managing Kubernetes apps to managed cloud services, to the kubectl command line. Tools such as Pulumi, that use familiar programming languages like JavaScript or PowerShell, also fall into this camp. YAML is a configuration format, however, used in so many widely-used tool and projects that it’s worth familiarising yourself with it, and understanding its benefits and drawbacks.

Date: 2019-09-30

URL: http://feeds.itpro.co.uk/~r/ITPro/Today/~3/1ndYPrTzqn8/what-is-yaml

itpro.co.uk

Apple looks set to launch first ARM-based MacBooks next week (2020-11-03) Apple is reportedly gearing up to launch a new range of MacBooks that will feature the companys own processors for the first time in the 36-year history of the Mac The company on Monday announced that it will hold a special event on 10 November with an invitation that features Apples famous one more thing tagline While Apple didnt reveal any further details it looks likely that we can expectthe an..
AWS ditches Nvidia for in-house ‘Inferentia’ silicon (2020-11-13) Amazon Web Services AWS will ditchNvidia chips responsible for the processing ofAlexa queries and will instead use itsown in-housesilicon the company confirmed on Friday The cloud giant willalso be shifting data processing for its cloud-based facial recognition system Rekognition over to these in-house chips according to Reuters SEE MORE Amazon opens up Alexa chatbot tools to developers SEE MORE A.. AWS ditches Nvidia for in-house ‘Inferentia’ silicon
Biden team signals president-elect may target Section 230 and data privacy (2020-12-04) A senior technology advisor to Joe Biden yesterday signaled that the President-elect is interested in changing Section 230 a key law protecting social media companies from legal liability Bruce Reed who also advised Biden on technology during his vice presidency made the announcement during the online launch of the book Which Side of History? How Technology is Reshaping Democracy and Our Lives in ..
What is shoulder surfing? (2019-07-24) With the UKs second lockdown coming to an end we now have more flexibility in where we can work While weve been confined to home offices for the past few months its likely that more will begin to work from coffee shops shared workspaces or company offices As such the device you use for said work will potentially be visible to others and the information on it more susceptible to shoulder surfing SE..
State-backed hackers are disrupting COVID-19 vaccine efforts (2020-11-16) Pharmaceutical companies researching treatments and vaccines for COVID-19 are being actively targeted by prominent nation state-backed hackers from Russia and North Korea Groups including Strontium Zinc and Cerium are launching unconscionable cyber attacks against companies running trials for COVID-19 vaccines one clinical research organisation and a company thats developed a virus test according ..
Manchester United resists ‘sophisticated’ cyber attack (2020-11-23) Manchester United Football Club has disclosed a sophisticated attempt to compromise its digital systems by organised cyber criminals The cyber attack forced the football club to bring in third-party advisors to investigate the incident and minimise the IT disruption caused which the club described as ongoing when revealing the attack on Friday evening The football clubs social media channels inclu..
Huawei Mate 40 Pro Gallery (2020-11-25) Huawei Mate 40 Pro
BenQ PD3220U review (2020-11-20) It isnt enough for manufacturers to lure creative pros with the promise of calibrated panels that have a Delta E under two anymore thats rapidly becoming the standard for mid-range screens Instead the likes of BenQ must entice people with features beyond normal monitors BenQ hopes that its Hotkey Puck G2 will do exactly that This connects to a port at the rear and provides a handy dial for control..
EU puts human rights at the heart of tougher tech export rules (2020-11-11) European-based technology vendors must apply for government licenses to export certain dual-use products and consider whether the use of their products in any deal poses a risk to human rights New rules established by EU lawmakers and the European Council beef up the export criteria of so-called dual-use technologies meaning vendors will have to clear a much higher bar when striking licensing deal..
NCSC battles surge of COVID-related cyber attacks (2020-11-03) The National Cyber Security Centre NCSC has been battling a surge in pandemic-related cyber attacks reporting that more thana quarter of all security incidents reported in the last year were related to COVID-19 The organisation handled 723 incidents between 1 September 2019 and 31 August 2020increase from the 658 reported in the year prior In a blog post published today the NCSC explained that the..