shell snippet fixes, nextjs-scripts upgrades
This commit is contained in:
parent
87f38e84ef
commit
66c34f5110
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
...require('@hashicorp/nextjs-scripts/.stylelintrc.js'),
|
||||
/* Specify overrides here */
|
||||
}
|
|
@ -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,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: () => [
|
||||
{
|
||||
|
@ -19,5 +18,8 @@ module.exports = withHashicorp({
|
|||
exportTrailingSlash: true,
|
||||
env: {
|
||||
HASHI_ENV: process.env.HASHI_ENV,
|
||||
SEGMENT_WRITE_KEY: 'AjXdfmTTk1I9q9dfyePuDFHBrz1tCO3l',
|
||||
BUGSNAG_CLIENT_KEY: 'de0b822b269aa57b620efd8927e03744',
|
||||
BUGSNAG_SERVER_KEY: 'b6c57b27a37e531a5de94f065dd98bc0',
|
||||
},
|
||||
})
|
||||
|
|
|
@ -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,20 @@ 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 +150,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,
|
||||
|
|
|
@ -18,7 +18,7 @@ join(separator, list)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> join(", ", ["foo", "bar", "baz"])
|
||||
foo, bar, baz
|
||||
> join(", ", ["foo"])
|
||||
|
|
|
@ -13,7 +13,7 @@ description: >-
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> lower("HELLO")
|
||||
hello
|
||||
> lower("АЛЛО!")
|
||||
|
|
|
@ -25,7 +25,7 @@ name of a capture group.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> regexreplace("hello world", "world", "everybody")
|
||||
hello everybody
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ replace(string, substring, replacement)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> replace("1 + 2 + 3", "+", "-")
|
||||
1 - 2 - 3
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ split(separator, string)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> split(",", "foo,bar,baz")
|
||||
[
|
||||
"foo",
|
||||
|
|
|
@ -16,7 +16,7 @@ strrev(string)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> strrev("hello")
|
||||
olleh
|
||||
> strrev("a ☃")
|
||||
|
|
|
@ -17,7 +17,7 @@ substr(string, offset, length)
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> substr("hello world", 1, 4)
|
||||
ello
|
||||
```
|
||||
|
@ -25,7 +25,7 @@ ello
|
|||
The offset and length are both counted in _unicode characters_ rather than
|
||||
bytes:
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> substr("🤔🤷", 0, 1)
|
||||
🤔
|
||||
```
|
||||
|
|
|
@ -13,7 +13,7 @@ description: |-
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> title("hello world")
|
||||
Hello World
|
||||
```
|
||||
|
|
|
@ -14,7 +14,7 @@ string.
|
|||
|
||||
## Examples
|
||||
|
||||
```text
|
||||
```shell-session
|
||||
> trim("?!hello?!", "!?")
|
||||
hello
|
||||
```
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue