Merge pull request #10388 from hashicorp/sdk_docs

Sdk docs
This commit is contained in:
Megan Marsh 2020-12-16 15:30:47 -08:00 committed by GitHub
commit dd9a8b2669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
167 changed files with 297 additions and 106 deletions

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,AlicloudDiskDevice"; DO NOT EDIT.
package ecs
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,BlockDevices,BlockDevice"; DO NOT EDIT.
package chroot
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type VaultAWSEngineOptions,AssumeRoleConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type BlockDevice"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type AmiFilterOptions,SecurityGroupFilterOptions,SubnetFilterOptions,VpcFilterOptions,PolicyDocument,Statement"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type AWSPollingConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package ebs
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,RootBlockDevice,BlockDevice"; DO NOT EDIT.
package ebssurrogate
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,BlockDevice"; DO NOT EDIT.
package ebsvolume
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package instance
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,PlanInformation"; DO NOT EDIT.
package arm
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package chroot
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type SharedImageGalleryDestination,TargetRegion"; DO NOT EDIT.
package chroot
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,DtlArtifact,ArtifactParameter"; DO NOT EDIT.
package dtl
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package cloudstack
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package digitalocean
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package docker
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package file
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,CustomerEncryptionKey"; DO NOT EDIT.
package googlecompute
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type IAPConfig"; DO NOT EDIT.
package googlecompute
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,imageFilter"; DO NOT EDIT.
package hcloud
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package hyperone
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type OutputConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package iso
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package vmcx
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package jdcloud
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package linode
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package lxc
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package lxd
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package ncloud
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package null
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package oneandone
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,ImageFilter,ImageFilterOptions"; DO NOT EDIT.
package openstack
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package classic
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest"; DO NOT EDIT.
package oci
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package bsu
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,RootBlockDevice"; DO NOT EDIT.
package bsusurrogate
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,BlockDevice"; DO NOT EDIT.
package bsuvolume
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package chroot
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type SecurityGroupFilterOptions,OmiFilterOptions,SubnetFilterOptions,NetFilterOptions,BlockDevice"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package iso
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package pvm
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package profitbricks
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package proxmoxclone
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig,storageConfig"; DO NOT EDIT.
package proxmox
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig"; DO NOT EDIT.
package proxmoxiso
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,QemuImgArgs"; DO NOT EDIT.
package qemu
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package scaleway
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package cvm
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type tencentCloudDataDisk"; DO NOT EDIT.
package cvm
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package triton
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type MachineImageFilter"; DO NOT EDIT.
package triton
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type ImageDestination"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package uhost
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package vagrant
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package iso
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package ovf
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package vm
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package iso
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package vmx
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package clone
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type CloneConfig,vAppConfig"; DO NOT EDIT.
package clone
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type CustomizeConfig,LinuxOptions,NetworkInterfaces,NetworkInterface,GlobalDnsSettings,GlobalRoutingSettings"; DO NOT EDIT.
package clone
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type LocationConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type OutputConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type CDRomConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type FloppyConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type ConfigParamsConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type ConnectConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type ExportConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type HardwareConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type ContentLibraryDestinationConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type RemoveCDRomConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type RunConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type ShutdownConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type WaitIpConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type StorageConfig,DiskConfig"; DO NOT EDIT.
package common
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package iso
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type NIC,CreateConfig"; DO NOT EDIT.
package iso
import (

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
package yandex
import (

View File

@ -141,7 +141,7 @@ func main() {
out := bytes.NewBuffer(nil)
fmt.Fprintf(out, `// Code generated by "%s %s"; DO NOT EDIT.`, mapstructureToHCL2, strings.Join(os.Args[1:], " "))
fmt.Fprintf(out, "\npackage %s\n", topPkg.Name)
fmt.Fprintf(out, "\n\npackage %s\n", topPkg.Name)
delete(usedImports, NamePath{topPkg.Name, topPkg.PkgPath})
usedImports[NamePath{"hcldec", "github.com/hashicorp/hcl/v2/hcldec"}] = types.NewPackage("hcldec", "github.com/hashicorp/hcl/v2/hcldec")

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag"; DO NOT EDIT.
package hcl2template
import (

View File

@ -1,6 +1,6 @@
/*
The acctest package provides an acceptance testing framework for testing
builders and provisioners.
Package acctest provides an acceptance testing framework for testing builders
and provisioners.
Writing Provisioner Acceptance Tests
@ -240,5 +240,4 @@ Once you finish these steps, you should be ready to run your new provisioner
acceptance test by setting the name used in the BuildersAccTest map as your
`ACC_TEST_BUILDERS` environment variable.
*/
package acctest

View File

@ -1,9 +1,8 @@
/*
The provisioneracc package creates a framework for provisioner acceptance
Package provisioneracc creates a framework for provisioner acceptance
testing. For builder acceptance testing, use the top level tooling in the
acctest package.
*/
package provisioneracc
import (

View File

@ -1,3 +1,5 @@
// Package testutils provides some simple ease-of-use tools for implementing
// acceptance testing.
package testutils
import "os"

View File

@ -10,5 +10,4 @@ You may want to use this adapter if you are writing a provisioner that wraps a
tool which under normal usage would be run locally and form a connection to the
remote instance itself.
*/
package adapter

View File

@ -1,13 +1,10 @@
/*
Package bootcommand generates and sends boot commands to the remote instance.
This package is relevant to people who want to create new builders, particularly
builders with the capacity to build a VM from an iso.
You can choose between three different drivers to send the command: a vnc
driver, a usb driver, and a PX-XT keyboard driver. The driver you choose will
depend on what kind of keyboard codes your hypervisor expects, and how you want
to implement the connection.
*/
// Package bootcommand generates and sends boot commands to the remote instance.
//
// This package is relevant to people who want to create new builders, particularly
// builders with the capacity to build a VM from an iso.
//
// You can choose between three different drivers to send the command: a vnc
// driver, a usb driver, and a PX-XT keyboard driver. The driver you choose will
// depend on what kind of keyboard codes your hypervisor expects, and how you want
// to implement the connection.
package bootcommand

View File

@ -1,3 +1,3 @@
package bootcommand
//go:generate pigeon -o boot_command.go boot_command.pigeon
package bootcommand

View File

@ -21,5 +21,4 @@ The HashiCorp-maintained Amazon and Azure builder plugins have chroot builders
which use this option and can serve as an example for how the chroot steps and
communicator are used.
*/
package chroot

View File

@ -1,3 +1,8 @@
// Package common provides the PackerConfig structure that gets passed to every
// plugin and contains information populated by the Packer core. This config
// contains data about command line flags that were used, as well as template
// information and information about the Packer core's version. It also
// proivdes string constants to use to access that config.
package common
import (

View File

@ -7,7 +7,10 @@ import (
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
)
// Generic commHost function that should work for most cloud builders.
// CommHost determines the IP address of the cloud instance that Packer
// should connect to. A custom CommHost function can be implemented in each
// builder if need be; this is a generic function that should work for most
// cloud builders.
func CommHost(host string, statebagKey string) func(multistep.StateBag) (string, error) {
return func(state multistep.StateBag) (string, error) {
if host != "" {

View File

@ -24,8 +24,9 @@ import (
"golang.org/x/crypto/ssh/agent"
)
// Config is the common configuration that communicators allow within
// a builder.
// Config is the common configuration a builder uses to define and configure a Packer
// communicator. Embed this struct in your builder config to implement
// communicator support.
type Config struct {
// Packer currently supports three kinds of communicators:
//
@ -59,6 +60,7 @@ type Config struct {
WinRM `mapstructure:",squash"`
}
// The SSH config defines configuration for the SSH communicator.
type SSH struct {
// The address to SSH to. This usually is automatically configured by the
// builder.
@ -189,7 +191,7 @@ type SSH struct {
}
// When no ssh credentials are specified, Packer will generate a temporary SSH
// keypair for the instance, you can change the algorithm type and bits
// keypair for the instance. You can change the algorithm type and bits
// settings.
type SSHTemporaryKeyPair struct {
// `dsa` | `ecdsa` | `ed25519` | `rsa` ( the default )
@ -208,6 +210,7 @@ type SSHTemporaryKeyPair struct {
SSHTemporaryKeyPairBits int `mapstructure:"temporary_key_pair_bits"`
}
// The WinRM config defines configuration for the WinRM communicator.
type WinRM struct {
// The username to use to connect to WinRM.
WinRMUser string `mapstructure:"winrm_username"`
@ -244,14 +247,19 @@ type WinRM struct {
WinRMTransportDecorator func() winrm.Transporter
}
func (c *SSH) ConfigSpec() hcldec.ObjectSpec { return c.FlatMapstructure().HCL2Spec() }
// The ConfigSpec funcs are used by the Packer core to parse HCL2 templates.
func (c *SSH) ConfigSpec() hcldec.ObjectSpec { return c.FlatMapstructure().HCL2Spec() }
// The ConfigSpec funcs are used by the Packer core to parse HCL2 templates.
func (c *WinRM) ConfigSpec() hcldec.ObjectSpec { return c.FlatMapstructure().HCL2Spec() }
// Configure parses the json template into the Config structs
func (c *SSH) Configure(raws ...interface{}) ([]string, error) {
err := config.Decode(c, nil, raws...)
return nil, err
}
// Configure parses the json template into the Config structs
func (c *WinRM) Configure(raws ...interface{}) ([]string, error) {
err := config.Decode(c, nil, raws...)
return nil, err
@ -262,6 +270,8 @@ var (
_ packersdk.ConfigurableCommunicator = new(WinRM)
)
// SSHInterface defines whether to use public or private, addresses, and whether
// to use IPv4 or IPv6.
type SSHInterface struct {
// One of `public_ip`, `private_ip`, `public_dns`, or `private_dns`. If
// set, either the public IP address, private IP address, public DNS name
@ -282,7 +292,7 @@ type SSHInterface struct {
SSHIPVersion string `mapstructure:"ssh_ip_version"`
}
// ReadSSHPrivateKeyFile returns the SSH private key bytes
// ReadSSHPrivateKeyFile returns the SSH private key bytes.
func (c *Config) ReadSSHPrivateKeyFile() ([]byte, error) {
var privateKey []byte

View File

@ -1,4 +1,5 @@
// Code generated by "mapstructure-to-hcl2 -type Config,SSH,WinRM,SSHTemporaryKeyPair"; DO NOT EDIT.
package communicator
import (

View File

@ -0,0 +1,10 @@
/*
Package communicator provides common steps for connecting to an instance
using the Packer communicator. These steps can be implemented by builders.
Normally, a builder will want to implement StepConnect, which is smart enough
to then determine which kind of communicator, and therefore which kind of
substep, it should implement.
Various helper functions are also supplied.
*/
package communicator

View File

@ -1,3 +1,5 @@
// Package SSH provides tooling for generating a temporary SSH keypair, and
// provides tooling for connecting to an instance via a tunnel.
package ssh
import (

View File

@ -2,5 +2,4 @@
Package filelock makes it easy to create and check file locks for concurrent
processes.
*/
package filelock

View File

@ -8,5 +8,4 @@ Note that to successfully use this package your provisioner must have knowledge
of the guest type, which is not information that builders generally collect --
your provisioner will have to require guest information in its config.
*/
package guestexec

View File

@ -1,28 +0,0 @@
package iochan
import (
"bufio"
"io"
)
// LineReader takes an io.Reader and produces the contents of the reader on the
// returned channel. Internally bufio.NewScanner is used, io.ScanLines parses
// lines and returns them without carriage return. Scan can panic if the split
// function returns too many empty tokens without advancing the input.
//
// The channel will be closed either by reaching the end of the input or an
// error.
func LineReader(r io.Reader) <-chan string {
ch := make(chan string)
go func() {
scanner := bufio.NewScanner(r)
defer close(ch)
for scanner.Scan() {
ch <- scanner.Text()
}
}()
return ch
}

View File

@ -1,28 +0,0 @@
package iochan
import (
"bytes"
"reflect"
"strings"
"testing"
)
func TestLineReader(t *testing.T) {
data := []string{"foo", "bar", "baz"}
buf := new(bytes.Buffer)
buf.WriteString(strings.Join(data, "\n") + "\n")
ch := LineReader(buf)
var result []string
expected := data
for v := range ch {
result = append(result, v)
}
if !reflect.DeepEqual(result, expected) {
t.Fatalf("unexpected results: %#v", result)
}
}

View File

@ -1 +0,0 @@
package json

Some files were not shown because too many files have changed in this diff Show More