Merge pull request #9329 from hashicorp/je.website-maintenance-5-29-20
🌷 Website Spring Maintenance
This commit is contained in:
commit
02590f6c44
|
@ -340,7 +340,7 @@ type Config struct {
|
|||
// tags to the image to ensure this information is not lost. The following
|
||||
// tags are added.
|
||||
//
|
||||
// ```
|
||||
// ```text
|
||||
// 1. PlanName
|
||||
// 2. PlanProduct
|
||||
// 3. PlanPublisher
|
||||
|
|
|
@ -139,7 +139,7 @@ type Config struct {
|
|||
// The Google Compute network id or URL to use for the launched instance.
|
||||
// Defaults to "default". If the value is not a URL, it will be
|
||||
// interpolated to
|
||||
// projects/((network_project_id))/global/networks/((network)). This value
|
||||
// `projects/((network_project_id))/global/networks/((network))`. This value
|
||||
// is not required if a subnet is specified.
|
||||
Network string `mapstructure:"network" required:"false"`
|
||||
// The project ID for the network and subnetwork to use for launched
|
||||
|
@ -197,7 +197,7 @@ type Config struct {
|
|||
// subnetting. Note, the region of the subnetwork must match the region or
|
||||
// zone in which the VM is launched. If the value is not a URL, it will be
|
||||
// interpolated to
|
||||
// projects/((network_project_id))/regions/((region))/subnetworks/((subnetwork))
|
||||
// `projects/((network_project_id))/regions/((region))/subnetworks/((subnetwork))`
|
||||
Subnetwork string `mapstructure:"subnetwork" required:"false"`
|
||||
// Assign network tags to apply firewall rules to VM instance.
|
||||
Tags []string `mapstructure:"tags" required:"false"`
|
||||
|
|
|
@ -39,7 +39,7 @@ type ExportConfig struct {
|
|||
// packer call like this (shell `>` continuation character snipped for easier
|
||||
// copy & paste):
|
||||
//
|
||||
// ``` shell
|
||||
// ```shell
|
||||
// vm_description='some
|
||||
// multiline
|
||||
// description'
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
...require('@hashicorp/nextjs-scripts/.stylelintrc.js'),
|
||||
/* Specify overrides here */
|
||||
}
|
|
@ -1,16 +1,46 @@
|
|||
# Packer Website
|
||||
# Packer Documentation Website
|
||||
|
||||
[![Netlify Status](https://img.shields.io/netlify/f7fa8963-0022-4a0e-9ccf-f5385355906b?style=flat-square)](https://app.netlify.com/sites/packer-docs-platform/deploys)
|
||||
[![Netlify Status](https://img.shields.io/netlify/0b9f9a3b-9bea-4889-8ad0-9c79583cb70e?style=flat-square)](https://app.netlify.com/sites/packer-www/deploys)
|
||||
|
||||
This subdirectory contains the entire source for the [Packer Website](https://packer.io/). This is a [NextJS](https://nextjs.org/) project, which builds a static site from these source files.
|
||||
|
||||
<!--
|
||||
This readme file contains several blocks of generated text, to make it easier to share common information
|
||||
across documentation website readmes. To generate these blocks from their source, run `npm run generate:readme`
|
||||
|
||||
Any edits to the readme are welcome outside the clearly noted boundaries of the blocks. Alternately, a
|
||||
block itself can be safely "forked" from the central implementation simply by removing the "BEGIN" and
|
||||
"END" comments from around it.
|
||||
-->
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Contributions](#contributions-welcome)
|
||||
- [Running the Site Locally](#running-the-site-locally)
|
||||
- [Editing Markdown Content](#editing-markdown-content)
|
||||
- [Editing Navigation Sidebars](#editing-navigation-sidebars)
|
||||
- [Changing the Release Version](#changing-the-release-version)
|
||||
- [Redirects](#redirects)
|
||||
- [Browser Support](#browser-support)
|
||||
- [Deployment](#deployment)
|
||||
|
||||
<!-- BEGIN: contributions -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Contributions Welcome!
|
||||
|
||||
If you find a typo or you feel like you can improve the HTML, CSS, or JavaScript, we welcome contributions. Feel free to open issues or pull requests like any normal GitHub project, and we'll merge it in 🚀
|
||||
|
||||
<!-- END: contributions -->
|
||||
|
||||
<!-- BEGIN: local-development -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Running the Site Locally
|
||||
|
||||
The website can be run locally through node.js or Docker. If you choose to run through Docker, everything will be a little bit slower due to the additional overhead, so for frequent contributors it may be worth it to use node. Also if you are a vim user, it's also worth noting that vim's swapfile usage can cause issues for the live reload functionality. In order to avoid these issues, make sure you have run `:set backupcopy=yes` within vim.
|
||||
The website can be run locally through node.js or [Docker](https://www.docker.com/get-started). If you choose to run through Docker, everything will be a little bit slower due to the additional overhead, so for frequent contributors it may be worth it to use node.
|
||||
|
||||
> **Note:** If you are using a text editor that uses a "safe write" save style such as **vim** or **goland**, this can cause issues with the live reload in development. If you turn off safe write, this should solve the problem. In vim, this can be done by running `:set backupcopy=yes`. In goland, search the settings for "safe write" and turn that setting off.
|
||||
|
||||
### With Docker
|
||||
|
||||
|
@ -25,11 +55,16 @@ If your local development environment has a supported version (v10.0.0+) of [nod
|
|||
- `npm install`
|
||||
- `npm start`
|
||||
|
||||
and then visit `http://localhost:3000`.
|
||||
...and then visit `http://localhost:3000`.
|
||||
|
||||
If you pull down new code from github, you should run `npm install` again. Otherwise, there's no need to re-run `npm install` each time the site is run, you can just run `npm start` to get it going.
|
||||
|
||||
## Editing Content
|
||||
<!-- END: local-development -->
|
||||
|
||||
<!-- BEGIN: editing-markdown -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Editing Markdown Content
|
||||
|
||||
Documentation content is written in [Markdown](https://www.markdownguide.org/cheat-sheet/) and you'll find all files listed under the `/pages` directory.
|
||||
|
||||
|
@ -50,73 +85,18 @@ The significant keys in the YAML frontmatter are:
|
|||
- `title` `(string)` - This is the title of the page that will be set in the HTML title.
|
||||
- `description` `(string)` - This is a description of the page that will be set in the HTML description.
|
||||
|
||||
> ⚠️Since `api` is a reserved directory within NextJS, all `/api/**` pages are listed under the `/pages/api-docs` path.
|
||||
|
||||
### Editing Sidebars
|
||||
|
||||
The structure of the sidebars are controlled by files in the [`/data` directory](data).
|
||||
|
||||
- Edit [this file](data/docs-navigation.js) to change the **docs** sidebar
|
||||
- Edit [this file](data/guides-navigation.js) to change the **guides** sidebar
|
||||
- Edit [this file](data/intro-navigation.js) to change the **intro** sidebar
|
||||
|
||||
To nest sidebar items, you'll want to add a new `category` key/value accompanied by the appropriate embedded `content` values.
|
||||
|
||||
- `category` values will be **directory names** within the `pages` directory
|
||||
- `content` values will be **file names** within their appropriately nested directory.
|
||||
> ⚠️ Since `api` is a reserved directory within NextJS, all `/api/**` pages are listed under the `/pages/api-docs` path.
|
||||
|
||||
### Creating New Pages
|
||||
|
||||
There is currently a small bug with new page creation - if you create a new page and link it up via subnav data while the server is running, it will report an error saying the page was not found. This can be resolved by restarting the server.
|
||||
|
||||
### Changing the Release Version
|
||||
|
||||
To change the version of Packer displayed for download on the website, head over to `data/version.js` and change the number there. It's important to note that the version number must match a version that has been released and is live on `releases.hashicorp.com` -- if it does not, the website will be unable to fetch links to the binaries and will not compile. So this version number should be changed _only after a release_.
|
||||
|
||||
#### Displaying a Prerelease
|
||||
|
||||
If there is a prerelease of any type that should be displayed on the downloads page, this can be done by editing `pages/downloads/index.jsx`. By default, the download component might look something like this:
|
||||
|
||||
```jsx
|
||||
<ProductDownloader
|
||||
product="Packer"
|
||||
version={VERSION}
|
||||
downloads={downloadData}
|
||||
community="/resources"
|
||||
/>
|
||||
```
|
||||
|
||||
To add a prerelease, an extra `prerelease` property can be added to the component as such:
|
||||
|
||||
```jsx
|
||||
<ProductDownloader
|
||||
product="Packer"
|
||||
version={VERSION}
|
||||
downloads={downloadData}
|
||||
community="/resources"
|
||||
prerelease={{
|
||||
type: 'release candidate', // the type of prerelease: beta, release candidate, etc.
|
||||
name: 'v1.0.0', // the name displayed in text on the website
|
||||
version: '1.0.0-rc1', // the actual version tag that was pushed to releases.hashicorp.com
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
This configuration would display something like the following text on the website, emphasis added to the configurable parameters:
|
||||
|
||||
```
|
||||
A {{ release candidate }} for Packer {{ v1.0.0 }} is available! The release can be <a href='https://releases.hashicorp.com/packer/{{ 1.0.0-rc1 }}'>downloaded here</a>.
|
||||
```
|
||||
|
||||
You may customize the parameters in any way you'd like. To remove a prerelease from the website, simply delete the `prerelease` paremeter from the above component.
|
||||
|
||||
|
||||
### Markdown Enhancements
|
||||
|
||||
There are several custom markdown plugins that are available by default that enhance standard markdown to fit our use cases. This set of plugins introduces a couple instances of custom syntax, and a couple specific pitfalls that are not present by default with markdown, detailed below:
|
||||
There are several custom markdown plugins that are available by default that enhance [standard markdown](https://commonmark.org/) to fit our use cases. This set of plugins introduces a couple instances of custom syntax, and a couple specific pitfalls that are not present by default with markdown, detailed below:
|
||||
|
||||
- If you see the symbols `~>`, `->`, `=>`, or `!>`, these represent [custom alerts](https://github.com/hashicorp/remark-plugins/tree/master/plugins/paragraph-custom-alerts#paragraph-custom-alerts). These render as colored boxes to draw the user's attention to some type of aside.
|
||||
- If you see `@include '/some/path.mdx'`, this is a [markdown include](https://github.com/hashicorp/remark-plugins/tree/master/plugins/include-markdown#include-markdown-plugin). It's worth noting as well that all includes resolve from `website/pages/partials` by default.
|
||||
- If you see `@include '/some/path.mdx'`, this is a [markdown include](https://github.com/hashicorp/remark-plugins/tree/master/plugins/include-markdown#include-markdown-plugin). It's worth noting as well that all includes resolve from `website/pages/partials` by default, and that changes to partials will not live-reload the website.
|
||||
- If you see `# Headline ((#slug))`, this is an example of an [anchor link alias](https://github.com/hashicorp/remark-plugins/tree/je.anchor-link-adjustments/plugins/anchor-links#anchor-link-aliases). It adds an extra permalink to a headline for compatibility and is removed from the output.
|
||||
- Due to [automatically generated permalinks](https://github.com/hashicorp/remark-plugins/tree/je.anchor-link-adjustments/plugins/anchor-links#anchor-links), any text changes to _headlines_ or _list items that begin with inline code_ can and will break existing permalinks. Be very cautious when changing either of these two text items.
|
||||
|
||||
|
@ -136,18 +116,159 @@ There are several custom markdown plugins that are available by default that enh
|
|||
|
||||
...while it perhaps would not be an improved user experience, no links would break because of it. The best approach is to **avoid changing headlines and inline code at the start of a list item**. If you must change one of these items, make sure to tag someone from the digital marketing development team on your pull request, they will help to ensure as much compatibility as possible.
|
||||
|
||||
### Redirects
|
||||
<!-- END: editing-markdown -->
|
||||
|
||||
<!-- BEGIN: editing-docs-sidebars -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Editing Navigation Sidebars
|
||||
|
||||
The structure of the sidebars are controlled by files in the [`/data` directory](data). For example, [this file](data/docs-navigation.js) controls the **docs** sidebar. Within the `data` folder, any file with `-navigation` after it controls the navigation for the given section.
|
||||
|
||||
The sidebar uses a simple recursive data structure to represent _files_ and _directories_. A file is represented by a string, and a directory is represented by an object. The sidebar is meant to reflect the structure of the docs within the filesystem while also allowing custom ordering. Let's look at an example. First, here's our example folder structure:
|
||||
|
||||
```text
|
||||
.
|
||||
├── docs
|
||||
│ └── directory
|
||||
│ ├── index.mdx
|
||||
│ ├── file.mdx
|
||||
│ ├── another-file.mdx
|
||||
│ └── nested-directory
|
||||
│ ├── index.mdx
|
||||
│ └── nested-file.mdx
|
||||
```
|
||||
|
||||
Here's how this folder structure could be represented as a sidebar navigation, in this example it would be the file `website/data/docs-navigation.js`:
|
||||
|
||||
```js
|
||||
export default {
|
||||
category: 'directory',
|
||||
content: [
|
||||
'file',
|
||||
'another-file',
|
||||
{
|
||||
category: 'nested-directory',
|
||||
content: ['nested-file'],
|
||||
},
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
- `category` values will be **directory names** within the `pages/<section>` directory
|
||||
- `content` values will be **file names** within their appropriately nested directory
|
||||
|
||||
A couple more important notes:
|
||||
|
||||
- Within this data structure, ordering does not matter, but hierarchy does. So while you could put `file` and `another-file` in any order, or even leave one or both of them out, you could not decide to un-nest the `nested-directory` object without also un-nesting it in the filesystem.
|
||||
- The `sidebar_title` frontmatter property on each `mdx` page is responsible for displaying the human-readable page name in the navigation.
|
||||
- _By default_, every directory/category must have an `index.mdx` file. This file will be automatically added to the navigation as "Overview", and its `sidebar_title` property will set the human-readable name of the entire category.
|
||||
|
||||
Below we will discuss a couple of more unusual but still helpful patterns.
|
||||
|
||||
### Index-less Categories
|
||||
|
||||
Sometimes you may want to include a category but not have a need for an index page for the category. This can be accomplished, but a human-readable category name needs to be set manually, since the category name is normally pulled from the `sidebar_title` property of the index page. Here's an example of how an index-less category might look:
|
||||
|
||||
```text
|
||||
.
|
||||
├── docs
|
||||
│ └── indexless-category
|
||||
│ └── file.mdx
|
||||
```
|
||||
|
||||
```js
|
||||
// website/data/docs-navigation.js
|
||||
export default {
|
||||
category: 'indexless-category',
|
||||
name: 'Indexless Category',
|
||||
content: ['file'],
|
||||
}
|
||||
```
|
||||
|
||||
The addition of the `name` property to a category object is all it takes to be able to skip the index file.
|
||||
|
||||
### Custom or External Links
|
||||
|
||||
Sometimes you may have a need to include a link that is not directly to a file within the docs hierarchy. This can also be supported using a different pattern. For example:
|
||||
|
||||
```js
|
||||
export default {
|
||||
category: 'directory',
|
||||
content: [
|
||||
'file',
|
||||
'another-file',
|
||||
{ title: 'Tao of HashiCorp', href: 'https://www.hashicorp.com/tao-of-hashicorp' }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
If the link provided in the `href` property is external, it will display a small icon indicating this. If it's internal, it will appear the same way as any other direct file link.
|
||||
|
||||
<!-- END: editing-docs-sidebars -->
|
||||
|
||||
<!-- BEGIN: releases -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Changing the Release Version
|
||||
|
||||
To change the version displayed for download on the website, head over to `data/version.js` and change the number there. It's important to note that the version number must match a version that has been released and is live on `releases.hashicorp.com` -- if it does not, the website will be unable to fetch links to the binaries and will not compile. So this version number should be changed _only after a release_.
|
||||
|
||||
### Displaying a Prerelease
|
||||
|
||||
If there is a prerelease of any type that should be displayed on the downloads page, this can be done by editing `pages/downloads/index.jsx`. By default, the download component might look something like this:
|
||||
|
||||
```jsx
|
||||
<ProductDownloader
|
||||
product="<Product>"
|
||||
version={VERSION}
|
||||
downloads={downloadData}
|
||||
community="/resources"
|
||||
/>
|
||||
```
|
||||
|
||||
To add a prerelease, an extra `prerelease` property can be added to the component as such:
|
||||
|
||||
```jsx
|
||||
<ProductDownloader
|
||||
product="<Product>"
|
||||
version={VERSION}
|
||||
downloads={downloadData}
|
||||
community="/resources"
|
||||
prerelease={{
|
||||
type: 'release candidate', // the type of prerelease: beta, release candidate, etc.
|
||||
name: 'v1.0.0', // the name displayed in text on the website
|
||||
version: '1.0.0-rc1', // the actual version tag that was pushed to releases.hashicorp.com
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
This configuration would display something like the following text on the website, emphasis added to the configurable parameters:
|
||||
|
||||
```
|
||||
A {{ release candidate }} for <Product> {{ v1.0.0 }} is available! The release can be <a href='https://releases.hashicorp.com/<product>/{{ 1.0.0-rc1 }}'>downloaded here</a>.
|
||||
```
|
||||
|
||||
You may customize the parameters in any way you'd like. To remove a prerelease from the website, simply delete the `prerelease` paremeter from the above component.
|
||||
|
||||
<!-- END: releases -->
|
||||
|
||||
<!-- BEGIN: redirects -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Redirects
|
||||
|
||||
This website structures URLs based on the filesystem layout. This means that if a file is moved, removed, or a folder is re-organized, links will break. If a path change is necessary, it can be mitigated using redirects.
|
||||
|
||||
To add a redirect, head over to the `_redirects` file - the format is fairly simple. On the left is the current path, and on the right is the path that should be redirected to. It's important to note that if there are links to a `.html` version of a page, that must also be explicitly redirected. For example:
|
||||
|
||||
```
|
||||
/foo /bar
|
||||
/foo.html /bar
|
||||
/foo /bar 301!
|
||||
/foo.html /bar 301!
|
||||
```
|
||||
|
||||
This redirect rule will send all incoming links to `/foo` and `/foo.html` to `/bar`. For more details on the redirects file format, [check out the docs on netlify](https://docs.netlify.com/routing/redirects/rewrites-proxies).
|
||||
This redirect rule will send all incoming links to `/foo` and `/foo.html` to `/bar`. For more details on the redirects file format, [check out the docs on netlify](https://docs.netlify.com/routing/redirects/rewrites-proxies). Note that it is critical that `301!` is added to every one-to-one redirect - if it is left off the redirect may not work.
|
||||
|
||||
There are a couple important caveats with redirects. First, redirects are applied at the hosting layer, and therefore will not work by default in local dev mode. To test in local dev mode, you can use [`netlify dev`](https://www.netlify.com/products/dev/), or just push a commit and check using the deploy preview.
|
||||
|
||||
|
@ -156,8 +277,8 @@ Second, redirects do not apply to client-side navigation. By default, all links
|
|||
Let's look at an example. Say you have a page called `/docs/foo` which needs to be moved to `/docs/nested/foo`. Additionally, this is a page that has been around for a while and we know there are links into `/docs/foo.html` left over from our previous website structure. First, we move the page, then adjust the docs sidenav, in `data/docs-navigation.js`. Find the category the page is in, and move it into the appropriate subcategory. Next, we add to `_redirects` as such:
|
||||
|
||||
```
|
||||
/foo /nested/foo
|
||||
/foo.html /nested/foo
|
||||
/foo /nested/foo 301!
|
||||
/foo.html /nested/foo 301!
|
||||
```
|
||||
|
||||
Finally, we run a global search for internal links to `/foo`, and make sure to adjust them to be `/nested/foo` - this is to ensure that client-side navigation still works correctly. _Adding a redirect alone is not enough_.
|
||||
|
@ -179,7 +300,7 @@ If we no longer want the link to be in the side nav, we can simply remove it. If
|
|||
{
|
||||
category: 'docs',
|
||||
content: [
|
||||
{ title: 'Foo Title', href: 'https://learn.hashicorp.com/vault/foo' }
|
||||
{ title: 'Foo Title', href: 'https://learn.hashicorp.com/<product>/foo' }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
@ -188,6 +309,26 @@ As the majority of items in the side nav are internal links, the structure makes
|
|||
|
||||
It's also worth noting that it is possible to do glob-based redirects, for example matching `/docs/*`, and you may see this pattern in the `_redirects` file. This type of redirect is much higher risk and the behavior is a bit more nuanced, so if you need to add a glob redirect, please reach out to the website maintainers and ask about it first.
|
||||
|
||||
### Deployment
|
||||
<!-- END: redirects -->
|
||||
|
||||
<!-- BEGIN: browser-support -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Browser Support
|
||||
|
||||
We support the following browsers targeting roughly the versions specified.
|
||||
|
||||
| ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_24x24.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_24x24.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_24x24.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_24x24.png) | ![Internet Explorer](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_24x24.png) |
|
||||
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| **Latest** | **Latest** | **Latest** | **Latest** | **11+** |
|
||||
|
||||
<!-- END: browser-support -->
|
||||
|
||||
<!-- BEGIN: deployment -->
|
||||
<!-- Generated text, do not edit directly -->
|
||||
|
||||
## Deployment
|
||||
|
||||
This website is hosted on Netlify and configured to automatically deploy anytime you push code to the `stable-website` branch. Any time a pull request is submitted that changes files within the `website` folder, a deployment preview will appear in the github checks which can be used to validate the way docs changes will look live. Deployments from `stable-website` will look and behave the same way as deployment previews.
|
||||
|
||||
<!-- END: deployment -->
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Subnav from '@hashicorp/react-subnav'
|
||||
import subnavItems from '../../data/subnav'
|
||||
import subnavItems from 'data/subnav'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
export default function PackerSubnav() {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "."
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import DocsPage from '@hashicorp/react-docs-page'
|
||||
import order from '../data/docs-navigation.js'
|
||||
import order from 'data/docs-navigation.js'
|
||||
import { frontMatter as data } from '../pages/docs/**/*.mdx'
|
||||
import Head from 'next/head'
|
||||
import Link from 'next/link'
|
||||
|
@ -14,14 +14,14 @@ function DocsLayoutWrapper(pageMeta) {
|
|||
is: Head,
|
||||
title: `${pageMeta.page_title} | Packer by HashiCorp`,
|
||||
description: pageMeta.description,
|
||||
siteName: 'Packer by HashiCorp'
|
||||
siteName: 'Packer by HashiCorp',
|
||||
}}
|
||||
sidenav={{
|
||||
Link,
|
||||
category: 'docs',
|
||||
currentPage: props.path,
|
||||
data,
|
||||
order
|
||||
order,
|
||||
}}
|
||||
resourceURL={`https://github.com/hashicorp/packer/blob/master/website/pages/${pageMeta.__resourcePath}`}
|
||||
/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import DocsPage from '@hashicorp/react-docs-page'
|
||||
import order from '../data/guides-navigation.js'
|
||||
import order from 'data/guides-navigation.js'
|
||||
import { frontMatter as data } from '../pages/guides/**/*.mdx'
|
||||
import Head from 'next/head'
|
||||
import Link from 'next/link'
|
||||
|
@ -14,14 +14,14 @@ function GuidesLayoutWrapper(pageMeta) {
|
|||
is: Head,
|
||||
title: `${pageMeta.page_title} | Packer by HashiCorp`,
|
||||
description: pageMeta.description,
|
||||
siteName: 'Packer by HashiCorp'
|
||||
siteName: 'Packer by HashiCorp',
|
||||
}}
|
||||
sidenav={{
|
||||
Link,
|
||||
category: 'guides',
|
||||
currentPage: props.path,
|
||||
data,
|
||||
order
|
||||
order,
|
||||
}}
|
||||
resourceURL={`https://github.com/hashicorp/packer/blob/master/website/pages/${pageMeta.__resourcePath}`}
|
||||
/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import DocsPage from '@hashicorp/react-docs-page'
|
||||
import order from '../data/intro-navigation.js'
|
||||
import order from 'data/intro-navigation.js'
|
||||
import { frontMatter as data } from '../pages/intro/**/*.mdx'
|
||||
import Head from 'next/head'
|
||||
import Link from 'next/link'
|
||||
|
@ -14,14 +14,14 @@ function IntroLayoutWrapper(pageMeta) {
|
|||
is: Head,
|
||||
title: `${pageMeta.page_title} | Packer by HashiCorp`,
|
||||
description: pageMeta.description,
|
||||
siteName: 'Packer by HashiCorp'
|
||||
siteName: 'Packer by HashiCorp',
|
||||
}}
|
||||
sidenav={{
|
||||
Link,
|
||||
category: 'intro',
|
||||
currentPage: props.path,
|
||||
data,
|
||||
order
|
||||
order,
|
||||
}}
|
||||
resourceURL={`https://github.com/hashicorp/packer/blob/master/website/pages/${pageMeta.__resourcePath}`}
|
||||
/>
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import React from 'react'
|
||||
import Bugsnag from '@bugsnag/js'
|
||||
import BugsnagReact from '@bugsnag/plugin-react'
|
||||
|
||||
const apiKey =
|
||||
typeof window === 'undefined'
|
||||
? 'b6c57b27a37e531a5de94f065dd98bc0'
|
||||
: 'de0b822b269aa57b620efd8927e03744'
|
||||
|
||||
if (!Bugsnag._client) {
|
||||
Bugsnag.start({
|
||||
apiKey,
|
||||
plugins: [new BugsnagReact(React)],
|
||||
otherOptions: { releaseStage: process.env.NODE_ENV || 'development' },
|
||||
})
|
||||
}
|
||||
|
||||
export default Bugsnag
|
|
@ -1,76 +0,0 @@
|
|||
const isProd = process.env.NODE_ENV === 'production'
|
||||
|
||||
const segmentWriteKey = isProd
|
||||
? 'AjXdfmTTk1I9q9dfyePuDFHBrz1tCO3l'
|
||||
: '0EXTgkNx0Ydje2PGXVbRhpKKoe5wtzcE'
|
||||
|
||||
// TODO: refactor into web components
|
||||
let utilityServerRoot = isProd
|
||||
? 'https://util.hashicorp.com'
|
||||
: 'https://hashicorp-web-util-staging.herokuapp.com'
|
||||
|
||||
if (process.env.UTIL_SERVER) {
|
||||
utilityServerRoot = process.env.UTIL_SERVER.replace(/\/$/, '')
|
||||
}
|
||||
|
||||
// Consent manager configuration
|
||||
export default {
|
||||
version: 3,
|
||||
container: '#consent-manager',
|
||||
companyName: 'HashiCorp',
|
||||
privacyPolicyLink: '/privacy',
|
||||
segmentWriteKey: segmentWriteKey,
|
||||
utilServerRoot: utilityServerRoot,
|
||||
segmentServices: [
|
||||
{
|
||||
key: 'googleanalytics',
|
||||
name: 'Google Analytics',
|
||||
description:
|
||||
'Google Analytics is a popular service for tracking web traffic. We use this data to determine what content our users find important so that we can dedicate more resources toward it.',
|
||||
category: 'Analytics',
|
||||
},
|
||||
{
|
||||
name: 'Hotjar',
|
||||
description:
|
||||
'Hotjar is a service that generates heatmaps of where users click on our sites. We use this information to ensure that our site is not confusing, and simple to use and navigate.',
|
||||
category: 'Analytics',
|
||||
},
|
||||
{
|
||||
name: 'LinkedIn Insight Tag',
|
||||
description:
|
||||
'This small script allows us to see how effective our linkedin campaigns are by showing which users have clicked through to our site.',
|
||||
category: 'Analytics',
|
||||
},
|
||||
{
|
||||
name: 'Marketo V2',
|
||||
description:
|
||||
'Marketo is a marketing automation tool that allows us to segment users into different categories based off of their behaviors. We use this information to provide tailored information to users in our email campaigns.',
|
||||
},
|
||||
],
|
||||
categories: [
|
||||
{
|
||||
name: 'Functional',
|
||||
description:
|
||||
'Functional services provide a utility to the website, such as the ability to log in, or to get live support. Disabling any of these scripts will cause that utility to be missing from the site.',
|
||||
},
|
||||
{
|
||||
name: 'Analytics',
|
||||
description:
|
||||
'Analytics services keep track of page traffic and user behavior while browsing the site. We use this data internally to improve the usability and performance of the site. Disabling any of these scripts makes it more difficult for us to understand how our site is being used, and slower to improve it.',
|
||||
},
|
||||
{
|
||||
name: 'Email Marketing',
|
||||
description:
|
||||
'Email Marketing services track user behavior while browsing the site. We use this data internally in our marketing efforts to provide users contextually relevant information based off of their behaviors. Disabling any of these scripts makes it more difficult for us to provide you contextually relevant information.',
|
||||
},
|
||||
],
|
||||
additionalServices: [
|
||||
{
|
||||
name: 'OptinMonster',
|
||||
description:
|
||||
"OptinMonster is a service that we use to show a prompt to sign up for our newsletter if it's perceived that you are interested in our content.",
|
||||
category: 'Functional',
|
||||
body: `var om598c8e3a6e43d,om598c8e3a6e43d_poll=function(){var r=0;return function(n,l){clearInterval(r),r=setInterval(n,l)}}();!function(e,t,n){if(e.getElementById(n)){om598c8e3a6e43d_poll(function(){if(window['om_loaded']){if(!om598c8e3a6e43d){om598c8e3a6e43d=new OptinMonsterApp();return om598c8e3a6e43d.init({"s":"35109.598c8e3a6e43d","staging":0,"dev":0,"beta":0});}}},25);return;}var d=false,o=e.createElement(t);o.id=n,o.src="https://a.optnmstr.com/app/js/api.min.js",o.async=true,o.onload=o.onreadystatechange=function(){if(!d){if(!this.readyState||this.readyState==="loaded"||this.readyState==="complete"){try{d=om_loaded=true;om598c8e3a6e43d=new OptinMonsterApp();om598c8e3a6e43d.init({"s":"35109.598c8e3a6e43d","staging":0,"dev":0,"beta":0});o.onload=o.onreadystatechange=null;}catch(t){}}}};(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(o)}(document,"script","omapi-script");`,
|
||||
},
|
||||
],
|
||||
}
|
|
@ -7,10 +7,10 @@
|
|||
command = "npm run static"
|
||||
|
||||
[context.production]
|
||||
environment = { HASHI_ENV = "production", NODE_ENV = "production"}
|
||||
environment = { HASHI_ENV = "production", NODE_ENV = "production" }
|
||||
|
||||
[context.deploy-preview]
|
||||
environment = { HASHI_ENV = "staging" }
|
||||
environment = { HASHI_ENV = "staging", NODE_ENV = "production" }
|
||||
|
||||
[[headers]]
|
||||
for = "/*"
|
||||
|
|
|
@ -7,7 +7,6 @@ module.exports = withHashicorp({
|
|||
mdx: { resolveIncludes: path.join(__dirname, 'pages/partials') },
|
||||
})({
|
||||
experimental: {
|
||||
css: true,
|
||||
modern: true,
|
||||
rewrites: () => [
|
||||
{
|
||||
|
@ -17,7 +16,11 @@ module.exports = withHashicorp({
|
|||
],
|
||||
},
|
||||
exportTrailingSlash: true,
|
||||
// Note: These are meant to be public, it's not a mistake that they are here
|
||||
env: {
|
||||
HASHI_ENV: process.env.HASHI_ENV,
|
||||
SEGMENT_WRITE_KEY: 'AjXdfmTTk1I9q9dfyePuDFHBrz1tCO3l',
|
||||
BUGSNAG_CLIENT_KEY: 'de0b822b269aa57b620efd8927e03744',
|
||||
BUGSNAG_SERVER_KEY: 'b6c57b27a37e531a5de94f065dd98bc0',
|
||||
},
|
||||
})
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,49 +1,28 @@
|
|||
{
|
||||
"name": "packer-docs",
|
||||
"description": "Description of your website",
|
||||
"version": "0.0.1",
|
||||
"description": "Documentation website for HashiCorp Packer",
|
||||
"version": "1.0.0",
|
||||
"author": "HashiCorp",
|
||||
"dependencies": {
|
||||
"@bugsnag/js": "^7.0.0",
|
||||
"@bugsnag/plugin-react": "^7.0.0",
|
||||
"@hashicorp/nextjs-scripts": "^6.2.0-9",
|
||||
"@hashicorp/react-alert": "^2.0.0",
|
||||
"@hashicorp/react-button": "^2.1.8",
|
||||
"@hashicorp/react-consent-manager": "^2.0.8",
|
||||
"@hashicorp/nextjs-scripts": "^8.3.2",
|
||||
"@hashicorp/react-button": "^2.2.0",
|
||||
"@hashicorp/react-content": "^3.0.0-0",
|
||||
"@hashicorp/react-docs-page": "^1.3.1",
|
||||
"@hashicorp/react-docs-page": "^2.0.0",
|
||||
"@hashicorp/react-docs-sidenav": "^3.2.3",
|
||||
"@hashicorp/react-docs-sitemap": "^1.0.0",
|
||||
"@hashicorp/react-footer": "^3.1.13",
|
||||
"@hashicorp/react-global-styles": "^4.1.0",
|
||||
"@hashicorp/react-head": "^0.1.1",
|
||||
"@hashicorp/react-hero": "^3.0.6",
|
||||
"@hashicorp/react-image": "^2.0.1",
|
||||
"@hashicorp/react-inline-svg": "^1.0.0",
|
||||
"@hashicorp/react-global-styles": "^4.4.0",
|
||||
"@hashicorp/react-head": "^1.0.0",
|
||||
"@hashicorp/react-mega-nav": "^4.0.1-2",
|
||||
"@hashicorp/react-product-downloader": "^3.1.1",
|
||||
"@hashicorp/react-product-downloader": "^3.3.0",
|
||||
"@hashicorp/react-section-header": "^2.0.0",
|
||||
"@hashicorp/react-subnav": "^3.1.0",
|
||||
"@hashicorp/react-text-and-content": "^4.0.8",
|
||||
"@hashicorp/react-text-split": "^0.2.5",
|
||||
"@hashicorp/react-text-split-with-code": "0.0.8",
|
||||
"@hashicorp/react-text-split-with-image": "^1.2.5",
|
||||
"@hashicorp/react-subnav": "^3.2.1",
|
||||
"@hashicorp/react-vertical-text-block-list": "^2.0.1",
|
||||
"babel-plugin-import-glob-array": "^0.2.0",
|
||||
"highlight.js": "^10.0.0",
|
||||
"imagemin-mozjpeg": "^8.0.0",
|
||||
"imagemin-optipng": "^7.1.0",
|
||||
"imagemin-svgo": "^7.1.0",
|
||||
"isomorphic-unfetch": "^3.0.0",
|
||||
"marked": "^0.7.0",
|
||||
"next": "9.3.5",
|
||||
"nprogress": "^0.2.0",
|
||||
"nuka-carousel": "^4.6.7",
|
||||
"imagemin-mozjpeg": "^9.0.0",
|
||||
"imagemin-optipng": "^8.0.0",
|
||||
"imagemin-svgo": "^8.0.0",
|
||||
"next": "9.4.4",
|
||||
"react": "^16.13.1",
|
||||
"react-device-detect": "^1.11.14",
|
||||
"react-dom": "^16.13.1",
|
||||
"slugify": "^1.4.0",
|
||||
"stringify-object": "^3.3.0"
|
||||
"react-dom": "^16.13.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dart-linkcheck": "^2.0.15",
|
||||
|
@ -64,6 +43,7 @@
|
|||
"export": "node --max-old-space-size=2048 ./node_modules/.bin/next export",
|
||||
"format": "next-hashicorp format",
|
||||
"generate:component": "next-hashicorp generate component",
|
||||
"generate:readme": "next-hashicorp markdown-blocks README.md",
|
||||
"lint": "next-hashicorp lint",
|
||||
"start": "rm -rf .next/cache/next-babel-loader/ && next dev",
|
||||
"static": "npm run build && npm run export && cp _redirects out/.",
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import Link from 'next/link'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
export default function NotFound() {
|
||||
useEffect(() => {
|
||||
if (
|
||||
typeof window !== 'undefined' &&
|
||||
typeof window?.analytics?.track === 'function' &&
|
||||
typeof window?.document?.referrer === 'string' &&
|
||||
typeof window?.location?.href === 'string'
|
||||
)
|
||||
window.analytics.track(window.location.href, {
|
||||
category: '404 Response',
|
||||
label: window.document.referrer || 'No Referrer',
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div id="p-404">
|
||||
<h1>Page Not Found</h1>
|
||||
<p>
|
||||
We're sorry but we can't find the page you're looking
|
||||
for.
|
||||
</p>
|
||||
<p>
|
||||
<Link href="/">
|
||||
<a>Back to Home</a>
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -1,87 +1,78 @@
|
|||
import './style.css'
|
||||
import App from 'next/app'
|
||||
import NProgress from 'nprogress'
|
||||
import Router from 'next/router'
|
||||
import ProductSubnav from '../components/subnav'
|
||||
import '@hashicorp/nextjs-scripts/lib/nprogress/style.css'
|
||||
|
||||
import ProductSubnav from 'components/subnav'
|
||||
import MegaNav from '@hashicorp/react-mega-nav'
|
||||
import Footer from '../components/footer'
|
||||
import { ConsentManager, open } from '@hashicorp/react-consent-manager'
|
||||
import consentManagerConfig from '../lib/consent-manager-config'
|
||||
import bugsnagClient from '../lib/bugsnag'
|
||||
import Footer from 'components/footer'
|
||||
import Error from './_error'
|
||||
import Head from 'next/head'
|
||||
import HashiHead from '@hashicorp/react-head'
|
||||
import Router from 'next/router'
|
||||
import NProgress from '@hashicorp/nextjs-scripts/lib/nprogress'
|
||||
import createConsentManager from '@hashicorp/nextjs-scripts/lib/consent-manager'
|
||||
import { ErrorBoundary } from '@hashicorp/nextjs-scripts/lib/bugsnag'
|
||||
import useAnchorLinkAnalytics from '@hashicorp/nextjs-scripts/lib/anchor-link-analytics'
|
||||
|
||||
Router.events.on('routeChangeStart', NProgress.start)
|
||||
Router.events.on('routeChangeError', NProgress.done)
|
||||
Router.events.on('routeChangeComplete', (url) => {
|
||||
setTimeout(() => window.analytics.page(url), 0)
|
||||
NProgress.done()
|
||||
NProgress({ Router })
|
||||
const { ConsentManager, openConsentManager } = createConsentManager({
|
||||
preset: 'oss',
|
||||
})
|
||||
|
||||
// Bugsnag
|
||||
const ErrorBoundary = bugsnagClient.getPlugin('react')
|
||||
export default function App({ Component, pageProps }) {
|
||||
useAnchorLinkAnalytics()
|
||||
|
||||
class NextApp extends App {
|
||||
static async getInitialProps({ Component, ctx }) {
|
||||
let pageProps = {}
|
||||
|
||||
if (Component.getInitialProps) {
|
||||
pageProps = await Component.getInitialProps(ctx)
|
||||
} else if (Component.isMDXComponent) {
|
||||
// fix for https://github.com/mdx-js/mdx/issues/382
|
||||
const mdxLayoutComponent = Component({}).props.originalType
|
||||
if (mdxLayoutComponent.getInitialProps) {
|
||||
pageProps = await mdxLayoutComponent.getInitialProps(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
return { pageProps }
|
||||
}
|
||||
|
||||
render() {
|
||||
const { Component, pageProps } = this.props
|
||||
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={Error}>
|
||||
<HashiHead
|
||||
is={Head}
|
||||
title="Packer by HashiCorp"
|
||||
siteName="Packer by HashiCorp"
|
||||
description="Packer is a free and open source tool for creating golden images for multiple
|
||||
platforms from a single source configuration."
|
||||
image="https://www.packer.io/img/og-image.png"
|
||||
stylesheet={[
|
||||
{ href: '/css/nprogress.css' },
|
||||
{
|
||||
href:
|
||||
'https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&display=swap',
|
||||
},
|
||||
]}
|
||||
icon={[{ href: '/favicon.ico' }]}
|
||||
preload={[
|
||||
{ href: '/fonts/klavika/medium.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/light.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/regular.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/medium.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/bold.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/book.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/regular.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/semi-bold.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/bold.woff2', as: 'font' },
|
||||
{ href: '/fonts/dejavu/mono.woff2', as: 'font' },
|
||||
]}
|
||||
/>
|
||||
<MegaNav product="Packer" />
|
||||
<ProductSubnav />
|
||||
<div className="content">
|
||||
<Component {...pageProps} />
|
||||
</div>
|
||||
<Footer openConsentManager={open} />
|
||||
<ConsentManager {...consentManagerConfig} />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={Error}>
|
||||
<HashiHead
|
||||
is={Head}
|
||||
title="Packer by HashiCorp"
|
||||
siteName="Packer by HashiCorp"
|
||||
description="Packer is a free and open source tool for creating golden images for multiple
|
||||
platforms from a single source configuration."
|
||||
image="https://www.packer.io/img/og-image.png"
|
||||
stylesheet={[
|
||||
{
|
||||
href:
|
||||
'https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&display=swap',
|
||||
},
|
||||
]}
|
||||
icon={[{ href: '/favicon.ico' }]}
|
||||
preload={[
|
||||
{ href: '/fonts/klavika/medium.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/light.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/regular.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/medium.woff2', as: 'font' },
|
||||
{ href: '/fonts/gilmer/bold.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/book.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/regular.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/semi-bold.woff2', as: 'font' },
|
||||
{ href: '/fonts/metro-sans/bold.woff2', as: 'font' },
|
||||
{ href: '/fonts/dejavu/mono.woff2', as: 'font' },
|
||||
]}
|
||||
/>
|
||||
<MegaNav product="Packer" />
|
||||
<ProductSubnav />
|
||||
<div className="content">
|
||||
<Component {...pageProps} />
|
||||
</div>
|
||||
<Footer openConsentManager={openConsentManager} />
|
||||
<ConsentManager />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
}
|
||||
|
||||
export default NextApp
|
||||
App.getInitialProps = async ({ Component, ctx }) => {
|
||||
let pageProps = {}
|
||||
|
||||
if (Component.getInitialProps) {
|
||||
pageProps = await Component.getInitialProps(ctx)
|
||||
} else if (Component.isMDXComponent) {
|
||||
// fix for https://github.com/mdx-js/mdx/issues/382
|
||||
const mdxLayoutComponent = Component({}).props.originalType
|
||||
if (mdxLayoutComponent.getInitialProps) {
|
||||
pageProps = await mdxLayoutComponent.getInitialProps(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
return { pageProps }
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export default class MyDocument extends Document {
|
|||
<script
|
||||
noModule
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `window.MSInputMethodContext && document.documentMode && document.write('<script src="/ie-custom-properties.js"><\\x2fscript>');`
|
||||
__html: `window.MSInputMethodContext && document.documentMode && document.write('<script src="/ie-custom-properties.js"><\\x2fscript>');`,
|
||||
}}
|
||||
/>
|
||||
</body>
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import React from 'react'
|
||||
import ErrorPage from 'next/error'
|
||||
import bugsnagClient from '../lib/bugsnag'
|
||||
import NotFound from './404'
|
||||
import Bugsnag from '@hashicorp/nextjs-scripts/lib/bugsnag'
|
||||
|
||||
export default class Page extends React.Component {
|
||||
static async getInitialProps(ctx) {
|
||||
if (ctx.err) bugsnagClient.notify(ctx.err)
|
||||
return ErrorPage.getInitialProps(ctx)
|
||||
}
|
||||
render() {
|
||||
return <ErrorPage statusCode={this.props.statusCode || '¯\\_(ツ)_/¯'} />
|
||||
}
|
||||
function Error({ statusCode }) {
|
||||
return <NotFound statusCode={statusCode} />
|
||||
}
|
||||
|
||||
Error.getInitialProps = ({ res, err }) => {
|
||||
if (err) Bugsnag.notify(err)
|
||||
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
|
||||
return { statusCode }
|
||||
}
|
||||
|
||||
export default Error
|
||||
|
|
|
@ -256,7 +256,7 @@ below.
|
|||
|
||||
autogenerated_password_https_boostrap.txt
|
||||
|
||||
``` ps1
|
||||
```powershell
|
||||
<powershell>
|
||||
|
||||
# MAKE SURE IN YOUR PACKER CONFIG TO SET:
|
||||
|
@ -308,15 +308,15 @@ cmd.exe /c net start winrm
|
|||
|
||||
You'll notice that this config does not define a user or password; instead,
|
||||
Packer will ask AWS to provide a random password that it generates
|
||||
automatically. The following config will work with the above template:
|
||||
automatically. The following config will work with the above template:
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"region": "us-east-1",
|
||||
"instance_type": "t2.micro",
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"region": "us-east-1",
|
||||
"instance_type": "t2.micro",
|
||||
"source_ami_filter": {
|
||||
"filters": {
|
||||
"virtualization-type": "hvm",
|
||||
|
@ -326,18 +326,18 @@ automatically. The following config will work with the above template:
|
|||
"most_recent": true,
|
||||
"owners": "amazon"
|
||||
},
|
||||
"ami_name": "default-packer",
|
||||
"user_data_file": "winrm_bootstrap.txt",
|
||||
"communicator": "winrm",
|
||||
"force_deregister": true,
|
||||
"winrm_insecure": true,
|
||||
"winrm_username": "Administrator",
|
||||
"winrm_use_ssl": true
|
||||
}]
|
||||
"ami_name": "default-packer",
|
||||
"user_data_file": "winrm_bootstrap.txt",
|
||||
"communicator": "winrm",
|
||||
"force_deregister": true,
|
||||
"winrm_insecure": true,
|
||||
"winrm_username": "Administrator",
|
||||
"winrm_use_ssl": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Windows 2016 Sysprep Commands - For Amazon Windows AMIs Only
|
||||
|
||||
For Amazon Windows 2016 AMIs it is necessary to run Sysprep commands which can
|
||||
|
|
|
@ -202,8 +202,8 @@ multiple lines for convenience of reading. The bundle volume command is
|
|||
responsible for executing `ec2-bundle-vol` in order to store and image of the
|
||||
root filesystem to use to create the AMI.
|
||||
|
||||
```text
|
||||
sudo -i -n ec2-bundle-vol \
|
||||
```shell-session
|
||||
$ sudo -i -n ec2-bundle-vol \
|
||||
-k {{.KeyPath}} \
|
||||
-u {{.AccountId}} \
|
||||
-c {{.CertPath}} \
|
||||
|
@ -230,8 +230,8 @@ across multiple lines for convenience of reading. Access key and secret key are
|
|||
omitted if using instance profile. The bundle upload command is responsible for
|
||||
taking the bundled volume and uploading it to S3.
|
||||
|
||||
```text
|
||||
sudo -i -n ec2-upload-bundle \
|
||||
```shell-session
|
||||
$ sudo -i -n ec2-upload-bundle \
|
||||
-b {{.BucketName}} \
|
||||
-m {{.ManifestPath}} \
|
||||
-a {{.AccessKey}} \
|
||||
|
|
|
@ -73,18 +73,24 @@ information.
|
|||
@include 'builder/azure/chroot/Config-not-required.mdx'
|
||||
|
||||
#### Output options:
|
||||
|
||||
At least one of these options needs to be specified:
|
||||
- `image_resource_id` (string) - The managed image to create using this build.
|
||||
|
||||
- `shared_image_destination` (object) - The shared image to create using this build.
|
||||
|
||||
- `image_resource_id` (string) - The managed image to create using this build.
|
||||
|
||||
- `shared_image_destination` (object) - The shared image to create using this build.
|
||||
|
||||
Where `shared_image_destination` is an object with the following properties:
|
||||
@include 'builder/azure/chroot/_SharedImageGalleryDestination-required.mdx
|
||||
@include 'builder/azure/chroot/_SharedImageGalleryDestination-not-required.mdx
|
||||
|
||||
@include 'builder/azure/chroot/SharedImageGalleryDestination-required.mdx'
|
||||
|
||||
@include 'builder/azure/chroot/SharedImageGalleryDestination-not-required.mdx'
|
||||
|
||||
And `target_regions` is an array of objects with the following properties:
|
||||
@include 'builder/azure/chroot/_TargetRegion-required.mdx
|
||||
@include 'builder/azure/chroot/_TargetRegion-not-required.mdx
|
||||
|
||||
@include 'builder/azure/chroot/TargetRegion-required.mdx'
|
||||
|
||||
@include 'builder/azure/chroot/TargetRegion-not-required.mdx'
|
||||
|
||||
## Chroot Mounts
|
||||
|
||||
|
@ -148,8 +154,8 @@ This builder requires privileged actions, such as mounting disks, running
|
|||
`chroot` and other admin commands. Usually it needs to be run with root
|
||||
permissions, for example:
|
||||
|
||||
```shell
|
||||
sudo -E packer build example.json
|
||||
```shell-session
|
||||
$ sudo -E packer build example.json
|
||||
```
|
||||
|
||||
### Using a VM with a Managed Identity
|
||||
|
|
|
@ -190,7 +190,7 @@ handles pushing the image to a container repository.
|
|||
If you want to do this manually, however, perhaps from a script, you can import
|
||||
the image using the process below:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ docker import - registry.mydomain.com/mycontainer:latest < artifact.tar
|
||||
```
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ scopes when launching the instance.
|
|||
|
||||
For `gcloud`, do this via the `--scopes` parameter:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ gcloud compute instances create INSTANCE-NAME \
|
||||
--project YOUR_GCP_PROJECT \
|
||||
--image-family ubuntu-1804-lts \
|
||||
|
|
|
@ -56,8 +56,8 @@ machine, HyperOne builder can use your credentials saved in a config file.
|
|||
|
||||
All you have to do is login within the tool:
|
||||
|
||||
```bash
|
||||
h1 login --username your.user@example.com
|
||||
```shell-session
|
||||
$ h1 login --username your.user@example.com
|
||||
```
|
||||
|
||||
You don't have to set `token` or `project` fields at all using this method.
|
||||
|
@ -66,8 +66,8 @@ You don't have to set `token` or `project` fields at all using this method.
|
|||
|
||||
Using `h1`, you can create a new token associated with chosen project.
|
||||
|
||||
```bash
|
||||
h1 project token add --name packer-builder --project PROJECT_ID
|
||||
```shell-session
|
||||
$ h1 project token add --name packer-builder --project PROJECT_ID
|
||||
```
|
||||
|
||||
Set the `token` field to the generated token or save it in the `HYPERONE_TOKEN`
|
||||
|
@ -279,4 +279,4 @@ build {
|
|||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
|
|
@ -215,7 +215,7 @@ substituted with the letter `a` and OCIDS have been shortened for brevity.
|
|||
}
|
||||
```
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
[opc@packerhost ~]$ packer build packer.json
|
||||
oracle-oci: output will be in this color.
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ image).
|
|||
When exporting from VirtualBox make sure to choose OVF Version 2, since Version
|
||||
1 is not compatible and will generate errors like this:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
==> virtualbox-ovf: Progress state: VBOX_E_FILE_ERROR
|
||||
==> virtualbox-ovf: VBoxManage: error: Appliance read failed
|
||||
==> virtualbox-ovf: VBoxManage: error: Error reading "source.ova": element "Section" has no "type" attribute, line 21
|
||||
|
|
|
@ -20,7 +20,7 @@ Type in the interpolation to test and hit \<enter\> to see the result.
|
|||
|
||||
To exit the console, type "exit" and hit \<enter\>, or use Control-C.
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ packer console my_template.json
|
||||
```
|
||||
|
||||
|
@ -49,7 +49,7 @@ help output, which can be seen via `packer console -h`.
|
|||
|
||||
Let's say you launch a console using a Packer template `example_template.json`:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ packer console example_template.json
|
||||
```
|
||||
|
||||
|
@ -67,29 +67,29 @@ your example_template's variable section:
|
|||
and you enter `` {{user `myvar`}} `` in the Packer console, you'll see the value of
|
||||
myvar:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> {{user `myvar`}}
|
||||
> asdfasdf
|
||||
```
|
||||
|
||||
From there you can test more complicated interpolations:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> {{user `myvar`}}-{{timestamp}}
|
||||
> asdfasdf-1559854396
|
||||
```
|
||||
|
||||
And when you're done using the console, just type "exit" or CTRL-C
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> exit
|
||||
$
|
||||
```
|
||||
|
||||
If you'd like to provide a variable or variable files, you'd do this:
|
||||
|
||||
```shell
|
||||
packer console -var "myvar=fdsafdsa" -var-file myvars.json example_template.json
|
||||
```shell-session
|
||||
$ packer console -var "myvar=fdsafdsa" -var-file myvars.json example_template.json
|
||||
```
|
||||
|
||||
If you don't have specific variables or var files you want to test, and just
|
||||
|
@ -100,7 +100,7 @@ If you'd like to just see a specific single interpolation without launching
|
|||
the REPL, you can do so by echoing and piping the string into the console
|
||||
command:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ echo {{timestamp}} | packer console
|
||||
1559855090
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@ The fix command will output the changed template to standard out, so you should
|
|||
redirect standard using standard OS-specific techniques if you want to save it
|
||||
to a file. For example, on Linux systems, you may want to do this:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ packer fix old.json > new.json
|
||||
```
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ The machine-readable output format can be enabled by passing the
|
|||
output to become machine-readable on stdout. Logging, if enabled, continues to
|
||||
appear on stderr. An example of the output is shown below:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
$ packer -machine-readable version
|
||||
1498365963,,version,1.0.2
|
||||
1498365963,,version-prelease,
|
||||
|
@ -127,7 +127,7 @@ You'll see these data types when you run `packer build`:
|
|||
|
||||
For example:
|
||||
|
||||
```shell
|
||||
```text
|
||||
1539967803,,ui,say,\n==> Builds finished. The artifacts of successful builds are:
|
||||
1539967803,amazon-ebs,artifact-count,2
|
||||
1539967803,amazon-ebs,artifact,0,builder-id,mitchellh.amazonebs
|
||||
|
@ -162,7 +162,7 @@ can invoke a new shell and use the feature.
|
|||
|
||||
For example, assume a tab is typed at the end of each prompt line:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ packer p
|
||||
plugin build
|
||||
$ packer build -
|
||||
|
|
|
@ -35,7 +35,7 @@ of your template by necessity.
|
|||
|
||||
Given a basic template, here is an example of what the output might look like:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
$ packer inspect template.json
|
||||
Variables and their defaults:
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ outputted.
|
|||
|
||||
Example usage:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
$ packer validate my-template.json
|
||||
Template validation failed. Errors are shown below.
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ chunklist(list, chunk_size)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> chunklist(["a", "b", "c", "d", "e"], 2)
|
||||
[
|
||||
["a", "b"],
|
||||
|
|
|
@ -14,7 +14,7 @@ that isn't null or an empty string.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> coalesce("a", "b")
|
||||
a
|
||||
> coalesce("", "b")
|
||||
|
@ -26,7 +26,7 @@ b
|
|||
To perform the `coalesce` operation with a list of strings, use the `...`
|
||||
symbol to expand the list as arguments:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> coalesce(["", "b"]...)
|
||||
b
|
||||
```
|
||||
|
|
|
@ -14,7 +14,7 @@ that isn't empty.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> coalescelist(["a", "b"], ["c", "d"])
|
||||
[
|
||||
"a",
|
||||
|
@ -30,7 +30,7 @@ that isn't empty.
|
|||
To perform the `coalescelist` operation with a list of lists, use the `...`
|
||||
symbol to expand the outer list as arguments:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> coalescelist([[], ["c", "d"]]...)
|
||||
[
|
||||
"c",
|
||||
|
|
|
@ -12,7 +12,7 @@ elements removed.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> compact(["a", "", "b", "c"])
|
||||
[
|
||||
"a",
|
||||
|
|
|
@ -11,7 +11,7 @@ description: The concat function combines two or more lists into a single list.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> concat(["a", ""], ["b", "c"])
|
||||
[
|
||||
"a",
|
||||
|
|
|
@ -16,7 +16,7 @@ contains(list, value)
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> contains(["a", "b", "c"], "a")
|
||||
true
|
||||
> contains(["a", "b", "c"], "d")
|
||||
|
|
|
@ -15,7 +15,7 @@ these elements is preserved.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> distinct(["a", "b", "a", "c", "d", "b"])
|
||||
[
|
||||
"a",
|
||||
|
|
|
@ -21,7 +21,7 @@ only for the special additional "wrap-around" behavior described below.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> element(["a", "b", "c"], 1)
|
||||
b
|
||||
```
|
||||
|
@ -29,7 +29,7 @@ b
|
|||
If the given index is greater than the length of the list then the index is
|
||||
"wrapped around" by taking the index modulo the length of the list:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> element(["a", "b", "c"], 3)
|
||||
a
|
||||
```
|
||||
|
|
|
@ -12,7 +12,7 @@ flattened sequence of the list contents.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> flatten([["a", "b"], [], ["c"]])
|
||||
["a", "b", "c"]
|
||||
```
|
||||
|
@ -20,7 +20,7 @@ flattened sequence of the list contents.
|
|||
If any of the nested lists also contain directly-nested lists, these too are
|
||||
flattened recursively:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> flatten([[["a", "b"], []], ["c"]])
|
||||
["a", "b", "c"]
|
||||
```
|
||||
|
|
|
@ -18,7 +18,7 @@ value is not present in the list.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> index(["a", "b", "c"], "b")
|
||||
1
|
||||
```
|
||||
|
|
|
@ -14,7 +14,7 @@ be identical as long as the keys in the map don't change.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> keys({a=1, c=2, d=3})
|
||||
[
|
||||
"a",
|
||||
|
|
|
@ -14,7 +14,7 @@ If given a string, the result is the number of characters in the string.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> length([])
|
||||
0
|
||||
> length(["a", "b"])
|
||||
|
@ -28,7 +28,7 @@ If given a string, the result is the number of characters in the string.
|
|||
When given a string, the result is the number of characters, rather than the
|
||||
number of bytes or Unicode sequences that form them:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> length("👾🕹️")
|
||||
2
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@ equivalent to the native index syntax, `map[key]`.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> lookup({a="ay", b="bee"}, "a", "what?")
|
||||
ay
|
||||
> lookup({a="ay", b="bee"}, "c", "what?")
|
||||
|
|
|
@ -17,7 +17,7 @@ in the argument sequence takes precedence.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> merge({"a"="b", "c"="d"}, {"e"="f", "c"="z"})
|
||||
{
|
||||
"a" = "b"
|
||||
|
|
|
@ -51,7 +51,7 @@ functions or `for` expressions.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> range(3)
|
||||
[
|
||||
0,
|
||||
|
|
|
@ -12,7 +12,7 @@ with all of the same elements as the given sequence but in reverse order.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> reverse([1, 2, 3])
|
||||
[
|
||||
3,
|
||||
|
|
|
@ -20,7 +20,7 @@ setintersection(sets...)
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> setintersection(["a", "b"], ["b", "c"], ["b", "d"])
|
||||
[
|
||||
"b",
|
||||
|
|
|
@ -21,7 +21,7 @@ This function is particularly useful for finding the exhaustive set of all
|
|||
combinations of members of multiple sets, such as per-application-per-environment
|
||||
resources.
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> setproduct(["development", "staging", "production"], ["app1", "app2"])
|
||||
[
|
||||
[
|
||||
|
@ -68,7 +68,7 @@ reusable folder situations.
|
|||
If any of the arguments is empty then the result is always empty itself,
|
||||
similar to how multiplying any number by zero gives zero:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> setproduct(["development", "staging", "production"], [])
|
||||
[]
|
||||
```
|
||||
|
@ -76,7 +76,7 @@ similar to how multiplying any number by zero gives zero:
|
|||
Similarly, if all of the arguments have only one element then the result has
|
||||
only one element, which is the first element of each argument:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> setproduct(["a"], ["b"])
|
||||
[
|
||||
[
|
||||
|
@ -92,7 +92,7 @@ error if such a conversion is impossible. For example, mixing both strings and
|
|||
numbers results in the numbers being converted to strings so that the result
|
||||
elements all have a consistent type:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> setproduct(["staging", "production"], ["a", 2])
|
||||
[
|
||||
[
|
||||
|
|
|
@ -20,7 +20,7 @@ setunion(sets...)
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> setunion(["a", "b"], ["b", "c"], ["d"])
|
||||
[
|
||||
"d",
|
||||
|
|
|
@ -19,7 +19,7 @@ list.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> slice(["a", "b", "c", "d"], 1, 3)
|
||||
[
|
||||
"b",
|
||||
|
|
|
@ -17,7 +17,7 @@ after lower ones in the result.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> sort(["e", "d", "a", "x"])
|
||||
[
|
||||
"a",
|
||||
|
|
|
@ -16,7 +16,7 @@ returned from [`keys`](/docs/from-1.5/functions/collection/keys).
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> values({a=3, c=2, d=1})
|
||||
[
|
||||
3,
|
||||
|
|
|
@ -26,7 +26,7 @@ is used in the resulting map.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> zipmap(["a", "b"], [1, 2])
|
||||
{
|
||||
"a" = 1,
|
||||
|
|
|
@ -30,7 +30,7 @@ prefer to use [`try`](/docs/from-1.5/functions/conversion/try).
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> local.foo
|
||||
{
|
||||
"bar" = "baz"
|
||||
|
@ -45,7 +45,7 @@ The `can` function will _not_ catch errors relating to constructs that are
|
|||
provably invalid even before dynamic expression evaluation, such as a malformed
|
||||
reference or a reference to a top-level object that has not been declared:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> can(local.nonexist)
|
||||
|
||||
Error: Reference to undeclared local value
|
||||
|
|
|
@ -26,7 +26,7 @@ All other values will produce an error.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> convert(3, string)
|
||||
"3"
|
||||
> convert("3", number)
|
||||
|
|
|
@ -84,7 +84,7 @@ to understand and maintain.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> local.foo
|
||||
{
|
||||
"bar" = "baz"
|
||||
|
@ -99,7 +99,7 @@ The `try` function will _not_ catch errors relating to constructs that are
|
|||
provably invalid even before dynamic expression evaluation, such as a malformed
|
||||
reference or a reference to a top-level object that has not been declared:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> try(local.nonexist, "fallback")
|
||||
|
||||
Error: Reference to undeclared local value
|
||||
|
|
|
@ -32,7 +32,7 @@ versions of Packer.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> bcrypt("hello world")
|
||||
$2a$10$D5grTTzcsqyvAeIAnY/mYOIqliCoG7eAMX0/oFcuD.iErkksEbcAa
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ considerations applying to the MD5 algorithm.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> md5("hello world")
|
||||
5eb63bbbe01eeed093cb22bb8f5acdc3
|
||||
```
|
||||
|
|
|
@ -27,7 +27,7 @@ negotiated out-of-band.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> rsadecrypt(base64(file("${path.folder}/ciphertext")), file("privatekey.pem"))
|
||||
Hello, world!
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ relevant literature to understand the security implications.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> sha1("hello world")
|
||||
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
|
||||
```
|
||||
|
|
|
@ -18,7 +18,7 @@ then encoded to lowercase hexadecimal digits before returning.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> sha256("hello world")
|
||||
b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
|
||||
```
|
||||
|
|
|
@ -18,7 +18,7 @@ then encoded to lowercase hexadecimal digits before returning.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> sha512("hello world")
|
||||
309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@ this syntax.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> formatdate("DD MMM YYYY hh:mm ZZZ", "2018-01-02T23:12:01Z")
|
||||
02 Jan 2018 23:12 UTC
|
||||
> formatdate("EEEE, DD-MMM-YY hh:mm:ss ZZZ", "2018-01-02T23:12:01Z")
|
||||
|
@ -75,7 +75,7 @@ Any non-letter characters, such as punctuation, are reproduced verbatim in the
|
|||
output. To include literal letters in the format string, enclose them in single
|
||||
quotes `'`. To include a literal quote, escape it by doubling the quotes.
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> formatdate("h'h'mm", "2018-01-02T23:12:01-08:00")
|
||||
23h12
|
||||
> formatdate("H 'o''clock'", "2018-01-02T23:12:01-08:00")
|
||||
|
|
|
@ -36,7 +36,7 @@ to format a date.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> timeadd("2017-11-22T00:00:00Z", "10m")
|
||||
2017-11-22T00:10:00Z
|
||||
```
|
||||
|
|
|
@ -28,7 +28,7 @@ to format a date.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> timestamp()
|
||||
2018-05-13T07:44:12Z
|
||||
```
|
||||
|
|
|
@ -27,7 +27,7 @@ or manipulate Base64 data directly.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> base64decode("SGVsbG8gV29ybGQ=")
|
||||
Hello World
|
||||
```
|
||||
|
|
|
@ -28,7 +28,7 @@ data to be easily provided to resource types that expect Base64 bytes.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> base64encode("Hello World")
|
||||
SGVsbG8gV29ybGQ=
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ number of fields, or this function will produce an error.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> csvdecode("a,b,c\n1,2,3\n4,5,6")
|
||||
[
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ and can just use the result in an intuitive way.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> jsondecode("{\"hello\": \"world\"}")
|
||||
{
|
||||
"hello" = "world"
|
||||
|
|
|
@ -34,7 +34,7 @@ rarely a problem in practice.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> jsonencode({"hello"="world"})
|
||||
{"hello":"world"}
|
||||
```
|
||||
|
|
|
@ -23,7 +23,7 @@ UTF-8 and then percent encoding is applied separately to each UTF-8 byte.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> urlencode("Hello World")
|
||||
Hello%20World
|
||||
> urlencode("☃")
|
||||
|
|
|
@ -56,7 +56,7 @@ supports only a subset of YAML 1.2, with restrictions including the following:
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> yamldecode("{\"hello\": \"world\"}")
|
||||
{
|
||||
"hello" = "world"
|
||||
|
|
|
@ -53,7 +53,7 @@ mean that this is rarely a problem in practice.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> yamlencode({"a":"b", "c":"d"})
|
||||
"a": "b"
|
||||
"c": "d"
|
||||
|
|
|
@ -19,7 +19,7 @@ only the contents are then stored) or in `connection` and `provisioner` blocks.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> abspath(path.root)
|
||||
/home/user/some/packer/root
|
||||
```
|
||||
|
|
|
@ -31,7 +31,7 @@ only the contents are then stored) or in `connection` and `provisioner` blocks.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> basename("foo/bar/baz.txt")
|
||||
baz.txt
|
||||
```
|
||||
|
|
|
@ -30,7 +30,7 @@ only the contents are then stored) or in `connection` and `provisioner` blocks.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> dirname("foo/bar/baz.txt")
|
||||
foo/bar
|
||||
```
|
||||
|
|
|
@ -32,7 +32,7 @@ to read files while respecting resource dependencies.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> file("${path.folder}/hello.txt")
|
||||
Hello World
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ or other special mode, it will return an error.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> fileexists("${path.folder}/hello.txt")
|
||||
true
|
||||
```
|
||||
|
|
|
@ -36,7 +36,7 @@ before Packer takes any actions.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> fileset(path.folder, "files/*.txt")
|
||||
[
|
||||
"files/hello.txt",
|
||||
|
|
|
@ -48,7 +48,7 @@ releases of Packer.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> pathexpand("~/.ssh/id_rsa")
|
||||
/home/steve/.ssh/id_rsa
|
||||
> pathexpand("/etc/resolv.conf")
|
||||
|
|
|
@ -36,7 +36,7 @@ the same addressing scheme as the given prefix.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> cidrhost("10.12.127.0/20", 16)
|
||||
10.12.112.16
|
||||
> cidrhost("10.12.127.0/20", 268)
|
||||
|
|
|
@ -27,7 +27,7 @@ produces an error if given an IPv6 address.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> cidrnetmask("172.16.0.0/12")
|
||||
255.240.0.0
|
||||
```
|
||||
|
|
|
@ -36,7 +36,7 @@ with zero.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> cidrsubnet("172.16.0.0/12", 4, 2)
|
||||
172.18.0.0/16
|
||||
> cidrsubnet("10.1.2.0/24", 4, 15)
|
||||
|
@ -73,7 +73,7 @@ The CLI tool [`ipcalc`](https://gitlab.com/ipcalc/ipcalc) is useful for
|
|||
visualizing CIDR prefixes as binary numbers. We can confirm the conversion
|
||||
above by providing the same prefix string to `ipcalc`:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ ipcalc 10.1.2.0/24
|
||||
Address: 10.1.2.0 00001010.00000001.00000010. 00000000
|
||||
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
|
||||
|
@ -129,7 +129,7 @@ gives 240, which can then be combined with our new prefix length of 28 to
|
|||
produce the result `10.1.2.240/28`. Again we can pass this prefix string to
|
||||
`ipcalc` to visualize it:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
$ ipcalc 10.1.2.240/28
|
||||
Address: 10.1.2.240 00001010.00000001.00000010.1111 0000
|
||||
Netmask: 255.255.255.240 = 28 11111111.11111111.11111111.1111 0000
|
||||
|
@ -148,7 +148,7 @@ the network's own address and the broadcast address. You can thus use
|
|||
[`cidrhost`](/docs/from-1.5/functions/ipnet/cidrhost) function to calculate those host addresses by
|
||||
providing it a value between 1 and 14:
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> cidrhost("10.1.2.240/28", 1)
|
||||
10.1.2.241
|
||||
> cidrhost("10.1.2.240/28", 14)
|
||||
|
|
|
@ -40,7 +40,7 @@ the same addressing scheme as the given prefix.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> cidrsubnets("10.1.0.0/16", 4, 4, 8, 4)
|
||||
[
|
||||
"10.1.0.0/20",
|
||||
|
@ -62,7 +62,7 @@ You can use nested `cidrsubnets` calls with
|
|||
[`for` expressions](/docs/from-1.5/expressions#for-expressions)
|
||||
to concisely allocate groups of network address blocks:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> [for cidr_block in cidrsubnets("10.0.0.0/8", 8, 8, 8, 8) : cidrsubnets(cidr_block, 4, 4)]
|
||||
[
|
||||
[
|
||||
|
|
|
@ -13,7 +13,7 @@ then it is multiplied by -1 to make it positive before returning it.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> abs(23)
|
||||
23
|
||||
> abs(0)
|
||||
|
|
|
@ -14,7 +14,7 @@ given value, which may be a fraction.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> ceil(5)
|
||||
5
|
||||
> ceil(5.1)
|
||||
|
|
|
@ -14,7 +14,7 @@ given value, which may be a fraction.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> floor(5)
|
||||
5
|
||||
> floor(4.9)
|
||||
|
|
|
@ -15,7 +15,7 @@ log(number, base)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> log(50, 10)
|
||||
1.6989700043360185
|
||||
> log(16, 2)
|
||||
|
@ -25,7 +25,7 @@ log(number, base)
|
|||
`log` and `ceil` can be used together to find the minimum number of binary
|
||||
digits required to represent a given number of distinct values:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> ceil(log(15, 2))
|
||||
4
|
||||
> ceil(log(16, 2))
|
||||
|
|
|
@ -11,7 +11,7 @@ description: The max function takes one or more numbers and returns the greatest
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> max(12, 54, 3)
|
||||
54
|
||||
```
|
||||
|
@ -19,7 +19,7 @@ description: The max function takes one or more numbers and returns the greatest
|
|||
If the numbers are in a list or set value, use `...` to expand the collection
|
||||
to individual arguments:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> max([12, 54, 3]...)
|
||||
54
|
||||
```
|
||||
|
|
|
@ -11,7 +11,7 @@ description: The min function takes one or more numbers and returns the smallest
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> min(12, 54, 3)
|
||||
3
|
||||
```
|
||||
|
@ -19,7 +19,7 @@ description: The min function takes one or more numbers and returns the smallest
|
|||
If the numbers are in a list or set value, use `...` to expand the collection
|
||||
to individual arguments:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> min([12, 54, 3]...)
|
||||
3
|
||||
```
|
||||
|
|
|
@ -23,7 +23,7 @@ are too large for the given base then `parseint` will produce an error.
|
|||
|
||||
## Examples
|
||||
|
||||
```shell
|
||||
```shell-session
|
||||
> parseint("100", 10)
|
||||
100
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ description: The pow function raises a number to a power.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> pow(3, 2)
|
||||
9
|
||||
> pow(4, 0)
|
||||
|
|
|
@ -12,7 +12,7 @@ description: The signum function determines the sign of a number.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> signum(-13)
|
||||
-1
|
||||
> signum(0)
|
||||
|
|
|
@ -14,7 +14,7 @@ a newline character at the end.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> chomp("hello\n")
|
||||
hello
|
||||
> chomp("hello\r\n")
|
||||
|
|
|
@ -19,7 +19,7 @@ format(spec, values...)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> format("Hello, %s!", "Ander")
|
||||
Hello, Ander!
|
||||
> format("There are %d lights", 4)
|
||||
|
@ -29,7 +29,7 @@ There are 4 lights
|
|||
Simple format verbs like `%s` and `%d` behave similarly to template
|
||||
interpolation syntax, which is often more readable:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> format("Hello, %s!", var.name)
|
||||
Hello, Valentina!
|
||||
> "Hello, ${var.name}!"
|
||||
|
|
|
@ -28,7 +28,7 @@ once per element of the list arguments.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> formatlist("Hello, %s!", ["Valentina", "Ander", "Olivia", "Sam"])
|
||||
[
|
||||
"Hello, Valentina!",
|
||||
|
|
|
@ -21,7 +21,7 @@ indent(num_spaces, string)
|
|||
This function is useful for inserting a multi-line string into an
|
||||
already-indented context in another string:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> " items: %{indent(2, "[\n foo,\n bar,\n]\n")}"
|
||||
items: [
|
||||
foo,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue