From 87ba7258b352d634b95f7e506685a725d8e46a45 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Fri, 16 Apr 2021 11:52:03 +0200 Subject: [PATCH] Use packer-sdc in packer + remove mapstructure-to-hcl2 & struct-markdown (#10913) * start using `go:generate packer-sdc struct-markdown` * Update Makefile remove @go install ./cmd/struct-markdown * run go generate for struct-markdown * use //go:generate packer-sdc mapstructure-to-hcl2 * run go generate for mapstructure-to-hcl2 * remove struct-markdown and mapstructure-to-hcl2 * vendor vendors --- Makefile | 3 +- builder/alicloud/ecs/access_config.go | 2 +- builder/alicloud/ecs/builder.go | 2 +- builder/alicloud/ecs/builder.hcl2spec.go | 2 +- builder/alicloud/ecs/image_config.go | 2 +- builder/alicloud/ecs/run_config.go | 2 +- builder/azure/arm/config.go | 4 +- builder/azure/arm/config.hcl2spec.go | 2 +- builder/azure/chroot/builder.go | 4 +- builder/azure/chroot/builder.hcl2spec.go | 2 +- .../shared_image_gallery_destination.go | 4 +- ...ared_image_gallery_destination.hcl2spec.go | 2 +- builder/azure/common/client/config.go | 2 +- builder/azure/dtl/config.go | 4 +- builder/azure/dtl/config.hcl2spec.go | 2 +- builder/cloudstack/config.go | 4 +- builder/cloudstack/config.hcl2spec.go | 2 +- builder/digitalocean/config.go | 4 +- builder/digitalocean/config.hcl2spec.go | 2 +- builder/file/config.go | 2 +- builder/file/config.hcl2spec.go | 2 +- builder/googlecompute/config.go | 4 +- builder/googlecompute/config.hcl2spec.go | 2 +- builder/googlecompute/step_start_tunnel.go | 4 +- .../step_start_tunnel.hcl2spec.go | 2 +- builder/hcloud/config.go | 2 +- builder/hcloud/config.hcl2spec.go | 2 +- builder/hyperone/config.go | 4 +- builder/hyperone/config.hcl2spec.go | 2 +- builder/hyperv/common/config.go | 2 +- builder/hyperv/common/output_config.go | 4 +- .../hyperv/common/output_config.hcl2spec.go | 2 +- builder/hyperv/iso/builder.go | 4 +- builder/hyperv/iso/builder.hcl2spec.go | 2 +- builder/hyperv/vmcx/builder.go | 4 +- builder/hyperv/vmcx/builder.hcl2spec.go | 2 +- builder/jdcloud/common.go | 2 +- builder/jdcloud/common.hcl2spec.go | 2 +- builder/linode/config.go | 2 +- builder/linode/config.hcl2spec.go | 2 +- builder/lxc/config.go | 4 +- builder/lxc/config.hcl2spec.go | 2 +- builder/lxd/config.go | 4 +- builder/lxd/config.hcl2spec.go | 2 +- builder/ncloud/config.go | 4 +- builder/ncloud/config.hcl2spec.go | 2 +- builder/null/config.go | 2 +- builder/null/config.hcl2spec.go | 2 +- builder/oneandone/config.go | 2 +- builder/oneandone/config.hcl2spec.go | 2 +- builder/openstack/access_config.go | 2 +- builder/openstack/builder.go | 2 +- builder/openstack/builder.hcl2spec.go | 2 +- builder/openstack/image_config.go | 2 +- builder/openstack/run_config.go | 2 +- builder/oracle/classic/builder.go | 2 +- builder/oracle/classic/builder.hcl2spec.go | 2 +- builder/oracle/oci/config.go | 2 +- builder/oracle/oci/config.hcl2spec.go | 2 +- builder/osc/bsu/builder.go | 2 +- builder/osc/bsu/builder.hcl2spec.go | 2 +- builder/osc/bsusurrogate/builder.go | 2 +- builder/osc/bsusurrogate/builder.hcl2spec.go | 2 +- builder/osc/bsuvolume/builder.go | 2 +- builder/osc/bsuvolume/builder.hcl2spec.go | 2 +- builder/osc/chroot/builder.go | 2 +- builder/osc/chroot/builder.hcl2spec.go | 2 +- builder/osc/common/run_config.go | 2 +- builder/osc/common/run_config.hcl2spec.go | 2 +- builder/parallels/common/hw_config.go | 2 +- builder/parallels/common/output_config.go | 2 +- builder/parallels/common/prlctl_config.go | 2 +- .../parallels/common/prlctl_post_config.go | 2 +- .../parallels/common/prlctl_version_config.go | 2 +- builder/parallels/common/tools_config.go | 2 +- builder/parallels/iso/builder.go | 4 +- builder/parallels/iso/builder.hcl2spec.go | 2 +- builder/parallels/pvm/config.go | 4 +- builder/parallels/pvm/config.hcl2spec.go | 2 +- builder/profitbricks/config.go | 2 +- builder/profitbricks/config.hcl2spec.go | 2 +- builder/proxmox/clone/config.go | 2 +- builder/proxmox/clone/config.hcl2spec.go | 2 +- builder/proxmox/common/config.go | 2 +- builder/proxmox/common/config.hcl2spec.go | 2 +- builder/proxmox/iso/config.go | 2 +- builder/proxmox/iso/config.hcl2spec.go | 2 +- builder/qemu/comm_config.go | 2 +- builder/qemu/config.go | 4 +- builder/qemu/config.hcl2spec.go | 2 +- builder/scaleway/config.go | 4 +- builder/scaleway/config.hcl2spec.go | 2 +- builder/tencentcloud/cvm/access_config.go | 2 +- builder/tencentcloud/cvm/builder.go | 2 +- builder/tencentcloud/cvm/builder.hcl2spec.go | 2 +- builder/tencentcloud/cvm/image_config.go | 2 +- builder/tencentcloud/cvm/run_config.go | 4 +- .../tencentcloud/cvm/run_config.hcl2spec.go | 2 +- builder/triton/access_config.go | 2 +- builder/triton/config.go | 2 +- builder/triton/config.hcl2spec.go | 2 +- builder/triton/source_machine_config.go | 4 +- .../triton/source_machine_config.hcl2spec.go | 2 +- builder/triton/target_image_config.go | 2 +- builder/ucloud/common/access_config.go | 2 +- builder/ucloud/common/image_config.go | 4 +- .../ucloud/common/image_config.hcl2spec.go | 2 +- builder/ucloud/common/run_config.go | 2 +- builder/ucloud/uhost/builder.go | 2 +- builder/ucloud/uhost/builder.hcl2spec.go | 2 +- builder/vagrant/builder.go | 4 +- builder/vagrant/builder.hcl2spec.go | 2 +- builder/virtualbox/common/comm_config.go | 2 +- builder/virtualbox/common/export_config.go | 2 +- .../common/guest_additions_config.go | 2 +- builder/virtualbox/common/hw_config.go | 2 +- builder/virtualbox/common/output_config.go | 2 +- builder/virtualbox/common/run_config.go | 2 +- builder/virtualbox/common/shutdown_config.go | 2 +- .../virtualbox/common/vbox_version_config.go | 2 +- .../virtualbox/common/vboxbundle_config.go | 2 +- .../virtualbox/common/vboxmanage_config.go | 2 +- builder/virtualbox/iso/builder.go | 4 +- builder/virtualbox/iso/builder.hcl2spec.go | 2 +- builder/virtualbox/ovf/config.go | 4 +- builder/virtualbox/ovf/config.hcl2spec.go | 2 +- builder/virtualbox/vm/config.go | 4 +- builder/virtualbox/vm/config.hcl2spec.go | 2 +- builder/vmware/common/disk_config.go | 2 +- builder/vmware/common/driver_config.go | 2 +- builder/vmware/common/export_config.go | 2 +- builder/vmware/common/hw_config.go | 2 +- builder/vmware/common/output_config.go | 2 +- builder/vmware/common/run_config.go | 2 +- builder/vmware/common/ssh_config.go | 2 +- builder/vmware/common/tools_config.go | 2 +- builder/vmware/common/vmx_config.go | 2 +- builder/vmware/iso/config.go | 4 +- builder/vmware/iso/config.hcl2spec.go | 2 +- builder/vmware/vmx/config.go | 4 +- builder/vmware/vmx/config.hcl2spec.go | 2 +- builder/yandex/access_config.go | 2 +- builder/yandex/common_config.go | 2 +- builder/yandex/config.go | 4 +- builder/yandex/config.hcl2spec.go | 2 +- .../mapstructure-to-hcl2.go | 598 -------- cmd/snippet-extractor/main.go | 146 -- cmd/struct-markdown/main.go | 189 --- cmd/struct-markdown/template.go | 37 - go.mod | 2 - go.sum | 2 - hcl2template/internal/mock.go | 2 +- hcl2template/internal/mock.hcl2spec.go | 2 +- hcl2template/shim/mock.go | 2 +- hcl2template/shim/mock.hcl2spec.go | 2 +- packer/post_processor_mock.go | 2 +- packer/post_processor_mock.hcl2spec.go | 2 +- .../alicloud-import/post-processor.go | 4 +- .../post-processor.hcl2spec.go | 2 +- post-processor/artifice/post-processor.go | 2 +- .../artifice/post-processor.hcl2spec.go | 2 +- post-processor/checksum/post-processor.go | 2 +- .../checksum/post-processor.hcl2spec.go | 2 +- post-processor/compress/post-processor.go | 2 +- .../compress/post-processor.hcl2spec.go | 2 +- .../digitalocean-import/post-processor.go | 2 +- .../post-processor.hcl2spec.go | 2 +- .../googlecompute-export/post-processor.go | 4 +- .../post-processor.hcl2spec.go | 2 +- .../googlecompute-import/post-processor.go | 4 +- .../post-processor.hcl2spec.go | 2 +- post-processor/manifest/post-processor.go | 4 +- .../manifest/post-processor.hcl2spec.go | 2 +- .../ucloud-import/post-processor.go | 4 +- .../ucloud-import/post-processor.hcl2spec.go | 2 +- .../vagrant-cloud/post-processor.go | 2 +- .../vagrant-cloud/post-processor.hcl2spec.go | 2 +- post-processor/vagrant/post-processor.go | 2 +- .../vagrant/post-processor.hcl2spec.go | 2 +- post-processor/yandex-export/config.go | 2 +- .../yandex-export/post-processor.go | 4 +- .../yandex-export/post-processor.hcl2spec.go | 2 +- .../yandex-import/post-processor.go | 4 +- .../yandex-import/post-processor.hcl2spec.go | 2 +- provisioner/ansible-local/provisioner.go | 4 +- .../ansible-local/provisioner.hcl2spec.go | 2 +- provisioner/ansible/provisioner.go | 4 +- provisioner/ansible/provisioner.hcl2spec.go | 2 +- provisioner/azure-dtlartifact/provisioner.go | 2 +- .../azure-dtlartifact/provisioner.hcl2spec.go | 2 +- provisioner/breakpoint/provisioner.go | 2 +- .../breakpoint/provisioner.hcl2spec.go | 2 +- provisioner/chef-client/provisioner.go | 2 +- .../chef-client/provisioner.hcl2spec.go | 2 +- provisioner/chef-solo/provisioner.go | 2 +- provisioner/chef-solo/provisioner.hcl2spec.go | 2 +- provisioner/converge/provisioner.go | 2 +- provisioner/converge/provisioner.hcl2spec.go | 2 +- provisioner/file/provisioner.go | 4 +- provisioner/file/provisioner.hcl2spec.go | 2 +- provisioner/inspec/provisioner.go | 2 +- provisioner/inspec/provisioner.hcl2spec.go | 2 +- provisioner/powershell/provisioner.go | 2 +- .../powershell/provisioner.hcl2spec.go | 2 +- provisioner/puppet-masterless/provisioner.go | 2 +- .../puppet-masterless/provisioner.hcl2spec.go | 2 +- provisioner/puppet-server/provisioner.go | 2 +- .../puppet-server/provisioner.hcl2spec.go | 2 +- provisioner/salt-masterless/provisioner.go | 2 +- .../salt-masterless/provisioner.hcl2spec.go | 2 +- provisioner/shell/provisioner.go | 2 +- provisioner/shell/provisioner.hcl2spec.go | 2 +- provisioner/sleep/provisioner.go | 2 +- provisioner/sleep/provisioner.hcl2spec.go | 2 +- provisioner/windows-restart/provisioner.go | 2 +- .../windows-restart/provisioner.hcl2spec.go | 2 +- provisioner/windows-shell/provisioner.go | 2 +- .../windows-shell/provisioner.hcl2spec.go | 2 +- vendor/github.com/fatih/camelcase/.travis.yml | 3 - vendor/github.com/fatih/camelcase/LICENSE.md | 20 - vendor/github.com/fatih/camelcase/README.md | 58 - .../github.com/fatih/camelcase/camelcase.go | 90 -- vendor/github.com/fatih/structtag/.travis.yml | 4 - vendor/github.com/fatih/structtag/LICENSE | 60 - vendor/github.com/fatih/structtag/README.md | 73 - vendor/github.com/fatih/structtag/tags.go | 309 ---- .../tools/go/internal/packagesdriver/sizes.go | 113 -- vendor/golang.org/x/tools/go/packages/doc.go | 221 --- .../x/tools/go/packages/external.go | 101 -- .../golang.org/x/tools/go/packages/golist.go | 1085 ------------- .../x/tools/go/packages/golist_overlay.go | 572 ------- .../x/tools/go/packages/loadmode_string.go | 57 - .../x/tools/go/packages/packages.go | 1233 --------------- .../golang.org/x/tools/go/packages/visit.go | 55 - .../internal/packagesinternal/packages.go | 17 - .../tools/internal/typesinternal/errorcode.go | 1358 ----------------- .../typesinternal/errorcode_string.go | 152 -- .../x/tools/internal/typesinternal/types.go | 28 - vendor/modules.txt | 10 - .../guides/hcl/component-object-spec.mdx | 2 +- .../ecs/AlicloudAccessConfig-not-required.mdx | 2 + .../ecs/AlicloudAccessConfig-required.mdx | 2 + .../alicloud/ecs/AlicloudAccessConfig.mdx | 2 + .../ecs/AlicloudDiskDevice-not-required.mdx | 2 + .../alicloud/ecs/AlicloudDiskDevice.mdx | 2 + .../ecs/AlicloudDiskDevices-not-required.mdx | 2 + .../alicloud/ecs/AlicloudDiskDevices.mdx | 2 + .../ecs/AlicloudImageConfig-not-required.mdx | 2 + .../ecs/AlicloudImageConfig-required.mdx | 2 + .../alicloud/ecs/RunConfig-not-required.mdx | 2 + .../alicloud/ecs/RunConfig-required.mdx | 2 + .../builder/azure/arm/Config-not-required.mdx | 2 + .../builder/azure/arm/Config-required.mdx | 2 + .../arm/PlanInformation-not-required.mdx | 2 + .../arm/SharedImageGallery-not-required.mdx | 2 + ...edImageGalleryDestination-not-required.mdx | 2 + .../azure/chroot/Config-not-required.mdx | 2 + .../builder/azure/chroot/Config-required.mdx | 2 + .../partials/builder/azure/chroot/Config.mdx | 2 + ...edImageGalleryDestination-not-required.mdx | 2 + ...SharedImageGalleryDestination-required.mdx | 2 + .../chroot/SharedImageGalleryDestination.mdx | 2 + .../chroot/TargetRegion-not-required.mdx | 2 + .../azure/chroot/TargetRegion-required.mdx | 2 + .../builder/azure/chroot/TargetRegion.mdx | 2 + .../common/client/Config-not-required.mdx | 2 + .../builder/azure/common/client/Config.mdx | 2 + .../dtl/ArtifactParameter-not-required.mdx | 2 + .../builder/azure/dtl/Config-not-required.mdx | 2 + .../azure/dtl/DtlArtifact-not-required.mdx | 2 + .../dtl/SharedImageGallery-not-required.mdx | 2 + ...edImageGalleryDestination-not-required.mdx | 2 + .../cloudstack/Config-not-required.mdx | 2 + .../builder/cloudstack/Config-required.mdx | 2 + .../partials/builder/cloudstack/Config.mdx | 2 + .../digitalocean/Config-not-required.mdx | 2 + .../builder/digitalocean/Config-required.mdx | 2 + .../googlecompute/Config-not-required.mdx | 2 + .../builder/googlecompute/Config-required.mdx | 2 + .../partials/builder/googlecompute/Config.mdx | 2 + .../CustomerEncryptionKey-not-required.mdx | 2 + .../googlecompute/IAPConfig-not-required.mdx | 2 + .../builder/googlecompute/IAPConfig.mdx | 2 + .../builder/hyperone/Config-not-required.mdx | 2 + .../builder/hyperone/Config-required.mdx | 2 + .../common/CommonConfig-not-required.mdx | 2 + .../common/OutputConfig-not-required.mdx | 2 + .../partials/builder/hyperv/iso/Builder.mdx | 2 + .../hyperv/iso/Config-not-required.mdx | 2 + .../partials/builder/hyperv/vmcx/Builder.mdx | 2 + .../hyperv/vmcx/Config-not-required.mdx | 2 + .../builder/lxc/Config-not-required.mdx | 2 + .../partials/builder/lxc/Config-required.mdx | 2 + .../builder/lxd/Config-not-required.mdx | 2 + .../partials/builder/lxd/Config-required.mdx | 2 + .../builder/ncloud/Config-not-required.mdx | 2 + .../builder/ncloud/Config-required.mdx | 2 + .../partials/builder/ncloud/Config.mdx | 2 + .../openstack/AccessConfig-not-required.mdx | 2 + .../openstack/AccessConfig-required.mdx | 2 + .../builder/openstack/AccessConfig.mdx | 2 + .../openstack/ImageConfig-not-required.mdx | 2 + .../openstack/ImageConfig-required.mdx | 2 + .../builder/openstack/ImageConfig.mdx | 2 + .../openstack/ImageFilter-not-required.mdx | 2 + .../ImageFilterOptions-not-required.mdx | 2 + .../openstack/RunConfig-not-required.mdx | 2 + .../builder/openstack/RunConfig-required.mdx | 2 + .../partials/builder/openstack/RunConfig.mdx | 2 + .../common/HWConfig-not-required.mdx | 2 + .../common/OutputConfig-not-required.mdx | 2 + .../builder/parallels/common/OutputConfig.mdx | 2 + .../common/PrlctlConfig-not-required.mdx | 2 + .../builder/parallels/common/PrlctlConfig.mdx | 2 + .../common/PrlctlPostConfig-not-required.mdx | 2 + .../parallels/common/PrlctlPostConfig.mdx | 2 + .../PrlctlVersionConfig-not-required.mdx | 2 + .../parallels/common/PrlctlVersionConfig.mdx | 2 + .../common/ToolsConfig-not-required.mdx | 2 + .../parallels/common/ToolsConfig-required.mdx | 2 + .../builder/parallels/common/ToolsConfig.mdx | 2 + .../parallels/iso/Config-not-required.mdx | 2 + .../parallels/pvm/Config-not-required.mdx | 2 + .../builder/parallels/pvm/Config-required.mdx | 2 + .../partials/builder/parallels/pvm/Config.mdx | 2 + .../builder/qemu/CommConfig-not-required.mdx | 2 + .../builder/qemu/Config-not-required.mdx | 2 + .../builder/qemu/QemuImgArgs-not-required.mdx | 2 + .../builder/scaleway/Config-not-required.mdx | 2 + .../builder/scaleway/Config-required.mdx | 2 + .../TencentCloudAccessConfig-not-required.mdx | 2 + .../cvm/TencentCloudAccessConfig-required.mdx | 2 + .../TencentCloudImageConfig-not-required.mdx | 2 + .../cvm/TencentCloudImageConfig-required.mdx | 2 + .../TencentCloudRunConfig-not-required.mdx | 2 + .../cvm/TencentCloudRunConfig-required.mdx | 2 + .../cvm/tencentCloudDataDisk-not-required.mdx | 2 + .../triton/AccessConfig-not-required.mdx | 2 + .../builder/triton/AccessConfig-required.mdx | 2 + .../partials/builder/triton/AccessConfig.mdx | 2 + .../MachineImageFilter-not-required.mdx | 2 + .../SourceMachineConfig-not-required.mdx | 2 + .../triton/SourceMachineConfig-required.mdx | 2 + .../builder/triton/SourceMachineConfig.mdx | 2 + .../triton/TargetImageConfig-not-required.mdx | 2 + .../triton/TargetImageConfig-required.mdx | 2 + .../builder/triton/TargetImageConfig.mdx | 2 + .../common/AccessConfig-not-required.mdx | 2 + .../ucloud/common/AccessConfig-required.mdx | 2 + .../common/ImageConfig-not-required.mdx | 2 + .../ucloud/common/ImageConfig-required.mdx | 2 + .../common/ImageDestination-not-required.mdx | 2 + .../ucloud/common/RunConfig-not-required.mdx | 2 + .../ucloud/common/RunConfig-required.mdx | 2 + .../partials/builder/vagrant/Builder.mdx | 2 + .../builder/vagrant/Config-not-required.mdx | 2 + .../builder/vagrant/Config-required.mdx | 2 + .../common/CommConfig-not-required.mdx | 2 + .../common/ExportConfig-not-required.mdx | 2 + .../GuestAdditionsConfig-not-required.mdx | 2 + .../common/HWConfig-not-required.mdx | 2 + .../common/OutputConfig-not-required.mdx | 2 + .../common/RunConfig-not-required.mdx | 2 + .../common/ShutdownConfig-not-required.mdx | 2 + .../common/VBoxBundleConfig-not-required.mdx | 2 + .../common/VBoxManageConfig-not-required.mdx | 2 + .../virtualbox/common/VBoxManageConfig.mdx | 2 + .../common/VBoxVersionConfig-not-required.mdx | 2 + .../virtualbox/iso/Config-not-required.mdx | 2 + .../virtualbox/ovf/Config-not-required.mdx | 2 + .../virtualbox/ovf/Config-required.mdx | 2 + .../builder/virtualbox/ovf/Config.mdx | 2 + .../virtualbox/vm/Config-not-required.mdx | 2 + .../builder/virtualbox/vm/Config-required.mdx | 2 + .../partials/builder/virtualbox/vm/Config.mdx | 2 + .../vmware/common/DiskConfig-not-required.mdx | 2 + .../common/DriverConfig-not-required.mdx | 2 + .../common/ExportConfig-not-required.mdx | 2 + .../vmware/common/HWConfig-not-required.mdx | 2 + .../common/OutputConfig-not-required.mdx | 2 + .../builder/vmware/common/ParallelUnion.mdx | 2 + .../vmware/common/RunConfig-not-required.mdx | 2 + .../builder/vmware/common/RunConfig.mdx | 2 + .../vmware/common/SerialConfigPipe.mdx | 2 + .../common/ToolsConfig-not-required.mdx | 2 + .../vmware/common/VMXConfig-not-required.mdx | 2 + .../vmware/iso/Config-not-required.mdx | 2 + .../vmware/vmx/Config-not-required.mdx | 2 + .../builder/vmware/vmx/Config-required.mdx | 2 + .../partials/builder/vmware/vmx/Config.mdx | 2 + .../yandex/AccessConfig-not-required.mdx | 2 + .../builder/yandex/AccessConfig-required.mdx | 2 + .../partials/builder/yandex/AccessConfig.mdx | 2 + .../builder/yandex/CloudConfig-required.mdx | 2 + .../yandex/CommonConfig-not-required.mdx | 2 + .../builder/yandex/Config-not-required.mdx | 2 + .../yandex/DiskConfig-not-required.mdx | 2 + .../yandex/ImageConfig-not-required.mdx | 2 + .../yandex/InstanceConfig-not-required.mdx | 2 + .../yandex/NetworkConfig-not-required.mdx | 2 + .../yandex/SourceImageConfig-not-required.mdx | 2 + .../yandex/SourceImageConfig-required.mdx | 2 + .../alicloud-import/Config-not-required.mdx | 2 + .../alicloud-import/Config-required.mdx | 2 + .../post-processor/alicloud-import/Config.mdx | 2 + .../Config-not-required.mdx | 2 + .../googlecompute-export/Config-required.mdx | 2 + .../Config-not-required.mdx | 2 + .../googlecompute-import/Config-required.mdx | 2 + .../manifest/Config-not-required.mdx | 2 + .../ucloud-import/Config-not-required.mdx | 2 + .../ucloud-import/Config-required.mdx | 2 + .../post-processor/ucloud-import/Config.mdx | 2 + .../yandex-export/Config-not-required.mdx | 2 + .../yandex-export/Config-required.mdx | 2 + .../yandex-export/ExchangeConfig-required.mdx | 2 + .../yandex-import/Config-not-required.mdx | 2 + .../ansible-local/Config-not-required.mdx | 2 + .../ansible/Config-not-required.mdx | 2 + .../provisioner/ansible/Config-required.mdx | 2 + .../provisioner/file/Config-not-required.mdx | 2 + .../provisioner/file/Config-required.mdx | 2 + 422 files changed, 616 insertions(+), 6846 deletions(-) delete mode 100644 cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go delete mode 100644 cmd/snippet-extractor/main.go delete mode 100644 cmd/struct-markdown/main.go delete mode 100644 cmd/struct-markdown/template.go delete mode 100644 vendor/github.com/fatih/camelcase/.travis.yml delete mode 100644 vendor/github.com/fatih/camelcase/LICENSE.md delete mode 100644 vendor/github.com/fatih/camelcase/README.md delete mode 100644 vendor/github.com/fatih/camelcase/camelcase.go delete mode 100644 vendor/github.com/fatih/structtag/.travis.yml delete mode 100644 vendor/github.com/fatih/structtag/LICENSE delete mode 100644 vendor/github.com/fatih/structtag/README.md delete mode 100644 vendor/github.com/fatih/structtag/tags.go delete mode 100644 vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go delete mode 100644 vendor/golang.org/x/tools/go/packages/doc.go delete mode 100644 vendor/golang.org/x/tools/go/packages/external.go delete mode 100644 vendor/golang.org/x/tools/go/packages/golist.go delete mode 100644 vendor/golang.org/x/tools/go/packages/golist_overlay.go delete mode 100644 vendor/golang.org/x/tools/go/packages/loadmode_string.go delete mode 100644 vendor/golang.org/x/tools/go/packages/packages.go delete mode 100644 vendor/golang.org/x/tools/go/packages/visit.go delete mode 100644 vendor/golang.org/x/tools/internal/packagesinternal/packages.go delete mode 100644 vendor/golang.org/x/tools/internal/typesinternal/errorcode.go delete mode 100644 vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go delete mode 100644 vendor/golang.org/x/tools/internal/typesinternal/types.go diff --git a/Makefile b/Makefile index 03e2eaefd..93fbaac5b 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,7 @@ install-gen-deps: ## Install dependencies for code generation # install` seems to install the last tagged version and we want to install # master. @(cd $(TEMPDIR) && GO111MODULE=on go get github.com/alvaroloes/enumer@master) - @go install ./cmd/struct-markdown - @go install ./cmd/mapstructure-to-hcl2 + @go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest install-lint-deps: ## Install linter dependencies # Pinning golangci-lint at v1.23.8 as --new-from-rev seems to work properly; the latest 1.24.0 has caused issues with memory consumption diff --git a/builder/alicloud/ecs/access_config.go b/builder/alicloud/ecs/access_config.go index d7892518b..aae96bd6c 100644 --- a/builder/alicloud/ecs/access_config.go +++ b/builder/alicloud/ecs/access_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package ecs diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 963aaae15..9aa9462a7 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,AlicloudDiskDevice +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,AlicloudDiskDevice // The alicloud contains a packersdk.Builder implementation that // builds ecs images for alicloud. diff --git a/builder/alicloud/ecs/builder.hcl2spec.go b/builder/alicloud/ecs/builder.hcl2spec.go index 16eb25cde..deef9bbb7 100644 --- a/builder/alicloud/ecs/builder.hcl2spec.go +++ b/builder/alicloud/ecs/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,AlicloudDiskDevice"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package ecs diff --git a/builder/alicloud/ecs/image_config.go b/builder/alicloud/ecs/image_config.go index c39d4c96c..38587a342 100644 --- a/builder/alicloud/ecs/image_config.go +++ b/builder/alicloud/ecs/image_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package ecs diff --git a/builder/alicloud/ecs/run_config.go b/builder/alicloud/ecs/run_config.go index f9c62ddee..2ecfda355 100644 --- a/builder/alicloud/ecs/run_config.go +++ b/builder/alicloud/ecs/run_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package ecs diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 0e7382be9..02f98b516 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,PlanInformation +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,PlanInformation package arm diff --git a/builder/azure/arm/config.hcl2spec.go b/builder/azure/arm/config.hcl2spec.go index 354535128..3ae69fbc4 100644 --- a/builder/azure/arm/config.hcl2spec.go +++ b/builder/azure/arm/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,PlanInformation"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package arm diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index 03143020d..9130cb461 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // Package chroot is able to create an Azure managed image without requiring the // launch of a new virtual machine for every build. It does this by attaching and diff --git a/builder/azure/chroot/builder.hcl2spec.go b/builder/azure/chroot/builder.hcl2spec.go index 97a372622..96f4c1ae9 100644 --- a/builder/azure/chroot/builder.hcl2spec.go +++ b/builder/azure/chroot/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package chroot diff --git a/builder/azure/chroot/shared_image_gallery_destination.go b/builder/azure/chroot/shared_image_gallery_destination.go index 8491424b2..de124f356 100644 --- a/builder/azure/chroot/shared_image_gallery_destination.go +++ b/builder/azure/chroot/shared_image_gallery_destination.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type SharedImageGalleryDestination,TargetRegion +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type SharedImageGalleryDestination,TargetRegion package chroot diff --git a/builder/azure/chroot/shared_image_gallery_destination.hcl2spec.go b/builder/azure/chroot/shared_image_gallery_destination.hcl2spec.go index cd708e96d..3da1bc72d 100644 --- a/builder/azure/chroot/shared_image_gallery_destination.hcl2spec.go +++ b/builder/azure/chroot/shared_image_gallery_destination.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type SharedImageGalleryDestination,TargetRegion"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package chroot diff --git a/builder/azure/common/client/config.go b/builder/azure/common/client/config.go index 70bed0abd..8fa077476 100644 --- a/builder/azure/common/client/config.go +++ b/builder/azure/common/client/config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package client diff --git a/builder/azure/dtl/config.go b/builder/azure/dtl/config.go index 3c28003a5..da9214b1e 100644 --- a/builder/azure/dtl/config.go +++ b/builder/azure/dtl/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,DtlArtifact,ArtifactParameter +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,DtlArtifact,ArtifactParameter package dtl diff --git a/builder/azure/dtl/config.hcl2spec.go b/builder/azure/dtl/config.hcl2spec.go index b0684e265..d0dd2c2d0 100644 --- a/builder/azure/dtl/config.hcl2spec.go +++ b/builder/azure/dtl/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,SharedImageGallery,SharedImageGalleryDestination,DtlArtifact,ArtifactParameter"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package dtl diff --git a/builder/cloudstack/config.go b/builder/cloudstack/config.go index 006e29b8f..65f5cd384 100644 --- a/builder/cloudstack/config.go +++ b/builder/cloudstack/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package cloudstack diff --git a/builder/cloudstack/config.hcl2spec.go b/builder/cloudstack/config.hcl2spec.go index 638223c4c..b59dcf123 100644 --- a/builder/cloudstack/config.hcl2spec.go +++ b/builder/cloudstack/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package cloudstack diff --git a/builder/digitalocean/config.go b/builder/digitalocean/config.go index 8ac9569b0..dce8e8d16 100644 --- a/builder/digitalocean/config.go +++ b/builder/digitalocean/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package digitalocean diff --git a/builder/digitalocean/config.hcl2spec.go b/builder/digitalocean/config.hcl2spec.go index b55bd0891..6aeef2df4 100644 --- a/builder/digitalocean/config.hcl2spec.go +++ b/builder/digitalocean/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package digitalocean diff --git a/builder/file/config.go b/builder/file/config.go index 988255692..b784400c1 100644 --- a/builder/file/config.go +++ b/builder/file/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package file diff --git a/builder/file/config.hcl2spec.go b/builder/file/config.hcl2spec.go index 4583c1e98..0ddc9ac4f 100644 --- a/builder/file/config.hcl2spec.go +++ b/builder/file/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package file diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index 24f4a39e8..a789b9e84 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config,CustomerEncryptionKey +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,CustomerEncryptionKey package googlecompute diff --git a/builder/googlecompute/config.hcl2spec.go b/builder/googlecompute/config.hcl2spec.go index 3879719fd..b0226c208 100644 --- a/builder/googlecompute/config.hcl2spec.go +++ b/builder/googlecompute/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,CustomerEncryptionKey"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package googlecompute diff --git a/builder/googlecompute/step_start_tunnel.go b/builder/googlecompute/step_start_tunnel.go index 92ffb776b..2f3f0bf7a 100644 --- a/builder/googlecompute/step_start_tunnel.go +++ b/builder/googlecompute/step_start_tunnel.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type IAPConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type IAPConfig package googlecompute diff --git a/builder/googlecompute/step_start_tunnel.hcl2spec.go b/builder/googlecompute/step_start_tunnel.hcl2spec.go index d28e0d39d..e9a0244f9 100644 --- a/builder/googlecompute/step_start_tunnel.hcl2spec.go +++ b/builder/googlecompute/step_start_tunnel.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type IAPConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package googlecompute diff --git a/builder/hcloud/config.go b/builder/hcloud/config.go index 8e2cf29f1..d86272a1e 100644 --- a/builder/hcloud/config.go +++ b/builder/hcloud/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,imageFilter +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,imageFilter package hcloud diff --git a/builder/hcloud/config.hcl2spec.go b/builder/hcloud/config.hcl2spec.go index c4f75aa0b..e926704a5 100644 --- a/builder/hcloud/config.hcl2spec.go +++ b/builder/hcloud/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,imageFilter"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package hcloud diff --git a/builder/hyperone/config.go b/builder/hyperone/config.go index c63f6d273..6b83e8acc 100644 --- a/builder/hyperone/config.go +++ b/builder/hyperone/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package hyperone diff --git a/builder/hyperone/config.hcl2spec.go b/builder/hyperone/config.hcl2spec.go index 3062b1445..f6b26acc6 100644 --- a/builder/hyperone/config.hcl2spec.go +++ b/builder/hyperone/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package hyperone diff --git a/builder/hyperv/common/config.go b/builder/hyperv/common/config.go index a7429afd5..5bf91232d 100644 --- a/builder/hyperv/common/config.go +++ b/builder/hyperv/common/config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/hyperv/common/output_config.go b/builder/hyperv/common/output_config.go index af663cd61..4f6387951 100644 --- a/builder/hyperv/common/output_config.go +++ b/builder/hyperv/common/output_config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type OutputConfig +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type OutputConfig package common diff --git a/builder/hyperv/common/output_config.hcl2spec.go b/builder/hyperv/common/output_config.hcl2spec.go index 461ca31dc..45dfb665b 100644 --- a/builder/hyperv/common/output_config.hcl2spec.go +++ b/builder/hyperv/common/output_config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type OutputConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index c87e89271..ebe37bfa2 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package iso diff --git a/builder/hyperv/iso/builder.hcl2spec.go b/builder/hyperv/iso/builder.hcl2spec.go index b2b74f892..83801b7d9 100644 --- a/builder/hyperv/iso/builder.hcl2spec.go +++ b/builder/hyperv/iso/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package iso diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index b2c06b4ee..5cc4c28fb 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package vmcx diff --git a/builder/hyperv/vmcx/builder.hcl2spec.go b/builder/hyperv/vmcx/builder.hcl2spec.go index b24a8c663..e2a64d05d 100644 --- a/builder/hyperv/vmcx/builder.hcl2spec.go +++ b/builder/hyperv/vmcx/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package vmcx diff --git a/builder/jdcloud/common.go b/builder/jdcloud/common.go index 2d52c6fa4..049421b72 100644 --- a/builder/jdcloud/common.go +++ b/builder/jdcloud/common.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package jdcloud diff --git a/builder/jdcloud/common.hcl2spec.go b/builder/jdcloud/common.hcl2spec.go index 5a1b2d912..8cfe8d8b5 100644 --- a/builder/jdcloud/common.hcl2spec.go +++ b/builder/jdcloud/common.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package jdcloud diff --git a/builder/linode/config.go b/builder/linode/config.go index a7dd7ab27..f72a498b4 100644 --- a/builder/linode/config.go +++ b/builder/linode/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package linode diff --git a/builder/linode/config.hcl2spec.go b/builder/linode/config.hcl2spec.go index 9420b8aba..747b5f514 100644 --- a/builder/linode/config.hcl2spec.go +++ b/builder/linode/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package linode diff --git a/builder/lxc/config.go b/builder/lxc/config.go index 7a59fbc2c..2981ca35a 100644 --- a/builder/lxc/config.go +++ b/builder/lxc/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package lxc diff --git a/builder/lxc/config.hcl2spec.go b/builder/lxc/config.hcl2spec.go index 2d501ca4a..1aa474f1c 100644 --- a/builder/lxc/config.hcl2spec.go +++ b/builder/lxc/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package lxc diff --git a/builder/lxd/config.go b/builder/lxd/config.go index 997ff1837..6e3670b6a 100644 --- a/builder/lxd/config.go +++ b/builder/lxd/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package lxd diff --git a/builder/lxd/config.hcl2spec.go b/builder/lxd/config.hcl2spec.go index 4759e91c4..7acf90ce9 100644 --- a/builder/lxd/config.hcl2spec.go +++ b/builder/lxd/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package lxd diff --git a/builder/ncloud/config.go b/builder/ncloud/config.go index 6bf088217..fc8908cf3 100644 --- a/builder/ncloud/config.go +++ b/builder/ncloud/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package ncloud diff --git a/builder/ncloud/config.hcl2spec.go b/builder/ncloud/config.hcl2spec.go index e5e90f53f..bf5978190 100644 --- a/builder/ncloud/config.hcl2spec.go +++ b/builder/ncloud/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package ncloud diff --git a/builder/null/config.go b/builder/null/config.go index d6fe1480f..39bec200a 100644 --- a/builder/null/config.go +++ b/builder/null/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package null diff --git a/builder/null/config.hcl2spec.go b/builder/null/config.hcl2spec.go index 03b0d7707..8d710f1e2 100644 --- a/builder/null/config.hcl2spec.go +++ b/builder/null/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package null diff --git a/builder/oneandone/config.go b/builder/oneandone/config.go index 77973d38f..d471987a7 100644 --- a/builder/oneandone/config.go +++ b/builder/oneandone/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package oneandone diff --git a/builder/oneandone/config.hcl2spec.go b/builder/oneandone/config.hcl2spec.go index 8fc50685a..c1ef9befb 100644 --- a/builder/oneandone/config.hcl2spec.go +++ b/builder/oneandone/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package oneandone diff --git a/builder/openstack/access_config.go b/builder/openstack/access_config.go index 49385f6de..499813eca 100644 --- a/builder/openstack/access_config.go +++ b/builder/openstack/access_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package openstack diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 34ff22b0d..70cf61fa4 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,ImageFilter,ImageFilterOptions +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,ImageFilter,ImageFilterOptions // The openstack package contains a packersdk.Builder implementation that // builds Images for openstack. diff --git a/builder/openstack/builder.hcl2spec.go b/builder/openstack/builder.hcl2spec.go index d1e72a2c0..cdc9e1b9b 100644 --- a/builder/openstack/builder.hcl2spec.go +++ b/builder/openstack/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,ImageFilter,ImageFilterOptions"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package openstack diff --git a/builder/openstack/image_config.go b/builder/openstack/image_config.go index 5daaecee7..5c23c2dee 100644 --- a/builder/openstack/image_config.go +++ b/builder/openstack/image_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package openstack diff --git a/builder/openstack/run_config.go b/builder/openstack/run_config.go index 7561de74d..34ca7b7a4 100644 --- a/builder/openstack/run_config.go +++ b/builder/openstack/run_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package openstack diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index 695007afd..4c975dec1 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package classic diff --git a/builder/oracle/classic/builder.hcl2spec.go b/builder/oracle/classic/builder.hcl2spec.go index 1528d3afa..93e5432d8 100644 --- a/builder/oracle/classic/builder.hcl2spec.go +++ b/builder/oracle/classic/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package classic diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index 50c442fe1..55347813b 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest,FlexShapeConfig +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest,FlexShapeConfig package oci diff --git a/builder/oracle/oci/config.hcl2spec.go b/builder/oracle/oci/config.hcl2spec.go index c564f1a5a..84c3493c4 100644 --- a/builder/oracle/oci/config.hcl2spec.go +++ b/builder/oracle/oci/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest,FlexShapeConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package oci diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index 25810c25f..20692a09a 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // Package bsu contains a packersdk.Builder implementation that // builds OMIs for Outscale OAPI. diff --git a/builder/osc/bsu/builder.hcl2spec.go b/builder/osc/bsu/builder.hcl2spec.go index 852499d7c..beba1f9da 100644 --- a/builder/osc/bsu/builder.hcl2spec.go +++ b/builder/osc/bsu/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package bsu diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index 31ac74211..22a5bc92d 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,RootBlockDevice +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,RootBlockDevice // Package bsusurrogate contains a packersdk.Builder implementation that // builds a new EBS-backed OMI using an ephemeral instance. diff --git a/builder/osc/bsusurrogate/builder.hcl2spec.go b/builder/osc/bsusurrogate/builder.hcl2spec.go index 30e58c816..6ba0f933f 100644 --- a/builder/osc/bsusurrogate/builder.hcl2spec.go +++ b/builder/osc/bsusurrogate/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,RootBlockDevice"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package bsusurrogate diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 4ad4ab320..7de1a3f33 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,BlockDevice +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,BlockDevice // The ebsvolume package contains a packersdk.Builder implementation that // builds EBS volumes for Outscale using an ephemeral instance, diff --git a/builder/osc/bsuvolume/builder.hcl2spec.go b/builder/osc/bsuvolume/builder.hcl2spec.go index ebd028b85..d6fd7c3de 100644 --- a/builder/osc/bsuvolume/builder.hcl2spec.go +++ b/builder/osc/bsuvolume/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,BlockDevice"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package bsuvolume diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 5734b63ad..cd4ec3dd3 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // Package chroot is able to create an Outscale OMI without requiring // the launch of a new instance for every build. It does this by attaching diff --git a/builder/osc/chroot/builder.hcl2spec.go b/builder/osc/chroot/builder.hcl2spec.go index b4b1fecea..b79773106 100644 --- a/builder/osc/chroot/builder.hcl2spec.go +++ b/builder/osc/chroot/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package chroot diff --git a/builder/osc/common/run_config.go b/builder/osc/common/run_config.go index db8d3354a..49081e058 100644 --- a/builder/osc/common/run_config.go +++ b/builder/osc/common/run_config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type SecurityGroupFilterOptions,OmiFilterOptions,SubnetFilterOptions,NetFilterOptions,BlockDevice +//go:generate packer-sdc mapstructure-to-hcl2 -type SecurityGroupFilterOptions,OmiFilterOptions,SubnetFilterOptions,NetFilterOptions,BlockDevice package common diff --git a/builder/osc/common/run_config.hcl2spec.go b/builder/osc/common/run_config.hcl2spec.go index da3bf98dc..3cdbde353 100644 --- a/builder/osc/common/run_config.hcl2spec.go +++ b/builder/osc/common/run_config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type SecurityGroupFilterOptions,OmiFilterOptions,SubnetFilterOptions,NetFilterOptions,BlockDevice"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/builder/parallels/common/hw_config.go b/builder/parallels/common/hw_config.go index 505e95169..4cd437f79 100644 --- a/builder/parallels/common/hw_config.go +++ b/builder/parallels/common/hw_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/parallels/common/output_config.go b/builder/parallels/common/output_config.go index 07e07c3d3..a1a02a379 100644 --- a/builder/parallels/common/output_config.go +++ b/builder/parallels/common/output_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/parallels/common/prlctl_config.go b/builder/parallels/common/prlctl_config.go index c2892bcf8..ef5db81cc 100644 --- a/builder/parallels/common/prlctl_config.go +++ b/builder/parallels/common/prlctl_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/parallels/common/prlctl_post_config.go b/builder/parallels/common/prlctl_post_config.go index 405104af7..a307ab819 100644 --- a/builder/parallels/common/prlctl_post_config.go +++ b/builder/parallels/common/prlctl_post_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/parallels/common/prlctl_version_config.go b/builder/parallels/common/prlctl_version_config.go index 835f94dc9..416553d1c 100644 --- a/builder/parallels/common/prlctl_version_config.go +++ b/builder/parallels/common/prlctl_version_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/parallels/common/tools_config.go b/builder/parallels/common/tools_config.go index 82cf49ea8..d3ccc2041 100644 --- a/builder/parallels/common/tools_config.go +++ b/builder/parallels/common/tools_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index a5d99b272..f0527dc42 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package iso diff --git a/builder/parallels/iso/builder.hcl2spec.go b/builder/parallels/iso/builder.hcl2spec.go index b4d20dc72..a740d858c 100644 --- a/builder/parallels/iso/builder.hcl2spec.go +++ b/builder/parallels/iso/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package iso diff --git a/builder/parallels/pvm/config.go b/builder/parallels/pvm/config.go index 63f63bc31..e758b6801 100644 --- a/builder/parallels/pvm/config.go +++ b/builder/parallels/pvm/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package pvm diff --git a/builder/parallels/pvm/config.hcl2spec.go b/builder/parallels/pvm/config.hcl2spec.go index 432bafe17..46e9df4bb 100644 --- a/builder/parallels/pvm/config.hcl2spec.go +++ b/builder/parallels/pvm/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package pvm diff --git a/builder/profitbricks/config.go b/builder/profitbricks/config.go index fd95300d5..eaa2e473d 100644 --- a/builder/profitbricks/config.go +++ b/builder/profitbricks/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package profitbricks diff --git a/builder/profitbricks/config.hcl2spec.go b/builder/profitbricks/config.hcl2spec.go index 2d907387c..ff975b345 100644 --- a/builder/profitbricks/config.hcl2spec.go +++ b/builder/profitbricks/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package profitbricks diff --git a/builder/proxmox/clone/config.go b/builder/proxmox/clone/config.go index 4a4c96feb..1e8bf32d2 100644 --- a/builder/proxmox/clone/config.go +++ b/builder/proxmox/clone/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package proxmoxclone diff --git a/builder/proxmox/clone/config.hcl2spec.go b/builder/proxmox/clone/config.hcl2spec.go index 5ea7b18c2..31feaa960 100644 --- a/builder/proxmox/clone/config.hcl2spec.go +++ b/builder/proxmox/clone/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package proxmoxclone diff --git a/builder/proxmox/common/config.go b/builder/proxmox/common/config.go index 19d7793cb..448115914 100644 --- a/builder/proxmox/common/config.go +++ b/builder/proxmox/common/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig,additionalISOsConfig +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig,additionalISOsConfig package proxmox diff --git a/builder/proxmox/common/config.hcl2spec.go b/builder/proxmox/common/config.hcl2spec.go index 95ba40895..cb4845f04 100644 --- a/builder/proxmox/common/config.hcl2spec.go +++ b/builder/proxmox/common/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig,additionalISOsConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package proxmox diff --git a/builder/proxmox/iso/config.go b/builder/proxmox/iso/config.go index 4a43066a3..1ff9f177e 100644 --- a/builder/proxmox/iso/config.go +++ b/builder/proxmox/iso/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig,additionalISOsConfig +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig,additionalISOsConfig package proxmoxiso diff --git a/builder/proxmox/iso/config.hcl2spec.go b/builder/proxmox/iso/config.hcl2spec.go index 24650d35e..06d38b6aa 100644 --- a/builder/proxmox/iso/config.hcl2spec.go +++ b/builder/proxmox/iso/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig,additionalISOsConfig"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package proxmoxiso diff --git a/builder/qemu/comm_config.go b/builder/qemu/comm_config.go index 0e90a0a9a..99b945507 100644 --- a/builder/qemu/comm_config.go +++ b/builder/qemu/comm_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package qemu import ( diff --git a/builder/qemu/config.go b/builder/qemu/config.go index 19370c698..4a8cf487e 100644 --- a/builder/qemu/config.go +++ b/builder/qemu/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config,QemuImgArgs +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,QemuImgArgs package qemu diff --git a/builder/qemu/config.hcl2spec.go b/builder/qemu/config.hcl2spec.go index dc331e20c..899b95885 100644 --- a/builder/qemu/config.hcl2spec.go +++ b/builder/qemu/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,QemuImgArgs"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package qemu diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index 878f5be1d..275b97525 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package scaleway diff --git a/builder/scaleway/config.hcl2spec.go b/builder/scaleway/config.hcl2spec.go index 720e02dae..ae799c042 100644 --- a/builder/scaleway/config.hcl2spec.go +++ b/builder/scaleway/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package scaleway diff --git a/builder/tencentcloud/cvm/access_config.go b/builder/tencentcloud/cvm/access_config.go index 6c0d7e06e..f900b0c80 100644 --- a/builder/tencentcloud/cvm/access_config.go +++ b/builder/tencentcloud/cvm/access_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package cvm diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 9424ade7e..3c1e42f0e 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package cvm diff --git a/builder/tencentcloud/cvm/builder.hcl2spec.go b/builder/tencentcloud/cvm/builder.hcl2spec.go index b150d91b9..89a9126b9 100644 --- a/builder/tencentcloud/cvm/builder.hcl2spec.go +++ b/builder/tencentcloud/cvm/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package cvm diff --git a/builder/tencentcloud/cvm/image_config.go b/builder/tencentcloud/cvm/image_config.go index c66655c59..96cf192dd 100644 --- a/builder/tencentcloud/cvm/image_config.go +++ b/builder/tencentcloud/cvm/image_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package cvm diff --git a/builder/tencentcloud/cvm/run_config.go b/builder/tencentcloud/cvm/run_config.go index 46256adcf..79936ce50 100644 --- a/builder/tencentcloud/cvm/run_config.go +++ b/builder/tencentcloud/cvm/run_config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type tencentCloudDataDisk +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type tencentCloudDataDisk package cvm diff --git a/builder/tencentcloud/cvm/run_config.hcl2spec.go b/builder/tencentcloud/cvm/run_config.hcl2spec.go index 776a951f0..0d0dfe9f4 100644 --- a/builder/tencentcloud/cvm/run_config.hcl2spec.go +++ b/builder/tencentcloud/cvm/run_config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type tencentCloudDataDisk"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package cvm diff --git a/builder/triton/access_config.go b/builder/triton/access_config.go index a032659d1..ab4d8ac06 100644 --- a/builder/triton/access_config.go +++ b/builder/triton/access_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package triton diff --git a/builder/triton/config.go b/builder/triton/config.go index ea821cd5c..957fc2f17 100644 --- a/builder/triton/config.go +++ b/builder/triton/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package triton diff --git a/builder/triton/config.hcl2spec.go b/builder/triton/config.hcl2spec.go index 35bbf517c..fcad473fd 100644 --- a/builder/triton/config.hcl2spec.go +++ b/builder/triton/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package triton diff --git a/builder/triton/source_machine_config.go b/builder/triton/source_machine_config.go index 0387a6624..6834b2a7b 100644 --- a/builder/triton/source_machine_config.go +++ b/builder/triton/source_machine_config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type MachineImageFilter +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type MachineImageFilter package triton diff --git a/builder/triton/source_machine_config.hcl2spec.go b/builder/triton/source_machine_config.hcl2spec.go index 9df636ac4..fdffc1275 100644 --- a/builder/triton/source_machine_config.hcl2spec.go +++ b/builder/triton/source_machine_config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type MachineImageFilter"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package triton diff --git a/builder/triton/target_image_config.go b/builder/triton/target_image_config.go index d5df9900b..e3b98fc34 100644 --- a/builder/triton/target_image_config.go +++ b/builder/triton/target_image_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package triton diff --git a/builder/ucloud/common/access_config.go b/builder/ucloud/common/access_config.go index de499fa55..9020dcd15 100644 --- a/builder/ucloud/common/access_config.go +++ b/builder/ucloud/common/access_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common import ( diff --git a/builder/ucloud/common/image_config.go b/builder/ucloud/common/image_config.go index 458203472..e1b73e9b0 100644 --- a/builder/ucloud/common/image_config.go +++ b/builder/ucloud/common/image_config.go @@ -1,5 +1,5 @@ -//go:generate mapstructure-to-hcl2 -type ImageDestination -//go:generate struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type ImageDestination +//go:generate packer-sdc struct-markdown package common diff --git a/builder/ucloud/common/image_config.hcl2spec.go b/builder/ucloud/common/image_config.hcl2spec.go index 436a6b467..a80521725 100644 --- a/builder/ucloud/common/image_config.hcl2spec.go +++ b/builder/ucloud/common/image_config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type ImageDestination"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common diff --git a/builder/ucloud/common/run_config.go b/builder/ucloud/common/run_config.go index 0c5b8dee1..d44936509 100644 --- a/builder/ucloud/common/run_config.go +++ b/builder/ucloud/common/run_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common import ( diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index 31c47eaa3..23251dd4c 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // The ucloud-uhost contains a packersdk.Builder implementation that // builds uhost images for UCloud UHost instance. diff --git a/builder/ucloud/uhost/builder.hcl2spec.go b/builder/ucloud/uhost/builder.hcl2spec.go index 01aa9562f..bba4694d0 100644 --- a/builder/ucloud/uhost/builder.hcl2spec.go +++ b/builder/ucloud/uhost/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package uhost diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index 96b0ebf30..29650c99d 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package vagrant diff --git a/builder/vagrant/builder.hcl2spec.go b/builder/vagrant/builder.hcl2spec.go index 09f5d7660..74d9bee2f 100644 --- a/builder/vagrant/builder.hcl2spec.go +++ b/builder/vagrant/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package vagrant diff --git a/builder/virtualbox/common/comm_config.go b/builder/virtualbox/common/comm_config.go index d635b17f2..194aa49c9 100644 --- a/builder/virtualbox/common/comm_config.go +++ b/builder/virtualbox/common/comm_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/export_config.go b/builder/virtualbox/common/export_config.go index 201be65fe..82ba3bb43 100644 --- a/builder/virtualbox/common/export_config.go +++ b/builder/virtualbox/common/export_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/guest_additions_config.go b/builder/virtualbox/common/guest_additions_config.go index 4a7e58538..178e63682 100644 --- a/builder/virtualbox/common/guest_additions_config.go +++ b/builder/virtualbox/common/guest_additions_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/hw_config.go b/builder/virtualbox/common/hw_config.go index b145d9d22..19fa89fb8 100644 --- a/builder/virtualbox/common/hw_config.go +++ b/builder/virtualbox/common/hw_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/output_config.go b/builder/virtualbox/common/output_config.go index cef8e11b6..f2e8d66ed 100644 --- a/builder/virtualbox/common/output_config.go +++ b/builder/virtualbox/common/output_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/run_config.go b/builder/virtualbox/common/run_config.go index 188f30035..f9b240be7 100644 --- a/builder/virtualbox/common/run_config.go +++ b/builder/virtualbox/common/run_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/shutdown_config.go b/builder/virtualbox/common/shutdown_config.go index 30debe198..26f8667da 100644 --- a/builder/virtualbox/common/shutdown_config.go +++ b/builder/virtualbox/common/shutdown_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/vbox_version_config.go b/builder/virtualbox/common/vbox_version_config.go index 568765e8f..64ad1eeea 100644 --- a/builder/virtualbox/common/vbox_version_config.go +++ b/builder/virtualbox/common/vbox_version_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/vboxbundle_config.go b/builder/virtualbox/common/vboxbundle_config.go index eb27436f1..23e28cfe5 100644 --- a/builder/virtualbox/common/vboxbundle_config.go +++ b/builder/virtualbox/common/vboxbundle_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/common/vboxmanage_config.go b/builder/virtualbox/common/vboxmanage_config.go index 915a47c45..cbf6eeec2 100644 --- a/builder/virtualbox/common/vboxmanage_config.go +++ b/builder/virtualbox/common/vboxmanage_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index f8adc5801..98c1f4c69 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package iso diff --git a/builder/virtualbox/iso/builder.hcl2spec.go b/builder/virtualbox/iso/builder.hcl2spec.go index c44c81ca8..7b7f5801f 100644 --- a/builder/virtualbox/iso/builder.hcl2spec.go +++ b/builder/virtualbox/iso/builder.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package iso diff --git a/builder/virtualbox/ovf/config.go b/builder/virtualbox/ovf/config.go index 5f6719af5..772e4cde4 100644 --- a/builder/virtualbox/ovf/config.go +++ b/builder/virtualbox/ovf/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package ovf diff --git a/builder/virtualbox/ovf/config.hcl2spec.go b/builder/virtualbox/ovf/config.hcl2spec.go index 1129ae208..6aedcc2b6 100644 --- a/builder/virtualbox/ovf/config.hcl2spec.go +++ b/builder/virtualbox/ovf/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package ovf diff --git a/builder/virtualbox/vm/config.go b/builder/virtualbox/vm/config.go index 2aa716f96..69a671f28 100644 --- a/builder/virtualbox/vm/config.go +++ b/builder/virtualbox/vm/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package vm diff --git a/builder/virtualbox/vm/config.hcl2spec.go b/builder/virtualbox/vm/config.hcl2spec.go index 9ac76a4f4..a6165e0e6 100644 --- a/builder/virtualbox/vm/config.hcl2spec.go +++ b/builder/virtualbox/vm/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package vm diff --git a/builder/vmware/common/disk_config.go b/builder/vmware/common/disk_config.go index 08e9b05ba..7cd8e64f8 100644 --- a/builder/vmware/common/disk_config.go +++ b/builder/vmware/common/disk_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/driver_config.go b/builder/vmware/common/driver_config.go index 22746afab..5bf7eada7 100644 --- a/builder/vmware/common/driver_config.go +++ b/builder/vmware/common/driver_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/export_config.go b/builder/vmware/common/export_config.go index 34e8df2d9..aad2f193a 100644 --- a/builder/vmware/common/export_config.go +++ b/builder/vmware/common/export_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/hw_config.go b/builder/vmware/common/hw_config.go index 0498a9e69..dc4b96a86 100644 --- a/builder/vmware/common/hw_config.go +++ b/builder/vmware/common/hw_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/output_config.go b/builder/vmware/common/output_config.go index 7bc895059..cf9302c5b 100644 --- a/builder/vmware/common/output_config.go +++ b/builder/vmware/common/output_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/run_config.go b/builder/vmware/common/run_config.go index 00d59a9a2..9609c42fd 100644 --- a/builder/vmware/common/run_config.go +++ b/builder/vmware/common/run_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/ssh_config.go b/builder/vmware/common/ssh_config.go index 5eebfa7e4..af64407d3 100644 --- a/builder/vmware/common/ssh_config.go +++ b/builder/vmware/common/ssh_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/tools_config.go b/builder/vmware/common/tools_config.go index 7774cce15..53098a919 100644 --- a/builder/vmware/common/tools_config.go +++ b/builder/vmware/common/tools_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/common/vmx_config.go b/builder/vmware/common/vmx_config.go index f8359116b..c91631901 100644 --- a/builder/vmware/common/vmx_config.go +++ b/builder/vmware/common/vmx_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package common diff --git a/builder/vmware/iso/config.go b/builder/vmware/iso/config.go index e1bf1cd39..4ba46b76c 100644 --- a/builder/vmware/iso/config.go +++ b/builder/vmware/iso/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package iso diff --git a/builder/vmware/iso/config.hcl2spec.go b/builder/vmware/iso/config.hcl2spec.go index 9ee645c8a..006c61651 100644 --- a/builder/vmware/iso/config.hcl2spec.go +++ b/builder/vmware/iso/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package iso diff --git a/builder/vmware/vmx/config.go b/builder/vmware/vmx/config.go index 2f1c07d53..4b44b1f52 100644 --- a/builder/vmware/vmx/config.go +++ b/builder/vmware/vmx/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package vmx diff --git a/builder/vmware/vmx/config.hcl2spec.go b/builder/vmware/vmx/config.hcl2spec.go index f18765929..d05b4aba1 100644 --- a/builder/vmware/vmx/config.hcl2spec.go +++ b/builder/vmware/vmx/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package vmx diff --git a/builder/yandex/access_config.go b/builder/yandex/access_config.go index ec55bf260..360b69ad2 100644 --- a/builder/yandex/access_config.go +++ b/builder/yandex/access_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package yandex diff --git a/builder/yandex/common_config.go b/builder/yandex/common_config.go index e99321c28..88a304d9e 100644 --- a/builder/yandex/common_config.go +++ b/builder/yandex/common_config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package yandex diff --git a/builder/yandex/config.go b/builder/yandex/config.go index 36ebfa5e3..ec17e4247 100644 --- a/builder/yandex/config.go +++ b/builder/yandex/config.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package yandex diff --git a/builder/yandex/config.hcl2spec.go b/builder/yandex/config.hcl2spec.go index c0d161844..af9c414db 100644 --- a/builder/yandex/config.hcl2spec.go +++ b/builder/yandex/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package yandex diff --git a/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go b/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go deleted file mode 100644 index 50c462acd..000000000 --- a/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go +++ /dev/null @@ -1,598 +0,0 @@ -// mapstructure-to-hcl2 fills the gaps between hcl2 and mapstructure for Packer -// -// By generating a struct that the HCL2 ecosystem understands making use of -// mapstructure tags. -// -// Packer heavily uses the mapstructure decoding library to load/parse user -// config files. Packer now needs to move to HCL2. -// -// Here are a few differences/gaps betweens hcl2 and mapstructure: -// -// * in HCL2 all basic struct fields (string/int/struct) that are not pointers -// are required ( must be set ). In mapstructure everything is optional. -// -// * mapstructure allows to 'squash' fields -// (ex: Field CommonStructType `mapstructure:",squash"`) this allows to -// decorate structs and reuse configuration code. HCL2 parsing libs don't have -// anything similar. -// -// mapstructure-to-hcl2 will parse Packer's config files and generate the HCL2 -// compliant code that will allow to not change any of the current builders in -// order to softly move to HCL2. -package main - -import ( - "bytes" - "flag" - "fmt" - "go/types" - "io" - "log" - "os" - "regexp" - "sort" - "strings" - - "github.com/fatih/structtag" - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" - - "golang.org/x/tools/go/packages" - "golang.org/x/tools/imports" -) - -const mapstructureToHCL2 = "mapstructure-to-hcl2" - -var ( - typeNames = flag.String("type", "", "comma-separated list of type names; must be set") - output = flag.String("output", "", "output file name; default srcdir/_hcl2.go") - trimprefix = flag.String("trimprefix", "", "trim the `prefix` from the generated constant names") -) - -// Usage is a replacement usage function for the flags package. -func Usage() { - fmt.Fprintf(os.Stderr, "Usage of "+mapstructureToHCL2+":\n") - fmt.Fprintf(os.Stderr, "\t"+mapstructureToHCL2+" [flags] -type T[,T...] pkg\n") - fmt.Fprintf(os.Stderr, "Flags:\n") - flag.PrintDefaults() -} - -func main() { - log.SetFlags(0) - log.SetPrefix(mapstructureToHCL2 + ": ") - flag.Usage = Usage - flag.Parse() - if len(*typeNames) == 0 { - flag.Usage() - os.Exit(2) - } - typeNames := strings.Split(*typeNames, ",") - - // We accept either one directory or a list of files. Which do we have? - args := flag.Args() - if len(args) == 0 { - // Default: process whole package in current directory. - args = []string{"."} - } - outputPath := strings.ToLower(typeNames[0]) + ".hcl2spec.go" - if goFile := os.Getenv("GOFILE"); goFile != "" { - outputPath = goFile[:len(goFile)-2] + "hcl2spec.go" - } - log.SetPrefix(fmt.Sprintf(mapstructureToHCL2+": %s.%v: ", os.Getenv("GOPACKAGE"), typeNames)) - - cfg := &packages.Config{ - Mode: packages.LoadSyntax, - } - pkgs, err := packages.Load(cfg, args...) - if err != nil { - log.Fatal(err) - } - if len(pkgs) != 1 { - log.Fatalf("error: %d packages found", len(pkgs)) - } - topPkg := pkgs[0] - sort.Strings(typeNames) - - var structs []StructDef - usedImports := map[NamePath]*types.Package{} - - for id, obj := range topPkg.TypesInfo.Defs { - if obj == nil { - continue - } - t := obj.Type() - nt, isANamedType := t.(*types.Named) - if !isANamedType { - continue - } - if nt.Obj().Pkg() != topPkg.Types { - // Sometimes a struct embeds another struct named the same. ex: - // builder/osc/bsuvolume.BlockDevice. This makes sure the type is - // defined in topPkg. - continue - } - ut := nt.Underlying() - utStruct, utOk := ut.(*types.Struct) - if !utOk { - continue - } - pos := sort.SearchStrings(typeNames, id.Name) - if pos >= len(typeNames) || typeNames[pos] != id.Name { - continue // not a struct we care about - } - // make sure each type is found once where somehow sometimes they can be found twice - typeNames = append(typeNames[:pos], typeNames[pos+1:]...) - flatenedStruct := getMapstructureSquashedStruct(obj.Pkg(), utStruct) - flatenedStruct = addCtyTagToStruct(flatenedStruct) - newStructName := "Flat" + id.Name - structs = append(structs, StructDef{ - OriginalStructName: id.Name, - FlatStructName: newStructName, - Struct: flatenedStruct, - }) - - for k, v := range getUsedImports(flatenedStruct) { - if _, found := usedImports[k]; !found { - usedImports[k] = v - } - } - } - - out := bytes.NewBuffer(nil) - - fmt.Fprintf(out, `// Code generated by "%s %s"; DO NOT EDIT.`, mapstructureToHCL2, strings.Join(os.Args[1:], " ")) - 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") - usedImports[NamePath{"cty", "github.com/zclconf/go-cty/cty"}] = types.NewPackage("cty", "github.com/zclconf/go-cty/cty") - outputImports(out, usedImports) - - sort.Slice(structs, func(i int, j int) bool { - return structs[i].OriginalStructName < structs[j].OriginalStructName - }) - for _, flatenedStruct := range structs { - fmt.Fprintf(out, "\n// %s is an auto-generated flat version of %s.", flatenedStruct.FlatStructName, flatenedStruct.OriginalStructName) - fmt.Fprintf(out, "\n// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.") - fmt.Fprintf(out, "\ntype %s struct {\n", flatenedStruct.FlatStructName) - outputStructFields(out, flatenedStruct.Struct) - fmt.Fprint(out, "}\n") - - fmt.Fprintf(out, "\n// FlatMapstructure returns a new %s.", flatenedStruct.FlatStructName) - fmt.Fprintf(out, "\n// %s is an auto-generated flat version of %s.", flatenedStruct.FlatStructName, flatenedStruct.OriginalStructName) - fmt.Fprintf(out, "\n// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.") - fmt.Fprintf(out, "\nfunc (*%s) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {", flatenedStruct.OriginalStructName) - fmt.Fprintf(out, "\nreturn new(%s)", flatenedStruct.FlatStructName) - fmt.Fprint(out, "\n}\n") - - fmt.Fprintf(out, "\n// HCL2Spec returns the hcl spec of a %s.", flatenedStruct.OriginalStructName) - fmt.Fprintf(out, "\n// This spec is used by HCL to read the fields of %s.", flatenedStruct.OriginalStructName) - fmt.Fprintf(out, "\n// The decoded values from this spec will then be applied to a %s.", flatenedStruct.FlatStructName) - fmt.Fprintf(out, "\nfunc (*%s) HCL2Spec() map[string]hcldec.Spec {\n", flatenedStruct.FlatStructName) - outputStructHCL2SpecBody(out, flatenedStruct.Struct) - fmt.Fprint(out, "}\n") - } - - for impt := range usedImports { - if strings.ContainsAny(impt.Path, "/") { - out = bytes.NewBuffer(bytes.ReplaceAll(out.Bytes(), - []byte(impt.Path+"."), - []byte(impt.Name+"."))) - } - } - - // avoid needing to import current pkg; there's probably a better way. - out = bytes.NewBuffer(bytes.ReplaceAll(out.Bytes(), - []byte(topPkg.PkgPath+"."), - nil)) - - outputFile, err := os.Create(outputPath) - if err != nil { - log.Fatalf("os.Create: %v", err) - } - - _, err = outputFile.Write(goFmt(outputFile.Name(), out.Bytes())) - if err != nil { - log.Fatalf("failed to write file: %v", err) - } -} - -type StructDef struct { - OriginalStructName string - FlatStructName string - Struct *types.Struct -} - -// outputStructHCL2SpecBody writes the map[string]hcldec.Spec that defines the HCL spec of a -// struct. Based on the layout of said struct. -// If a field of s is a struct then the HCL2Spec() function of that struct will be called, otherwise a -// cty.Type is outputed. -func outputStructHCL2SpecBody(w io.Writer, s *types.Struct) { - fmt.Fprintf(w, "s := map[string]hcldec.Spec{\n") - - for i := 0; i < s.NumFields(); i++ { - field, tag := s.Field(i), s.Tag(i) - st, _ := structtag.Parse(tag) - ctyTag, _ := st.Get("cty") - fmt.Fprintf(w, " \"%s\": ", ctyTag.Name) - outputHCL2SpecField(w, ctyTag.Name, field.Type(), st) - fmt.Fprintln(w, `,`) - } - - fmt.Fprintln(w, `}`) - fmt.Fprintln(w, `return s`) -} - -// outputHCL2SpecField is called on each field of a struct. -// outputHCL2SpecField writes the values of the `map[string]hcldec.Spec` map -// supposed to define the HCL spec of a struct. -func outputHCL2SpecField(w io.Writer, accessor string, fieldType types.Type, tag *structtag.Tags) { - if m2h, err := tag.Get(mapstructureToHCL2); err == nil && m2h.HasOption("self-defined") { - fmt.Fprintf(w, `(&%s{}).HCL2Spec()`, fieldType.String()) - return - } - spec, _ := goFieldToCtyType(accessor, fieldType) - switch spec := spec.(type) { - case string: - fmt.Fprintf(w, spec) - default: - fmt.Fprintf(w, `%#v`, spec) - } - -} - -// goFieldToCtyType is a recursive method that returns a cty.Type (or a string) based on the fieldType. -// goFieldToCtyType returns the values of the `map[string]hcldec.Spec` map -// supposed to define the HCL spec of a struct. -// To allow it to be recursive, the method returns two values: an interface that can either be -// a cty.Type or a string. The second argument is used for recursion and is the -// type that will be used by the parent. For example when fieldType is a []string; a -// recursive goFieldToCtyType call will return a cty.String. -func goFieldToCtyType(accessor string, fieldType types.Type) (interface{}, cty.Type) { - switch f := fieldType.(type) { - case *types.Pointer: - return goFieldToCtyType(accessor, f.Elem()) - case *types.Basic: - ctyType := basicKindToCtyType(f.Kind()) - return &hcldec.AttrSpec{ - Name: accessor, - Type: ctyType, - Required: false, - }, ctyType - case *types.Map: - return &hcldec.AttrSpec{ - Name: accessor, - Type: cty.Map(cty.String), // for now everything can be simplified to a map[string]string - }, cty.Map(cty.String) - case *types.Named: - // Named is the relative type when of a field with a struct. - // E.g. SourceAmiFilter *common.FlatAmiFilterOptions - // SourceAmiFilter will become a block with nested elements from the struct itself. - underlyingType := f.Underlying() - switch underlyingType.(type) { - case *types.Struct: - // A struct returns NilType because its HCL2Spec is written in the related file - // and we don't need to write it again. - return fmt.Sprintf(`&hcldec.BlockSpec{TypeName: "%s",`+ - ` Nested: hcldec.ObjectSpec((*%s)(nil).HCL2Spec())}`, accessor, f.String()), cty.NilType - default: - return goFieldToCtyType(accessor, underlyingType) - } - case *types.Slice: - elem := f.Elem() - if ptr, isPtr := elem.(*types.Pointer); isPtr { - elem = ptr.Elem() - } - switch elem := elem.(type) { - case *types.Named: - // A Slice of Named is the relative type of a filed with a slice of structs. - // E.g. LaunchMappings []common.FlatBlockDevice - // LaunchMappings will validate more than one block with nested elements. - b := bytes.NewBuffer(nil) - underlyingType := elem.Underlying() - switch underlyingType.(type) { - case *types.Struct: - fmt.Fprintf(b, `hcldec.ObjectSpec((*%s)(nil).HCL2Spec())`, elem.String()) - } - return fmt.Sprintf(`&hcldec.BlockListSpec{TypeName: "%s", Nested: %s}`, accessor, b.String()), cty.NilType - default: - _, specType := goFieldToCtyType(accessor, elem) - if specType == cty.NilType { - return goFieldToCtyType(accessor, elem.Underlying()) - } - return &hcldec.AttrSpec{ - Name: accessor, - Type: cty.List(specType), - Required: false, - }, cty.List(specType) - } - } - b := bytes.NewBuffer(nil) - fmt.Fprintf(b, `%#v`, &hcldec.AttrSpec{ - Name: accessor, - Type: basicKindToCtyType(types.Bool), - Required: false, - }) - fmt.Fprintf(b, `/* TODO(azr): could not find type */`) - return b.String(), cty.NilType -} - -func basicKindToCtyType(kind types.BasicKind) cty.Type { - switch kind { - case types.Bool: - return cty.Bool - case types.String: - return cty.String - case types.Int, types.Int8, types.Int16, types.Int32, types.Int64, - types.Uint, types.Uint8, types.Uint16, types.Uint32, types.Uint64, - types.Float32, types.Float64, - types.Complex64, types.Complex128: - return cty.Number - case types.Invalid: - return cty.String // TODO(azr): fix that beforehand ? - default: - log.Printf("Un handled basic kind: %d", kind) - return cty.String - } -} - -func outputStructFields(w io.Writer, s *types.Struct) { - for i := 0; i < s.NumFields(); i++ { - field, tag := s.Field(i), s.Tag(i) - fieldNameStr := field.String() - fieldNameStr = strings.Replace(fieldNameStr, "field ", "", 1) - fmt.Fprintf(w, " %s `%s`\n", fieldNameStr, tag) - } -} - -type NamePath struct { - Name, Path string -} - -func outputImports(w io.Writer, imports map[NamePath]*types.Package) { - if len(imports) == 0 { - return - } - // naive implementation - pkgs := []NamePath{} - for k := range imports { - pkgs = append(pkgs, k) - } - sort.Slice(pkgs, func(i int, j int) bool { - return pkgs[i].Path < pkgs[j].Path - }) - - fmt.Fprint(w, "import (\n") - for _, pkg := range pkgs { - if pkg.Name == pkg.Path || strings.HasSuffix(pkg.Path, "/"+pkg.Name) { - fmt.Fprintf(w, " \"%s\"\n", pkg.Path) - } else { - fmt.Fprintf(w, " %s \"%s\"\n", pkg.Name, pkg.Path) - } - } - fmt.Fprint(w, ")\n") -} - -func getUsedImports(s *types.Struct) map[NamePath]*types.Package { - res := map[NamePath]*types.Package{} - for i := 0; i < s.NumFields(); i++ { - fieldType := s.Field(i).Type() - if p, ok := fieldType.(*types.Pointer); ok { - fieldType = p.Elem() - } - if p, ok := fieldType.(*types.Slice); ok { - fieldType = p.Elem() - } - namedType, ok := fieldType.(*types.Named) - if !ok { - continue - } - pkg := namedType.Obj().Pkg() - if pkg == nil { - continue - } - res[NamePath{pkg.Name(), pkg.Path()}] = pkg - } - return res -} - -func addCtyTagToStruct(s *types.Struct) *types.Struct { - vars, tags := structFields(s) - for i := range tags { - field, tag := vars[i], tags[i] - ctyAccessor := ToSnakeCase(field.Name()) - st, err := structtag.Parse(tag) - if err == nil { - if ms, err := st.Get("mapstructure"); err == nil && ms.Name != "" { - ctyAccessor = ms.Name - } - } - st.Set(&structtag.Tag{Key: "cty", Name: ctyAccessor}) - _ = st.Set(&structtag.Tag{Key: "hcl", Name: ctyAccessor}) - tags[i] = st.String() - } - return types.NewStruct(uniqueTags("cty", vars, tags)) -} - -func uniqueTags(tagName string, fields []*types.Var, tags []string) ([]*types.Var, []string) { - outVars := []*types.Var{} - outTags := []string{} - uniqueTags := map[string]bool{} - for i := range fields { - field, tag := fields[i], tags[i] - structtag, _ := structtag.Parse(tag) - h, err := structtag.Get(tagName) - if err == nil { - if uniqueTags[h.Name] { - log.Printf("skipping field %s ( duplicate `%s` %s tag )", field.Name(), h.Name, tagName) - continue - } - uniqueTags[h.Name] = true - } - outVars = append(outVars, field) - outTags = append(outTags, tag) - } - return outVars, outTags -} - -// getMapstructureSquashedStruct will return the same struct but embedded -// fields with a `mapstructure:",squash"` tag will be un-nested. -func getMapstructureSquashedStruct(topPkg *types.Package, utStruct *types.Struct) *types.Struct { - res := &types.Struct{} - for i := 0; i < utStruct.NumFields(); i++ { - field, tag := utStruct.Field(i), utStruct.Tag(i) - if !field.Exported() { - continue - } - if _, ok := field.Type().(*types.Signature); ok { - continue // ignore funcs - } - structtag, err := structtag.Parse(tag) - if err != nil { - log.Printf("could not parse field tag %s of : %v", tag, err) - continue - } - - // Contains mapstructure-to-hcl2 tag - if ms, err := structtag.Get("mapstructure-to-hcl2"); err == nil { - // Stop if is telling to skip it - if ms.HasOption("skip") { - continue - } - } - - // Contains mapstructure tag - if ms, err := structtag.Get("mapstructure"); err == nil { - // Squash structs - if ms.HasOption("squash") { - ot := field.Type() - uot := ot.Underlying() - utStruct, utOk := uot.(*types.Struct) - if !utOk { - continue - } - - res = squashStructs(res, getMapstructureSquashedStruct(topPkg, utStruct)) - continue - } - } - - if field.Pkg() != topPkg { - field = types.NewField(field.Pos(), topPkg, field.Name(), field.Type(), field.Embedded()) - } - if p, isPointer := field.Type().(*types.Pointer); isPointer { - // in order to make the following switch simpler we 'unwrap' this - // pointer all structs are going to be made pointers anyways. - field = types.NewField(field.Pos(), field.Pkg(), field.Name(), p.Elem(), field.Embedded()) - } - switch f := field.Type().(type) { - case *types.Named: - switch f.String() { - case "time.Duration": - field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(types.Typ[types.String]), field.Embedded()) - case "github.com/hashicorp/packer-plugin-sdk/template/config.Trilean": // TODO(azr): unhack this situation - field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(types.Typ[types.Bool]), field.Embedded()) - case "github.com/hashicorp/packer/provisioner/powershell.ExecutionPolicy": // TODO(azr): unhack this situation - field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(types.Typ[types.String]), field.Embedded()) - default: - if str, isStruct := f.Underlying().(*types.Struct); isStruct { - obj := flattenNamed(f, str) - field = types.NewField(field.Pos(), field.Pkg(), field.Name(), obj, field.Embedded()) - field = makePointer(field) - } - if slice, isSlice := f.Underlying().(*types.Slice); isSlice { - if f, fNamed := slice.Elem().(*types.Named); fNamed { - if str, isStruct := f.Underlying().(*types.Struct); isStruct { - // this is a slice of named structs; we want to change - // the struct ref to a 'FlatStruct'. - obj := flattenNamed(f, str) - slice := types.NewSlice(obj) - field = types.NewField(field.Pos(), field.Pkg(), field.Name(), slice, field.Embedded()) - } - } - } - if _, isBasic := f.Underlying().(*types.Basic); isBasic { - field = makePointer(field) - } - } - case *types.Slice: - if f, fNamed := f.Elem().(*types.Named); fNamed { - if str, isStruct := f.Underlying().(*types.Struct); isStruct { - obj := flattenNamed(f, str) - field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewSlice(obj), field.Embedded()) - } - } - case *types.Basic: - // since everything is optional, everything must be a pointer - // non optional fields should be non pointers. - field = makePointer(field) - } - res = addFieldToStruct(res, field, tag) - } - return res -} - -func flattenNamed(f *types.Named, underlying types.Type) *types.Named { - obj := f.Obj() - obj = types.NewTypeName(obj.Pos(), obj.Pkg(), "Flat"+obj.Name(), obj.Type()) - return types.NewNamed(obj, underlying, nil) -} - -func makePointer(field *types.Var) *types.Var { - return types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(field.Type()), field.Embedded()) -} - -func addFieldToStruct(s *types.Struct, field *types.Var, tag string) *types.Struct { - sf, st := structFields(s) - return types.NewStruct(uniqueFields(append(sf, field), append(st, tag))) -} - -func squashStructs(a, b *types.Struct) *types.Struct { - va, ta := structFields(a) - vb, tb := structFields(b) - return types.NewStruct(uniqueFields(append(va, vb...), append(ta, tb...))) -} - -func uniqueFields(fields []*types.Var, tags []string) ([]*types.Var, []string) { - outVars := []*types.Var{} - outTags := []string{} - fieldNames := map[string]bool{} - for i := range fields { - field, tag := fields[i], tags[i] - if fieldNames[field.Name()] { - log.Printf("skipping duplicate %s field", field.Name()) - continue - } - fieldNames[field.Name()] = true - outVars = append(outVars, field) - outTags = append(outTags, tag) - } - return outVars, outTags -} - -func structFields(s *types.Struct) (vars []*types.Var, tags []string) { - for i := 0; i < s.NumFields(); i++ { - field, tag := s.Field(i), s.Tag(i) - vars = append(vars, field) - tags = append(tags, tag) - } - return vars, tags -} - -var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)") -var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])") - -func ToSnakeCase(str string) string { - snake := matchFirstCap.ReplaceAllString(str, "${1}_${2}") - snake = matchAllCap.ReplaceAllString(snake, "${1}_${2}") - return strings.ToLower(snake) -} - -func goFmt(filename string, b []byte) []byte { - fb, err := imports.Process(filename, b, nil) - if err != nil { - log.Printf("formatting err: %v", err) - return b - } - return fb -} diff --git a/cmd/snippet-extractor/main.go b/cmd/snippet-extractor/main.go deleted file mode 100644 index 30b2f475b..000000000 --- a/cmd/snippet-extractor/main.go +++ /dev/null @@ -1,146 +0,0 @@ -// snippet-extract --begin=#_BEGIN_WRAP_TAG_ --end=#_END_WRAP_TAG_ -output_dir=./docs/ [./file|./directory/]... -// Extracts markdown snippets from relative files into output_dir, keeping the -// directory layout. -// It is not mandatory to terminate a snippet, the extractor will simply add -// line until EOF. -// Lines matching begin or end tags will not be put in the resulting file. -// When a directory is passed, all files from directory will be parsed. -package main - -import ( - "bufio" - "bytes" - "flag" - "fmt" - "io/ioutil" - "log" - "os" - "path/filepath" - "strings" -) - -type options struct { - filenames []string - begin, end string - outputDir string - extension string -} - -func (o *options) AddFlagSets(fs *flag.FlagSet) { - fs.StringVar(&o.begin, "begin", "#_BEGIN_WRAP_TAG_", "flag to mark beginning of a snippet") - fs.StringVar(&o.end, "end", "#_END_WRAP_TAG_", "flag to mark ending of a snippet") - fs.StringVar(&o.outputDir, "output_dir", "./docs/", "directory in which the files will be generated, note that the directory layout is kept") - fs.StringVar(&o.extension, "extension", ".mdx", "extension for generated files") -} - -func main() { - fs := flag.NewFlagSet("snippet-extract", flag.ContinueOnError) - opts := options{} - opts.AddFlagSets(fs) - if err := fs.Parse(os.Args[1:]); err != nil { - fs.Usage() - os.Exit(1) - } - wd, _ := os.Getwd() - fmt.Printf("working from %s\n", wd) - opts.filenames = extactFilenames(fs.Args()) - for _, filename := range opts.filenames { - ext := filepath.Ext(filename) - snippets := extractSnippets(opts.begin, opts.end, filename) - for _, snippet := range snippets { - outputFile := filepath.Join(opts.outputDir, filepath.Base(filename), snippet.Identifier+opts.extension) - folder := filepath.Dir(outputFile) - err := os.MkdirAll(folder, os.ModePerm) - if err != nil { - log.Printf("cannot mkdir %s: %s", folder, err) - } - f := bytes.NewBuffer(nil) - fmt.Fprintf(f, ``, strings.Join(os.Args[1:], " ")) - fmt.Fprintf(f, "\n\n```%s\n%s```\n", ext, snippet.Text) - err = ioutil.WriteFile(outputFile, f.Bytes(), 0600) - if err != nil { - log.Printf("cannot write %s in %s: %s", filepath.Base(outputFile), folder, err) - } - } - } -} - -type snippet struct { - Identifier string - Text string - Closed bool -} - -func extractSnippets(beginPattern, endPattern, filename string) []snippet { - file, err := os.Open(filename) - if err != nil { - log.Printf("could not open file: %s", err) - os.Exit(1) - } - defer file.Close() - - scanner := bufio.NewScanner(file) - - snippets := []snippet{} - for scanner.Scan() { - line := scanner.Text() - if identifier := matches(line, beginPattern); identifier != "" { - snippets = append(snippets, snippet{ - Identifier: identifier, - }) - continue - } - if identifier := matches(line, endPattern); identifier != "" { - for i := range snippets { - snippet := &snippets[i] - if snippet.Identifier == identifier { - snippet.Closed = true - } - } - continue - } - for i := range snippets { - snippet := &snippets[i] - if snippet.Closed { - continue - } - snippet.Text = snippet.Text + line + "\n" - } - } - return snippets -} - -func matches(s, prefix string) string { - trimmed := strings.TrimSpace(s) - lenDiff := len(s) - len(trimmed) - if strings.HasPrefix(trimmed, prefix) { - return s[len(prefix)+lenDiff:] - } - return "" -} - -// if an entry is a directory all files from directory will be listed. -func extactFilenames(in []string) []string { - out := []string{} - for _, path := range in { - fi, err := os.Stat(path) - if err != nil { - log.Fatalf("%s: %s", path, err) - } - if !fi.IsDir() { - out = append(out, path) - continue - } - files, err := ioutil.ReadDir(path) - if err != nil { - log.Fatalf("could not read directory %s: %s", path, err) - } - for _, file := range files { - if file.IsDir() { - continue - } - out = append(out, file.Name()) - } - } - return in -} diff --git a/cmd/struct-markdown/main.go b/cmd/struct-markdown/main.go deleted file mode 100644 index 9a6394630..000000000 --- a/cmd/struct-markdown/main.go +++ /dev/null @@ -1,189 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "go/ast" - "go/parser" - "go/token" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/fatih/camelcase" - "github.com/fatih/structtag" -) - -func main() { - args := flag.Args() - if len(args) == 0 { - // Default: process the file - args = []string{os.Getenv("GOFILE")} - } - fname := args[0] - - absFilePath, err := filepath.Abs(fname) - if err != nil { - panic(err) - } - - projectRoot := os.Getenv("PROJECT_ROOT") - var paths []string - if projectRoot == "" { - // fall back to the packer root. - paths = strings.SplitAfter(absFilePath, "packer"+string(os.PathSeparator)) - projectRoot = paths[0] - } else { - paths = strings.SplitAfter(absFilePath, projectRoot+string(os.PathSeparator)) - } - builderName, _ := filepath.Split(paths[1]) - builderName = strings.Trim(builderName, string(os.PathSeparator)) - - b, err := ioutil.ReadFile(fname) - if err != nil { - fmt.Printf("ReadFile: %+v", err) - os.Exit(1) - } - - fset := token.NewFileSet() - f, err := parser.ParseFile(fset, fname, b, parser.ParseComments) - if err != nil { - fmt.Printf("ParseFile: %+v", err) - os.Exit(1) - } - - for _, decl := range f.Decls { - typeDecl, ok := decl.(*ast.GenDecl) - if !ok { - continue - } - typeSpec, ok := typeDecl.Specs[0].(*ast.TypeSpec) - if !ok { - continue - } - structDecl, ok := typeSpec.Type.(*ast.StructType) - if !ok { - continue - } - - fields := structDecl.Fields.List - sourcePath := filepath.ToSlash(paths[1]) - header := Struct{ - SourcePath: sourcePath, - Name: typeSpec.Name.Name, - Filename: typeSpec.Name.Name + ".mdx", - Header: strings.TrimSpace(typeDecl.Doc.Text()), - } - dataSourceOutput := Struct{ - SourcePath: sourcePath, - Name: typeSpec.Name.Name, - Filename: typeSpec.Name.Name + ".mdx", - } - required := Struct{ - SourcePath: sourcePath, - Name: typeSpec.Name.Name, - Filename: typeSpec.Name.Name + "-required.mdx", - } - notRequired := Struct{ - SourcePath: sourcePath, - Name: typeSpec.Name.Name, - Filename: typeSpec.Name.Name + "-not-required.mdx", - } - - for _, field := range fields { - if len(field.Names) == 0 || field.Tag == nil { - continue - } - tag := field.Tag.Value[1:] - tag = tag[:len(tag)-1] - tags, err := structtag.Parse(tag) - if err != nil { - fmt.Printf("structtag.Parse(%s): err: %v", field.Tag.Value, err) - os.Exit(1) - } - - // Leave undocumented tags out of markdown. This is useful for - // fields which exist for backwards compatability, or internal-use - // only fields - undocumented, _ := tags.Get("undocumented") - if undocumented != nil { - if undocumented.Name == "true" { - continue - } - } - mstr, err := tags.Get("mapstructure") - if err != nil { - continue - } - name := mstr.Name - - if name == "" { - continue - } - - var docs string - if field.Doc != nil { - docs = field.Doc.Text() - } else { - docs = strings.Join(camelcase.Split(field.Names[0].Name), " ") - } - - if strings.Contains(docs, "TODO") { - continue - } - fieldType := string(b[field.Type.Pos()-1 : field.Type.End()-1]) - fieldType = strings.ReplaceAll(fieldType, "*", `\*`) - switch fieldType { - case "time.Duration": - fieldType = `duration string | ex: "1h5m2s"` - case "config.Trilean": - fieldType = `boolean` - case "config.NameValues": - fieldType = `[]{name string, value string}` - case "config.KeyValues": - fieldType = `[]{key string, value string}` - } - - field := Field{ - Name: name, - Type: fieldType, - Docs: docs, - } - - if typeSpec.Name.Name == "DatasourceOutput" { - dataSourceOutput.Fields = append(dataSourceOutput.Fields, field) - continue - } - - if req, err := tags.Get("required"); err == nil && req.Value() == "true" { - required.Fields = append(required.Fields, field) - } else { - notRequired.Fields = append(notRequired.Fields, field) - } - } - - dir := filepath.Join(projectRoot, "website", "content", "partials", builderName) - os.MkdirAll(dir, 0755) - - for _, str := range []Struct{header, dataSourceOutput, required, notRequired} { - if len(str.Fields) == 0 && len(str.Header) == 0 { - continue - } - outputPath := filepath.Join(dir, str.Filename) - - outputFile, err := os.Create(outputPath) - if err != nil { - panic(err) - } - defer outputFile.Close() - - err = structDocsTemplate.Execute(outputFile, str) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - } - } - -} diff --git a/cmd/struct-markdown/template.go b/cmd/struct-markdown/template.go deleted file mode 100644 index 434a0899e..000000000 --- a/cmd/struct-markdown/template.go +++ /dev/null @@ -1,37 +0,0 @@ -package main - -import ( - "strings" - "text/template" -) - -type Field struct { - Name string - Type string - Docs string -} - -type Struct struct { - SourcePath string - Name string - Filename string - Header string - Fields []Field -} - -var structDocsTemplate = template.Must(template.New("structDocsTemplate"). - Funcs(template.FuncMap{ - "indent": indent, - }). - Parse(` -{{ if .Header }} -{{ .Header }} -{{ end -}} -{{ range .Fields }} -- ` + "`" + `{{ .Name}}` + "`" + ` ({{ .Type }}) - {{ .Docs | indent 2 }} -{{ end }}`)) - -func indent(spaces int, v string) string { - pad := strings.Repeat(" ", spaces) - return strings.TrimSpace(strings.Replace(v, "\n", "\n"+pad, -1)) -} diff --git a/go.mod b/go.mod index 1eec3f4d6..d6dccd95e 100644 --- a/go.mod +++ b/go.mod @@ -27,8 +27,6 @@ require ( github.com/digitalocean/godo v1.11.1 github.com/dsnet/compress v0.0.1 github.com/exoscale/packer-plugin-exoscale v0.1.1 - github.com/fatih/camelcase v1.0.0 - github.com/fatih/structtag v1.0.0 github.com/go-ini/ini v1.25.4 github.com/go-resty/resty/v2 v2.3.0 github.com/gobwas/glob v0.2.3 diff --git a/go.sum b/go.sum index 9ce19fb30..c4aa579c3 100644 --- a/go.sum +++ b/go.sum @@ -217,13 +217,11 @@ github.com/exoscale/egoscale v0.43.1/go.mod h1:mpEXBpROAa/2i5GC0r33rfxG+TxSEka11 github.com/exoscale/packer-plugin-exoscale v0.1.0/go.mod h1:ZmJRkxsAlmEsVYOMxYPupDkax54uZ+ph0h3W59aIMZ8= github.com/exoscale/packer-plugin-exoscale v0.1.1 h1:NJ9UvMvSe3LK3H50hJv9nMG2reqgWKBAUhAEs4JJNso= github.com/exoscale/packer-plugin-exoscale v0.1.1/go.mod h1:5S07HizadGVKST/m0a5+aNmDiFfY7EbPvnkU4rJWRE8= -github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/fatih/structtag v1.0.0 h1:pTHj65+u3RKWYPSGaU290FpI/dXxTaHdVwVwbcPKmEc= github.com/fatih/structtag v1.0.0/go.mod h1:IKitwq45uXL/yqi5mYghiD3w9H6eTOvI9vnk8tXMphA= github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw= github.com/getkin/kin-openapi v0.37.0/go.mod h1:ZJSfy1PxJv2QQvH9EdBj3nupRTVvV42mkW6zKUlRBwk= diff --git a/hcl2template/internal/mock.go b/hcl2template/internal/mock.go index eece997ea..2939b3b94 100644 --- a/hcl2template/internal/mock.go +++ b/hcl2template/internal/mock.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag +//go:generate packer-sdc mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag package hcl2template diff --git a/hcl2template/internal/mock.hcl2spec.go b/hcl2template/internal/mock.hcl2spec.go index b0e417846..8449859b4 100644 --- a/hcl2template/internal/mock.hcl2spec.go +++ b/hcl2template/internal/mock.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package hcl2template diff --git a/hcl2template/shim/mock.go b/hcl2template/shim/mock.go index 4e1c493ea..5ed9ce6b5 100644 --- a/hcl2template/shim/mock.go +++ b/hcl2template/shim/mock.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag +//go:generate packer-sdc mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag package hcl2shim diff --git a/hcl2template/shim/mock.hcl2spec.go b/hcl2template/shim/mock.hcl2spec.go index 9f63e2876..3dadeca3a 100644 --- a/hcl2template/shim/mock.hcl2spec.go +++ b/hcl2template/shim/mock.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package hcl2shim diff --git a/packer/post_processor_mock.go b/packer/post_processor_mock.go index 0491a031e..20d36f87b 100644 --- a/packer/post_processor_mock.go +++ b/packer/post_processor_mock.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type MockPostProcessor +//go:generate packer-sdc mapstructure-to-hcl2 -type MockPostProcessor package packer import ( diff --git a/packer/post_processor_mock.hcl2spec.go b/packer/post_processor_mock.hcl2spec.go index faf66821f..51829b0e4 100644 --- a/packer/post_processor_mock.hcl2spec.go +++ b/packer/post_processor_mock.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type MockPostProcessor"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package packer diff --git a/post-processor/alicloud-import/post-processor.go b/post-processor/alicloud-import/post-processor.go index 83f5aaf2b..5a0abf6e5 100644 --- a/post-processor/alicloud-import/post-processor.go +++ b/post-processor/alicloud-import/post-processor.go @@ -1,5 +1,5 @@ -//go:generate mapstructure-to-hcl2 -type Config -//go:generate struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown package alicloudimport diff --git a/post-processor/alicloud-import/post-processor.hcl2spec.go b/post-processor/alicloud-import/post-processor.hcl2spec.go index c1effd5bd..cefa27151 100644 --- a/post-processor/alicloud-import/post-processor.hcl2spec.go +++ b/post-processor/alicloud-import/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package alicloudimport diff --git a/post-processor/artifice/post-processor.go b/post-processor/artifice/post-processor.go index a18ee9488..71cc7339a 100644 --- a/post-processor/artifice/post-processor.go +++ b/post-processor/artifice/post-processor.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package artifice diff --git a/post-processor/artifice/post-processor.hcl2spec.go b/post-processor/artifice/post-processor.hcl2spec.go index 350c60723..d2f4f985a 100644 --- a/post-processor/artifice/post-processor.hcl2spec.go +++ b/post-processor/artifice/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package artifice diff --git a/post-processor/checksum/post-processor.go b/post-processor/checksum/post-processor.go index 63d44ae14..81d2d85a1 100644 --- a/post-processor/checksum/post-processor.go +++ b/post-processor/checksum/post-processor.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package checksum diff --git a/post-processor/checksum/post-processor.hcl2spec.go b/post-processor/checksum/post-processor.hcl2spec.go index 80955fcb5..52eed2440 100644 --- a/post-processor/checksum/post-processor.hcl2spec.go +++ b/post-processor/checksum/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package checksum diff --git a/post-processor/compress/post-processor.go b/post-processor/compress/post-processor.go index 32012533e..8214bce0c 100644 --- a/post-processor/compress/post-processor.go +++ b/post-processor/compress/post-processor.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package compress diff --git a/post-processor/compress/post-processor.hcl2spec.go b/post-processor/compress/post-processor.hcl2spec.go index bee3d6c56..00521061c 100644 --- a/post-processor/compress/post-processor.hcl2spec.go +++ b/post-processor/compress/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package compress diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index 8d814bb1d..306756a0c 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package digitaloceanimport diff --git a/post-processor/digitalocean-import/post-processor.hcl2spec.go b/post-processor/digitalocean-import/post-processor.hcl2spec.go index 3a41fe43b..7697797b6 100644 --- a/post-processor/digitalocean-import/post-processor.hcl2spec.go +++ b/post-processor/digitalocean-import/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package digitaloceanimport diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index 85e43b863..25c691756 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package googlecomputeexport diff --git a/post-processor/googlecompute-export/post-processor.hcl2spec.go b/post-processor/googlecompute-export/post-processor.hcl2spec.go index 569764682..41d58dc9f 100644 --- a/post-processor/googlecompute-export/post-processor.hcl2spec.go +++ b/post-processor/googlecompute-export/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package googlecomputeexport diff --git a/post-processor/googlecompute-import/post-processor.go b/post-processor/googlecompute-import/post-processor.go index b36e254e6..6829d0d14 100644 --- a/post-processor/googlecompute-import/post-processor.go +++ b/post-processor/googlecompute-import/post-processor.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package googlecomputeimport diff --git a/post-processor/googlecompute-import/post-processor.hcl2spec.go b/post-processor/googlecompute-import/post-processor.hcl2spec.go index af2e4e84b..69300a459 100644 --- a/post-processor/googlecompute-import/post-processor.hcl2spec.go +++ b/post-processor/googlecompute-import/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package googlecomputeimport diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 59e0664bd..2b32243f1 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -1,5 +1,5 @@ -//go:generate mapstructure-to-hcl2 -type Config -//go:generate struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown package manifest diff --git a/post-processor/manifest/post-processor.hcl2spec.go b/post-processor/manifest/post-processor.hcl2spec.go index fd50620dd..86fb26a47 100644 --- a/post-processor/manifest/post-processor.hcl2spec.go +++ b/post-processor/manifest/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package manifest diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index 5d8f0f73f..43c3aedd3 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -1,5 +1,5 @@ -//go:generate mapstructure-to-hcl2 -type Config -//go:generate struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown package ucloudimport diff --git a/post-processor/ucloud-import/post-processor.hcl2spec.go b/post-processor/ucloud-import/post-processor.hcl2spec.go index bcb5b4538..b9e0e22d6 100644 --- a/post-processor/ucloud-import/post-processor.hcl2spec.go +++ b/post-processor/ucloud-import/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package ucloudimport diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index 3594045ba..ecb9db9f9 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // vagrant_cloud implements the packersdk.PostProcessor interface and adds a // post-processor that uploads artifacts from the vagrant post-processor diff --git a/post-processor/vagrant-cloud/post-processor.hcl2spec.go b/post-processor/vagrant-cloud/post-processor.hcl2spec.go index df52bd8f7..8dce364ec 100644 --- a/post-processor/vagrant-cloud/post-processor.hcl2spec.go +++ b/post-processor/vagrant-cloud/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package vagrantcloud diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index d3df56080..eb615ea09 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // vagrant implements the packersdk.PostProcessor interface and adds a // post-processor that turns artifacts of known builders into Vagrant diff --git a/post-processor/vagrant/post-processor.hcl2spec.go b/post-processor/vagrant/post-processor.hcl2spec.go index 7ac8a8352..e5649c0d6 100644 --- a/post-processor/vagrant/post-processor.hcl2spec.go +++ b/post-processor/vagrant/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package vagrant diff --git a/post-processor/yandex-export/config.go b/post-processor/yandex-export/config.go index 5c5abb21e..5dda9fcef 100644 --- a/post-processor/yandex-export/config.go +++ b/post-processor/yandex-export/config.go @@ -1,4 +1,4 @@ -//go:generate struct-markdown +//go:generate packer-sdc struct-markdown package yandexexport import ( diff --git a/post-processor/yandex-export/post-processor.go b/post-processor/yandex-export/post-processor.go index c3dee4de4..94dcec1fd 100644 --- a/post-processor/yandex-export/post-processor.go +++ b/post-processor/yandex-export/post-processor.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package yandexexport diff --git a/post-processor/yandex-export/post-processor.hcl2spec.go b/post-processor/yandex-export/post-processor.hcl2spec.go index 296bea7aa..a21fbe0b2 100644 --- a/post-processor/yandex-export/post-processor.hcl2spec.go +++ b/post-processor/yandex-export/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package yandexexport diff --git a/post-processor/yandex-import/post-processor.go b/post-processor/yandex-import/post-processor.go index 7095739c6..e6f5e845b 100644 --- a/post-processor/yandex-import/post-processor.go +++ b/post-processor/yandex-import/post-processor.go @@ -1,5 +1,5 @@ -//go:generate struct-markdown -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package yandeximport diff --git a/post-processor/yandex-import/post-processor.hcl2spec.go b/post-processor/yandex-import/post-processor.hcl2spec.go index 21784ed56..57d51c891 100644 --- a/post-processor/yandex-import/post-processor.hcl2spec.go +++ b/post-processor/yandex-import/post-processor.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package yandeximport diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index 436b1175c..31723f750 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -1,5 +1,5 @@ -//go:generate mapstructure-to-hcl2 -type Config -//go:generate struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown package ansiblelocal diff --git a/provisioner/ansible-local/provisioner.hcl2spec.go b/provisioner/ansible-local/provisioner.hcl2spec.go index 75bc2e347..89e0a4998 100644 --- a/provisioner/ansible-local/provisioner.hcl2spec.go +++ b/provisioner/ansible-local/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package ansiblelocal diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index d997e9fa3..e6a67071c 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -1,5 +1,5 @@ -//go:generate mapstructure-to-hcl2 -type Config -//go:generate struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown package ansible diff --git a/provisioner/ansible/provisioner.hcl2spec.go b/provisioner/ansible/provisioner.hcl2spec.go index b2ea7fd85..5765c38e0 100644 --- a/provisioner/ansible/provisioner.hcl2spec.go +++ b/provisioner/ansible/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package ansible diff --git a/provisioner/azure-dtlartifact/provisioner.go b/provisioner/azure-dtlartifact/provisioner.go index 39d415257..c48873427 100644 --- a/provisioner/azure-dtlartifact/provisioner.go +++ b/provisioner/azure-dtlartifact/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,DtlArtifact,ArtifactParameter +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,DtlArtifact,ArtifactParameter package devtestlabsartifacts diff --git a/provisioner/azure-dtlartifact/provisioner.hcl2spec.go b/provisioner/azure-dtlartifact/provisioner.hcl2spec.go index dc914de5c..e966230b6 100644 --- a/provisioner/azure-dtlartifact/provisioner.hcl2spec.go +++ b/provisioner/azure-dtlartifact/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,DtlArtifact,ArtifactParameter"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package devtestlabsartifacts diff --git a/provisioner/breakpoint/provisioner.go b/provisioner/breakpoint/provisioner.go index 6219d8bc4..a708a67b1 100644 --- a/provisioner/breakpoint/provisioner.go +++ b/provisioner/breakpoint/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package breakpoint diff --git a/provisioner/breakpoint/provisioner.hcl2spec.go b/provisioner/breakpoint/provisioner.hcl2spec.go index fd66e84df..6f6806cdb 100644 --- a/provisioner/breakpoint/provisioner.hcl2spec.go +++ b/provisioner/breakpoint/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package breakpoint diff --git a/provisioner/chef-client/provisioner.go b/provisioner/chef-client/provisioner.go index a5b87889e..9f9b3402e 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // This package implements a provisioner for Packer that uses // Chef to provision the remote machine, specifically with chef-client (that is, diff --git a/provisioner/chef-client/provisioner.hcl2spec.go b/provisioner/chef-client/provisioner.hcl2spec.go index 47d7f994b..96d3eae6e 100644 --- a/provisioner/chef-client/provisioner.hcl2spec.go +++ b/provisioner/chef-client/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package chefclient diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 54e7f8f59..abe102906 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // This package implements a provisioner for Packer that uses // Chef to provision the remote machine, specifically with chef-solo (that is, diff --git a/provisioner/chef-solo/provisioner.hcl2spec.go b/provisioner/chef-solo/provisioner.hcl2spec.go index 84bb9124a..bf8dd12cf 100644 --- a/provisioner/chef-solo/provisioner.hcl2spec.go +++ b/provisioner/chef-solo/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package chefsolo diff --git a/provisioner/converge/provisioner.go b/provisioner/converge/provisioner.go index 77a3f749b..905423d03 100644 --- a/provisioner/converge/provisioner.go +++ b/provisioner/converge/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,ModuleDir +//go:generate packer-sdc mapstructure-to-hcl2 -type Config,ModuleDir // This package implements a provisioner for Packer that executes // Converge to provision a remote machine diff --git a/provisioner/converge/provisioner.hcl2spec.go b/provisioner/converge/provisioner.hcl2spec.go index 216e5dbda..6ede93963 100644 --- a/provisioner/converge/provisioner.hcl2spec.go +++ b/provisioner/converge/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,ModuleDir"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package converge diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index fedbae922..6054ddb2c 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -1,5 +1,5 @@ -//go:generate mapstructure-to-hcl2 -type Config -//go:generate struct-markdown +//go:generate packer-sdc mapstructure-to-hcl2 -type Config +//go:generate packer-sdc struct-markdown package file diff --git a/provisioner/file/provisioner.hcl2spec.go b/provisioner/file/provisioner.hcl2spec.go index 80ae6cb05..428acfea3 100644 --- a/provisioner/file/provisioner.hcl2spec.go +++ b/provisioner/file/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package file diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index c832bb6b4..a3fc0211d 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package inspec diff --git a/provisioner/inspec/provisioner.hcl2spec.go b/provisioner/inspec/provisioner.hcl2spec.go index fda139628..0940aaa5a 100644 --- a/provisioner/inspec/provisioner.hcl2spec.go +++ b/provisioner/inspec/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package inspec diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 597b9a8e0..a7ab1696e 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // This package implements a provisioner for Packer that executes powershell // scripts within the remote machine. diff --git a/provisioner/powershell/provisioner.hcl2spec.go b/provisioner/powershell/provisioner.hcl2spec.go index 811d14048..ce4a84c33 100644 --- a/provisioner/powershell/provisioner.hcl2spec.go +++ b/provisioner/powershell/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package powershell diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index 686333d4b..6ec699e4a 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // Package puppetmasterless implements a provisioner for Packer that executes // Puppet on the remote machine, configured to apply a local manifest diff --git a/provisioner/puppet-masterless/provisioner.hcl2spec.go b/provisioner/puppet-masterless/provisioner.hcl2spec.go index 58a759e08..c17611081 100644 --- a/provisioner/puppet-masterless/provisioner.hcl2spec.go +++ b/provisioner/puppet-masterless/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package puppetmasterless diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index e0e936fa7..47c5066f4 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // Package puppetserver implements a provisioner for Packer that executes // Puppet on the remote machine connecting to a Puppet master. diff --git a/provisioner/puppet-server/provisioner.hcl2spec.go b/provisioner/puppet-server/provisioner.hcl2spec.go index fa232211f..26efe907c 100644 --- a/provisioner/puppet-server/provisioner.hcl2spec.go +++ b/provisioner/puppet-server/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package puppetserver diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index 5c3d098c7..790f62a92 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // This package implements a provisioner for Packer that executes a // saltstack state within the remote machine diff --git a/provisioner/salt-masterless/provisioner.hcl2spec.go b/provisioner/salt-masterless/provisioner.hcl2spec.go index ddafc2abb..dbc660ac4 100644 --- a/provisioner/salt-masterless/provisioner.hcl2spec.go +++ b/provisioner/salt-masterless/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package saltmasterless diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 56333b15d..d9dff3596 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // This package implements a provisioner for Packer that executes // shell scripts within the remote machine. diff --git a/provisioner/shell/provisioner.hcl2spec.go b/provisioner/shell/provisioner.hcl2spec.go index 8356f6ce9..d287215b4 100644 --- a/provisioner/shell/provisioner.hcl2spec.go +++ b/provisioner/shell/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package shell diff --git a/provisioner/sleep/provisioner.go b/provisioner/sleep/provisioner.go index ea64933a2..20955fe8a 100644 --- a/provisioner/sleep/provisioner.go +++ b/provisioner/sleep/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Provisioner +//go:generate packer-sdc mapstructure-to-hcl2 -type Provisioner package sleep diff --git a/provisioner/sleep/provisioner.hcl2spec.go b/provisioner/sleep/provisioner.hcl2spec.go index 86a4f9328..2b7361912 100644 --- a/provisioner/sleep/provisioner.hcl2spec.go +++ b/provisioner/sleep/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Provisioner"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package sleep diff --git a/provisioner/windows-restart/provisioner.go b/provisioner/windows-restart/provisioner.go index b921dcd3c..c7761c7ff 100644 --- a/provisioner/windows-restart/provisioner.go +++ b/provisioner/windows-restart/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package restart diff --git a/provisioner/windows-restart/provisioner.hcl2spec.go b/provisioner/windows-restart/provisioner.hcl2spec.go index c5a2ff06b..6383c2ce0 100644 --- a/provisioner/windows-restart/provisioner.hcl2spec.go +++ b/provisioner/windows-restart/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package restart diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index b319bf9d0..bcafa2aed 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config // This package implements a provisioner for Packer that executes // shell scripts within the remote machine. diff --git a/provisioner/windows-shell/provisioner.hcl2spec.go b/provisioner/windows-shell/provisioner.hcl2spec.go index dcf67124a..abcbcee21 100644 --- a/provisioner/windows-shell/provisioner.hcl2spec.go +++ b/provisioner/windows-shell/provisioner.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package shell diff --git a/vendor/github.com/fatih/camelcase/.travis.yml b/vendor/github.com/fatih/camelcase/.travis.yml deleted file mode 100644 index 3489e3871..000000000 --- a/vendor/github.com/fatih/camelcase/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: go -go: 1.x - diff --git a/vendor/github.com/fatih/camelcase/LICENSE.md b/vendor/github.com/fatih/camelcase/LICENSE.md deleted file mode 100644 index aa4a536ca..000000000 --- a/vendor/github.com/fatih/camelcase/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Fatih Arslan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/fatih/camelcase/README.md b/vendor/github.com/fatih/camelcase/README.md deleted file mode 100644 index 105a6ae33..000000000 --- a/vendor/github.com/fatih/camelcase/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# CamelCase [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/fatih/camelcase) [![Build Status](http://img.shields.io/travis/fatih/camelcase.svg?style=flat-square)](https://travis-ci.org/fatih/camelcase) - -CamelCase is a Golang (Go) package to split the words of a camelcase type -string into a slice of words. It can be used to convert a camelcase word (lower -or upper case) into any type of word. - -## Splitting rules: - -1. If string is not valid UTF-8, return it without splitting as - single item array. -2. Assign all unicode characters into one of 4 sets: lower case - letters, upper case letters, numbers, and all other characters. -3. Iterate through characters of string, introducing splits - between adjacent characters that belong to different sets. -4. Iterate through array of split strings, and if a given string - is upper case: - * if subsequent string is lower case: - * move last character of upper case string to beginning of - lower case string - -## Install - -```bash -go get github.com/fatih/camelcase -``` - -## Usage and examples - -```go -splitted := camelcase.Split("GolangPackage") - -fmt.Println(splitted[0], splitted[1]) // prints: "Golang", "Package" -``` - -Both lower camel case and upper camel case are supported. For more info please -check: [http://en.wikipedia.org/wiki/CamelCase](http://en.wikipedia.org/wiki/CamelCase) - -Below are some example cases: - -``` -"" => [] -"lowercase" => ["lowercase"] -"Class" => ["Class"] -"MyClass" => ["My", "Class"] -"MyC" => ["My", "C"] -"HTML" => ["HTML"] -"PDFLoader" => ["PDF", "Loader"] -"AString" => ["A", "String"] -"SimpleXMLParser" => ["Simple", "XML", "Parser"] -"vimRPCPlugin" => ["vim", "RPC", "Plugin"] -"GL11Version" => ["GL", "11", "Version"] -"99Bottles" => ["99", "Bottles"] -"May5" => ["May", "5"] -"BFG9000" => ["BFG", "9000"] -"BöseÜberraschung" => ["Böse", "Überraschung"] -"Two spaces" => ["Two", " ", "spaces"] -"BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"] -``` diff --git a/vendor/github.com/fatih/camelcase/camelcase.go b/vendor/github.com/fatih/camelcase/camelcase.go deleted file mode 100644 index 02160c9a4..000000000 --- a/vendor/github.com/fatih/camelcase/camelcase.go +++ /dev/null @@ -1,90 +0,0 @@ -// Package camelcase is a micro package to split the words of a camelcase type -// string into a slice of words. -package camelcase - -import ( - "unicode" - "unicode/utf8" -) - -// Split splits the camelcase word and returns a list of words. It also -// supports digits. Both lower camel case and upper camel case are supported. -// For more info please check: http://en.wikipedia.org/wiki/CamelCase -// -// Examples -// -// "" => [""] -// "lowercase" => ["lowercase"] -// "Class" => ["Class"] -// "MyClass" => ["My", "Class"] -// "MyC" => ["My", "C"] -// "HTML" => ["HTML"] -// "PDFLoader" => ["PDF", "Loader"] -// "AString" => ["A", "String"] -// "SimpleXMLParser" => ["Simple", "XML", "Parser"] -// "vimRPCPlugin" => ["vim", "RPC", "Plugin"] -// "GL11Version" => ["GL", "11", "Version"] -// "99Bottles" => ["99", "Bottles"] -// "May5" => ["May", "5"] -// "BFG9000" => ["BFG", "9000"] -// "BöseÜberraschung" => ["Böse", "Überraschung"] -// "Two spaces" => ["Two", " ", "spaces"] -// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"] -// -// Splitting rules -// -// 1) If string is not valid UTF-8, return it without splitting as -// single item array. -// 2) Assign all unicode characters into one of 4 sets: lower case -// letters, upper case letters, numbers, and all other characters. -// 3) Iterate through characters of string, introducing splits -// between adjacent characters that belong to different sets. -// 4) Iterate through array of split strings, and if a given string -// is upper case: -// if subsequent string is lower case: -// move last character of upper case string to beginning of -// lower case string -func Split(src string) (entries []string) { - // don't split invalid utf8 - if !utf8.ValidString(src) { - return []string{src} - } - entries = []string{} - var runes [][]rune - lastClass := 0 - class := 0 - // split into fields based on class of unicode character - for _, r := range src { - switch true { - case unicode.IsLower(r): - class = 1 - case unicode.IsUpper(r): - class = 2 - case unicode.IsDigit(r): - class = 3 - default: - class = 4 - } - if class == lastClass { - runes[len(runes)-1] = append(runes[len(runes)-1], r) - } else { - runes = append(runes, []rune{r}) - } - lastClass = class - } - // handle upper case -> lower case sequences, e.g. - // "PDFL", "oader" -> "PDF", "Loader" - for i := 0; i < len(runes)-1; i++ { - if unicode.IsUpper(runes[i][0]) && unicode.IsLower(runes[i+1][0]) { - runes[i+1] = append([]rune{runes[i][len(runes[i])-1]}, runes[i+1]...) - runes[i] = runes[i][:len(runes[i])-1] - } - } - // construct []string from results - for _, s := range runes { - if len(s) > 0 { - entries = append(entries, string(s)) - } - } - return -} diff --git a/vendor/github.com/fatih/structtag/.travis.yml b/vendor/github.com/fatih/structtag/.travis.yml deleted file mode 100644 index a668283da..000000000 --- a/vendor/github.com/fatih/structtag/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: go -go: - - 1.7.x - - tip diff --git a/vendor/github.com/fatih/structtag/LICENSE b/vendor/github.com/fatih/structtag/LICENSE deleted file mode 100644 index 4fd15f9f8..000000000 --- a/vendor/github.com/fatih/structtag/LICENSE +++ /dev/null @@ -1,60 +0,0 @@ -Copyright (c) 2017, Fatih Arslan -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of structtag nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software includes some portions from Go. Go is used under the terms of the -BSD like license. - -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The Go gopher was designed by Renee French. http://reneefrench.blogspot.com/ The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: https://blog.golang.org/gopher diff --git a/vendor/github.com/fatih/structtag/README.md b/vendor/github.com/fatih/structtag/README.md deleted file mode 100644 index bc11a8b99..000000000 --- a/vendor/github.com/fatih/structtag/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# structtag [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/fatih/structtag) [![Build Status](https://travis-ci.org/fatih/structtag.svg?branch=master)](https://travis-ci.org/fatih/structtag) - -structtag provides an easy way of parsing and manipulating struct tag fields. -Please vendor the library as it might change in future versions. - -# Install - -```bash -go get github.com/fatih/structtag -``` - -# Example - -```go -package main - -import ( - "fmt" - "reflect" - "sort" - - "github.com/fatih/structtag" -) - -func main() { - type t struct { - t string `json:"foo,omitempty,string" xml:"foo"` - } - - // get field tag - tag := reflect.TypeOf(t{}).Field(0).Tag - - // ... and start using structtag by parsing the tag - tags, err := structtag.Parse(string(tag)) - if err != nil { - panic(err) - } - - // iterate over all tags - for _, t := range tags.Tags() { - fmt.Printf("tag: %+v\n", t) - } - - // get a single tag - jsonTag, err := tags.Get("json") - if err != nil { - panic(err) - } - fmt.Println(jsonTag) // Output: json:"foo,omitempty,string" - fmt.Println(jsonTag.Key) // Output: json - fmt.Println(jsonTag.Name) // Output: foo - fmt.Println(jsonTag.Options) // Output: [omitempty string] - - // change existing tag - jsonTag.Name = "foo_bar" - jsonTag.Options = nil - tags.Set(jsonTag) - - // add new tag - tags.Set(&structtag.Tag{ - Key: "hcl", - Name: "foo", - Options: []string{"squash"}, - }) - - // print the tags - fmt.Println(tags) // Output: json:"foo_bar" xml:"foo" hcl:"foo,squash" - - // sort tags according to keys - sort.Sort(tags) - fmt.Println(tags) // Output: hcl:"foo,squash" json:"foo_bar" xml:"foo" -} -``` diff --git a/vendor/github.com/fatih/structtag/tags.go b/vendor/github.com/fatih/structtag/tags.go deleted file mode 100644 index be28a9880..000000000 --- a/vendor/github.com/fatih/structtag/tags.go +++ /dev/null @@ -1,309 +0,0 @@ -package structtag - -import ( - "bytes" - "errors" - "fmt" - "strconv" - "strings" -) - -var ( - errTagSyntax = errors.New("bad syntax for struct tag pair") - errTagKeySyntax = errors.New("bad syntax for struct tag key") - errTagValueSyntax = errors.New("bad syntax for struct tag value") - - errKeyNotSet = errors.New("tag key does not exist") - errTagNotExist = errors.New("tag does not exist") - errTagKeyMismatch = errors.New("mismatch between key and tag.key") -) - -// Tags represent a set of tags from a single struct field -type Tags struct { - tags []*Tag -} - -// Tag defines a single struct's string literal tag -type Tag struct { - // Key is the tag key, such as json, xml, etc.. - // i.e: `json:"foo,omitempty". Here key is: "json" - Key string - - // Name is a part of the value - // i.e: `json:"foo,omitempty". Here name is: "foo" - Name string - - // Options is a part of the value. It contains a slice of tag options i.e: - // `json:"foo,omitempty". Here options is: ["omitempty"] - Options []string -} - -// Parse parses a single struct field tag and returns the set of tags. -func Parse(tag string) (*Tags, error) { - var tags []*Tag - - // NOTE(arslan) following code is from reflect and vet package with some - // modifications to collect all necessary information and extend it with - // usable methods - for tag != "" { - // Skip leading space. - i := 0 - for i < len(tag) && tag[i] == ' ' { - i++ - } - tag = tag[i:] - if tag == "" { - return nil, nil - } - - // Scan to colon. A space, a quote or a control character is a syntax - // error. Strictly speaking, control chars include the range [0x7f, - // 0x9f], not just [0x00, 0x1f], but in practice, we ignore the - // multi-byte control characters as it is simpler to inspect the tag's - // bytes than the tag's runes. - i = 0 - for i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '"' && tag[i] != 0x7f { - i++ - } - - if i == 0 { - return nil, errTagKeySyntax - } - if i+1 >= len(tag) || tag[i] != ':' { - return nil, errTagSyntax - } - if tag[i+1] != '"' { - return nil, errTagValueSyntax - } - - key := string(tag[:i]) - tag = tag[i+1:] - - // Scan quoted string to find value. - i = 1 - for i < len(tag) && tag[i] != '"' { - if tag[i] == '\\' { - i++ - } - i++ - } - if i >= len(tag) { - return nil, errTagValueSyntax - } - - qvalue := string(tag[:i+1]) - tag = tag[i+1:] - - value, err := strconv.Unquote(qvalue) - if err != nil { - return nil, errTagValueSyntax - } - - res := strings.Split(value, ",") - name := res[0] - options := res[1:] - if len(options) == 0 { - options = nil - } - - tags = append(tags, &Tag{ - Key: key, - Name: name, - Options: options, - }) - } - - return &Tags{ - tags: tags, - }, nil -} - -// Get returns the tag associated with the given key. If the key is present -// in the tag the value (which may be empty) is returned. Otherwise the -// returned value will be the empty string. The ok return value reports whether -// the tag exists or not (which the return value is nil). -func (t *Tags) Get(key string) (*Tag, error) { - for _, tag := range t.tags { - if tag.Key == key { - return tag, nil - } - } - - return nil, errTagNotExist -} - -// Set sets the given tag. If the tag key already exists it'll override it -func (t *Tags) Set(tag *Tag) error { - if tag.Key == "" { - return errKeyNotSet - } - - added := false - for i, tg := range t.tags { - if tg.Key == tag.Key { - added = true - t.tags[i] = tag - } - } - - if !added { - // this means this is a new tag, add it - t.tags = append(t.tags, tag) - } - - return nil -} - -// AddOptions adds the given option for the given key. If the option already -// exists it doesn't add it again. -func (t *Tags) AddOptions(key string, options ...string) { - for i, tag := range t.tags { - if tag.Key != key { - continue - } - - for _, opt := range options { - if !tag.HasOption(opt) { - tag.Options = append(tag.Options, opt) - } - } - - t.tags[i] = tag - } -} - -// DeleteOptions deletes the given options for the given key -func (t *Tags) DeleteOptions(key string, options ...string) { - hasOption := func(option string) bool { - for _, opt := range options { - if opt == option { - return true - } - } - return false - } - - for i, tag := range t.tags { - if tag.Key != key { - continue - } - - var updated []string - for _, opt := range tag.Options { - if !hasOption(opt) { - updated = append(updated, opt) - } - } - - tag.Options = updated - t.tags[i] = tag - } -} - -// Delete deletes the tag for the given keys -func (t *Tags) Delete(keys ...string) { - hasKey := func(key string) bool { - for _, k := range keys { - if k == key { - return true - } - } - return false - } - - var updated []*Tag - for _, tag := range t.tags { - if !hasKey(tag.Key) { - updated = append(updated, tag) - } - } - - t.tags = updated -} - -// Tags returns a slice of tags. The order is the original tag order unless it -// was changed. -func (t *Tags) Tags() []*Tag { - return t.tags -} - -// Tags returns a slice of tags. The order is the original tag order unless it -// was changed. -func (t *Tags) Keys() []string { - var keys []string - for _, tag := range t.tags { - keys = append(keys, tag.Key) - } - return keys -} - -// String reassembles the tags into a valid literal tag field representation -func (t *Tags) String() string { - tags := t.Tags() - if len(tags) == 0 { - return "" - } - - var buf bytes.Buffer - for i, tag := range t.Tags() { - buf.WriteString(tag.String()) - if i != len(tags)-1 { - buf.WriteString(" ") - } - } - return buf.String() -} - -// HasOption returns true if the given option is available in options -func (t *Tag) HasOption(opt string) bool { - for _, tagOpt := range t.Options { - if tagOpt == opt { - return true - } - } - - return false -} - -// Value returns the raw value of the tag, i.e. if the tag is -// `json:"foo,omitempty", the Value is "foo,omitempty" -func (t *Tag) Value() string { - options := strings.Join(t.Options, ",") - if options != "" { - return fmt.Sprintf(`%s,%s`, t.Name, options) - } - return t.Name -} - -// String reassembles the tag into a valid tag field representation -func (t *Tag) String() string { - return fmt.Sprintf(`%s:"%s"`, t.Key, t.Value()) -} - -// GoString implements the fmt.GoStringer interface -func (t *Tag) GoString() string { - template := `{ - Key: '%s', - Name: '%s', - Option: '%s', - }` - - if t.Options == nil { - return fmt.Sprintf(template, t.Key, t.Name, "nil") - } - - options := strings.Join(t.Options, ",") - return fmt.Sprintf(template, t.Key, t.Name, options) -} - -func (t *Tags) Len() int { - return len(t.tags) -} - -func (t *Tags) Less(i int, j int) bool { - return t.tags[i].Key < t.tags[j].Key -} - -func (t *Tags) Swap(i int, j int) { - t.tags[i], t.tags[j] = t.tags[j], t.tags[i] -} diff --git a/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go b/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go deleted file mode 100644 index 35bc6a412..000000000 --- a/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package packagesdriver fetches type sizes for go/packages and go/analysis. -package packagesdriver - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "go/types" - "os/exec" - "strings" - - "golang.org/x/tools/internal/gocommand" -) - -var debug = false - -func GetSizes(ctx context.Context, buildFlags, env []string, gocmdRunner *gocommand.Runner, dir string) (types.Sizes, error) { - // TODO(matloob): Clean this up. This code is mostly a copy of packages.findExternalDriver. - const toolPrefix = "GOPACKAGESDRIVER=" - tool := "" - for _, env := range env { - if val := strings.TrimPrefix(env, toolPrefix); val != env { - tool = val - } - } - - if tool == "" { - var err error - tool, err = exec.LookPath("gopackagesdriver") - if err != nil { - // We did not find the driver, so use "go list". - tool = "off" - } - } - - if tool == "off" { - inv := gocommand.Invocation{ - BuildFlags: buildFlags, - Env: env, - WorkingDir: dir, - } - return GetSizesGolist(ctx, inv, gocmdRunner) - } - - req, err := json.Marshal(struct { - Command string `json:"command"` - Env []string `json:"env"` - BuildFlags []string `json:"build_flags"` - }{ - Command: "sizes", - Env: env, - BuildFlags: buildFlags, - }) - if err != nil { - return nil, fmt.Errorf("failed to encode message to driver tool: %v", err) - } - - buf := new(bytes.Buffer) - cmd := exec.CommandContext(ctx, tool) - cmd.Dir = dir - cmd.Env = env - cmd.Stdin = bytes.NewReader(req) - cmd.Stdout = buf - cmd.Stderr = new(bytes.Buffer) - if err := cmd.Run(); err != nil { - return nil, fmt.Errorf("%v: %v: %s", tool, err, cmd.Stderr) - } - var response struct { - // Sizes, if not nil, is the types.Sizes to use when type checking. - Sizes *types.StdSizes - } - if err := json.Unmarshal(buf.Bytes(), &response); err != nil { - return nil, err - } - return response.Sizes, nil -} - -func GetSizesGolist(ctx context.Context, inv gocommand.Invocation, gocmdRunner *gocommand.Runner) (types.Sizes, error) { - inv.Verb = "list" - inv.Args = []string{"-f", "{{context.GOARCH}} {{context.Compiler}}", "--", "unsafe"} - stdout, stderr, friendlyErr, rawErr := gocmdRunner.RunRaw(ctx, inv) - var goarch, compiler string - if rawErr != nil { - if strings.Contains(rawErr.Error(), "cannot find main module") { - // User's running outside of a module. All bets are off. Get GOARCH and guess compiler is gc. - // TODO(matloob): Is this a problem in practice? - inv.Verb = "env" - inv.Args = []string{"GOARCH"} - envout, enverr := gocmdRunner.Run(ctx, inv) - if enverr != nil { - return nil, enverr - } - goarch = strings.TrimSpace(envout.String()) - compiler = "gc" - } else { - return nil, friendlyErr - } - } else { - fields := strings.Fields(stdout.String()) - if len(fields) < 2 { - return nil, fmt.Errorf("could not parse GOARCH and Go compiler in format \" \":\nstdout: <<%s>>\nstderr: <<%s>>", - stdout.String(), stderr.String()) - } - goarch = fields[0] - compiler = fields[1] - } - return types.SizesFor(compiler, goarch), nil -} diff --git a/vendor/golang.org/x/tools/go/packages/doc.go b/vendor/golang.org/x/tools/go/packages/doc.go deleted file mode 100644 index 4bfe28a51..000000000 --- a/vendor/golang.org/x/tools/go/packages/doc.go +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -Package packages loads Go packages for inspection and analysis. - -The Load function takes as input a list of patterns and return a list of Package -structs describing individual packages matched by those patterns. -The LoadMode controls the amount of detail in the loaded packages. - -Load passes most patterns directly to the underlying build tool, -but all patterns with the prefix "query=", where query is a -non-empty string of letters from [a-z], are reserved and may be -interpreted as query operators. - -Two query operators are currently supported: "file" and "pattern". - -The query "file=path/to/file.go" matches the package or packages enclosing -the Go source file path/to/file.go. For example "file=~/go/src/fmt/print.go" -might return the packages "fmt" and "fmt [fmt.test]". - -The query "pattern=string" causes "string" to be passed directly to -the underlying build tool. In most cases this is unnecessary, -but an application can use Load("pattern=" + x) as an escaping mechanism -to ensure that x is not interpreted as a query operator if it contains '='. - -All other query operators are reserved for future use and currently -cause Load to report an error. - -The Package struct provides basic information about the package, including - - - ID, a unique identifier for the package in the returned set; - - GoFiles, the names of the package's Go source files; - - Imports, a map from source import strings to the Packages they name; - - Types, the type information for the package's exported symbols; - - Syntax, the parsed syntax trees for the package's source code; and - - TypeInfo, the result of a complete type-check of the package syntax trees. - -(See the documentation for type Package for the complete list of fields -and more detailed descriptions.) - -For example, - - Load(nil, "bytes", "unicode...") - -returns four Package structs describing the standard library packages -bytes, unicode, unicode/utf16, and unicode/utf8. Note that one pattern -can match multiple packages and that a package might be matched by -multiple patterns: in general it is not possible to determine which -packages correspond to which patterns. - -Note that the list returned by Load contains only the packages matched -by the patterns. Their dependencies can be found by walking the import -graph using the Imports fields. - -The Load function can be configured by passing a pointer to a Config as -the first argument. A nil Config is equivalent to the zero Config, which -causes Load to run in LoadFiles mode, collecting minimal information. -See the documentation for type Config for details. - -As noted earlier, the Config.Mode controls the amount of detail -reported about the loaded packages. See the documentation for type LoadMode -for details. - -Most tools should pass their command-line arguments (after any flags) -uninterpreted to the loader, so that the loader can interpret them -according to the conventions of the underlying build system. -See the Example function for typical usage. - -*/ -package packages // import "golang.org/x/tools/go/packages" - -/* - -Motivation and design considerations - -The new package's design solves problems addressed by two existing -packages: go/build, which locates and describes packages, and -golang.org/x/tools/go/loader, which loads, parses and type-checks them. -The go/build.Package structure encodes too much of the 'go build' way -of organizing projects, leaving us in need of a data type that describes a -package of Go source code independent of the underlying build system. -We wanted something that works equally well with go build and vgo, and -also other build systems such as Bazel and Blaze, making it possible to -construct analysis tools that work in all these environments. -Tools such as errcheck and staticcheck were essentially unavailable to -the Go community at Google, and some of Google's internal tools for Go -are unavailable externally. -This new package provides a uniform way to obtain package metadata by -querying each of these build systems, optionally supporting their -preferred command-line notations for packages, so that tools integrate -neatly with users' build environments. The Metadata query function -executes an external query tool appropriate to the current workspace. - -Loading packages always returns the complete import graph "all the way down", -even if all you want is information about a single package, because the query -mechanisms of all the build systems we currently support ({go,vgo} list, and -blaze/bazel aspect-based query) cannot provide detailed information -about one package without visiting all its dependencies too, so there is -no additional asymptotic cost to providing transitive information. -(This property might not be true of a hypothetical 5th build system.) - -In calls to TypeCheck, all initial packages, and any package that -transitively depends on one of them, must be loaded from source. -Consider A->B->C->D->E: if A,C are initial, A,B,C must be loaded from -source; D may be loaded from export data, and E may not be loaded at all -(though it's possible that D's export data mentions it, so a -types.Package may be created for it and exposed.) - -The old loader had a feature to suppress type-checking of function -bodies on a per-package basis, primarily intended to reduce the work of -obtaining type information for imported packages. Now that imports are -satisfied by export data, the optimization no longer seems necessary. - -Despite some early attempts, the old loader did not exploit export data, -instead always using the equivalent of WholeProgram mode. This was due -to the complexity of mixing source and export data packages (now -resolved by the upward traversal mentioned above), and because export data -files were nearly always missing or stale. Now that 'go build' supports -caching, all the underlying build systems can guarantee to produce -export data in a reasonable (amortized) time. - -Test "main" packages synthesized by the build system are now reported as -first-class packages, avoiding the need for clients (such as go/ssa) to -reinvent this generation logic. - -One way in which go/packages is simpler than the old loader is in its -treatment of in-package tests. In-package tests are packages that -consist of all the files of the library under test, plus the test files. -The old loader constructed in-package tests by a two-phase process of -mutation called "augmentation": first it would construct and type check -all the ordinary library packages and type-check the packages that -depend on them; then it would add more (test) files to the package and -type-check again. This two-phase approach had four major problems: -1) in processing the tests, the loader modified the library package, - leaving no way for a client application to see both the test - package and the library package; one would mutate into the other. -2) because test files can declare additional methods on types defined in - the library portion of the package, the dispatch of method calls in - the library portion was affected by the presence of the test files. - This should have been a clue that the packages were logically - different. -3) this model of "augmentation" assumed at most one in-package test - per library package, which is true of projects using 'go build', - but not other build systems. -4) because of the two-phase nature of test processing, all packages that - import the library package had to be processed before augmentation, - forcing a "one-shot" API and preventing the client from calling Load - in several times in sequence as is now possible in WholeProgram mode. - (TypeCheck mode has a similar one-shot restriction for a different reason.) - -Early drafts of this package supported "multi-shot" operation. -Although it allowed clients to make a sequence of calls (or concurrent -calls) to Load, building up the graph of Packages incrementally, -it was of marginal value: it complicated the API -(since it allowed some options to vary across calls but not others), -it complicated the implementation, -it cannot be made to work in Types mode, as explained above, -and it was less efficient than making one combined call (when this is possible). -Among the clients we have inspected, none made multiple calls to load -but could not be easily and satisfactorily modified to make only a single call. -However, applications changes may be required. -For example, the ssadump command loads the user-specified packages -and in addition the runtime package. It is tempting to simply append -"runtime" to the user-provided list, but that does not work if the user -specified an ad-hoc package such as [a.go b.go]. -Instead, ssadump no longer requests the runtime package, -but seeks it among the dependencies of the user-specified packages, -and emits an error if it is not found. - -Overlays: The Overlay field in the Config allows providing alternate contents -for Go source files, by providing a mapping from file path to contents. -go/packages will pull in new imports added in overlay files when go/packages -is run in LoadImports mode or greater. -Overlay support for the go list driver isn't complete yet: if the file doesn't -exist on disk, it will only be recognized in an overlay if it is a non-test file -and the package would be reported even without the overlay. - -Questions & Tasks - -- Add GOARCH/GOOS? - They are not portable concepts, but could be made portable. - Our goal has been to allow users to express themselves using the conventions - of the underlying build system: if the build system honors GOARCH - during a build and during a metadata query, then so should - applications built atop that query mechanism. - Conversely, if the target architecture of the build is determined by - command-line flags, the application can pass the relevant - flags through to the build system using a command such as: - myapp -query_flag="--cpu=amd64" -query_flag="--os=darwin" - However, this approach is low-level, unwieldy, and non-portable. - GOOS and GOARCH seem important enough to warrant a dedicated option. - -- How should we handle partial failures such as a mixture of good and - malformed patterns, existing and non-existent packages, successful and - failed builds, import failures, import cycles, and so on, in a call to - Load? - -- Support bazel, blaze, and go1.10 list, not just go1.11 list. - -- Handle (and test) various partial success cases, e.g. - a mixture of good packages and: - invalid patterns - nonexistent packages - empty packages - packages with malformed package or import declarations - unreadable files - import cycles - other parse errors - type errors - Make sure we record errors at the correct place in the graph. - -- Missing packages among initial arguments are not reported. - Return bogus packages for them, like golist does. - -- "undeclared name" errors (for example) are reported out of source file - order. I suspect this is due to the breadth-first resolution now used - by go/types. Is that a bug? Discuss with gri. - -*/ diff --git a/vendor/golang.org/x/tools/go/packages/external.go b/vendor/golang.org/x/tools/go/packages/external.go deleted file mode 100644 index 8c8473fd0..000000000 --- a/vendor/golang.org/x/tools/go/packages/external.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file enables an external tool to intercept package requests. -// If the tool is present then its results are used in preference to -// the go list command. - -package packages - -import ( - "bytes" - "encoding/json" - "fmt" - "os" - "os/exec" - "strings" -) - -// The Driver Protocol -// -// The driver, given the inputs to a call to Load, returns metadata about the packages specified. -// This allows for different build systems to support go/packages by telling go/packages how the -// packages' source is organized. -// The driver is a binary, either specified by the GOPACKAGESDRIVER environment variable or in -// the path as gopackagesdriver. It's given the inputs to load in its argv. See the package -// documentation in doc.go for the full description of the patterns that need to be supported. -// A driver receives as a JSON-serialized driverRequest struct in standard input and will -// produce a JSON-serialized driverResponse (see definition in packages.go) in its standard output. - -// driverRequest is used to provide the portion of Load's Config that is needed by a driver. -type driverRequest struct { - Mode LoadMode `json:"mode"` - // Env specifies the environment the underlying build system should be run in. - Env []string `json:"env"` - // BuildFlags are flags that should be passed to the underlying build system. - BuildFlags []string `json:"build_flags"` - // Tests specifies whether the patterns should also return test packages. - Tests bool `json:"tests"` - // Overlay maps file paths (relative to the driver's working directory) to the byte contents - // of overlay files. - Overlay map[string][]byte `json:"overlay"` -} - -// findExternalDriver returns the file path of a tool that supplies -// the build system package structure, or "" if not found." -// If GOPACKAGESDRIVER is set in the environment findExternalTool returns its -// value, otherwise it searches for a binary named gopackagesdriver on the PATH. -func findExternalDriver(cfg *Config) driver { - const toolPrefix = "GOPACKAGESDRIVER=" - tool := "" - for _, env := range cfg.Env { - if val := strings.TrimPrefix(env, toolPrefix); val != env { - tool = val - } - } - if tool != "" && tool == "off" { - return nil - } - if tool == "" { - var err error - tool, err = exec.LookPath("gopackagesdriver") - if err != nil { - return nil - } - } - return func(cfg *Config, words ...string) (*driverResponse, error) { - req, err := json.Marshal(driverRequest{ - Mode: cfg.Mode, - Env: cfg.Env, - BuildFlags: cfg.BuildFlags, - Tests: cfg.Tests, - Overlay: cfg.Overlay, - }) - if err != nil { - return nil, fmt.Errorf("failed to encode message to driver tool: %v", err) - } - - buf := new(bytes.Buffer) - stderr := new(bytes.Buffer) - cmd := exec.CommandContext(cfg.Context, tool, words...) - cmd.Dir = cfg.Dir - cmd.Env = cfg.Env - cmd.Stdin = bytes.NewReader(req) - cmd.Stdout = buf - cmd.Stderr = stderr - - if err := cmd.Run(); err != nil { - return nil, fmt.Errorf("%v: %v: %s", tool, err, cmd.Stderr) - } - if len(stderr.Bytes()) != 0 && os.Getenv("GOPACKAGESPRINTDRIVERERRORS") != "" { - fmt.Fprintf(os.Stderr, "%s stderr: <<%s>>\n", cmdDebugStr(cmd, words...), stderr) - } - - var response driverResponse - if err := json.Unmarshal(buf.Bytes(), &response); err != nil { - return nil, err - } - return &response, nil - } -} diff --git a/vendor/golang.org/x/tools/go/packages/golist.go b/vendor/golang.org/x/tools/go/packages/golist.go deleted file mode 100644 index 81381fa1c..000000000 --- a/vendor/golang.org/x/tools/go/packages/golist.go +++ /dev/null @@ -1,1085 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package packages - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "go/types" - "io/ioutil" - "log" - "os" - "os/exec" - "path" - "path/filepath" - "reflect" - "sort" - "strconv" - "strings" - "sync" - "unicode" - - "golang.org/x/tools/go/internal/packagesdriver" - "golang.org/x/tools/internal/gocommand" - "golang.org/x/xerrors" -) - -// debug controls verbose logging. -var debug, _ = strconv.ParseBool(os.Getenv("GOPACKAGESDEBUG")) - -// A goTooOldError reports that the go command -// found by exec.LookPath is too old to use the new go list behavior. -type goTooOldError struct { - error -} - -// responseDeduper wraps a driverResponse, deduplicating its contents. -type responseDeduper struct { - seenRoots map[string]bool - seenPackages map[string]*Package - dr *driverResponse -} - -func newDeduper() *responseDeduper { - return &responseDeduper{ - dr: &driverResponse{}, - seenRoots: map[string]bool{}, - seenPackages: map[string]*Package{}, - } -} - -// addAll fills in r with a driverResponse. -func (r *responseDeduper) addAll(dr *driverResponse) { - for _, pkg := range dr.Packages { - r.addPackage(pkg) - } - for _, root := range dr.Roots { - r.addRoot(root) - } -} - -func (r *responseDeduper) addPackage(p *Package) { - if r.seenPackages[p.ID] != nil { - return - } - r.seenPackages[p.ID] = p - r.dr.Packages = append(r.dr.Packages, p) -} - -func (r *responseDeduper) addRoot(id string) { - if r.seenRoots[id] { - return - } - r.seenRoots[id] = true - r.dr.Roots = append(r.dr.Roots, id) -} - -type golistState struct { - cfg *Config - ctx context.Context - - envOnce sync.Once - goEnvError error - goEnv map[string]string - - rootsOnce sync.Once - rootDirsError error - rootDirs map[string]string - - goVersionOnce sync.Once - goVersionError error - goVersion int // The X in Go 1.X. - - // vendorDirs caches the (non)existence of vendor directories. - vendorDirs map[string]bool -} - -// getEnv returns Go environment variables. Only specific variables are -// populated -- computing all of them is slow. -func (state *golistState) getEnv() (map[string]string, error) { - state.envOnce.Do(func() { - var b *bytes.Buffer - b, state.goEnvError = state.invokeGo("env", "-json", "GOMOD", "GOPATH") - if state.goEnvError != nil { - return - } - - state.goEnv = make(map[string]string) - decoder := json.NewDecoder(b) - if state.goEnvError = decoder.Decode(&state.goEnv); state.goEnvError != nil { - return - } - }) - return state.goEnv, state.goEnvError -} - -// mustGetEnv is a convenience function that can be used if getEnv has already succeeded. -func (state *golistState) mustGetEnv() map[string]string { - env, err := state.getEnv() - if err != nil { - panic(fmt.Sprintf("mustGetEnv: %v", err)) - } - return env -} - -// goListDriver uses the go list command to interpret the patterns and produce -// the build system package structure. -// See driver for more details. -func goListDriver(cfg *Config, patterns ...string) (*driverResponse, error) { - // Make sure that any asynchronous go commands are killed when we return. - parentCtx := cfg.Context - if parentCtx == nil { - parentCtx = context.Background() - } - ctx, cancel := context.WithCancel(parentCtx) - defer cancel() - - response := newDeduper() - - state := &golistState{ - cfg: cfg, - ctx: ctx, - vendorDirs: map[string]bool{}, - } - - // Fill in response.Sizes asynchronously if necessary. - var sizeserr error - var sizeswg sync.WaitGroup - if cfg.Mode&NeedTypesSizes != 0 || cfg.Mode&NeedTypes != 0 { - sizeswg.Add(1) - go func() { - var sizes types.Sizes - sizes, sizeserr = packagesdriver.GetSizesGolist(ctx, state.cfgInvocation(), cfg.gocmdRunner) - // types.SizesFor always returns nil or a *types.StdSizes. - response.dr.Sizes, _ = sizes.(*types.StdSizes) - sizeswg.Done() - }() - } - - // Determine files requested in contains patterns - var containFiles []string - restPatterns := make([]string, 0, len(patterns)) - // Extract file= and other [querytype]= patterns. Report an error if querytype - // doesn't exist. -extractQueries: - for _, pattern := range patterns { - eqidx := strings.Index(pattern, "=") - if eqidx < 0 { - restPatterns = append(restPatterns, pattern) - } else { - query, value := pattern[:eqidx], pattern[eqidx+len("="):] - switch query { - case "file": - containFiles = append(containFiles, value) - case "pattern": - restPatterns = append(restPatterns, value) - case "": // not a reserved query - restPatterns = append(restPatterns, pattern) - default: - for _, rune := range query { - if rune < 'a' || rune > 'z' { // not a reserved query - restPatterns = append(restPatterns, pattern) - continue extractQueries - } - } - // Reject all other patterns containing "=" - return nil, fmt.Errorf("invalid query type %q in query pattern %q", query, pattern) - } - } - } - - // See if we have any patterns to pass through to go list. Zero initial - // patterns also requires a go list call, since it's the equivalent of - // ".". - if len(restPatterns) > 0 || len(patterns) == 0 { - dr, err := state.createDriverResponse(restPatterns...) - if err != nil { - return nil, err - } - response.addAll(dr) - } - - if len(containFiles) != 0 { - if err := state.runContainsQueries(response, containFiles); err != nil { - return nil, err - } - } - - // Only use go/packages' overlay processing if we're using a Go version - // below 1.16. Otherwise, go list handles it. - if goVersion, err := state.getGoVersion(); err == nil && goVersion < 16 { - modifiedPkgs, needPkgs, err := state.processGolistOverlay(response) - if err != nil { - return nil, err - } - - var containsCandidates []string - if len(containFiles) > 0 { - containsCandidates = append(containsCandidates, modifiedPkgs...) - containsCandidates = append(containsCandidates, needPkgs...) - } - if err := state.addNeededOverlayPackages(response, needPkgs); err != nil { - return nil, err - } - // Check candidate packages for containFiles. - if len(containFiles) > 0 { - for _, id := range containsCandidates { - pkg, ok := response.seenPackages[id] - if !ok { - response.addPackage(&Package{ - ID: id, - Errors: []Error{{ - Kind: ListError, - Msg: fmt.Sprintf("package %s expected but not seen", id), - }}, - }) - continue - } - for _, f := range containFiles { - for _, g := range pkg.GoFiles { - if sameFile(f, g) { - response.addRoot(id) - } - } - } - } - } - // Add root for any package that matches a pattern. This applies only to - // packages that are modified by overlays, since they are not added as - // roots automatically. - for _, pattern := range restPatterns { - match := matchPattern(pattern) - for _, pkgID := range modifiedPkgs { - pkg, ok := response.seenPackages[pkgID] - if !ok { - continue - } - if match(pkg.PkgPath) { - response.addRoot(pkg.ID) - } - } - } - } - - sizeswg.Wait() - if sizeserr != nil { - return nil, sizeserr - } - return response.dr, nil -} - -func (state *golistState) addNeededOverlayPackages(response *responseDeduper, pkgs []string) error { - if len(pkgs) == 0 { - return nil - } - dr, err := state.createDriverResponse(pkgs...) - if err != nil { - return err - } - for _, pkg := range dr.Packages { - response.addPackage(pkg) - } - _, needPkgs, err := state.processGolistOverlay(response) - if err != nil { - return err - } - return state.addNeededOverlayPackages(response, needPkgs) -} - -func (state *golistState) runContainsQueries(response *responseDeduper, queries []string) error { - for _, query := range queries { - // TODO(matloob): Do only one query per directory. - fdir := filepath.Dir(query) - // Pass absolute path of directory to go list so that it knows to treat it as a directory, - // not a package path. - pattern, err := filepath.Abs(fdir) - if err != nil { - return fmt.Errorf("could not determine absolute path of file= query path %q: %v", query, err) - } - dirResponse, err := state.createDriverResponse(pattern) - - // If there was an error loading the package, or the package is returned - // with errors, try to load the file as an ad-hoc package. - // Usually the error will appear in a returned package, but may not if we're - // in module mode and the ad-hoc is located outside a module. - if err != nil || len(dirResponse.Packages) == 1 && len(dirResponse.Packages[0].GoFiles) == 0 && - len(dirResponse.Packages[0].Errors) == 1 { - var queryErr error - if dirResponse, queryErr = state.adhocPackage(pattern, query); queryErr != nil { - return err // return the original error - } - } - isRoot := make(map[string]bool, len(dirResponse.Roots)) - for _, root := range dirResponse.Roots { - isRoot[root] = true - } - for _, pkg := range dirResponse.Packages { - // Add any new packages to the main set - // We don't bother to filter packages that will be dropped by the changes of roots, - // that will happen anyway during graph construction outside this function. - // Over-reporting packages is not a problem. - response.addPackage(pkg) - // if the package was not a root one, it cannot have the file - if !isRoot[pkg.ID] { - continue - } - for _, pkgFile := range pkg.GoFiles { - if filepath.Base(query) == filepath.Base(pkgFile) { - response.addRoot(pkg.ID) - break - } - } - } - } - return nil -} - -// adhocPackage attempts to load or construct an ad-hoc package for a given -// query, if the original call to the driver produced inadequate results. -func (state *golistState) adhocPackage(pattern, query string) (*driverResponse, error) { - response, err := state.createDriverResponse(query) - if err != nil { - return nil, err - } - // If we get nothing back from `go list`, - // try to make this file into its own ad-hoc package. - // TODO(rstambler): Should this check against the original response? - if len(response.Packages) == 0 { - response.Packages = append(response.Packages, &Package{ - ID: "command-line-arguments", - PkgPath: query, - GoFiles: []string{query}, - CompiledGoFiles: []string{query}, - Imports: make(map[string]*Package), - }) - response.Roots = append(response.Roots, "command-line-arguments") - } - // Handle special cases. - if len(response.Packages) == 1 { - // golang/go#33482: If this is a file= query for ad-hoc packages where - // the file only exists on an overlay, and exists outside of a module, - // add the file to the package and remove the errors. - if response.Packages[0].ID == "command-line-arguments" || - filepath.ToSlash(response.Packages[0].PkgPath) == filepath.ToSlash(query) { - if len(response.Packages[0].GoFiles) == 0 { - filename := filepath.Join(pattern, filepath.Base(query)) // avoid recomputing abspath - // TODO(matloob): check if the file is outside of a root dir? - for path := range state.cfg.Overlay { - if path == filename { - response.Packages[0].Errors = nil - response.Packages[0].GoFiles = []string{path} - response.Packages[0].CompiledGoFiles = []string{path} - } - } - } - } - } - return response, nil -} - -// Fields must match go list; -// see $GOROOT/src/cmd/go/internal/load/pkg.go. -type jsonPackage struct { - ImportPath string - Dir string - Name string - Export string - GoFiles []string - CompiledGoFiles []string - IgnoredGoFiles []string - IgnoredOtherFiles []string - CFiles []string - CgoFiles []string - CXXFiles []string - MFiles []string - HFiles []string - FFiles []string - SFiles []string - SwigFiles []string - SwigCXXFiles []string - SysoFiles []string - Imports []string - ImportMap map[string]string - Deps []string - Module *Module - TestGoFiles []string - TestImports []string - XTestGoFiles []string - XTestImports []string - ForTest string // q in a "p [q.test]" package, else "" - DepOnly bool - - Error *jsonPackageError -} - -type jsonPackageError struct { - ImportStack []string - Pos string - Err string -} - -func otherFiles(p *jsonPackage) [][]string { - return [][]string{p.CFiles, p.CXXFiles, p.MFiles, p.HFiles, p.FFiles, p.SFiles, p.SwigFiles, p.SwigCXXFiles, p.SysoFiles} -} - -// createDriverResponse uses the "go list" command to expand the pattern -// words and return a response for the specified packages. -func (state *golistState) createDriverResponse(words ...string) (*driverResponse, error) { - // go list uses the following identifiers in ImportPath and Imports: - // - // "p" -- importable package or main (command) - // "q.test" -- q's test executable - // "p [q.test]" -- variant of p as built for q's test executable - // "q_test [q.test]" -- q's external test package - // - // The packages p that are built differently for a test q.test - // are q itself, plus any helpers used by the external test q_test, - // typically including "testing" and all its dependencies. - - // Run "go list" for complete - // information on the specified packages. - buf, err := state.invokeGo("list", golistargs(state.cfg, words)...) - if err != nil { - return nil, err - } - seen := make(map[string]*jsonPackage) - pkgs := make(map[string]*Package) - additionalErrors := make(map[string][]Error) - // Decode the JSON and convert it to Package form. - var response driverResponse - for dec := json.NewDecoder(buf); dec.More(); { - p := new(jsonPackage) - if err := dec.Decode(p); err != nil { - return nil, fmt.Errorf("JSON decoding failed: %v", err) - } - - if p.ImportPath == "" { - // The documentation for go list says that “[e]rroneous packages will have - // a non-empty ImportPath”. If for some reason it comes back empty, we - // prefer to error out rather than silently discarding data or handing - // back a package without any way to refer to it. - if p.Error != nil { - return nil, Error{ - Pos: p.Error.Pos, - Msg: p.Error.Err, - } - } - return nil, fmt.Errorf("package missing import path: %+v", p) - } - - // Work around https://golang.org/issue/33157: - // go list -e, when given an absolute path, will find the package contained at - // that directory. But when no package exists there, it will return a fake package - // with an error and the ImportPath set to the absolute path provided to go list. - // Try to convert that absolute path to what its package path would be if it's - // contained in a known module or GOPATH entry. This will allow the package to be - // properly "reclaimed" when overlays are processed. - if filepath.IsAbs(p.ImportPath) && p.Error != nil { - pkgPath, ok, err := state.getPkgPath(p.ImportPath) - if err != nil { - return nil, err - } - if ok { - p.ImportPath = pkgPath - } - } - - if old, found := seen[p.ImportPath]; found { - // If one version of the package has an error, and the other doesn't, assume - // that this is a case where go list is reporting a fake dependency variant - // of the imported package: When a package tries to invalidly import another - // package, go list emits a variant of the imported package (with the same - // import path, but with an error on it, and the package will have a - // DepError set on it). An example of when this can happen is for imports of - // main packages: main packages can not be imported, but they may be - // separately matched and listed by another pattern. - // See golang.org/issue/36188 for more details. - - // The plan is that eventually, hopefully in Go 1.15, the error will be - // reported on the importing package rather than the duplicate "fake" - // version of the imported package. Once all supported versions of Go - // have the new behavior this logic can be deleted. - // TODO(matloob): delete the workaround logic once all supported versions of - // Go return the errors on the proper package. - - // There should be exactly one version of a package that doesn't have an - // error. - if old.Error == nil && p.Error == nil { - if !reflect.DeepEqual(p, old) { - return nil, fmt.Errorf("internal error: go list gives conflicting information for package %v", p.ImportPath) - } - continue - } - - // Determine if this package's error needs to be bubbled up. - // This is a hack, and we expect for go list to eventually set the error - // on the package. - if old.Error != nil { - var errkind string - if strings.Contains(old.Error.Err, "not an importable package") { - errkind = "not an importable package" - } else if strings.Contains(old.Error.Err, "use of internal package") && strings.Contains(old.Error.Err, "not allowed") { - errkind = "use of internal package not allowed" - } - if errkind != "" { - if len(old.Error.ImportStack) < 1 { - return nil, fmt.Errorf(`internal error: go list gave a %q error with empty import stack`, errkind) - } - importingPkg := old.Error.ImportStack[len(old.Error.ImportStack)-1] - if importingPkg == old.ImportPath { - // Using an older version of Go which put this package itself on top of import - // stack, instead of the importer. Look for importer in second from top - // position. - if len(old.Error.ImportStack) < 2 { - return nil, fmt.Errorf(`internal error: go list gave a %q error with an import stack without importing package`, errkind) - } - importingPkg = old.Error.ImportStack[len(old.Error.ImportStack)-2] - } - additionalErrors[importingPkg] = append(additionalErrors[importingPkg], Error{ - Pos: old.Error.Pos, - Msg: old.Error.Err, - Kind: ListError, - }) - } - } - - // Make sure that if there's a version of the package without an error, - // that's the one reported to the user. - if old.Error == nil { - continue - } - - // This package will replace the old one at the end of the loop. - } - seen[p.ImportPath] = p - - pkg := &Package{ - Name: p.Name, - ID: p.ImportPath, - GoFiles: absJoin(p.Dir, p.GoFiles, p.CgoFiles), - CompiledGoFiles: absJoin(p.Dir, p.CompiledGoFiles), - OtherFiles: absJoin(p.Dir, otherFiles(p)...), - IgnoredFiles: absJoin(p.Dir, p.IgnoredGoFiles, p.IgnoredOtherFiles), - forTest: p.ForTest, - Module: p.Module, - } - - if (state.cfg.Mode&typecheckCgo) != 0 && len(p.CgoFiles) != 0 { - if len(p.CompiledGoFiles) > len(p.GoFiles) { - // We need the cgo definitions, which are in the first - // CompiledGoFile after the non-cgo ones. This is a hack but there - // isn't currently a better way to find it. We also need the pure - // Go files and unprocessed cgo files, all of which are already - // in pkg.GoFiles. - cgoTypes := p.CompiledGoFiles[len(p.GoFiles)] - pkg.CompiledGoFiles = append([]string{cgoTypes}, pkg.GoFiles...) - } else { - // golang/go#38990: go list silently fails to do cgo processing - pkg.CompiledGoFiles = nil - pkg.Errors = append(pkg.Errors, Error{ - Msg: "go list failed to return CompiledGoFiles; https://golang.org/issue/38990?", - Kind: ListError, - }) - } - } - - // Work around https://golang.org/issue/28749: - // cmd/go puts assembly, C, and C++ files in CompiledGoFiles. - // Filter out any elements of CompiledGoFiles that are also in OtherFiles. - // We have to keep this workaround in place until go1.12 is a distant memory. - if len(pkg.OtherFiles) > 0 { - other := make(map[string]bool, len(pkg.OtherFiles)) - for _, f := range pkg.OtherFiles { - other[f] = true - } - - out := pkg.CompiledGoFiles[:0] - for _, f := range pkg.CompiledGoFiles { - if other[f] { - continue - } - out = append(out, f) - } - pkg.CompiledGoFiles = out - } - - // Extract the PkgPath from the package's ID. - if i := strings.IndexByte(pkg.ID, ' '); i >= 0 { - pkg.PkgPath = pkg.ID[:i] - } else { - pkg.PkgPath = pkg.ID - } - - if pkg.PkgPath == "unsafe" { - pkg.GoFiles = nil // ignore fake unsafe.go file - } - - // Assume go list emits only absolute paths for Dir. - if p.Dir != "" && !filepath.IsAbs(p.Dir) { - log.Fatalf("internal error: go list returned non-absolute Package.Dir: %s", p.Dir) - } - - if p.Export != "" && !filepath.IsAbs(p.Export) { - pkg.ExportFile = filepath.Join(p.Dir, p.Export) - } else { - pkg.ExportFile = p.Export - } - - // imports - // - // Imports contains the IDs of all imported packages. - // ImportsMap records (path, ID) only where they differ. - ids := make(map[string]bool) - for _, id := range p.Imports { - ids[id] = true - } - pkg.Imports = make(map[string]*Package) - for path, id := range p.ImportMap { - pkg.Imports[path] = &Package{ID: id} // non-identity import - delete(ids, id) - } - for id := range ids { - if id == "C" { - continue - } - - pkg.Imports[id] = &Package{ID: id} // identity import - } - if !p.DepOnly { - response.Roots = append(response.Roots, pkg.ID) - } - - // Work around for pre-go.1.11 versions of go list. - // TODO(matloob): they should be handled by the fallback. - // Can we delete this? - if len(pkg.CompiledGoFiles) == 0 { - pkg.CompiledGoFiles = pkg.GoFiles - } - - // Temporary work-around for golang/go#39986. Parse filenames out of - // error messages. This happens if there are unrecoverable syntax - // errors in the source, so we can't match on a specific error message. - if err := p.Error; err != nil && state.shouldAddFilenameFromError(p) { - addFilenameFromPos := func(pos string) bool { - split := strings.Split(pos, ":") - if len(split) < 1 { - return false - } - filename := strings.TrimSpace(split[0]) - if filename == "" { - return false - } - if !filepath.IsAbs(filename) { - filename = filepath.Join(state.cfg.Dir, filename) - } - info, _ := os.Stat(filename) - if info == nil { - return false - } - pkg.CompiledGoFiles = append(pkg.CompiledGoFiles, filename) - pkg.GoFiles = append(pkg.GoFiles, filename) - return true - } - found := addFilenameFromPos(err.Pos) - // In some cases, go list only reports the error position in the - // error text, not the error position. One such case is when the - // file's package name is a keyword (see golang.org/issue/39763). - if !found { - addFilenameFromPos(err.Err) - } - } - - if p.Error != nil { - msg := strings.TrimSpace(p.Error.Err) // Trim to work around golang.org/issue/32363. - // Address golang.org/issue/35964 by appending import stack to error message. - if msg == "import cycle not allowed" && len(p.Error.ImportStack) != 0 { - msg += fmt.Sprintf(": import stack: %v", p.Error.ImportStack) - } - pkg.Errors = append(pkg.Errors, Error{ - Pos: p.Error.Pos, - Msg: msg, - Kind: ListError, - }) - } - - pkgs[pkg.ID] = pkg - } - - for id, errs := range additionalErrors { - if p, ok := pkgs[id]; ok { - p.Errors = append(p.Errors, errs...) - } - } - for _, pkg := range pkgs { - response.Packages = append(response.Packages, pkg) - } - sort.Slice(response.Packages, func(i, j int) bool { return response.Packages[i].ID < response.Packages[j].ID }) - - return &response, nil -} - -func (state *golistState) shouldAddFilenameFromError(p *jsonPackage) bool { - if len(p.GoFiles) > 0 || len(p.CompiledGoFiles) > 0 { - return false - } - - goV, err := state.getGoVersion() - if err != nil { - return false - } - - // On Go 1.14 and earlier, only add filenames from errors if the import stack is empty. - // The import stack behaves differently for these versions than newer Go versions. - if goV < 15 { - return len(p.Error.ImportStack) == 0 - } - - // On Go 1.15 and later, only parse filenames out of error if there's no import stack, - // or the current package is at the top of the import stack. This is not guaranteed - // to work perfectly, but should avoid some cases where files in errors don't belong to this - // package. - return len(p.Error.ImportStack) == 0 || p.Error.ImportStack[len(p.Error.ImportStack)-1] == p.ImportPath -} - -func (state *golistState) getGoVersion() (int, error) { - state.goVersionOnce.Do(func() { - state.goVersion, state.goVersionError = gocommand.GoVersion(state.ctx, state.cfgInvocation(), state.cfg.gocmdRunner) - }) - return state.goVersion, state.goVersionError -} - -// getPkgPath finds the package path of a directory if it's relative to a root -// directory. -func (state *golistState) getPkgPath(dir string) (string, bool, error) { - absDir, err := filepath.Abs(dir) - if err != nil { - return "", false, err - } - roots, err := state.determineRootDirs() - if err != nil { - return "", false, err - } - - for rdir, rpath := range roots { - // Make sure that the directory is in the module, - // to avoid creating a path relative to another module. - if !strings.HasPrefix(absDir, rdir) { - continue - } - // TODO(matloob): This doesn't properly handle symlinks. - r, err := filepath.Rel(rdir, dir) - if err != nil { - continue - } - if rpath != "" { - // We choose only one root even though the directory even it can belong in multiple modules - // or GOPATH entries. This is okay because we only need to work with absolute dirs when a - // file is missing from disk, for instance when gopls calls go/packages in an overlay. - // Once the file is saved, gopls, or the next invocation of the tool will get the correct - // result straight from golist. - // TODO(matloob): Implement module tiebreaking? - return path.Join(rpath, filepath.ToSlash(r)), true, nil - } - return filepath.ToSlash(r), true, nil - } - return "", false, nil -} - -// absJoin absolutizes and flattens the lists of files. -func absJoin(dir string, fileses ...[]string) (res []string) { - for _, files := range fileses { - for _, file := range files { - if !filepath.IsAbs(file) { - file = filepath.Join(dir, file) - } - res = append(res, file) - } - } - return res -} - -func golistargs(cfg *Config, words []string) []string { - const findFlags = NeedImports | NeedTypes | NeedSyntax | NeedTypesInfo - fullargs := []string{ - "-e", "-json", - fmt.Sprintf("-compiled=%t", cfg.Mode&(NeedCompiledGoFiles|NeedSyntax|NeedTypes|NeedTypesInfo|NeedTypesSizes) != 0), - fmt.Sprintf("-test=%t", cfg.Tests), - fmt.Sprintf("-export=%t", usesExportData(cfg)), - fmt.Sprintf("-deps=%t", cfg.Mode&NeedImports != 0), - // go list doesn't let you pass -test and -find together, - // probably because you'd just get the TestMain. - fmt.Sprintf("-find=%t", !cfg.Tests && cfg.Mode&findFlags == 0), - } - fullargs = append(fullargs, cfg.BuildFlags...) - fullargs = append(fullargs, "--") - fullargs = append(fullargs, words...) - return fullargs -} - -// cfgInvocation returns an Invocation that reflects cfg's settings. -func (state *golistState) cfgInvocation() gocommand.Invocation { - cfg := state.cfg - return gocommand.Invocation{ - BuildFlags: cfg.BuildFlags, - ModFile: cfg.modFile, - ModFlag: cfg.modFlag, - Env: cfg.Env, - Logf: cfg.Logf, - WorkingDir: cfg.Dir, - } -} - -// invokeGo returns the stdout of a go command invocation. -func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer, error) { - cfg := state.cfg - - inv := state.cfgInvocation() - - // For Go versions 1.16 and above, `go list` accepts overlays directly via - // the -overlay flag. Set it, if it's available. - // - // The check for "list" is not necessarily required, but we should avoid - // getting the go version if possible. - if verb == "list" { - goVersion, err := state.getGoVersion() - if err != nil { - return nil, err - } - if goVersion >= 16 { - filename, cleanup, err := state.writeOverlays() - if err != nil { - return nil, err - } - defer cleanup() - inv.Overlay = filename - } - } - inv.Verb = verb - inv.Args = args - gocmdRunner := cfg.gocmdRunner - if gocmdRunner == nil { - gocmdRunner = &gocommand.Runner{} - } - stdout, stderr, _, err := gocmdRunner.RunRaw(cfg.Context, inv) - if err != nil { - // Check for 'go' executable not being found. - if ee, ok := err.(*exec.Error); ok && ee.Err == exec.ErrNotFound { - return nil, fmt.Errorf("'go list' driver requires 'go', but %s", exec.ErrNotFound) - } - - exitErr, ok := err.(*exec.ExitError) - if !ok { - // Catastrophic error: - // - context cancellation - return nil, xerrors.Errorf("couldn't run 'go': %w", err) - } - - // Old go version? - if strings.Contains(stderr.String(), "flag provided but not defined") { - return nil, goTooOldError{fmt.Errorf("unsupported version of go: %s: %s", exitErr, stderr)} - } - - // Related to #24854 - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "unexpected directory layout") { - return nil, fmt.Errorf("%s", stderr.String()) - } - - // Is there an error running the C compiler in cgo? This will be reported in the "Error" field - // and should be suppressed by go list -e. - // - // This condition is not perfect yet because the error message can include other error messages than runtime/cgo. - isPkgPathRune := func(r rune) bool { - // From https://golang.org/ref/spec#Import_declarations: - // Implementation restriction: A compiler may restrict ImportPaths to non-empty strings - // using only characters belonging to Unicode's L, M, N, P, and S general categories - // (the Graphic characters without spaces) and may also exclude the - // characters !"#$%&'()*,:;<=>?[\]^`{|} and the Unicode replacement character U+FFFD. - return unicode.IsOneOf([]*unicode.RangeTable{unicode.L, unicode.M, unicode.N, unicode.P, unicode.S}, r) && - !strings.ContainsRune("!\"#$%&'()*,:;<=>?[\\]^`{|}\uFFFD", r) - } - if len(stderr.String()) > 0 && strings.HasPrefix(stderr.String(), "# ") { - msg := stderr.String()[len("# "):] - if strings.HasPrefix(strings.TrimLeftFunc(msg, isPkgPathRune), "\n") { - return stdout, nil - } - // Treat pkg-config errors as a special case (golang.org/issue/36770). - if strings.HasPrefix(msg, "pkg-config") { - return stdout, nil - } - } - - // This error only appears in stderr. See golang.org/cl/166398 for a fix in go list to show - // the error in the Err section of stdout in case -e option is provided. - // This fix is provided for backwards compatibility. - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "named files must be .go files") { - output := fmt.Sprintf(`{"ImportPath": "command-line-arguments","Incomplete": true,"Error": {"Pos": "","Err": %q}}`, - strings.Trim(stderr.String(), "\n")) - return bytes.NewBufferString(output), nil - } - - // Similar to the previous error, but currently lacks a fix in Go. - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "named files must all be in one directory") { - output := fmt.Sprintf(`{"ImportPath": "command-line-arguments","Incomplete": true,"Error": {"Pos": "","Err": %q}}`, - strings.Trim(stderr.String(), "\n")) - return bytes.NewBufferString(output), nil - } - - // Backwards compatibility for Go 1.11 because 1.12 and 1.13 put the directory in the ImportPath. - // If the package doesn't exist, put the absolute path of the directory into the error message, - // as Go 1.13 list does. - const noSuchDirectory = "no such directory" - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), noSuchDirectory) { - errstr := stderr.String() - abspath := strings.TrimSpace(errstr[strings.Index(errstr, noSuchDirectory)+len(noSuchDirectory):]) - output := fmt.Sprintf(`{"ImportPath": %q,"Incomplete": true,"Error": {"Pos": "","Err": %q}}`, - abspath, strings.Trim(stderr.String(), "\n")) - return bytes.NewBufferString(output), nil - } - - // Workaround for #29280: go list -e has incorrect behavior when an ad-hoc package doesn't exist. - // Note that the error message we look for in this case is different that the one looked for above. - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "no such file or directory") { - output := fmt.Sprintf(`{"ImportPath": "command-line-arguments","Incomplete": true,"Error": {"Pos": "","Err": %q}}`, - strings.Trim(stderr.String(), "\n")) - return bytes.NewBufferString(output), nil - } - - // Workaround for #34273. go list -e with GO111MODULE=on has incorrect behavior when listing a - // directory outside any module. - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "outside available modules") { - output := fmt.Sprintf(`{"ImportPath": %q,"Incomplete": true,"Error": {"Pos": "","Err": %q}}`, - // TODO(matloob): command-line-arguments isn't correct here. - "command-line-arguments", strings.Trim(stderr.String(), "\n")) - return bytes.NewBufferString(output), nil - } - - // Another variation of the previous error - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "outside module root") { - output := fmt.Sprintf(`{"ImportPath": %q,"Incomplete": true,"Error": {"Pos": "","Err": %q}}`, - // TODO(matloob): command-line-arguments isn't correct here. - "command-line-arguments", strings.Trim(stderr.String(), "\n")) - return bytes.NewBufferString(output), nil - } - - // Workaround for an instance of golang.org/issue/26755: go list -e will return a non-zero exit - // status if there's a dependency on a package that doesn't exist. But it should return - // a zero exit status and set an error on that package. - if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "no Go files in") { - // Don't clobber stdout if `go list` actually returned something. - if len(stdout.String()) > 0 { - return stdout, nil - } - // try to extract package name from string - stderrStr := stderr.String() - var importPath string - colon := strings.Index(stderrStr, ":") - if colon > 0 && strings.HasPrefix(stderrStr, "go build ") { - importPath = stderrStr[len("go build "):colon] - } - output := fmt.Sprintf(`{"ImportPath": %q,"Incomplete": true,"Error": {"Pos": "","Err": %q}}`, - importPath, strings.Trim(stderrStr, "\n")) - return bytes.NewBufferString(output), nil - } - - // Export mode entails a build. - // If that build fails, errors appear on stderr - // (despite the -e flag) and the Export field is blank. - // Do not fail in that case. - // The same is true if an ad-hoc package given to go list doesn't exist. - // TODO(matloob): Remove these once we can depend on go list to exit with a zero status with -e even when - // packages don't exist or a build fails. - if !usesExportData(cfg) && !containsGoFile(args) { - return nil, fmt.Errorf("go %v: %s: %s", args, exitErr, stderr) - } - } - return stdout, nil -} - -// OverlayJSON is the format overlay files are expected to be in. -// The Replace map maps from overlaid paths to replacement paths: -// the Go command will forward all reads trying to open -// each overlaid path to its replacement path, or consider the overlaid -// path not to exist if the replacement path is empty. -// -// From golang/go#39958. -type OverlayJSON struct { - Replace map[string]string `json:"replace,omitempty"` -} - -// writeOverlays writes out files for go list's -overlay flag, as described -// above. -func (state *golistState) writeOverlays() (filename string, cleanup func(), err error) { - // Do nothing if there are no overlays in the config. - if len(state.cfg.Overlay) == 0 { - return "", func() {}, nil - } - dir, err := ioutil.TempDir("", "gopackages-*") - if err != nil { - return "", nil, err - } - // The caller must clean up this directory, unless this function returns an - // error. - cleanup = func() { - os.RemoveAll(dir) - } - defer func() { - if err != nil { - cleanup() - } - }() - overlays := map[string]string{} - for k, v := range state.cfg.Overlay { - // Create a unique filename for the overlaid files, to avoid - // creating nested directories. - noSeparator := strings.Join(strings.Split(filepath.ToSlash(k), "/"), "") - f, err := ioutil.TempFile(dir, fmt.Sprintf("*-%s", noSeparator)) - if err != nil { - return "", func() {}, err - } - if _, err := f.Write(v); err != nil { - return "", func() {}, err - } - if err := f.Close(); err != nil { - return "", func() {}, err - } - overlays[k] = f.Name() - } - b, err := json.Marshal(OverlayJSON{Replace: overlays}) - if err != nil { - return "", func() {}, err - } - // Write out the overlay file that contains the filepath mappings. - filename = filepath.Join(dir, "overlay.json") - if err := ioutil.WriteFile(filename, b, 0665); err != nil { - return "", func() {}, err - } - return filename, cleanup, nil -} - -func containsGoFile(s []string) bool { - for _, f := range s { - if strings.HasSuffix(f, ".go") { - return true - } - } - return false -} - -func cmdDebugStr(cmd *exec.Cmd, args ...string) string { - env := make(map[string]string) - for _, kv := range cmd.Env { - split := strings.Split(kv, "=") - k, v := split[0], split[1] - env[k] = v - } - var quotedArgs []string - for _, arg := range args { - quotedArgs = append(quotedArgs, strconv.Quote(arg)) - } - - return fmt.Sprintf("GOROOT=%v GOPATH=%v GO111MODULE=%v PWD=%v go %s", env["GOROOT"], env["GOPATH"], env["GO111MODULE"], env["PWD"], strings.Join(quotedArgs, " ")) -} diff --git a/vendor/golang.org/x/tools/go/packages/golist_overlay.go b/vendor/golang.org/x/tools/go/packages/golist_overlay.go deleted file mode 100644 index de2c1dc57..000000000 --- a/vendor/golang.org/x/tools/go/packages/golist_overlay.go +++ /dev/null @@ -1,572 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package packages - -import ( - "encoding/json" - "fmt" - "go/parser" - "go/token" - "log" - "os" - "path/filepath" - "regexp" - "sort" - "strconv" - "strings" - - "golang.org/x/tools/internal/gocommand" -) - -// processGolistOverlay provides rudimentary support for adding -// files that don't exist on disk to an overlay. The results can be -// sometimes incorrect. -// TODO(matloob): Handle unsupported cases, including the following: -// - determining the correct package to add given a new import path -func (state *golistState) processGolistOverlay(response *responseDeduper) (modifiedPkgs, needPkgs []string, err error) { - havePkgs := make(map[string]string) // importPath -> non-test package ID - needPkgsSet := make(map[string]bool) - modifiedPkgsSet := make(map[string]bool) - - pkgOfDir := make(map[string][]*Package) - for _, pkg := range response.dr.Packages { - // This is an approximation of import path to id. This can be - // wrong for tests, vendored packages, and a number of other cases. - havePkgs[pkg.PkgPath] = pkg.ID - x := commonDir(pkg.GoFiles) - if x != "" { - pkgOfDir[x] = append(pkgOfDir[x], pkg) - } - } - - // If no new imports are added, it is safe to avoid loading any needPkgs. - // Otherwise, it's hard to tell which package is actually being loaded - // (due to vendoring) and whether any modified package will show up - // in the transitive set of dependencies (because new imports are added, - // potentially modifying the transitive set of dependencies). - var overlayAddsImports bool - - // If both a package and its test package are created by the overlay, we - // need the real package first. Process all non-test files before test - // files, and make the whole process deterministic while we're at it. - var overlayFiles []string - for opath := range state.cfg.Overlay { - overlayFiles = append(overlayFiles, opath) - } - sort.Slice(overlayFiles, func(i, j int) bool { - iTest := strings.HasSuffix(overlayFiles[i], "_test.go") - jTest := strings.HasSuffix(overlayFiles[j], "_test.go") - if iTest != jTest { - return !iTest // non-tests are before tests. - } - return overlayFiles[i] < overlayFiles[j] - }) - for _, opath := range overlayFiles { - contents := state.cfg.Overlay[opath] - base := filepath.Base(opath) - dir := filepath.Dir(opath) - var pkg *Package // if opath belongs to both a package and its test variant, this will be the test variant - var testVariantOf *Package // if opath is a test file, this is the package it is testing - var fileExists bool - isTestFile := strings.HasSuffix(opath, "_test.go") - pkgName, ok := extractPackageName(opath, contents) - if !ok { - // Don't bother adding a file that doesn't even have a parsable package statement - // to the overlay. - continue - } - // If all the overlay files belong to a different package, change the - // package name to that package. - maybeFixPackageName(pkgName, isTestFile, pkgOfDir[dir]) - nextPackage: - for _, p := range response.dr.Packages { - if pkgName != p.Name && p.ID != "command-line-arguments" { - continue - } - for _, f := range p.GoFiles { - if !sameFile(filepath.Dir(f), dir) { - continue - } - // Make sure to capture information on the package's test variant, if needed. - if isTestFile && !hasTestFiles(p) { - // TODO(matloob): Are there packages other than the 'production' variant - // of a package that this can match? This shouldn't match the test main package - // because the file is generated in another directory. - testVariantOf = p - continue nextPackage - } else if !isTestFile && hasTestFiles(p) { - // We're examining a test variant, but the overlaid file is - // a non-test file. Because the overlay implementation - // (currently) only adds a file to one package, skip this - // package, so that we can add the file to the production - // variant of the package. (https://golang.org/issue/36857 - // tracks handling overlays on both the production and test - // variant of a package). - continue nextPackage - } - if pkg != nil && p != pkg && pkg.PkgPath == p.PkgPath { - // We have already seen the production version of the - // for which p is a test variant. - if hasTestFiles(p) { - testVariantOf = pkg - } - } - pkg = p - if filepath.Base(f) == base { - fileExists = true - } - } - } - // The overlay could have included an entirely new package or an - // ad-hoc package. An ad-hoc package is one that we have manually - // constructed from inadequate `go list` results for a file= query. - // It will have the ID command-line-arguments. - if pkg == nil || pkg.ID == "command-line-arguments" { - // Try to find the module or gopath dir the file is contained in. - // Then for modules, add the module opath to the beginning. - pkgPath, ok, err := state.getPkgPath(dir) - if err != nil { - return nil, nil, err - } - if !ok { - break - } - var forTest string // only set for x tests - isXTest := strings.HasSuffix(pkgName, "_test") - if isXTest { - forTest = pkgPath - pkgPath += "_test" - } - id := pkgPath - if isTestFile { - if isXTest { - id = fmt.Sprintf("%s [%s.test]", pkgPath, forTest) - } else { - id = fmt.Sprintf("%s [%s.test]", pkgPath, pkgPath) - } - } - if pkg != nil { - // TODO(rstambler): We should change the package's path and ID - // here. The only issue is that this messes with the roots. - } else { - // Try to reclaim a package with the same ID, if it exists in the response. - for _, p := range response.dr.Packages { - if reclaimPackage(p, id, opath, contents) { - pkg = p - break - } - } - // Otherwise, create a new package. - if pkg == nil { - pkg = &Package{ - PkgPath: pkgPath, - ID: id, - Name: pkgName, - Imports: make(map[string]*Package), - } - response.addPackage(pkg) - havePkgs[pkg.PkgPath] = id - // Add the production package's sources for a test variant. - if isTestFile && !isXTest && testVariantOf != nil { - pkg.GoFiles = append(pkg.GoFiles, testVariantOf.GoFiles...) - pkg.CompiledGoFiles = append(pkg.CompiledGoFiles, testVariantOf.CompiledGoFiles...) - // Add the package under test and its imports to the test variant. - pkg.forTest = testVariantOf.PkgPath - for k, v := range testVariantOf.Imports { - pkg.Imports[k] = &Package{ID: v.ID} - } - } - if isXTest { - pkg.forTest = forTest - } - } - } - } - if !fileExists { - pkg.GoFiles = append(pkg.GoFiles, opath) - // TODO(matloob): Adding the file to CompiledGoFiles can exhibit the wrong behavior - // if the file will be ignored due to its build tags. - pkg.CompiledGoFiles = append(pkg.CompiledGoFiles, opath) - modifiedPkgsSet[pkg.ID] = true - } - imports, err := extractImports(opath, contents) - if err != nil { - // Let the parser or type checker report errors later. - continue - } - for _, imp := range imports { - // TODO(rstambler): If the package is an x test and the import has - // a test variant, make sure to replace it. - if _, found := pkg.Imports[imp]; found { - continue - } - overlayAddsImports = true - id, ok := havePkgs[imp] - if !ok { - var err error - id, err = state.resolveImport(dir, imp) - if err != nil { - return nil, nil, err - } - } - pkg.Imports[imp] = &Package{ID: id} - // Add dependencies to the non-test variant version of this package as well. - if testVariantOf != nil { - testVariantOf.Imports[imp] = &Package{ID: id} - } - } - } - - // toPkgPath guesses the package path given the id. - toPkgPath := func(sourceDir, id string) (string, error) { - if i := strings.IndexByte(id, ' '); i >= 0 { - return state.resolveImport(sourceDir, id[:i]) - } - return state.resolveImport(sourceDir, id) - } - - // Now that new packages have been created, do another pass to determine - // the new set of missing packages. - for _, pkg := range response.dr.Packages { - for _, imp := range pkg.Imports { - if len(pkg.GoFiles) == 0 { - return nil, nil, fmt.Errorf("cannot resolve imports for package %q with no Go files", pkg.PkgPath) - } - pkgPath, err := toPkgPath(filepath.Dir(pkg.GoFiles[0]), imp.ID) - if err != nil { - return nil, nil, err - } - if _, ok := havePkgs[pkgPath]; !ok { - needPkgsSet[pkgPath] = true - } - } - } - - if overlayAddsImports { - needPkgs = make([]string, 0, len(needPkgsSet)) - for pkg := range needPkgsSet { - needPkgs = append(needPkgs, pkg) - } - } - modifiedPkgs = make([]string, 0, len(modifiedPkgsSet)) - for pkg := range modifiedPkgsSet { - modifiedPkgs = append(modifiedPkgs, pkg) - } - return modifiedPkgs, needPkgs, err -} - -// resolveImport finds the ID of a package given its import path. -// In particular, it will find the right vendored copy when in GOPATH mode. -func (state *golistState) resolveImport(sourceDir, importPath string) (string, error) { - env, err := state.getEnv() - if err != nil { - return "", err - } - if env["GOMOD"] != "" { - return importPath, nil - } - - searchDir := sourceDir - for { - vendorDir := filepath.Join(searchDir, "vendor") - exists, ok := state.vendorDirs[vendorDir] - if !ok { - info, err := os.Stat(vendorDir) - exists = err == nil && info.IsDir() - state.vendorDirs[vendorDir] = exists - } - - if exists { - vendoredPath := filepath.Join(vendorDir, importPath) - if info, err := os.Stat(vendoredPath); err == nil && info.IsDir() { - // We should probably check for .go files here, but shame on anyone who fools us. - path, ok, err := state.getPkgPath(vendoredPath) - if err != nil { - return "", err - } - if ok { - return path, nil - } - } - } - - // We know we've hit the top of the filesystem when we Dir / and get /, - // or C:\ and get C:\, etc. - next := filepath.Dir(searchDir) - if next == searchDir { - break - } - searchDir = next - } - return importPath, nil -} - -func hasTestFiles(p *Package) bool { - for _, f := range p.GoFiles { - if strings.HasSuffix(f, "_test.go") { - return true - } - } - return false -} - -// determineRootDirs returns a mapping from absolute directories that could -// contain code to their corresponding import path prefixes. -func (state *golistState) determineRootDirs() (map[string]string, error) { - env, err := state.getEnv() - if err != nil { - return nil, err - } - if env["GOMOD"] != "" { - state.rootsOnce.Do(func() { - state.rootDirs, state.rootDirsError = state.determineRootDirsModules() - }) - } else { - state.rootsOnce.Do(func() { - state.rootDirs, state.rootDirsError = state.determineRootDirsGOPATH() - }) - } - return state.rootDirs, state.rootDirsError -} - -func (state *golistState) determineRootDirsModules() (map[string]string, error) { - // List all of the modules--the first will be the directory for the main - // module. Any replaced modules will also need to be treated as roots. - // Editing files in the module cache isn't a great idea, so we don't - // plan to ever support that. - out, err := state.invokeGo("list", "-m", "-json", "all") - if err != nil { - // 'go list all' will fail if we're outside of a module and - // GO111MODULE=on. Try falling back without 'all'. - var innerErr error - out, innerErr = state.invokeGo("list", "-m", "-json") - if innerErr != nil { - return nil, err - } - } - roots := map[string]string{} - modules := map[string]string{} - var i int - for dec := json.NewDecoder(out); dec.More(); { - mod := new(gocommand.ModuleJSON) - if err := dec.Decode(mod); err != nil { - return nil, err - } - if mod.Dir != "" && mod.Path != "" { - // This is a valid module; add it to the map. - absDir, err := filepath.Abs(mod.Dir) - if err != nil { - return nil, err - } - modules[absDir] = mod.Path - // The first result is the main module. - if i == 0 || mod.Replace != nil && mod.Replace.Path != "" { - roots[absDir] = mod.Path - } - } - i++ - } - return roots, nil -} - -func (state *golistState) determineRootDirsGOPATH() (map[string]string, error) { - m := map[string]string{} - for _, dir := range filepath.SplitList(state.mustGetEnv()["GOPATH"]) { - absDir, err := filepath.Abs(dir) - if err != nil { - return nil, err - } - m[filepath.Join(absDir, "src")] = "" - } - return m, nil -} - -func extractImports(filename string, contents []byte) ([]string, error) { - f, err := parser.ParseFile(token.NewFileSet(), filename, contents, parser.ImportsOnly) // TODO(matloob): reuse fileset? - if err != nil { - return nil, err - } - var res []string - for _, imp := range f.Imports { - quotedPath := imp.Path.Value - path, err := strconv.Unquote(quotedPath) - if err != nil { - return nil, err - } - res = append(res, path) - } - return res, nil -} - -// reclaimPackage attempts to reuse a package that failed to load in an overlay. -// -// If the package has errors and has no Name, GoFiles, or Imports, -// then it's possible that it doesn't yet exist on disk. -func reclaimPackage(pkg *Package, id string, filename string, contents []byte) bool { - // TODO(rstambler): Check the message of the actual error? - // It differs between $GOPATH and module mode. - if pkg.ID != id { - return false - } - if len(pkg.Errors) != 1 { - return false - } - if pkg.Name != "" || pkg.ExportFile != "" { - return false - } - if len(pkg.GoFiles) > 0 || len(pkg.CompiledGoFiles) > 0 || len(pkg.OtherFiles) > 0 { - return false - } - if len(pkg.Imports) > 0 { - return false - } - pkgName, ok := extractPackageName(filename, contents) - if !ok { - return false - } - pkg.Name = pkgName - pkg.Errors = nil - return true -} - -func extractPackageName(filename string, contents []byte) (string, bool) { - // TODO(rstambler): Check the message of the actual error? - // It differs between $GOPATH and module mode. - f, err := parser.ParseFile(token.NewFileSet(), filename, contents, parser.PackageClauseOnly) // TODO(matloob): reuse fileset? - if err != nil { - return "", false - } - return f.Name.Name, true -} - -func commonDir(a []string) string { - seen := make(map[string]bool) - x := append([]string{}, a...) - for _, f := range x { - seen[filepath.Dir(f)] = true - } - if len(seen) > 1 { - log.Fatalf("commonDir saw %v for %v", seen, x) - } - for k := range seen { - // len(seen) == 1 - return k - } - return "" // no files -} - -// It is possible that the files in the disk directory dir have a different package -// name from newName, which is deduced from the overlays. If they all have a different -// package name, and they all have the same package name, then that name becomes -// the package name. -// It returns true if it changes the package name, false otherwise. -func maybeFixPackageName(newName string, isTestFile bool, pkgsOfDir []*Package) { - names := make(map[string]int) - for _, p := range pkgsOfDir { - names[p.Name]++ - } - if len(names) != 1 { - // some files are in different packages - return - } - var oldName string - for k := range names { - oldName = k - } - if newName == oldName { - return - } - // We might have a case where all of the package names in the directory are - // the same, but the overlay file is for an x test, which belongs to its - // own package. If the x test does not yet exist on disk, we may not yet - // have its package name on disk, but we should not rename the packages. - // - // We use a heuristic to determine if this file belongs to an x test: - // The test file should have a package name whose package name has a _test - // suffix or looks like "newName_test". - maybeXTest := strings.HasPrefix(oldName+"_test", newName) || strings.HasSuffix(newName, "_test") - if isTestFile && maybeXTest { - return - } - for _, p := range pkgsOfDir { - p.Name = newName - } -} - -// This function is copy-pasted from -// https://github.com/golang/go/blob/9706f510a5e2754595d716bd64be8375997311fb/src/cmd/go/internal/search/search.go#L360. -// It should be deleted when we remove support for overlays from go/packages. -// -// NOTE: This does not handle any ./... or ./ style queries, as this function -// doesn't know the working directory. -// -// matchPattern(pattern)(name) reports whether -// name matches pattern. Pattern is a limited glob -// pattern in which '...' means 'any string' and there -// is no other special syntax. -// Unfortunately, there are two special cases. Quoting "go help packages": -// -// First, /... at the end of the pattern can match an empty string, -// so that net/... matches both net and packages in its subdirectories, like net/http. -// Second, any slash-separated pattern element containing a wildcard never -// participates in a match of the "vendor" element in the path of a vendored -// package, so that ./... does not match packages in subdirectories of -// ./vendor or ./mycode/vendor, but ./vendor/... and ./mycode/vendor/... do. -// Note, however, that a directory named vendor that itself contains code -// is not a vendored package: cmd/vendor would be a command named vendor, -// and the pattern cmd/... matches it. -func matchPattern(pattern string) func(name string) bool { - // Convert pattern to regular expression. - // The strategy for the trailing /... is to nest it in an explicit ? expression. - // The strategy for the vendor exclusion is to change the unmatchable - // vendor strings to a disallowed code point (vendorChar) and to use - // "(anything but that codepoint)*" as the implementation of the ... wildcard. - // This is a bit complicated but the obvious alternative, - // namely a hand-written search like in most shell glob matchers, - // is too easy to make accidentally exponential. - // Using package regexp guarantees linear-time matching. - - const vendorChar = "\x00" - - if strings.Contains(pattern, vendorChar) { - return func(name string) bool { return false } - } - - re := regexp.QuoteMeta(pattern) - re = replaceVendor(re, vendorChar) - switch { - case strings.HasSuffix(re, `/`+vendorChar+`/\.\.\.`): - re = strings.TrimSuffix(re, `/`+vendorChar+`/\.\.\.`) + `(/vendor|/` + vendorChar + `/\.\.\.)` - case re == vendorChar+`/\.\.\.`: - re = `(/vendor|/` + vendorChar + `/\.\.\.)` - case strings.HasSuffix(re, `/\.\.\.`): - re = strings.TrimSuffix(re, `/\.\.\.`) + `(/\.\.\.)?` - } - re = strings.ReplaceAll(re, `\.\.\.`, `[^`+vendorChar+`]*`) - - reg := regexp.MustCompile(`^` + re + `$`) - - return func(name string) bool { - if strings.Contains(name, vendorChar) { - return false - } - return reg.MatchString(replaceVendor(name, vendorChar)) - } -} - -// replaceVendor returns the result of replacing -// non-trailing vendor path elements in x with repl. -func replaceVendor(x, repl string) string { - if !strings.Contains(x, "vendor") { - return x - } - elem := strings.Split(x, "/") - for i := 0; i < len(elem)-1; i++ { - if elem[i] == "vendor" { - elem[i] = repl - } - } - return strings.Join(elem, "/") -} diff --git a/vendor/golang.org/x/tools/go/packages/loadmode_string.go b/vendor/golang.org/x/tools/go/packages/loadmode_string.go deleted file mode 100644 index 7ea37e7ee..000000000 --- a/vendor/golang.org/x/tools/go/packages/loadmode_string.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package packages - -import ( - "fmt" - "strings" -) - -var allModes = []LoadMode{ - NeedName, - NeedFiles, - NeedCompiledGoFiles, - NeedImports, - NeedDeps, - NeedExportsFile, - NeedTypes, - NeedSyntax, - NeedTypesInfo, - NeedTypesSizes, -} - -var modeStrings = []string{ - "NeedName", - "NeedFiles", - "NeedCompiledGoFiles", - "NeedImports", - "NeedDeps", - "NeedExportsFile", - "NeedTypes", - "NeedSyntax", - "NeedTypesInfo", - "NeedTypesSizes", -} - -func (mod LoadMode) String() string { - m := mod - if m == 0 { - return "LoadMode(0)" - } - var out []string - for i, x := range allModes { - if x > m { - break - } - if (m & x) != 0 { - out = append(out, modeStrings[i]) - m = m ^ x - } - } - if m != 0 { - out = append(out, "Unknown") - } - return fmt.Sprintf("LoadMode(%s)", strings.Join(out, "|")) -} diff --git a/vendor/golang.org/x/tools/go/packages/packages.go b/vendor/golang.org/x/tools/go/packages/packages.go deleted file mode 100644 index 38475e871..000000000 --- a/vendor/golang.org/x/tools/go/packages/packages.go +++ /dev/null @@ -1,1233 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package packages - -// See doc.go for package documentation and implementation notes. - -import ( - "context" - "encoding/json" - "fmt" - "go/ast" - "go/parser" - "go/scanner" - "go/token" - "go/types" - "io/ioutil" - "log" - "os" - "path/filepath" - "strings" - "sync" - "time" - - "golang.org/x/tools/go/gcexportdata" - "golang.org/x/tools/internal/gocommand" - "golang.org/x/tools/internal/packagesinternal" - "golang.org/x/tools/internal/typesinternal" -) - -// A LoadMode controls the amount of detail to return when loading. -// The bits below can be combined to specify which fields should be -// filled in the result packages. -// The zero value is a special case, equivalent to combining -// the NeedName, NeedFiles, and NeedCompiledGoFiles bits. -// ID and Errors (if present) will always be filled. -// Load may return more information than requested. -type LoadMode int - -// TODO(matloob): When a V2 of go/packages is released, rename NeedExportsFile to -// NeedExportFile to make it consistent with the Package field it's adding. - -const ( - // NeedName adds Name and PkgPath. - NeedName LoadMode = 1 << iota - - // NeedFiles adds GoFiles and OtherFiles. - NeedFiles - - // NeedCompiledGoFiles adds CompiledGoFiles. - NeedCompiledGoFiles - - // NeedImports adds Imports. If NeedDeps is not set, the Imports field will contain - // "placeholder" Packages with only the ID set. - NeedImports - - // NeedDeps adds the fields requested by the LoadMode in the packages in Imports. - NeedDeps - - // NeedExportsFile adds ExportFile. - NeedExportsFile - - // NeedTypes adds Types, Fset, and IllTyped. - NeedTypes - - // NeedSyntax adds Syntax. - NeedSyntax - - // NeedTypesInfo adds TypesInfo. - NeedTypesInfo - - // NeedTypesSizes adds TypesSizes. - NeedTypesSizes - - // typecheckCgo enables full support for type checking cgo. Requires Go 1.15+. - // Modifies CompiledGoFiles and Types, and has no effect on its own. - typecheckCgo - - // NeedModule adds Module. - NeedModule -) - -const ( - // Deprecated: LoadFiles exists for historical compatibility - // and should not be used. Please directly specify the needed fields using the Need values. - LoadFiles = NeedName | NeedFiles | NeedCompiledGoFiles - - // Deprecated: LoadImports exists for historical compatibility - // and should not be used. Please directly specify the needed fields using the Need values. - LoadImports = LoadFiles | NeedImports - - // Deprecated: LoadTypes exists for historical compatibility - // and should not be used. Please directly specify the needed fields using the Need values. - LoadTypes = LoadImports | NeedTypes | NeedTypesSizes - - // Deprecated: LoadSyntax exists for historical compatibility - // and should not be used. Please directly specify the needed fields using the Need values. - LoadSyntax = LoadTypes | NeedSyntax | NeedTypesInfo - - // Deprecated: LoadAllSyntax exists for historical compatibility - // and should not be used. Please directly specify the needed fields using the Need values. - LoadAllSyntax = LoadSyntax | NeedDeps -) - -// A Config specifies details about how packages should be loaded. -// The zero value is a valid configuration. -// Calls to Load do not modify this struct. -type Config struct { - // Mode controls the level of information returned for each package. - Mode LoadMode - - // Context specifies the context for the load operation. - // If the context is cancelled, the loader may stop early - // and return an ErrCancelled error. - // If Context is nil, the load cannot be cancelled. - Context context.Context - - // Logf is the logger for the config. - // If the user provides a logger, debug logging is enabled. - // If the GOPACKAGESDEBUG environment variable is set to true, - // but the logger is nil, default to log.Printf. - Logf func(format string, args ...interface{}) - - // Dir is the directory in which to run the build system's query tool - // that provides information about the packages. - // If Dir is empty, the tool is run in the current directory. - Dir string - - // Env is the environment to use when invoking the build system's query tool. - // If Env is nil, the current environment is used. - // As in os/exec's Cmd, only the last value in the slice for - // each environment key is used. To specify the setting of only - // a few variables, append to the current environment, as in: - // - // opt.Env = append(os.Environ(), "GOOS=plan9", "GOARCH=386") - // - Env []string - - // gocmdRunner guards go command calls from concurrency errors. - gocmdRunner *gocommand.Runner - - // BuildFlags is a list of command-line flags to be passed through to - // the build system's query tool. - BuildFlags []string - - // modFile will be used for -modfile in go command invocations. - modFile string - - // modFlag will be used for -modfile in go command invocations. - modFlag string - - // Fset provides source position information for syntax trees and types. - // If Fset is nil, Load will use a new fileset, but preserve Fset's value. - Fset *token.FileSet - - // ParseFile is called to read and parse each file - // when preparing a package's type-checked syntax tree. - // It must be safe to call ParseFile simultaneously from multiple goroutines. - // If ParseFile is nil, the loader will uses parser.ParseFile. - // - // ParseFile should parse the source from src and use filename only for - // recording position information. - // - // An application may supply a custom implementation of ParseFile - // to change the effective file contents or the behavior of the parser, - // or to modify the syntax tree. For example, selectively eliminating - // unwanted function bodies can significantly accelerate type checking. - ParseFile func(fset *token.FileSet, filename string, src []byte) (*ast.File, error) - - // If Tests is set, the loader includes not just the packages - // matching a particular pattern but also any related test packages, - // including test-only variants of the package and the test executable. - // - // For example, when using the go command, loading "fmt" with Tests=true - // returns four packages, with IDs "fmt" (the standard package), - // "fmt [fmt.test]" (the package as compiled for the test), - // "fmt_test" (the test functions from source files in package fmt_test), - // and "fmt.test" (the test binary). - // - // In build systems with explicit names for tests, - // setting Tests may have no effect. - Tests bool - - // Overlay provides a mapping of absolute file paths to file contents. - // If the file with the given path already exists, the parser will use the - // alternative file contents provided by the map. - // - // Overlays provide incomplete support for when a given file doesn't - // already exist on disk. See the package doc above for more details. - Overlay map[string][]byte -} - -// driver is the type for functions that query the build system for the -// packages named by the patterns. -type driver func(cfg *Config, patterns ...string) (*driverResponse, error) - -// driverResponse contains the results for a driver query. -type driverResponse struct { - // NotHandled is returned if the request can't be handled by the current - // driver. If an external driver returns a response with NotHandled, the - // rest of the driverResponse is ignored, and go/packages will fallback - // to the next driver. If go/packages is extended in the future to support - // lists of multiple drivers, go/packages will fall back to the next driver. - NotHandled bool - - // Sizes, if not nil, is the types.Sizes to use when type checking. - Sizes *types.StdSizes - - // Roots is the set of package IDs that make up the root packages. - // We have to encode this separately because when we encode a single package - // we cannot know if it is one of the roots as that requires knowledge of the - // graph it is part of. - Roots []string `json:",omitempty"` - - // Packages is the full set of packages in the graph. - // The packages are not connected into a graph. - // The Imports if populated will be stubs that only have their ID set. - // Imports will be connected and then type and syntax information added in a - // later pass (see refine). - Packages []*Package -} - -// Load loads and returns the Go packages named by the given patterns. -// -// Config specifies loading options; -// nil behaves the same as an empty Config. -// -// Load returns an error if any of the patterns was invalid -// as defined by the underlying build system. -// It may return an empty list of packages without an error, -// for instance for an empty expansion of a valid wildcard. -// Errors associated with a particular package are recorded in the -// corresponding Package's Errors list, and do not cause Load to -// return an error. Clients may need to handle such errors before -// proceeding with further analysis. The PrintErrors function is -// provided for convenient display of all errors. -func Load(cfg *Config, patterns ...string) ([]*Package, error) { - l := newLoader(cfg) - response, err := defaultDriver(&l.Config, patterns...) - if err != nil { - return nil, err - } - l.sizes = response.Sizes - return l.refine(response.Roots, response.Packages...) -} - -// defaultDriver is a driver that implements go/packages' fallback behavior. -// It will try to request to an external driver, if one exists. If there's -// no external driver, or the driver returns a response with NotHandled set, -// defaultDriver will fall back to the go list driver. -func defaultDriver(cfg *Config, patterns ...string) (*driverResponse, error) { - driver := findExternalDriver(cfg) - if driver == nil { - driver = goListDriver - } - response, err := driver(cfg, patterns...) - if err != nil { - return response, err - } else if response.NotHandled { - return goListDriver(cfg, patterns...) - } - return response, nil -} - -// A Package describes a loaded Go package. -type Package struct { - // ID is a unique identifier for a package, - // in a syntax provided by the underlying build system. - // - // Because the syntax varies based on the build system, - // clients should treat IDs as opaque and not attempt to - // interpret them. - ID string - - // Name is the package name as it appears in the package source code. - Name string - - // PkgPath is the package path as used by the go/types package. - PkgPath string - - // Errors contains any errors encountered querying the metadata - // of the package, or while parsing or type-checking its files. - Errors []Error - - // GoFiles lists the absolute file paths of the package's Go source files. - GoFiles []string - - // CompiledGoFiles lists the absolute file paths of the package's source - // files that are suitable for type checking. - // This may differ from GoFiles if files are processed before compilation. - CompiledGoFiles []string - - // OtherFiles lists the absolute file paths of the package's non-Go source files, - // including assembly, C, C++, Fortran, Objective-C, SWIG, and so on. - OtherFiles []string - - // IgnoredFiles lists source files that are not part of the package - // using the current build configuration but that might be part of - // the package using other build configurations. - IgnoredFiles []string - - // ExportFile is the absolute path to a file containing type - // information for the package as provided by the build system. - ExportFile string - - // Imports maps import paths appearing in the package's Go source files - // to corresponding loaded Packages. - Imports map[string]*Package - - // Types provides type information for the package. - // The NeedTypes LoadMode bit sets this field for packages matching the - // patterns; type information for dependencies may be missing or incomplete, - // unless NeedDeps and NeedImports are also set. - Types *types.Package - - // Fset provides position information for Types, TypesInfo, and Syntax. - // It is set only when Types is set. - Fset *token.FileSet - - // IllTyped indicates whether the package or any dependency contains errors. - // It is set only when Types is set. - IllTyped bool - - // Syntax is the package's syntax trees, for the files listed in CompiledGoFiles. - // - // The NeedSyntax LoadMode bit populates this field for packages matching the patterns. - // If NeedDeps and NeedImports are also set, this field will also be populated - // for dependencies. - Syntax []*ast.File - - // TypesInfo provides type information about the package's syntax trees. - // It is set only when Syntax is set. - TypesInfo *types.Info - - // TypesSizes provides the effective size function for types in TypesInfo. - TypesSizes types.Sizes - - // forTest is the package under test, if any. - forTest string - - // module is the module information for the package if it exists. - Module *Module -} - -// Module provides module information for a package. -type Module struct { - Path string // module path - Version string // module version - Replace *Module // replaced by this module - Time *time.Time // time version was created - Main bool // is this the main module? - Indirect bool // is this module only an indirect dependency of main module? - Dir string // directory holding files for this module, if any - GoMod string // path to go.mod file used when loading this module, if any - GoVersion string // go version used in module - Error *ModuleError // error loading module -} - -// ModuleError holds errors loading a module. -type ModuleError struct { - Err string // the error itself -} - -func init() { - packagesinternal.GetForTest = func(p interface{}) string { - return p.(*Package).forTest - } - packagesinternal.GetGoCmdRunner = func(config interface{}) *gocommand.Runner { - return config.(*Config).gocmdRunner - } - packagesinternal.SetGoCmdRunner = func(config interface{}, runner *gocommand.Runner) { - config.(*Config).gocmdRunner = runner - } - packagesinternal.SetModFile = func(config interface{}, value string) { - config.(*Config).modFile = value - } - packagesinternal.SetModFlag = func(config interface{}, value string) { - config.(*Config).modFlag = value - } - packagesinternal.TypecheckCgo = int(typecheckCgo) -} - -// An Error describes a problem with a package's metadata, syntax, or types. -type Error struct { - Pos string // "file:line:col" or "file:line" or "" or "-" - Msg string - Kind ErrorKind -} - -// ErrorKind describes the source of the error, allowing the user to -// differentiate between errors generated by the driver, the parser, or the -// type-checker. -type ErrorKind int - -const ( - UnknownError ErrorKind = iota - ListError - ParseError - TypeError -) - -func (err Error) Error() string { - pos := err.Pos - if pos == "" { - pos = "-" // like token.Position{}.String() - } - return pos + ": " + err.Msg -} - -// flatPackage is the JSON form of Package -// It drops all the type and syntax fields, and transforms the Imports -// -// TODO(adonovan): identify this struct with Package, effectively -// publishing the JSON protocol. -type flatPackage struct { - ID string - Name string `json:",omitempty"` - PkgPath string `json:",omitempty"` - Errors []Error `json:",omitempty"` - GoFiles []string `json:",omitempty"` - CompiledGoFiles []string `json:",omitempty"` - OtherFiles []string `json:",omitempty"` - IgnoredFiles []string `json:",omitempty"` - ExportFile string `json:",omitempty"` - Imports map[string]string `json:",omitempty"` -} - -// MarshalJSON returns the Package in its JSON form. -// For the most part, the structure fields are written out unmodified, and -// the type and syntax fields are skipped. -// The imports are written out as just a map of path to package id. -// The errors are written using a custom type that tries to preserve the -// structure of error types we know about. -// -// This method exists to enable support for additional build systems. It is -// not intended for use by clients of the API and we may change the format. -func (p *Package) MarshalJSON() ([]byte, error) { - flat := &flatPackage{ - ID: p.ID, - Name: p.Name, - PkgPath: p.PkgPath, - Errors: p.Errors, - GoFiles: p.GoFiles, - CompiledGoFiles: p.CompiledGoFiles, - OtherFiles: p.OtherFiles, - IgnoredFiles: p.IgnoredFiles, - ExportFile: p.ExportFile, - } - if len(p.Imports) > 0 { - flat.Imports = make(map[string]string, len(p.Imports)) - for path, ipkg := range p.Imports { - flat.Imports[path] = ipkg.ID - } - } - return json.Marshal(flat) -} - -// UnmarshalJSON reads in a Package from its JSON format. -// See MarshalJSON for details about the format accepted. -func (p *Package) UnmarshalJSON(b []byte) error { - flat := &flatPackage{} - if err := json.Unmarshal(b, &flat); err != nil { - return err - } - *p = Package{ - ID: flat.ID, - Name: flat.Name, - PkgPath: flat.PkgPath, - Errors: flat.Errors, - GoFiles: flat.GoFiles, - CompiledGoFiles: flat.CompiledGoFiles, - OtherFiles: flat.OtherFiles, - ExportFile: flat.ExportFile, - } - if len(flat.Imports) > 0 { - p.Imports = make(map[string]*Package, len(flat.Imports)) - for path, id := range flat.Imports { - p.Imports[path] = &Package{ID: id} - } - } - return nil -} - -func (p *Package) String() string { return p.ID } - -// loaderPackage augments Package with state used during the loading phase -type loaderPackage struct { - *Package - importErrors map[string]error // maps each bad import to its error - loadOnce sync.Once - color uint8 // for cycle detection - needsrc bool // load from source (Mode >= LoadTypes) - needtypes bool // type information is either requested or depended on - initial bool // package was matched by a pattern -} - -// loader holds the working state of a single call to load. -type loader struct { - pkgs map[string]*loaderPackage - Config - sizes types.Sizes - parseCache map[string]*parseValue - parseCacheMu sync.Mutex - exportMu sync.Mutex // enforces mutual exclusion of exportdata operations - - // Config.Mode contains the implied mode (see impliedLoadMode). - // Implied mode contains all the fields we need the data for. - // In requestedMode there are the actually requested fields. - // We'll zero them out before returning packages to the user. - // This makes it easier for us to get the conditions where - // we need certain modes right. - requestedMode LoadMode -} - -type parseValue struct { - f *ast.File - err error - ready chan struct{} -} - -func newLoader(cfg *Config) *loader { - ld := &loader{ - parseCache: map[string]*parseValue{}, - } - if cfg != nil { - ld.Config = *cfg - // If the user has provided a logger, use it. - ld.Config.Logf = cfg.Logf - } - if ld.Config.Logf == nil { - // If the GOPACKAGESDEBUG environment variable is set to true, - // but the user has not provided a logger, default to log.Printf. - if debug { - ld.Config.Logf = log.Printf - } else { - ld.Config.Logf = func(format string, args ...interface{}) {} - } - } - if ld.Config.Mode == 0 { - ld.Config.Mode = NeedName | NeedFiles | NeedCompiledGoFiles // Preserve zero behavior of Mode for backwards compatibility. - } - if ld.Config.Env == nil { - ld.Config.Env = os.Environ() - } - if ld.Config.gocmdRunner == nil { - ld.Config.gocmdRunner = &gocommand.Runner{} - } - if ld.Context == nil { - ld.Context = context.Background() - } - if ld.Dir == "" { - if dir, err := os.Getwd(); err == nil { - ld.Dir = dir - } - } - - // Save the actually requested fields. We'll zero them out before returning packages to the user. - ld.requestedMode = ld.Mode - ld.Mode = impliedLoadMode(ld.Mode) - - if ld.Mode&NeedTypes != 0 || ld.Mode&NeedSyntax != 0 { - if ld.Fset == nil { - ld.Fset = token.NewFileSet() - } - - // ParseFile is required even in LoadTypes mode - // because we load source if export data is missing. - if ld.ParseFile == nil { - ld.ParseFile = func(fset *token.FileSet, filename string, src []byte) (*ast.File, error) { - const mode = parser.AllErrors | parser.ParseComments - return parser.ParseFile(fset, filename, src, mode) - } - } - } - - return ld -} - -// refine connects the supplied packages into a graph and then adds type and -// and syntax information as requested by the LoadMode. -func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) { - rootMap := make(map[string]int, len(roots)) - for i, root := range roots { - rootMap[root] = i - } - ld.pkgs = make(map[string]*loaderPackage) - // first pass, fixup and build the map and roots - var initial = make([]*loaderPackage, len(roots)) - for _, pkg := range list { - rootIndex := -1 - if i, found := rootMap[pkg.ID]; found { - rootIndex = i - } - - // Overlays can invalidate export data. - // TODO(matloob): make this check fine-grained based on dependencies on overlaid files - exportDataInvalid := len(ld.Overlay) > 0 || pkg.ExportFile == "" && pkg.PkgPath != "unsafe" - // This package needs type information if the caller requested types and the package is - // either a root, or it's a non-root and the user requested dependencies ... - needtypes := (ld.Mode&NeedTypes|NeedTypesInfo != 0 && (rootIndex >= 0 || ld.Mode&NeedDeps != 0)) - // This package needs source if the call requested source (or types info, which implies source) - // and the package is either a root, or itas a non- root and the user requested dependencies... - needsrc := ((ld.Mode&(NeedSyntax|NeedTypesInfo) != 0 && (rootIndex >= 0 || ld.Mode&NeedDeps != 0)) || - // ... or if we need types and the exportData is invalid. We fall back to (incompletely) - // typechecking packages from source if they fail to compile. - (ld.Mode&NeedTypes|NeedTypesInfo != 0 && exportDataInvalid)) && pkg.PkgPath != "unsafe" - lpkg := &loaderPackage{ - Package: pkg, - needtypes: needtypes, - needsrc: needsrc, - } - ld.pkgs[lpkg.ID] = lpkg - if rootIndex >= 0 { - initial[rootIndex] = lpkg - lpkg.initial = true - } - } - for i, root := range roots { - if initial[i] == nil { - return nil, fmt.Errorf("root package %v is missing", root) - } - } - - // Materialize the import graph. - - const ( - white = 0 // new - grey = 1 // in progress - black = 2 // complete - ) - - // visit traverses the import graph, depth-first, - // and materializes the graph as Packages.Imports. - // - // Valid imports are saved in the Packages.Import map. - // Invalid imports (cycles and missing nodes) are saved in the importErrors map. - // Thus, even in the presence of both kinds of errors, the Import graph remains a DAG. - // - // visit returns whether the package needs src or has a transitive - // dependency on a package that does. These are the only packages - // for which we load source code. - var stack []*loaderPackage - var visit func(lpkg *loaderPackage) bool - var srcPkgs []*loaderPackage - visit = func(lpkg *loaderPackage) bool { - switch lpkg.color { - case black: - return lpkg.needsrc - case grey: - panic("internal error: grey node") - } - lpkg.color = grey - stack = append(stack, lpkg) // push - stubs := lpkg.Imports // the structure form has only stubs with the ID in the Imports - // If NeedImports isn't set, the imports fields will all be zeroed out. - if ld.Mode&NeedImports != 0 { - lpkg.Imports = make(map[string]*Package, len(stubs)) - for importPath, ipkg := range stubs { - var importErr error - imp := ld.pkgs[ipkg.ID] - if imp == nil { - // (includes package "C" when DisableCgo) - importErr = fmt.Errorf("missing package: %q", ipkg.ID) - } else if imp.color == grey { - importErr = fmt.Errorf("import cycle: %s", stack) - } - if importErr != nil { - if lpkg.importErrors == nil { - lpkg.importErrors = make(map[string]error) - } - lpkg.importErrors[importPath] = importErr - continue - } - - if visit(imp) { - lpkg.needsrc = true - } - lpkg.Imports[importPath] = imp.Package - } - } - if lpkg.needsrc { - srcPkgs = append(srcPkgs, lpkg) - } - if ld.Mode&NeedTypesSizes != 0 { - lpkg.TypesSizes = ld.sizes - } - stack = stack[:len(stack)-1] // pop - lpkg.color = black - - return lpkg.needsrc - } - - if ld.Mode&NeedImports == 0 { - // We do this to drop the stub import packages that we are not even going to try to resolve. - for _, lpkg := range initial { - lpkg.Imports = nil - } - } else { - // For each initial package, create its import DAG. - for _, lpkg := range initial { - visit(lpkg) - } - } - if ld.Mode&NeedImports != 0 && ld.Mode&NeedTypes != 0 { - for _, lpkg := range srcPkgs { - // Complete type information is required for the - // immediate dependencies of each source package. - for _, ipkg := range lpkg.Imports { - imp := ld.pkgs[ipkg.ID] - imp.needtypes = true - } - } - } - // Load type data and syntax if needed, starting at - // the initial packages (roots of the import DAG). - if ld.Mode&NeedTypes != 0 || ld.Mode&NeedSyntax != 0 { - var wg sync.WaitGroup - for _, lpkg := range initial { - wg.Add(1) - go func(lpkg *loaderPackage) { - ld.loadRecursive(lpkg) - wg.Done() - }(lpkg) - } - wg.Wait() - } - - result := make([]*Package, len(initial)) - for i, lpkg := range initial { - result[i] = lpkg.Package - } - for i := range ld.pkgs { - // Clear all unrequested fields, - // to catch programs that use more than they request. - if ld.requestedMode&NeedName == 0 { - ld.pkgs[i].Name = "" - ld.pkgs[i].PkgPath = "" - } - if ld.requestedMode&NeedFiles == 0 { - ld.pkgs[i].GoFiles = nil - ld.pkgs[i].OtherFiles = nil - ld.pkgs[i].IgnoredFiles = nil - } - if ld.requestedMode&NeedCompiledGoFiles == 0 { - ld.pkgs[i].CompiledGoFiles = nil - } - if ld.requestedMode&NeedImports == 0 { - ld.pkgs[i].Imports = nil - } - if ld.requestedMode&NeedExportsFile == 0 { - ld.pkgs[i].ExportFile = "" - } - if ld.requestedMode&NeedTypes == 0 { - ld.pkgs[i].Types = nil - ld.pkgs[i].Fset = nil - ld.pkgs[i].IllTyped = false - } - if ld.requestedMode&NeedSyntax == 0 { - ld.pkgs[i].Syntax = nil - } - if ld.requestedMode&NeedTypesInfo == 0 { - ld.pkgs[i].TypesInfo = nil - } - if ld.requestedMode&NeedTypesSizes == 0 { - ld.pkgs[i].TypesSizes = nil - } - if ld.requestedMode&NeedModule == 0 { - ld.pkgs[i].Module = nil - } - } - - return result, nil -} - -// loadRecursive loads the specified package and its dependencies, -// recursively, in parallel, in topological order. -// It is atomic and idempotent. -// Precondition: ld.Mode&NeedTypes. -func (ld *loader) loadRecursive(lpkg *loaderPackage) { - lpkg.loadOnce.Do(func() { - // Load the direct dependencies, in parallel. - var wg sync.WaitGroup - for _, ipkg := range lpkg.Imports { - imp := ld.pkgs[ipkg.ID] - wg.Add(1) - go func(imp *loaderPackage) { - ld.loadRecursive(imp) - wg.Done() - }(imp) - } - wg.Wait() - ld.loadPackage(lpkg) - }) -} - -// loadPackage loads the specified package. -// It must be called only once per Package, -// after immediate dependencies are loaded. -// Precondition: ld.Mode & NeedTypes. -func (ld *loader) loadPackage(lpkg *loaderPackage) { - if lpkg.PkgPath == "unsafe" { - // Fill in the blanks to avoid surprises. - lpkg.Types = types.Unsafe - lpkg.Fset = ld.Fset - lpkg.Syntax = []*ast.File{} - lpkg.TypesInfo = new(types.Info) - lpkg.TypesSizes = ld.sizes - return - } - - // Call NewPackage directly with explicit name. - // This avoids skew between golist and go/types when the files' - // package declarations are inconsistent. - lpkg.Types = types.NewPackage(lpkg.PkgPath, lpkg.Name) - lpkg.Fset = ld.Fset - - // Subtle: we populate all Types fields with an empty Package - // before loading export data so that export data processing - // never has to create a types.Package for an indirect dependency, - // which would then require that such created packages be explicitly - // inserted back into the Import graph as a final step after export data loading. - // The Diamond test exercises this case. - if !lpkg.needtypes && !lpkg.needsrc { - return - } - if !lpkg.needsrc { - ld.loadFromExportData(lpkg) - return // not a source package, don't get syntax trees - } - - appendError := func(err error) { - // Convert various error types into the one true Error. - var errs []Error - switch err := err.(type) { - case Error: - // from driver - errs = append(errs, err) - - case *os.PathError: - // from parser - errs = append(errs, Error{ - Pos: err.Path + ":1", - Msg: err.Err.Error(), - Kind: ParseError, - }) - - case scanner.ErrorList: - // from parser - for _, err := range err { - errs = append(errs, Error{ - Pos: err.Pos.String(), - Msg: err.Msg, - Kind: ParseError, - }) - } - - case types.Error: - // from type checker - errs = append(errs, Error{ - Pos: err.Fset.Position(err.Pos).String(), - Msg: err.Msg, - Kind: TypeError, - }) - - default: - // unexpected impoverished error from parser? - errs = append(errs, Error{ - Pos: "-", - Msg: err.Error(), - Kind: UnknownError, - }) - - // If you see this error message, please file a bug. - log.Printf("internal error: error %q (%T) without position", err, err) - } - - lpkg.Errors = append(lpkg.Errors, errs...) - } - - if ld.Config.Mode&NeedTypes != 0 && len(lpkg.CompiledGoFiles) == 0 && lpkg.ExportFile != "" { - // The config requested loading sources and types, but sources are missing. - // Add an error to the package and fall back to loading from export data. - appendError(Error{"-", fmt.Sprintf("sources missing for package %s", lpkg.ID), ParseError}) - ld.loadFromExportData(lpkg) - return // can't get syntax trees for this package - } - - files, errs := ld.parseFiles(lpkg.CompiledGoFiles) - for _, err := range errs { - appendError(err) - } - - lpkg.Syntax = files - if ld.Config.Mode&NeedTypes == 0 { - return - } - - lpkg.TypesInfo = &types.Info{ - Types: make(map[ast.Expr]types.TypeAndValue), - Defs: make(map[*ast.Ident]types.Object), - Uses: make(map[*ast.Ident]types.Object), - Implicits: make(map[ast.Node]types.Object), - Scopes: make(map[ast.Node]*types.Scope), - Selections: make(map[*ast.SelectorExpr]*types.Selection), - } - lpkg.TypesSizes = ld.sizes - - importer := importerFunc(func(path string) (*types.Package, error) { - if path == "unsafe" { - return types.Unsafe, nil - } - - // The imports map is keyed by import path. - ipkg := lpkg.Imports[path] - if ipkg == nil { - if err := lpkg.importErrors[path]; err != nil { - return nil, err - } - // There was skew between the metadata and the - // import declarations, likely due to an edit - // race, or because the ParseFile feature was - // used to supply alternative file contents. - return nil, fmt.Errorf("no metadata for %s", path) - } - - if ipkg.Types != nil && ipkg.Types.Complete() { - return ipkg.Types, nil - } - log.Fatalf("internal error: package %q without types was imported from %q", path, lpkg) - panic("unreachable") - }) - - // type-check - tc := &types.Config{ - Importer: importer, - - // Type-check bodies of functions only in non-initial packages. - // Example: for import graph A->B->C and initial packages {A,C}, - // we can ignore function bodies in B. - IgnoreFuncBodies: ld.Mode&NeedDeps == 0 && !lpkg.initial, - - Error: appendError, - Sizes: ld.sizes, - } - if (ld.Mode & typecheckCgo) != 0 { - if !typesinternal.SetUsesCgo(tc) { - appendError(Error{ - Msg: "typecheckCgo requires Go 1.15+", - Kind: ListError, - }) - return - } - } - types.NewChecker(tc, ld.Fset, lpkg.Types, lpkg.TypesInfo).Files(lpkg.Syntax) - - lpkg.importErrors = nil // no longer needed - - // If !Cgo, the type-checker uses FakeImportC mode, so - // it doesn't invoke the importer for import "C", - // nor report an error for the import, - // or for any undefined C.f reference. - // We must detect this explicitly and correctly - // mark the package as IllTyped (by reporting an error). - // TODO(adonovan): if these errors are annoying, - // we could just set IllTyped quietly. - if tc.FakeImportC { - outer: - for _, f := range lpkg.Syntax { - for _, imp := range f.Imports { - if imp.Path.Value == `"C"` { - err := types.Error{Fset: ld.Fset, Pos: imp.Pos(), Msg: `import "C" ignored`} - appendError(err) - break outer - } - } - } - } - - // Record accumulated errors. - illTyped := len(lpkg.Errors) > 0 - if !illTyped { - for _, imp := range lpkg.Imports { - if imp.IllTyped { - illTyped = true - break - } - } - } - lpkg.IllTyped = illTyped -} - -// An importFunc is an implementation of the single-method -// types.Importer interface based on a function value. -type importerFunc func(path string) (*types.Package, error) - -func (f importerFunc) Import(path string) (*types.Package, error) { return f(path) } - -// We use a counting semaphore to limit -// the number of parallel I/O calls per process. -var ioLimit = make(chan bool, 20) - -func (ld *loader) parseFile(filename string) (*ast.File, error) { - ld.parseCacheMu.Lock() - v, ok := ld.parseCache[filename] - if ok { - // cache hit - ld.parseCacheMu.Unlock() - <-v.ready - } else { - // cache miss - v = &parseValue{ready: make(chan struct{})} - ld.parseCache[filename] = v - ld.parseCacheMu.Unlock() - - var src []byte - for f, contents := range ld.Config.Overlay { - if sameFile(f, filename) { - src = contents - } - } - var err error - if src == nil { - ioLimit <- true // wait - src, err = ioutil.ReadFile(filename) - <-ioLimit // signal - } - if err != nil { - v.err = err - } else { - v.f, v.err = ld.ParseFile(ld.Fset, filename, src) - } - - close(v.ready) - } - return v.f, v.err -} - -// parseFiles reads and parses the Go source files and returns the ASTs -// of the ones that could be at least partially parsed, along with a -// list of I/O and parse errors encountered. -// -// Because files are scanned in parallel, the token.Pos -// positions of the resulting ast.Files are not ordered. -// -func (ld *loader) parseFiles(filenames []string) ([]*ast.File, []error) { - var wg sync.WaitGroup - n := len(filenames) - parsed := make([]*ast.File, n) - errors := make([]error, n) - for i, file := range filenames { - if ld.Config.Context.Err() != nil { - parsed[i] = nil - errors[i] = ld.Config.Context.Err() - continue - } - wg.Add(1) - go func(i int, filename string) { - parsed[i], errors[i] = ld.parseFile(filename) - wg.Done() - }(i, file) - } - wg.Wait() - - // Eliminate nils, preserving order. - var o int - for _, f := range parsed { - if f != nil { - parsed[o] = f - o++ - } - } - parsed = parsed[:o] - - o = 0 - for _, err := range errors { - if err != nil { - errors[o] = err - o++ - } - } - errors = errors[:o] - - return parsed, errors -} - -// sameFile returns true if x and y have the same basename and denote -// the same file. -// -func sameFile(x, y string) bool { - if x == y { - // It could be the case that y doesn't exist. - // For instance, it may be an overlay file that - // hasn't been written to disk. To handle that case - // let x == y through. (We added the exact absolute path - // string to the CompiledGoFiles list, so the unwritten - // overlay case implies x==y.) - return true - } - if strings.EqualFold(filepath.Base(x), filepath.Base(y)) { // (optimisation) - if xi, err := os.Stat(x); err == nil { - if yi, err := os.Stat(y); err == nil { - return os.SameFile(xi, yi) - } - } - } - return false -} - -// loadFromExportData returns type information for the specified -// package, loading it from an export data file on the first request. -func (ld *loader) loadFromExportData(lpkg *loaderPackage) (*types.Package, error) { - if lpkg.PkgPath == "" { - log.Fatalf("internal error: Package %s has no PkgPath", lpkg) - } - - // Because gcexportdata.Read has the potential to create or - // modify the types.Package for each node in the transitive - // closure of dependencies of lpkg, all exportdata operations - // must be sequential. (Finer-grained locking would require - // changes to the gcexportdata API.) - // - // The exportMu lock guards the Package.Pkg field and the - // types.Package it points to, for each Package in the graph. - // - // Not all accesses to Package.Pkg need to be protected by exportMu: - // graph ordering ensures that direct dependencies of source - // packages are fully loaded before the importer reads their Pkg field. - ld.exportMu.Lock() - defer ld.exportMu.Unlock() - - if tpkg := lpkg.Types; tpkg != nil && tpkg.Complete() { - return tpkg, nil // cache hit - } - - lpkg.IllTyped = true // fail safe - - if lpkg.ExportFile == "" { - // Errors while building export data will have been printed to stderr. - return nil, fmt.Errorf("no export data file") - } - f, err := os.Open(lpkg.ExportFile) - if err != nil { - return nil, err - } - defer f.Close() - - // Read gc export data. - // - // We don't currently support gccgo export data because all - // underlying workspaces use the gc toolchain. (Even build - // systems that support gccgo don't use it for workspace - // queries.) - r, err := gcexportdata.NewReader(f) - if err != nil { - return nil, fmt.Errorf("reading %s: %v", lpkg.ExportFile, err) - } - - // Build the view. - // - // The gcexportdata machinery has no concept of package ID. - // It identifies packages by their PkgPath, which although not - // globally unique is unique within the scope of one invocation - // of the linker, type-checker, or gcexportdata. - // - // So, we must build a PkgPath-keyed view of the global - // (conceptually ID-keyed) cache of packages and pass it to - // gcexportdata. The view must contain every existing - // package that might possibly be mentioned by the - // current package---its transitive closure. - // - // In loadPackage, we unconditionally create a types.Package for - // each dependency so that export data loading does not - // create new ones. - // - // TODO(adonovan): it would be simpler and more efficient - // if the export data machinery invoked a callback to - // get-or-create a package instead of a map. - // - view := make(map[string]*types.Package) // view seen by gcexportdata - seen := make(map[*loaderPackage]bool) // all visited packages - var visit func(pkgs map[string]*Package) - visit = func(pkgs map[string]*Package) { - for _, p := range pkgs { - lpkg := ld.pkgs[p.ID] - if !seen[lpkg] { - seen[lpkg] = true - view[lpkg.PkgPath] = lpkg.Types - visit(lpkg.Imports) - } - } - } - visit(lpkg.Imports) - - viewLen := len(view) + 1 // adding the self package - // Parse the export data. - // (May modify incomplete packages in view but not create new ones.) - tpkg, err := gcexportdata.Read(r, ld.Fset, view, lpkg.PkgPath) - if err != nil { - return nil, fmt.Errorf("reading %s: %v", lpkg.ExportFile, err) - } - if viewLen != len(view) { - log.Fatalf("Unexpected package creation during export data loading") - } - - lpkg.Types = tpkg - lpkg.IllTyped = false - - return tpkg, nil -} - -// impliedLoadMode returns loadMode with its dependencies. -func impliedLoadMode(loadMode LoadMode) LoadMode { - if loadMode&NeedTypesInfo != 0 && loadMode&NeedImports == 0 { - // If NeedTypesInfo, go/packages needs to do typechecking itself so it can - // associate type info with the AST. To do so, we need the export data - // for dependencies, which means we need to ask for the direct dependencies. - // NeedImports is used to ask for the direct dependencies. - loadMode |= NeedImports - } - - if loadMode&NeedDeps != 0 && loadMode&NeedImports == 0 { - // With NeedDeps we need to load at least direct dependencies. - // NeedImports is used to ask for the direct dependencies. - loadMode |= NeedImports - } - - return loadMode -} - -func usesExportData(cfg *Config) bool { - return cfg.Mode&NeedExportsFile != 0 || cfg.Mode&NeedTypes != 0 && cfg.Mode&NeedDeps == 0 -} diff --git a/vendor/golang.org/x/tools/go/packages/visit.go b/vendor/golang.org/x/tools/go/packages/visit.go deleted file mode 100644 index b13cb081f..000000000 --- a/vendor/golang.org/x/tools/go/packages/visit.go +++ /dev/null @@ -1,55 +0,0 @@ -package packages - -import ( - "fmt" - "os" - "sort" -) - -// Visit visits all the packages in the import graph whose roots are -// pkgs, calling the optional pre function the first time each package -// is encountered (preorder), and the optional post function after a -// package's dependencies have been visited (postorder). -// The boolean result of pre(pkg) determines whether -// the imports of package pkg are visited. -func Visit(pkgs []*Package, pre func(*Package) bool, post func(*Package)) { - seen := make(map[*Package]bool) - var visit func(*Package) - visit = func(pkg *Package) { - if !seen[pkg] { - seen[pkg] = true - - if pre == nil || pre(pkg) { - paths := make([]string, 0, len(pkg.Imports)) - for path := range pkg.Imports { - paths = append(paths, path) - } - sort.Strings(paths) // Imports is a map, this makes visit stable - for _, path := range paths { - visit(pkg.Imports[path]) - } - } - - if post != nil { - post(pkg) - } - } - } - for _, pkg := range pkgs { - visit(pkg) - } -} - -// PrintErrors prints to os.Stderr the accumulated errors of all -// packages in the import graph rooted at pkgs, dependencies first. -// PrintErrors returns the number of errors printed. -func PrintErrors(pkgs []*Package) int { - var n int - Visit(pkgs, nil, func(pkg *Package) { - for _, err := range pkg.Errors { - fmt.Fprintln(os.Stderr, err) - n++ - } - }) - return n -} diff --git a/vendor/golang.org/x/tools/internal/packagesinternal/packages.go b/vendor/golang.org/x/tools/internal/packagesinternal/packages.go deleted file mode 100644 index 1335a5eed..000000000 --- a/vendor/golang.org/x/tools/internal/packagesinternal/packages.go +++ /dev/null @@ -1,17 +0,0 @@ -// Package packagesinternal exposes internal-only fields from go/packages. -package packagesinternal - -import ( - "golang.org/x/tools/internal/gocommand" -) - -var GetForTest = func(p interface{}) string { return "" } - -var GetGoCmdRunner = func(config interface{}) *gocommand.Runner { return nil } - -var SetGoCmdRunner = func(config interface{}, runner *gocommand.Runner) {} - -var TypecheckCgo int - -var SetModFlag = func(config interface{}, value string) {} -var SetModFile = func(config interface{}, value string) {} diff --git a/vendor/golang.org/x/tools/internal/typesinternal/errorcode.go b/vendor/golang.org/x/tools/internal/typesinternal/errorcode.go deleted file mode 100644 index 65473eb22..000000000 --- a/vendor/golang.org/x/tools/internal/typesinternal/errorcode.go +++ /dev/null @@ -1,1358 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package typesinternal - -//go:generate stringer -type=ErrorCode - -type ErrorCode int - -// This file defines the error codes that can be produced during type-checking. -// Collectively, these codes provide an identifier that may be used to -// implement special handling for certain types of errors. -// -// Error codes should be fine-grained enough that the exact nature of the error -// can be easily determined, but coarse enough that they are not an -// implementation detail of the type checking algorithm. As a rule-of-thumb, -// errors should be considered equivalent if there is a theoretical refactoring -// of the type checker in which they are emitted in exactly one place. For -// example, the type checker emits different error messages for "too many -// arguments" and "too few arguments", but one can imagine an alternative type -// checker where this check instead just emits a single "wrong number of -// arguments", so these errors should have the same code. -// -// Error code names should be as brief as possible while retaining accuracy and -// distinctiveness. In most cases names should start with an adjective -// describing the nature of the error (e.g. "invalid", "unused", "misplaced"), -// and end with a noun identifying the relevant language object. For example, -// "DuplicateDecl" or "InvalidSliceExpr". For brevity, naming follows the -// convention that "bad" implies a problem with syntax, and "invalid" implies a -// problem with types. - -const ( - _ ErrorCode = iota - - // Test is reserved for errors that only apply while in self-test mode. - Test - - /* package names */ - - // BlankPkgName occurs when a package name is the blank identifier "_". - // - // Per the spec: - // "The PackageName must not be the blank identifier." - BlankPkgName - - // MismatchedPkgName occurs when a file's package name doesn't match the - // package name already established by other files. - MismatchedPkgName - - // InvalidPkgUse occurs when a package identifier is used outside of a - // selector expression. - // - // Example: - // import "fmt" - // - // var _ = fmt - InvalidPkgUse - - /* imports */ - - // BadImportPath occurs when an import path is not valid. - BadImportPath - - // BrokenImport occurs when importing a package fails. - // - // Example: - // import "amissingpackage" - BrokenImport - - // ImportCRenamed occurs when the special import "C" is renamed. "C" is a - // pseudo-package, and must not be renamed. - // - // Example: - // import _ "C" - ImportCRenamed - - // UnusedImport occurs when an import is unused. - // - // Example: - // import "fmt" - // - // func main() {} - UnusedImport - - /* initialization */ - - // InvalidInitCycle occurs when an invalid cycle is detected within the - // initialization graph. - // - // Example: - // var x int = f() - // - // func f() int { return x } - InvalidInitCycle - - /* decls */ - - // DuplicateDecl occurs when an identifier is declared multiple times. - // - // Example: - // var x = 1 - // var x = 2 - DuplicateDecl - - // InvalidDeclCycle occurs when a declaration cycle is not valid. - // - // Example: - // import "unsafe" - // - // type T struct { - // a [n]int - // } - // - // var n = unsafe.Sizeof(T{}) - InvalidDeclCycle - - // InvalidTypeCycle occurs when a cycle in type definitions results in a - // type that is not well-defined. - // - // Example: - // import "unsafe" - // - // type T [unsafe.Sizeof(T{})]int - InvalidTypeCycle - - /* decls > const */ - - // InvalidConstInit occurs when a const declaration has a non-constant - // initializer. - // - // Example: - // var x int - // const _ = x - InvalidConstInit - - // InvalidConstVal occurs when a const value cannot be converted to its - // target type. - // - // TODO(findleyr): this error code and example are not very clear. Consider - // removing it. - // - // Example: - // const _ = 1 << "hello" - InvalidConstVal - - // InvalidConstType occurs when the underlying type in a const declaration - // is not a valid constant type. - // - // Example: - // const c *int = 4 - InvalidConstType - - /* decls > var (+ other variable assignment codes) */ - - // UntypedNil occurs when the predeclared (untyped) value nil is used to - // initialize a variable declared without an explicit type. - // - // Example: - // var x = nil - UntypedNil - - // WrongAssignCount occurs when the number of values on the right-hand side - // of an assignment or or initialization expression does not match the number - // of variables on the left-hand side. - // - // Example: - // var x = 1, 2 - WrongAssignCount - - // UnassignableOperand occurs when the left-hand side of an assignment is - // not assignable. - // - // Example: - // func f() { - // const c = 1 - // c = 2 - // } - UnassignableOperand - - // NoNewVar occurs when a short variable declaration (':=') does not declare - // new variables. - // - // Example: - // func f() { - // x := 1 - // x := 2 - // } - NoNewVar - - // MultiValAssignOp occurs when an assignment operation (+=, *=, etc) does - // not have single-valued left-hand or right-hand side. - // - // Per the spec: - // "In assignment operations, both the left- and right-hand expression lists - // must contain exactly one single-valued expression" - // - // Example: - // func f() int { - // x, y := 1, 2 - // x, y += 1 - // return x + y - // } - MultiValAssignOp - - // InvalidIfaceAssign occurs when a value of type T is used as an - // interface, but T does not implement a method of the expected interface. - // - // Example: - // type I interface { - // f() - // } - // - // type T int - // - // var x I = T(1) - InvalidIfaceAssign - - // InvalidChanAssign occurs when a chan assignment is invalid. - // - // Per the spec, a value x is assignable to a channel type T if: - // "x is a bidirectional channel value, T is a channel type, x's type V and - // T have identical element types, and at least one of V or T is not a - // defined type." - // - // Example: - // type T1 chan int - // type T2 chan int - // - // var x T1 - // // Invalid assignment because both types are named - // var _ T2 = x - InvalidChanAssign - - // IncompatibleAssign occurs when the type of the right-hand side expression - // in an assignment cannot be assigned to the type of the variable being - // assigned. - // - // Example: - // var x []int - // var _ int = x - IncompatibleAssign - - // UnaddressableFieldAssign occurs when trying to assign to a struct field - // in a map value. - // - // Example: - // func f() { - // m := make(map[string]struct{i int}) - // m["foo"].i = 42 - // } - UnaddressableFieldAssign - - /* decls > type (+ other type expression codes) */ - - // NotAType occurs when the identifier used as the underlying type in a type - // declaration or the right-hand side of a type alias does not denote a type. - // - // Example: - // var S = 2 - // - // type T S - NotAType - - // InvalidArrayLen occurs when an array length is not a constant value. - // - // Example: - // var n = 3 - // var _ = [n]int{} - InvalidArrayLen - - // BlankIfaceMethod occurs when a method name is '_'. - // - // Per the spec: - // "The name of each explicitly specified method must be unique and not - // blank." - // - // Example: - // type T interface { - // _(int) - // } - BlankIfaceMethod - - // IncomparableMapKey occurs when a map key type does not support the == and - // != operators. - // - // Per the spec: - // "The comparison operators == and != must be fully defined for operands of - // the key type; thus the key type must not be a function, map, or slice." - // - // Example: - // var x map[T]int - // - // type T []int - IncomparableMapKey - - // InvalidIfaceEmbed occurs when a non-interface type is embedded in an - // interface. - // - // Example: - // type T struct {} - // - // func (T) m() - // - // type I interface { - // T - // } - InvalidIfaceEmbed - - // InvalidPtrEmbed occurs when an embedded field is of the pointer form *T, - // and T itself is itself a pointer, an unsafe.Pointer, or an interface. - // - // Per the spec: - // "An embedded field must be specified as a type name T or as a pointer to - // a non-interface type name *T, and T itself may not be a pointer type." - // - // Example: - // type T *int - // - // type S struct { - // *T - // } - InvalidPtrEmbed - - /* decls > func and method */ - - // BadRecv occurs when a method declaration does not have exactly one - // receiver parameter. - // - // Example: - // func () _() {} - BadRecv - - // InvalidRecv occurs when a receiver type expression is not of the form T - // or *T, or T is a pointer type. - // - // Example: - // type T struct {} - // - // func (**T) m() {} - InvalidRecv - - // DuplicateFieldAndMethod occurs when an identifier appears as both a field - // and method name. - // - // Example: - // type T struct { - // m int - // } - // - // func (T) m() {} - DuplicateFieldAndMethod - - // DuplicateMethod occurs when two methods on the same receiver type have - // the same name. - // - // Example: - // type T struct {} - // func (T) m() {} - // func (T) m(i int) int { return i } - DuplicateMethod - - /* decls > special */ - - // InvalidBlank occurs when a blank identifier is used as a value or type. - // - // Per the spec: - // "The blank identifier may appear as an operand only on the left-hand side - // of an assignment." - // - // Example: - // var x = _ - InvalidBlank - - // InvalidIota occurs when the predeclared identifier iota is used outside - // of a constant declaration. - // - // Example: - // var x = iota - InvalidIota - - // MissingInitBody occurs when an init function is missing its body. - // - // Example: - // func init() - MissingInitBody - - // InvalidInitSig occurs when an init function declares parameters or - // results. - // - // Example: - // func init() int { return 1 } - InvalidInitSig - - // InvalidInitDecl occurs when init is declared as anything other than a - // function. - // - // Example: - // var init = 1 - InvalidInitDecl - - // InvalidMainDecl occurs when main is declared as anything other than a - // function, in a main package. - InvalidMainDecl - - /* exprs */ - - // TooManyValues occurs when a function returns too many values for the - // expression context in which it is used. - // - // Example: - // func ReturnTwo() (int, int) { - // return 1, 2 - // } - // - // var x = ReturnTwo() - TooManyValues - - // NotAnExpr occurs when a type expression is used where a value expression - // is expected. - // - // Example: - // type T struct {} - // - // func f() { - // T - // } - NotAnExpr - - /* exprs > const */ - - // TruncatedFloat occurs when a float constant is truncated to an integer - // value. - // - // Example: - // var _ int = 98.6 - TruncatedFloat - - // NumericOverflow occurs when a numeric constant overflows its target type. - // - // Example: - // var x int8 = 1000 - NumericOverflow - - /* exprs > operation */ - - // UndefinedOp occurs when an operator is not defined for the type(s) used - // in an operation. - // - // Example: - // var c = "a" - "b" - UndefinedOp - - // MismatchedTypes occurs when operand types are incompatible in a binary - // operation. - // - // Example: - // var a = "hello" - // var b = 1 - // var c = a - b - MismatchedTypes - - // DivByZero occurs when a division operation is provable at compile - // time to be a division by zero. - // - // Example: - // const divisor = 0 - // var x int = 1/divisor - DivByZero - - // NonNumericIncDec occurs when an increment or decrement operator is - // applied to a non-numeric value. - // - // Example: - // func f() { - // var c = "c" - // c++ - // } - NonNumericIncDec - - /* exprs > ptr */ - - // UnaddressableOperand occurs when the & operator is applied to an - // unaddressable expression. - // - // Example: - // var x = &1 - UnaddressableOperand - - // InvalidIndirection occurs when a non-pointer value is indirected via the - // '*' operator. - // - // Example: - // var x int - // var y = *x - InvalidIndirection - - /* exprs > [] */ - - // NonIndexableOperand occurs when an index operation is applied to a value - // that cannot be indexed. - // - // Example: - // var x = 1 - // var y = x[1] - NonIndexableOperand - - // InvalidIndex occurs when an index argument is not of integer type, - // negative, or out-of-bounds. - // - // Example: - // var s = [...]int{1,2,3} - // var x = s[5] - // - // Example: - // var s = []int{1,2,3} - // var _ = s[-1] - // - // Example: - // var s = []int{1,2,3} - // var i string - // var _ = s[i] - InvalidIndex - - // SwappedSliceIndices occurs when constant indices in a slice expression - // are decreasing in value. - // - // Example: - // var _ = []int{1,2,3}[2:1] - SwappedSliceIndices - - /* operators > slice */ - - // NonSliceableOperand occurs when a slice operation is applied to a value - // whose type is not sliceable, or is unaddressable. - // - // Example: - // var x = [...]int{1, 2, 3}[:1] - // - // Example: - // var x = 1 - // var y = 1[:1] - NonSliceableOperand - - // InvalidSliceExpr occurs when a three-index slice expression (a[x:y:z]) is - // applied to a string. - // - // Example: - // var s = "hello" - // var x = s[1:2:3] - InvalidSliceExpr - - /* exprs > shift */ - - // InvalidShiftCount occurs when the right-hand side of a shift operation is - // either non-integer, negative, or too large. - // - // Example: - // var ( - // x string - // y int = 1 << x - // ) - InvalidShiftCount - - // InvalidShiftOperand occurs when the shifted operand is not an integer. - // - // Example: - // var s = "hello" - // var x = s << 2 - InvalidShiftOperand - - /* exprs > chan */ - - // InvalidReceive occurs when there is a channel receive from a value that - // is either not a channel, or is a send-only channel. - // - // Example: - // func f() { - // var x = 1 - // <-x - // } - InvalidReceive - - // InvalidSend occurs when there is a channel send to a value that is not a - // channel, or is a receive-only channel. - // - // Example: - // func f() { - // var x = 1 - // x <- "hello!" - // } - InvalidSend - - /* exprs > literal */ - - // DuplicateLitKey occurs when an index is duplicated in a slice, array, or - // map literal. - // - // Example: - // var _ = []int{0:1, 0:2} - // - // Example: - // var _ = map[string]int{"a": 1, "a": 2} - DuplicateLitKey - - // MissingLitKey occurs when a map literal is missing a key expression. - // - // Example: - // var _ = map[string]int{1} - MissingLitKey - - // InvalidLitIndex occurs when the key in a key-value element of a slice or - // array literal is not an integer constant. - // - // Example: - // var i = 0 - // var x = []string{i: "world"} - InvalidLitIndex - - // OversizeArrayLit occurs when an array literal exceeds its length. - // - // Example: - // var _ = [2]int{1,2,3} - OversizeArrayLit - - // MixedStructLit occurs when a struct literal contains a mix of positional - // and named elements. - // - // Example: - // var _ = struct{i, j int}{i: 1, 2} - MixedStructLit - - // InvalidStructLit occurs when a positional struct literal has an incorrect - // number of values. - // - // Example: - // var _ = struct{i, j int}{1,2,3} - InvalidStructLit - - // MissingLitField occurs when a struct literal refers to a field that does - // not exist on the struct type. - // - // Example: - // var _ = struct{i int}{j: 2} - MissingLitField - - // DuplicateLitField occurs when a struct literal contains duplicated - // fields. - // - // Example: - // var _ = struct{i int}{i: 1, i: 2} - DuplicateLitField - - // UnexportedLitField occurs when a positional struct literal implicitly - // assigns an unexported field of an imported type. - UnexportedLitField - - // InvalidLitField occurs when a field name is not a valid identifier. - // - // Example: - // var _ = struct{i int}{1: 1} - InvalidLitField - - // UntypedLit occurs when a composite literal omits a required type - // identifier. - // - // Example: - // type outer struct{ - // inner struct { i int } - // } - // - // var _ = outer{inner: {1}} - UntypedLit - - // InvalidLit occurs when a composite literal expression does not match its - // type. - // - // Example: - // type P *struct{ - // x int - // } - // var _ = P {} - InvalidLit - - /* exprs > selector */ - - // AmbiguousSelector occurs when a selector is ambiguous. - // - // Example: - // type E1 struct { i int } - // type E2 struct { i int } - // type T struct { E1; E2 } - // - // var x T - // var _ = x.i - AmbiguousSelector - - // UndeclaredImportedName occurs when a package-qualified identifier is - // undeclared by the imported package. - // - // Example: - // import "go/types" - // - // var _ = types.NotAnActualIdentifier - UndeclaredImportedName - - // UnexportedName occurs when a selector refers to an unexported identifier - // of an imported package. - // - // Example: - // import "reflect" - // - // type _ reflect.flag - UnexportedName - - // UndeclaredName occurs when an identifier is not declared in the current - // scope. - // - // Example: - // var x T - UndeclaredName - - // MissingFieldOrMethod occurs when a selector references a field or method - // that does not exist. - // - // Example: - // type T struct {} - // - // var x = T{}.f - MissingFieldOrMethod - - /* exprs > ... */ - - // BadDotDotDotSyntax occurs when a "..." occurs in a context where it is - // not valid. - // - // Example: - // var _ = map[int][...]int{0: {}} - BadDotDotDotSyntax - - // NonVariadicDotDotDot occurs when a "..." is used on the final argument to - // a non-variadic function. - // - // Example: - // func printArgs(s []string) { - // for _, a := range s { - // println(a) - // } - // } - // - // func f() { - // s := []string{"a", "b", "c"} - // printArgs(s...) - // } - NonVariadicDotDotDot - - // MisplacedDotDotDot occurs when a "..." is used somewhere other than the - // final argument to a function call. - // - // Example: - // func printArgs(args ...int) { - // for _, a := range args { - // println(a) - // } - // } - // - // func f() { - // a := []int{1,2,3} - // printArgs(0, a...) - // } - MisplacedDotDotDot - - // InvalidDotDotDotOperand occurs when a "..." operator is applied to a - // single-valued operand. - // - // Example: - // func printArgs(args ...int) { - // for _, a := range args { - // println(a) - // } - // } - // - // func f() { - // a := 1 - // printArgs(a...) - // } - // - // Example: - // func args() (int, int) { - // return 1, 2 - // } - // - // func printArgs(args ...int) { - // for _, a := range args { - // println(a) - // } - // } - // - // func g() { - // printArgs(args()...) - // } - InvalidDotDotDotOperand - - // InvalidDotDotDot occurs when a "..." is used in a non-variadic built-in - // function. - // - // Example: - // var s = []int{1, 2, 3} - // var l = len(s...) - InvalidDotDotDot - - /* exprs > built-in */ - - // UncalledBuiltin occurs when a built-in function is used as a - // function-valued expression, instead of being called. - // - // Per the spec: - // "The built-in functions do not have standard Go types, so they can only - // appear in call expressions; they cannot be used as function values." - // - // Example: - // var _ = copy - UncalledBuiltin - - // InvalidAppend occurs when append is called with a first argument that is - // not a slice. - // - // Example: - // var _ = append(1, 2) - InvalidAppend - - // InvalidCap occurs when an argument to the cap built-in function is not of - // supported type. - // - // See https://golang.org/ref/spec#Lengthand_capacity for information on - // which underlying types are supported as arguments to cap and len. - // - // Example: - // var s = 2 - // var x = cap(s) - InvalidCap - - // InvalidClose occurs when close(...) is called with an argument that is - // not of channel type, or that is a receive-only channel. - // - // Example: - // func f() { - // var x int - // close(x) - // } - InvalidClose - - // InvalidCopy occurs when the arguments are not of slice type or do not - // have compatible type. - // - // See https://golang.org/ref/spec#Appendingand_copying_slices for more - // information on the type requirements for the copy built-in. - // - // Example: - // func f() { - // var x []int - // y := []int64{1,2,3} - // copy(x, y) - // } - InvalidCopy - - // InvalidComplex occurs when the complex built-in function is called with - // arguments with incompatible types. - // - // Example: - // var _ = complex(float32(1), float64(2)) - InvalidComplex - - // InvalidDelete occurs when the delete built-in function is called with a - // first argument that is not a map. - // - // Example: - // func f() { - // m := "hello" - // delete(m, "e") - // } - InvalidDelete - - // InvalidImag occurs when the imag built-in function is called with an - // argument that does not have complex type. - // - // Example: - // var _ = imag(int(1)) - InvalidImag - - // InvalidLen occurs when an argument to the len built-in function is not of - // supported type. - // - // See https://golang.org/ref/spec#Lengthand_capacity for information on - // which underlying types are supported as arguments to cap and len. - // - // Example: - // var s = 2 - // var x = len(s) - InvalidLen - - // SwappedMakeArgs occurs when make is called with three arguments, and its - // length argument is larger than its capacity argument. - // - // Example: - // var x = make([]int, 3, 2) - SwappedMakeArgs - - // InvalidMake occurs when make is called with an unsupported type argument. - // - // See https://golang.org/ref/spec#Makingslices_maps_and_channels for - // information on the types that may be created using make. - // - // Example: - // var x = make(int) - InvalidMake - - // InvalidReal occurs when the real built-in function is called with an - // argument that does not have complex type. - // - // Example: - // var _ = real(int(1)) - InvalidReal - - /* exprs > assertion */ - - // InvalidAssert occurs when a type assertion is applied to a - // value that is not of interface type. - // - // Example: - // var x = 1 - // var _ = x.(float64) - InvalidAssert - - // ImpossibleAssert occurs for a type assertion x.(T) when the value x of - // interface cannot have dynamic type T, due to a missing or mismatching - // method on T. - // - // Example: - // type T int - // - // func (t *T) m() int { return int(*t) } - // - // type I interface { m() int } - // - // var x I - // var _ = x.(T) - ImpossibleAssert - - /* exprs > conversion */ - - // InvalidConversion occurs when the argument type cannot be converted to the - // target. - // - // See https://golang.org/ref/spec#Conversions for the rules of - // convertibility. - // - // Example: - // var x float64 - // var _ = string(x) - InvalidConversion - - // InvalidUntypedConversion occurs when an there is no valid implicit - // conversion from an untyped value satisfying the type constraints of the - // context in which it is used. - // - // Example: - // var _ = 1 + "" - InvalidUntypedConversion - - /* offsetof */ - - // BadOffsetofSyntax occurs when unsafe.Offsetof is called with an argument - // that is not a selector expression. - // - // Example: - // import "unsafe" - // - // var x int - // var _ = unsafe.Offsetof(x) - BadOffsetofSyntax - - // InvalidOffsetof occurs when unsafe.Offsetof is called with a method - // selector, rather than a field selector, or when the field is embedded via - // a pointer. - // - // Per the spec: - // - // "If f is an embedded field, it must be reachable without pointer - // indirections through fields of the struct. " - // - // Example: - // import "unsafe" - // - // type T struct { f int } - // type S struct { *T } - // var s S - // var _ = unsafe.Offsetof(s.f) - // - // Example: - // import "unsafe" - // - // type S struct{} - // - // func (S) m() {} - // - // var s S - // var _ = unsafe.Offsetof(s.m) - InvalidOffsetof - - /* control flow > scope */ - - // UnusedExpr occurs when a side-effect free expression is used as a - // statement. Such a statement has no effect. - // - // Example: - // func f(i int) { - // i*i - // } - UnusedExpr - - // UnusedVar occurs when a variable is declared but unused. - // - // Example: - // func f() { - // x := 1 - // } - UnusedVar - - // MissingReturn occurs when a function with results is missing a return - // statement. - // - // Example: - // func f() int {} - MissingReturn - - // WrongResultCount occurs when a return statement returns an incorrect - // number of values. - // - // Example: - // func ReturnOne() int { - // return 1, 2 - // } - WrongResultCount - - // OutOfScopeResult occurs when the name of a value implicitly returned by - // an empty return statement is shadowed in a nested scope. - // - // Example: - // func factor(n int) (i int) { - // for i := 2; i < n; i++ { - // if n%i == 0 { - // return - // } - // } - // return 0 - // } - OutOfScopeResult - - /* control flow > if */ - - // InvalidCond occurs when an if condition is not a boolean expression. - // - // Example: - // func checkReturn(i int) { - // if i { - // panic("non-zero return") - // } - // } - InvalidCond - - /* control flow > for */ - - // InvalidPostDecl occurs when there is a declaration in a for-loop post - // statement. - // - // Example: - // func f() { - // for i := 0; i < 10; j := 0 {} - // } - InvalidPostDecl - - // InvalidChanRange occurs when a send-only channel used in a range - // expression. - // - // Example: - // func sum(c chan<- int) { - // s := 0 - // for i := range c { - // s += i - // } - // } - InvalidChanRange - - // InvalidIterVar occurs when two iteration variables are used while ranging - // over a channel. - // - // Example: - // func f(c chan int) { - // for k, v := range c { - // println(k, v) - // } - // } - InvalidIterVar - - // InvalidRangeExpr occurs when the type of a range expression is not array, - // slice, string, map, or channel. - // - // Example: - // func f(i int) { - // for j := range i { - // println(j) - // } - // } - InvalidRangeExpr - - /* control flow > switch */ - - // MisplacedBreak occurs when a break statement is not within a for, switch, - // or select statement of the innermost function definition. - // - // Example: - // func f() { - // break - // } - MisplacedBreak - - // MisplacedContinue occurs when a continue statement is not within a for - // loop of the innermost function definition. - // - // Example: - // func sumeven(n int) int { - // proceed := func() { - // continue - // } - // sum := 0 - // for i := 1; i <= n; i++ { - // if i % 2 != 0 { - // proceed() - // } - // sum += i - // } - // return sum - // } - MisplacedContinue - - // MisplacedFallthrough occurs when a fallthrough statement is not within an - // expression switch. - // - // Example: - // func typename(i interface{}) string { - // switch i.(type) { - // case int64: - // fallthrough - // case int: - // return "int" - // } - // return "unsupported" - // } - MisplacedFallthrough - - // DuplicateCase occurs when a type or expression switch has duplicate - // cases. - // - // Example: - // func printInt(i int) { - // switch i { - // case 1: - // println("one") - // case 1: - // println("One") - // } - // } - DuplicateCase - - // DuplicateDefault occurs when a type or expression switch has multiple - // default clauses. - // - // Example: - // func printInt(i int) { - // switch i { - // case 1: - // println("one") - // default: - // println("One") - // default: - // println("1") - // } - // } - DuplicateDefault - - // BadTypeKeyword occurs when a .(type) expression is used anywhere other - // than a type switch. - // - // Example: - // type I interface { - // m() - // } - // var t I - // var _ = t.(type) - BadTypeKeyword - - // InvalidTypeSwitch occurs when .(type) is used on an expression that is - // not of interface type. - // - // Example: - // func f(i int) { - // switch x := i.(type) {} - // } - InvalidTypeSwitch - - /* control flow > select */ - - // InvalidSelectCase occurs when a select case is not a channel send or - // receive. - // - // Example: - // func checkChan(c <-chan int) bool { - // select { - // case c: - // return true - // default: - // return false - // } - // } - InvalidSelectCase - - /* control flow > labels and jumps */ - - // UndeclaredLabel occurs when an undeclared label is jumped to. - // - // Example: - // func f() { - // goto L - // } - UndeclaredLabel - - // DuplicateLabel occurs when a label is declared more than once. - // - // Example: - // func f() int { - // L: - // L: - // return 1 - // } - DuplicateLabel - - // MisplacedLabel occurs when a break or continue label is not on a for, - // switch, or select statement. - // - // Example: - // func f() { - // L: - // a := []int{1,2,3} - // for _, e := range a { - // if e > 10 { - // break L - // } - // println(a) - // } - // } - MisplacedLabel - - // UnusedLabel occurs when a label is declared but not used. - // - // Example: - // func f() { - // L: - // } - UnusedLabel - - // JumpOverDecl occurs when a label jumps over a variable declaration. - // - // Example: - // func f() int { - // goto L - // x := 2 - // L: - // x++ - // return x - // } - JumpOverDecl - - // JumpIntoBlock occurs when a forward jump goes to a label inside a nested - // block. - // - // Example: - // func f(x int) { - // goto L - // if x > 0 { - // L: - // print("inside block") - // } - // } - JumpIntoBlock - - /* control flow > calls */ - - // InvalidMethodExpr occurs when a pointer method is called but the argument - // is not addressable. - // - // Example: - // type T struct {} - // - // func (*T) m() int { return 1 } - // - // var _ = T.m(T{}) - InvalidMethodExpr - - // WrongArgCount occurs when too few or too many arguments are passed by a - // function call. - // - // Example: - // func f(i int) {} - // var x = f() - WrongArgCount - - // InvalidCall occurs when an expression is called that is not of function - // type. - // - // Example: - // var x = "x" - // var y = x() - InvalidCall - - /* control flow > suspended */ - - // UnusedResults occurs when a restricted expression-only built-in function - // is suspended via go or defer. Such a suspension discards the results of - // these side-effect free built-in functions, and therefore is ineffectual. - // - // Example: - // func f(a []int) int { - // defer len(a) - // return i - // } - UnusedResults - - // InvalidDefer occurs when a deferred expression is not a function call, - // for example if the expression is a type conversion. - // - // Example: - // func f(i int) int { - // defer int32(i) - // return i - // } - InvalidDefer - - // InvalidGo occurs when a go expression is not a function call, for example - // if the expression is a type conversion. - // - // Example: - // func f(i int) int { - // go int32(i) - // return i - // } - InvalidGo -) diff --git a/vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go b/vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go deleted file mode 100644 index 97f3ec891..000000000 --- a/vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by "stringer -type=ErrorCode"; DO NOT EDIT. - -package typesinternal - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[Test-1] - _ = x[BlankPkgName-2] - _ = x[MismatchedPkgName-3] - _ = x[InvalidPkgUse-4] - _ = x[BadImportPath-5] - _ = x[BrokenImport-6] - _ = x[ImportCRenamed-7] - _ = x[UnusedImport-8] - _ = x[InvalidInitCycle-9] - _ = x[DuplicateDecl-10] - _ = x[InvalidDeclCycle-11] - _ = x[InvalidTypeCycle-12] - _ = x[InvalidConstInit-13] - _ = x[InvalidConstVal-14] - _ = x[InvalidConstType-15] - _ = x[UntypedNil-16] - _ = x[WrongAssignCount-17] - _ = x[UnassignableOperand-18] - _ = x[NoNewVar-19] - _ = x[MultiValAssignOp-20] - _ = x[InvalidIfaceAssign-21] - _ = x[InvalidChanAssign-22] - _ = x[IncompatibleAssign-23] - _ = x[UnaddressableFieldAssign-24] - _ = x[NotAType-25] - _ = x[InvalidArrayLen-26] - _ = x[BlankIfaceMethod-27] - _ = x[IncomparableMapKey-28] - _ = x[InvalidIfaceEmbed-29] - _ = x[InvalidPtrEmbed-30] - _ = x[BadRecv-31] - _ = x[InvalidRecv-32] - _ = x[DuplicateFieldAndMethod-33] - _ = x[DuplicateMethod-34] - _ = x[InvalidBlank-35] - _ = x[InvalidIota-36] - _ = x[MissingInitBody-37] - _ = x[InvalidInitSig-38] - _ = x[InvalidInitDecl-39] - _ = x[InvalidMainDecl-40] - _ = x[TooManyValues-41] - _ = x[NotAnExpr-42] - _ = x[TruncatedFloat-43] - _ = x[NumericOverflow-44] - _ = x[UndefinedOp-45] - _ = x[MismatchedTypes-46] - _ = x[DivByZero-47] - _ = x[NonNumericIncDec-48] - _ = x[UnaddressableOperand-49] - _ = x[InvalidIndirection-50] - _ = x[NonIndexableOperand-51] - _ = x[InvalidIndex-52] - _ = x[SwappedSliceIndices-53] - _ = x[NonSliceableOperand-54] - _ = x[InvalidSliceExpr-55] - _ = x[InvalidShiftCount-56] - _ = x[InvalidShiftOperand-57] - _ = x[InvalidReceive-58] - _ = x[InvalidSend-59] - _ = x[DuplicateLitKey-60] - _ = x[MissingLitKey-61] - _ = x[InvalidLitIndex-62] - _ = x[OversizeArrayLit-63] - _ = x[MixedStructLit-64] - _ = x[InvalidStructLit-65] - _ = x[MissingLitField-66] - _ = x[DuplicateLitField-67] - _ = x[UnexportedLitField-68] - _ = x[InvalidLitField-69] - _ = x[UntypedLit-70] - _ = x[InvalidLit-71] - _ = x[AmbiguousSelector-72] - _ = x[UndeclaredImportedName-73] - _ = x[UnexportedName-74] - _ = x[UndeclaredName-75] - _ = x[MissingFieldOrMethod-76] - _ = x[BadDotDotDotSyntax-77] - _ = x[NonVariadicDotDotDot-78] - _ = x[MisplacedDotDotDot-79] - _ = x[InvalidDotDotDotOperand-80] - _ = x[InvalidDotDotDot-81] - _ = x[UncalledBuiltin-82] - _ = x[InvalidAppend-83] - _ = x[InvalidCap-84] - _ = x[InvalidClose-85] - _ = x[InvalidCopy-86] - _ = x[InvalidComplex-87] - _ = x[InvalidDelete-88] - _ = x[InvalidImag-89] - _ = x[InvalidLen-90] - _ = x[SwappedMakeArgs-91] - _ = x[InvalidMake-92] - _ = x[InvalidReal-93] - _ = x[InvalidAssert-94] - _ = x[ImpossibleAssert-95] - _ = x[InvalidConversion-96] - _ = x[InvalidUntypedConversion-97] - _ = x[BadOffsetofSyntax-98] - _ = x[InvalidOffsetof-99] - _ = x[UnusedExpr-100] - _ = x[UnusedVar-101] - _ = x[MissingReturn-102] - _ = x[WrongResultCount-103] - _ = x[OutOfScopeResult-104] - _ = x[InvalidCond-105] - _ = x[InvalidPostDecl-106] - _ = x[InvalidChanRange-107] - _ = x[InvalidIterVar-108] - _ = x[InvalidRangeExpr-109] - _ = x[MisplacedBreak-110] - _ = x[MisplacedContinue-111] - _ = x[MisplacedFallthrough-112] - _ = x[DuplicateCase-113] - _ = x[DuplicateDefault-114] - _ = x[BadTypeKeyword-115] - _ = x[InvalidTypeSwitch-116] - _ = x[InvalidSelectCase-117] - _ = x[UndeclaredLabel-118] - _ = x[DuplicateLabel-119] - _ = x[MisplacedLabel-120] - _ = x[UnusedLabel-121] - _ = x[JumpOverDecl-122] - _ = x[JumpIntoBlock-123] - _ = x[InvalidMethodExpr-124] - _ = x[WrongArgCount-125] - _ = x[InvalidCall-126] - _ = x[UnusedResults-127] - _ = x[InvalidDefer-128] - _ = x[InvalidGo-129] -} - -const _ErrorCode_name = "TestBlankPkgNameMismatchedPkgNameInvalidPkgUseBadImportPathBrokenImportImportCRenamedUnusedImportInvalidInitCycleDuplicateDeclInvalidDeclCycleInvalidTypeCycleInvalidConstInitInvalidConstValInvalidConstTypeUntypedNilWrongAssignCountUnassignableOperandNoNewVarMultiValAssignOpInvalidIfaceAssignInvalidChanAssignIncompatibleAssignUnaddressableFieldAssignNotATypeInvalidArrayLenBlankIfaceMethodIncomparableMapKeyInvalidIfaceEmbedInvalidPtrEmbedBadRecvInvalidRecvDuplicateFieldAndMethodDuplicateMethodInvalidBlankInvalidIotaMissingInitBodyInvalidInitSigInvalidInitDeclInvalidMainDeclTooManyValuesNotAnExprTruncatedFloatNumericOverflowUndefinedOpMismatchedTypesDivByZeroNonNumericIncDecUnaddressableOperandInvalidIndirectionNonIndexableOperandInvalidIndexSwappedSliceIndicesNonSliceableOperandInvalidSliceExprInvalidShiftCountInvalidShiftOperandInvalidReceiveInvalidSendDuplicateLitKeyMissingLitKeyInvalidLitIndexOversizeArrayLitMixedStructLitInvalidStructLitMissingLitFieldDuplicateLitFieldUnexportedLitFieldInvalidLitFieldUntypedLitInvalidLitAmbiguousSelectorUndeclaredImportedNameUnexportedNameUndeclaredNameMissingFieldOrMethodBadDotDotDotSyntaxNonVariadicDotDotDotMisplacedDotDotDotInvalidDotDotDotOperandInvalidDotDotDotUncalledBuiltinInvalidAppendInvalidCapInvalidCloseInvalidCopyInvalidComplexInvalidDeleteInvalidImagInvalidLenSwappedMakeArgsInvalidMakeInvalidRealInvalidAssertImpossibleAssertInvalidConversionInvalidUntypedConversionBadOffsetofSyntaxInvalidOffsetofUnusedExprUnusedVarMissingReturnWrongResultCountOutOfScopeResultInvalidCondInvalidPostDeclInvalidChanRangeInvalidIterVarInvalidRangeExprMisplacedBreakMisplacedContinueMisplacedFallthroughDuplicateCaseDuplicateDefaultBadTypeKeywordInvalidTypeSwitchInvalidSelectCaseUndeclaredLabelDuplicateLabelMisplacedLabelUnusedLabelJumpOverDeclJumpIntoBlockInvalidMethodExprWrongArgCountInvalidCallUnusedResultsInvalidDeferInvalidGo" - -var _ErrorCode_index = [...]uint16{0, 4, 16, 33, 46, 59, 71, 85, 97, 113, 126, 142, 158, 174, 189, 205, 215, 231, 250, 258, 274, 292, 309, 327, 351, 359, 374, 390, 408, 425, 440, 447, 458, 481, 496, 508, 519, 534, 548, 563, 578, 591, 600, 614, 629, 640, 655, 664, 680, 700, 718, 737, 749, 768, 787, 803, 820, 839, 853, 864, 879, 892, 907, 923, 937, 953, 968, 985, 1003, 1018, 1028, 1038, 1055, 1077, 1091, 1105, 1125, 1143, 1163, 1181, 1204, 1220, 1235, 1248, 1258, 1270, 1281, 1295, 1308, 1319, 1329, 1344, 1355, 1366, 1379, 1395, 1412, 1436, 1453, 1468, 1478, 1487, 1500, 1516, 1532, 1543, 1558, 1574, 1588, 1604, 1618, 1635, 1655, 1668, 1684, 1698, 1715, 1732, 1747, 1761, 1775, 1786, 1798, 1811, 1828, 1841, 1852, 1865, 1877, 1886} - -func (i ErrorCode) String() string { - i -= 1 - if i < 0 || i >= ErrorCode(len(_ErrorCode_index)-1) { - return "ErrorCode(" + strconv.FormatInt(int64(i+1), 10) + ")" - } - return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]] -} diff --git a/vendor/golang.org/x/tools/internal/typesinternal/types.go b/vendor/golang.org/x/tools/internal/typesinternal/types.go deleted file mode 100644 index a5bb408e2..000000000 --- a/vendor/golang.org/x/tools/internal/typesinternal/types.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package typesinternal - -import ( - "go/types" - "reflect" - "unsafe" -) - -func SetUsesCgo(conf *types.Config) bool { - v := reflect.ValueOf(conf).Elem() - - f := v.FieldByName("go115UsesCgo") - if !f.IsValid() { - f = v.FieldByName("UsesCgo") - if !f.IsValid() { - return false - } - } - - addr := unsafe.Pointer(f.UnsafeAddr()) - *(*bool)(addr) = true - - return true -} diff --git a/vendor/modules.txt b/vendor/modules.txt index e27716ab4..89835e8a3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -308,14 +308,8 @@ github.com/exoscale/egoscale/v2/internal/public-api # github.com/exoscale/packer-plugin-exoscale v0.1.1 ## explicit github.com/exoscale/packer-plugin-exoscale/post-processor/exoscale-import -# github.com/fatih/camelcase v1.0.0 -## explicit -github.com/fatih/camelcase # github.com/fatih/color v1.9.0 github.com/fatih/color -# github.com/fatih/structtag v1.0.0 -## explicit -github.com/fatih/structtag # github.com/ghodss/yaml v1.0.0 github.com/ghodss/yaml # github.com/go-ini/ini v1.25.4 @@ -1033,8 +1027,6 @@ golang.org/x/tools/cmd/goimports golang.org/x/tools/go/ast/astutil golang.org/x/tools/go/gcexportdata golang.org/x/tools/go/internal/gcimporter -golang.org/x/tools/go/internal/packagesdriver -golang.org/x/tools/go/packages golang.org/x/tools/imports golang.org/x/tools/internal/event golang.org/x/tools/internal/event/core @@ -1044,8 +1036,6 @@ golang.org/x/tools/internal/fastwalk golang.org/x/tools/internal/gocommand golang.org/x/tools/internal/gopathwalk golang.org/x/tools/internal/imports -golang.org/x/tools/internal/packagesinternal -golang.org/x/tools/internal/typesinternal # golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 golang.org/x/xerrors golang.org/x/xerrors/internal diff --git a/website/content/guides/hcl/component-object-spec.mdx b/website/content/guides/hcl/component-object-spec.mdx index 257b8966a..9f44cc367 100644 --- a/website/content/guides/hcl/component-object-spec.mdx +++ b/website/content/guides/hcl/component-object-spec.mdx @@ -18,7 +18,7 @@ follow to make it HCL2 enabled: - run `go install github.com/hashicorp/packer/cmd/mapstructure-to-hcl2` -- Add `//go:generate mapstructure-to-hcl2 -type Config` at the top of +- Add `//go:generate packer-sdc mapstructure-to-hcl2 -type Config` at the top of `config.go` - run `go generate ./my/example-plugin/...` diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-not-required.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-not-required.mdx index 3d41ca923..49f1bad34 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-not-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-not-required.mdx @@ -14,3 +14,5 @@ - `security_token` (string) - STS access token, can be set through template or by exporting as environment variable such as `export SECURITY_TOKEN=value`. + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-required.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-required.mdx index 5850bff3f..c372783f7 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig-required.mdx @@ -8,3 +8,5 @@ - `region` (string) - Alicloud region must be provided unless `profile` is set, but it can also be sourced from the `ALICLOUD_REGION` environment variable. + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig.mdx index 687425869..86bf41249 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudAccessConfig.mdx @@ -1,3 +1,5 @@ Config of alicloud + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx index 9d0a99c0e..8f32fbd26 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx @@ -38,3 +38,5 @@ data disk. Otherwise, Packer will keep the encryption setting to what it was in the source image. Please refer to Introduction of ECS disk encryption for more details. + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice.mdx index 6a724de7b..d407a356a 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevice.mdx @@ -2,3 +2,5 @@ The "AlicloudDiskDevice" object us used for the `ECSSystemDiskMapping` and `ECSImagesDiskMappings` options, and contains the following fields: + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx index 01f5c4edb..33d7a5cc1 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx @@ -33,3 +33,5 @@ ... } ``` + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices.mdx index d7656e239..55bd9c237 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudDiskDevices.mdx @@ -2,3 +2,5 @@ The "AlicloudDiskDevices" object is used to define disk mappings for your instance. + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-not-required.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-not-required.mdx index ea27adc86..796d7d63d 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-not-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-not-required.mdx @@ -57,3 +57,5 @@ containing a `key` and a `value` field. In HCL2 mode the [`dynamic_block`](/docs/templates/hcl_templates/expressions#dynamic-blocks) will allow you to create those programatically. + + diff --git a/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-required.mdx b/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-required.mdx index 657687dec..a8853dc96 100644 --- a/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/AlicloudImageConfig-required.mdx @@ -4,3 +4,5 @@ characters. It must begin with an uppercase/lowercase letter or a Chinese character, and may contain numbers, `_` or `-`. It cannot begin with `http://` or `https://`. + + diff --git a/website/content/partials/builder/alicloud/ecs/RunConfig-not-required.mdx b/website/content/partials/builder/alicloud/ecs/RunConfig-not-required.mdx index d8bcad19b..54fbca452 100644 --- a/website/content/partials/builder/alicloud/ecs/RunConfig-not-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/RunConfig-not-required.mdx @@ -95,3 +95,5 @@ - `ssh_private_ip` (bool) - If this value is true, packer will connect to the ECS created through private ip instead of allocating a public ip or an EIP. The default value is false. + + diff --git a/website/content/partials/builder/alicloud/ecs/RunConfig-required.mdx b/website/content/partials/builder/alicloud/ecs/RunConfig-required.mdx index 8ecb59861..21bce0b3a 100644 --- a/website/content/partials/builder/alicloud/ecs/RunConfig-required.mdx +++ b/website/content/partials/builder/alicloud/ecs/RunConfig-required.mdx @@ -9,3 +9,5 @@ - `source_image` (string) - This is the base image id which you want to create your customized images. + + diff --git a/website/content/partials/builder/azure/arm/Config-not-required.mdx b/website/content/partials/builder/azure/arm/Config-not-required.mdx index e3c969fe5..101f7b83e 100644 --- a/website/content/partials/builder/azure/arm/Config-not-required.mdx +++ b/website/content/partials/builder/azure/arm/Config-not-required.mdx @@ -291,3 +291,5 @@ temporary resource group asynchronously set this value. It's a boolean value and defaults to false. Important Setting this true means that your builds are faster, however any failed deletes are not reported. + + diff --git a/website/content/partials/builder/azure/arm/Config-required.mdx b/website/content/partials/builder/azure/arm/Config-required.mdx index 69126952b..eb4bd5cc3 100644 --- a/website/content/partials/builder/azure/arm/Config-required.mdx +++ b/website/content/partials/builder/azure/arm/Config-required.mdx @@ -36,3 +36,5 @@ `custom_managed_image_name` must also be set. See [documentation](https://docs.microsoft.com/en-us/azure/storage/storage-managed-disks-overview#images) to learn more about managed images. + + diff --git a/website/content/partials/builder/azure/arm/PlanInformation-not-required.mdx b/website/content/partials/builder/azure/arm/PlanInformation-not-required.mdx index 5d6ac93f7..df20d3fa9 100644 --- a/website/content/partials/builder/azure/arm/PlanInformation-not-required.mdx +++ b/website/content/partials/builder/azure/arm/PlanInformation-not-required.mdx @@ -7,3 +7,5 @@ - `plan_publisher` (string) - Plan Publisher - `plan_promotion_code` (string) - Plan Promotion Code + + diff --git a/website/content/partials/builder/azure/arm/SharedImageGallery-not-required.mdx b/website/content/partials/builder/azure/arm/SharedImageGallery-not-required.mdx index 1832eb1f3..3d7259951 100644 --- a/website/content/partials/builder/azure/arm/SharedImageGallery-not-required.mdx +++ b/website/content/partials/builder/azure/arm/SharedImageGallery-not-required.mdx @@ -13,3 +13,5 @@ across regions due to image synchronization latency. To ensure a consistent version across regions set this value to one that is available in all regions where you are deploying. + + diff --git a/website/content/partials/builder/azure/arm/SharedImageGalleryDestination-not-required.mdx b/website/content/partials/builder/azure/arm/SharedImageGalleryDestination-not-required.mdx index d641fe1e1..085ed5e13 100644 --- a/website/content/partials/builder/azure/arm/SharedImageGalleryDestination-not-required.mdx +++ b/website/content/partials/builder/azure/arm/SharedImageGalleryDestination-not-required.mdx @@ -11,3 +11,5 @@ - `image_version` (string) - Sig Destination Image Version - `replication_regions` ([]string) - Sig Destination Replication Regions + + diff --git a/website/content/partials/builder/azure/chroot/Config-not-required.mdx b/website/content/partials/builder/azure/chroot/Config-not-required.mdx index 76e2ea5e7..4508bd71e 100644 --- a/website/content/partials/builder/azure/chroot/Config-not-required.mdx +++ b/website/content/partials/builder/azure/chroot/Config-not-required.mdx @@ -62,3 +62,5 @@ - `image_resource_id` (string) - The managed image to create using this build. - `shared_image_destination` (SharedImageGalleryDestination) - The shared image to create using this build. + + diff --git a/website/content/partials/builder/azure/chroot/Config-required.mdx b/website/content/partials/builder/azure/chroot/Config-required.mdx index 449553c66..655da4bcd 100644 --- a/website/content/partials/builder/azure/chroot/Config-required.mdx +++ b/website/content/partials/builder/azure/chroot/Config-required.mdx @@ -4,3 +4,5 @@ - a shared image version resource ID - a managed disk resource ID - a publisher:offer:sku:version specifier for plaform image sources. + + diff --git a/website/content/partials/builder/azure/chroot/Config.mdx b/website/content/partials/builder/azure/chroot/Config.mdx index 49d57bcb2..e104d62f7 100644 --- a/website/content/partials/builder/azure/chroot/Config.mdx +++ b/website/content/partials/builder/azure/chroot/Config.mdx @@ -2,3 +2,5 @@ Config is the configuration that is chained through the steps and settable from the template. + + diff --git a/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-not-required.mdx b/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-not-required.mdx index 2cb522d8c..4a90d461f 100644 --- a/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-not-required.mdx +++ b/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-not-required.mdx @@ -3,3 +3,5 @@ - `target_regions` ([]TargetRegion) - Target Regions - `exclude_from_latest` (bool) - Exclude From Latest + + diff --git a/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-required.mdx b/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-required.mdx index 731830936..7ec91ff39 100644 --- a/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-required.mdx +++ b/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination-required.mdx @@ -7,3 +7,5 @@ - `image_name` (string) - Image Name - `image_version` (string) - Image Version + + diff --git a/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination.mdx b/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination.mdx index ef8e701f9..565c5eda1 100644 --- a/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination.mdx +++ b/website/content/partials/builder/azure/chroot/SharedImageGalleryDestination.mdx @@ -2,3 +2,5 @@ SharedImageGalleryDestination models an image version in a Shared Image Gallery that can be used as a destination. + + diff --git a/website/content/partials/builder/azure/chroot/TargetRegion-not-required.mdx b/website/content/partials/builder/azure/chroot/TargetRegion-not-required.mdx index 25312b24d..d277b7f54 100644 --- a/website/content/partials/builder/azure/chroot/TargetRegion-not-required.mdx +++ b/website/content/partials/builder/azure/chroot/TargetRegion-not-required.mdx @@ -3,3 +3,5 @@ - `replicas` (int32) - Number of replicas in this region. Default: 1 - `storage_account_type` (string) - Storage account type: Standard_LRS or Standard_ZRS. Default: Standard_ZRS + + diff --git a/website/content/partials/builder/azure/chroot/TargetRegion-required.mdx b/website/content/partials/builder/azure/chroot/TargetRegion-required.mdx index 198e49065..c76629422 100644 --- a/website/content/partials/builder/azure/chroot/TargetRegion-required.mdx +++ b/website/content/partials/builder/azure/chroot/TargetRegion-required.mdx @@ -1,3 +1,5 @@ - `name` (string) - Name of the Azure region + + diff --git a/website/content/partials/builder/azure/chroot/TargetRegion.mdx b/website/content/partials/builder/azure/chroot/TargetRegion.mdx index 6a5e060b3..28ac589e2 100644 --- a/website/content/partials/builder/azure/chroot/TargetRegion.mdx +++ b/website/content/partials/builder/azure/chroot/TargetRegion.mdx @@ -1,3 +1,5 @@ TargetRegion describes a region where the shared image should be replicated + + diff --git a/website/content/partials/builder/azure/common/client/Config-not-required.mdx b/website/content/partials/builder/azure/common/client/Config-not-required.mdx index c45b07915..85f3489a5 100644 --- a/website/content/partials/builder/azure/common/client/Config-not-required.mdx +++ b/website/content/partials/builder/azure/common/client/Config-not-required.mdx @@ -32,3 +32,5 @@ Azure CLI authentication will use the credential marked as `isDefault` and can be verified using `az account show`. Works with normal authentication (`az login`) and service principals (`az login --service-principal --username APP_ID --password PASSWORD --tenant TENANT_ID`). Ignores all other configurations if enabled. + + diff --git a/website/content/partials/builder/azure/common/client/Config.mdx b/website/content/partials/builder/azure/common/client/Config.mdx index 0be21ae33..16806af81 100644 --- a/website/content/partials/builder/azure/common/client/Config.mdx +++ b/website/content/partials/builder/azure/common/client/Config.mdx @@ -8,3 +8,5 @@ log on the current user (tokens will be cached). If none of these options are specified, Packer will attempt to use the Managed Identity and subscription of the VM that Packer is running on. This will only work if Packer is running on an Azure VM. + + diff --git a/website/content/partials/builder/azure/dtl/ArtifactParameter-not-required.mdx b/website/content/partials/builder/azure/dtl/ArtifactParameter-not-required.mdx index 05071c8c6..fc507c1bd 100644 --- a/website/content/partials/builder/azure/dtl/ArtifactParameter-not-required.mdx +++ b/website/content/partials/builder/azure/dtl/ArtifactParameter-not-required.mdx @@ -5,3 +5,5 @@ - `value` (string) - Value - `type` (string) - Type + + diff --git a/website/content/partials/builder/azure/dtl/Config-not-required.mdx b/website/content/partials/builder/azure/dtl/Config-not-required.mdx index 7a84f7bb6..afb160163 100644 --- a/website/content/partials/builder/azure/dtl/Config-not-required.mdx +++ b/website/content/partials/builder/azure/dtl/Config-not-required.mdx @@ -165,3 +165,5 @@ - `dtl_artifacts` ([]DtlArtifact) - Dtl Artifacts - `vm_name` (string) - VM Name + + diff --git a/website/content/partials/builder/azure/dtl/DtlArtifact-not-required.mdx b/website/content/partials/builder/azure/dtl/DtlArtifact-not-required.mdx index 00cfc5811..4df27fc30 100644 --- a/website/content/partials/builder/azure/dtl/DtlArtifact-not-required.mdx +++ b/website/content/partials/builder/azure/dtl/DtlArtifact-not-required.mdx @@ -7,3 +7,5 @@ - `artifact_id` (string) - Artifact Id - `parameters` ([]ArtifactParameter) - Parameters + + diff --git a/website/content/partials/builder/azure/dtl/SharedImageGallery-not-required.mdx b/website/content/partials/builder/azure/dtl/SharedImageGallery-not-required.mdx index adad4c26f..7869d459a 100644 --- a/website/content/partials/builder/azure/dtl/SharedImageGallery-not-required.mdx +++ b/website/content/partials/builder/azure/dtl/SharedImageGallery-not-required.mdx @@ -9,3 +9,5 @@ - `image_name` (string) - Image Name - `image_version` (string) - Image Version + + diff --git a/website/content/partials/builder/azure/dtl/SharedImageGalleryDestination-not-required.mdx b/website/content/partials/builder/azure/dtl/SharedImageGalleryDestination-not-required.mdx index 7fc167c31..6cd1f91a5 100644 --- a/website/content/partials/builder/azure/dtl/SharedImageGalleryDestination-not-required.mdx +++ b/website/content/partials/builder/azure/dtl/SharedImageGalleryDestination-not-required.mdx @@ -9,3 +9,5 @@ - `image_version` (string) - Sig Destination Image Version - `replication_regions` ([]string) - Sig Destination Replication Regions + + diff --git a/website/content/partials/builder/cloudstack/Config-not-required.mdx b/website/content/partials/builder/cloudstack/Config-not-required.mdx index da039db9f..e8fd71860 100644 --- a/website/content/partials/builder/cloudstack/Config-not-required.mdx +++ b/website/content/partials/builder/cloudstack/Config-not-required.mdx @@ -107,3 +107,5 @@ - `template_tag` (string) - - `tags` (map[string]string) - Tags + + diff --git a/website/content/partials/builder/cloudstack/Config-required.mdx b/website/content/partials/builder/cloudstack/Config-required.mdx index 3ad2c53dc..906133d4c 100644 --- a/website/content/partials/builder/cloudstack/Config-required.mdx +++ b/website/content/partials/builder/cloudstack/Config-required.mdx @@ -30,3 +30,5 @@ - `template_os` (string) - The name or ID of the template OS for the new template that will be created. + + diff --git a/website/content/partials/builder/cloudstack/Config.mdx b/website/content/partials/builder/cloudstack/Config.mdx index 607ce4dc6..57d01102e 100644 --- a/website/content/partials/builder/cloudstack/Config.mdx +++ b/website/content/partials/builder/cloudstack/Config.mdx @@ -1,3 +1,5 @@ Config holds all the details needed to configure the builder. + + diff --git a/website/content/partials/builder/digitalocean/Config-not-required.mdx b/website/content/partials/builder/digitalocean/Config-not-required.mdx index 4eabeacce..b6e4c3372 100644 --- a/website/content/partials/builder/digitalocean/Config-not-required.mdx +++ b/website/content/partials/builder/digitalocean/Config-not-required.mdx @@ -51,3 +51,5 @@ If the droplet is or going to be accessible only from the local network because it is at behind a firewall, then communicators should use the private IP instead of the public IP. Before using this, private_networking should be enabled. + + diff --git a/website/content/partials/builder/digitalocean/Config-required.mdx b/website/content/partials/builder/digitalocean/Config-required.mdx index 79df1f162..ad080d36c 100644 --- a/website/content/partials/builder/digitalocean/Config-required.mdx +++ b/website/content/partials/builder/digitalocean/Config-required.mdx @@ -18,3 +18,5 @@ image that will be used to launch a new droplet and provision it. See https://developers.digitalocean.com/documentation/v2/#list-all-images for details on how to get a list of the accepted image names/slugs. + + diff --git a/website/content/partials/builder/googlecompute/Config-not-required.mdx b/website/content/partials/builder/googlecompute/Config-not-required.mdx index 90ab25cdf..c4a15667b 100644 --- a/website/content/partials/builder/googlecompute/Config-not-required.mdx +++ b/website/content/partials/builder/googlecompute/Config-not-required.mdx @@ -252,3 +252,5 @@ Note: All other instance metadata, including startup scripts, are still added to the instance during it's creation. Example value: `5m`. + + diff --git a/website/content/partials/builder/googlecompute/Config-required.mdx b/website/content/partials/builder/googlecompute/Config-required.mdx index ba9e0c308..ca868e695 100644 --- a/website/content/partials/builder/googlecompute/Config-required.mdx +++ b/website/content/partials/builder/googlecompute/Config-required.mdx @@ -13,3 +13,5 @@ - `zone` (string) - The zone in which to launch the instance used to create the image. Example: "us-central1-a" + + diff --git a/website/content/partials/builder/googlecompute/Config.mdx b/website/content/partials/builder/googlecompute/Config.mdx index f78d2a727..c9b6c2ab7 100644 --- a/website/content/partials/builder/googlecompute/Config.mdx +++ b/website/content/partials/builder/googlecompute/Config.mdx @@ -3,3 +3,5 @@ Config is the configuration structure for the GCE builder. It stores both the publicly settable state as well as the privately generated state of the config object. + + diff --git a/website/content/partials/builder/googlecompute/CustomerEncryptionKey-not-required.mdx b/website/content/partials/builder/googlecompute/CustomerEncryptionKey-not-required.mdx index cb1e2fdee..8faa301c9 100644 --- a/website/content/partials/builder/googlecompute/CustomerEncryptionKey-not-required.mdx +++ b/website/content/partials/builder/googlecompute/CustomerEncryptionKey-not-required.mdx @@ -5,3 +5,5 @@ - `rawKey` (string) - RawKey: Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. + + diff --git a/website/content/partials/builder/googlecompute/IAPConfig-not-required.mdx b/website/content/partials/builder/googlecompute/IAPConfig-not-required.mdx index 0ce215f50..e2ddb54ef 100644 --- a/website/content/partials/builder/googlecompute/IAPConfig-not-required.mdx +++ b/website/content/partials/builder/googlecompute/IAPConfig-not-required.mdx @@ -23,3 +23,5 @@ - `iap_tunnel_launch_wait` (int) - How long to wait, in seconds, before assuming a tunnel launch was successful. Defaults to 30 seconds for SSH or 40 seconds for WinRM. + + diff --git a/website/content/partials/builder/googlecompute/IAPConfig.mdx b/website/content/partials/builder/googlecompute/IAPConfig.mdx index d32db76be..ed082968f 100644 --- a/website/content/partials/builder/googlecompute/IAPConfig.mdx +++ b/website/content/partials/builder/googlecompute/IAPConfig.mdx @@ -1,3 +1,5 @@ StepStartTunnel represents a Packer build step that launches an IAP tunnel + + diff --git a/website/content/partials/builder/hyperone/Config-not-required.mdx b/website/content/partials/builder/hyperone/Config-not-required.mdx index b8b3fbb94..a29fcd1be 100644 --- a/website/content/partials/builder/hyperone/Config-not-required.mdx +++ b/website/content/partials/builder/hyperone/Config-not-required.mdx @@ -88,3 +88,5 @@ - `user_data` (string) - User data to launch with the server. Packer will not automatically wait for a user script to finish before shutting down the instance, this must be handled in a provisioner. + + diff --git a/website/content/partials/builder/hyperone/Config-required.mdx b/website/content/partials/builder/hyperone/Config-required.mdx index 8d9846d25..f9b5552e1 100644 --- a/website/content/partials/builder/hyperone/Config-required.mdx +++ b/website/content/partials/builder/hyperone/Config-required.mdx @@ -13,3 +13,5 @@ - `vm_type` (string) - ID or name of the type this server should be created with. - `disk_size` (float32) - Size of the created disk, in GiB. + + diff --git a/website/content/partials/builder/hyperv/common/CommonConfig-not-required.mdx b/website/content/partials/builder/hyperv/common/CommonConfig-not-required.mdx index aa7a2b789..29344edb3 100644 --- a/website/content/partials/builder/hyperv/common/CommonConfig-not-required.mdx +++ b/website/content/partials/builder/hyperv/common/CommonConfig-not-required.mdx @@ -137,3 +137,5 @@ include itself as the first boot option. **NB** This only works for Generation 2 machines. + + diff --git a/website/content/partials/builder/hyperv/common/OutputConfig-not-required.mdx b/website/content/partials/builder/hyperv/common/OutputConfig-not-required.mdx index 77f3be65d..7fe7d5ce4 100644 --- a/website/content/partials/builder/hyperv/common/OutputConfig-not-required.mdx +++ b/website/content/partials/builder/hyperv/common/OutputConfig-not-required.mdx @@ -7,3 +7,5 @@ packer is executed from. This directory must not exist or, if created, must be empty prior to running the builder. By default this is "output-BUILDNAME" where "BUILDNAME" is the name of the build. + + diff --git a/website/content/partials/builder/hyperv/iso/Builder.mdx b/website/content/partials/builder/hyperv/iso/Builder.mdx index d1741938a..779bc2330 100644 --- a/website/content/partials/builder/hyperv/iso/Builder.mdx +++ b/website/content/partials/builder/hyperv/iso/Builder.mdx @@ -2,3 +2,5 @@ Builder implements packersdk.Builder and builds the actual Hyperv images. + + diff --git a/website/content/partials/builder/hyperv/iso/Config-not-required.mdx b/website/content/partials/builder/hyperv/iso/Config-not-required.mdx index 163b2b7f5..0554b02cb 100644 --- a/website/content/partials/builder/hyperv/iso/Config-not-required.mdx +++ b/website/content/partials/builder/hyperv/iso/Config-not-required.mdx @@ -20,3 +20,5 @@ disk_block_size will be ignored. The most likely use case for this option is outputing a disk that is in the format required for upload to Azure. + + diff --git a/website/content/partials/builder/hyperv/vmcx/Builder.mdx b/website/content/partials/builder/hyperv/vmcx/Builder.mdx index e32f49ca6..1670a5e47 100644 --- a/website/content/partials/builder/hyperv/vmcx/Builder.mdx +++ b/website/content/partials/builder/hyperv/vmcx/Builder.mdx @@ -2,3 +2,5 @@ Builder implements packersdk.Builder and builds the actual Hyperv images. + + diff --git a/website/content/partials/builder/hyperv/vmcx/Config-not-required.mdx b/website/content/partials/builder/hyperv/vmcx/Config-not-required.mdx index 4da6bda6e..fd2b6c65f 100644 --- a/website/content/partials/builder/hyperv/vmcx/Config-not-required.mdx +++ b/website/content/partials/builder/hyperv/vmcx/Config-not-required.mdx @@ -21,3 +21,5 @@ - `copy_in_compare` (bool) - When cloning a vm to build from, we run a powershell Compare-VM command, which, depending on your version of Windows, may need the "Copy" flag to be set to true or false. Defaults to "false". Command: + + diff --git a/website/content/partials/builder/lxc/Config-not-required.mdx b/website/content/partials/builder/lxc/Config-not-required.mdx index 753a24554..03e3c005e 100644 --- a/website/content/partials/builder/lxc/Config-not-required.mdx +++ b/website/content/partials/builder/lxc/Config-not-required.mdx @@ -38,3 +38,5 @@ - `target_runlevel` (int) - The minimum run level to wait for the container to reach. Note some distributions (Ubuntu) simulate run levels and may report 5 rather than 3. + + diff --git a/website/content/partials/builder/lxc/Config-required.mdx b/website/content/partials/builder/lxc/Config-required.mdx index 2a7e07dce..bcd9b77d2 100644 --- a/website/content/partials/builder/lxc/Config-required.mdx +++ b/website/content/partials/builder/lxc/Config-required.mdx @@ -6,3 +6,5 @@ - `template_environment_vars` ([]string) - Environmental variables to use to build the template with. + + diff --git a/website/content/partials/builder/lxd/Config-not-required.mdx b/website/content/partials/builder/lxd/Config-not-required.mdx index 8f95f14ac..579374114 100644 --- a/website/content/partials/builder/lxd/Config-not-required.mdx +++ b/website/content/partials/builder/lxd/Config-not-required.mdx @@ -22,3 +22,5 @@ - `launch_config` (map[string]string) - List of key/value pairs you wish to pass to lxc launch via --config. Defaults to empty. + + diff --git a/website/content/partials/builder/lxd/Config-required.mdx b/website/content/partials/builder/lxd/Config-required.mdx index 781918447..add0c0f31 100644 --- a/website/content/partials/builder/lxd/Config-required.mdx +++ b/website/content/partials/builder/lxd/Config-required.mdx @@ -3,3 +3,5 @@ - `image` (string) - The source image to use when creating the build container. This can be a (local or remote) image (name or fingerprint). E.G. my-base-image, ubuntu-daily:x, 08fababf6f27, ... + + diff --git a/website/content/partials/builder/ncloud/Config-not-required.mdx b/website/content/partials/builder/ncloud/Config-not-required.mdx index 92dcd967b..6d4683716 100644 --- a/website/content/partials/builder/ncloud/Config-not-required.mdx +++ b/website/content/partials/builder/ncloud/Config-not-required.mdx @@ -43,3 +43,5 @@ - `vpc_no` (string) - The ID of the VPC where you want to place the Server Instance. If this field is left blank, Packer will try to get the VPC ID from the `subnet_no`. (You are required to least one between two parameters if u want using VPC environment: `vpc_no` or `subnet_no`) + + diff --git a/website/content/partials/builder/ncloud/Config-required.mdx b/website/content/partials/builder/ncloud/Config-required.mdx index a8a731a31..2268da5f5 100644 --- a/website/content/partials/builder/ncloud/Config-required.mdx +++ b/website/content/partials/builder/ncloud/Config-required.mdx @@ -4,3 +4,5 @@ (member_server_image_no is required if not specified) - `server_product_code` (string) - Product (spec) code to create. + + diff --git a/website/content/partials/builder/ncloud/Config.mdx b/website/content/partials/builder/ncloud/Config.mdx index c44a8beb1..6695ac43b 100644 --- a/website/content/partials/builder/ncloud/Config.mdx +++ b/website/content/partials/builder/ncloud/Config.mdx @@ -1,3 +1,5 @@ Config is structure to use packer builder plugin for Naver Cloud Platform + + diff --git a/website/content/partials/builder/openstack/AccessConfig-not-required.mdx b/website/content/partials/builder/openstack/AccessConfig-not-required.mdx index ae008068c..b13a72832 100644 --- a/website/content/partials/builder/openstack/AccessConfig-not-required.mdx +++ b/website/content/partials/builder/openstack/AccessConfig-not-required.mdx @@ -54,3 +54,5 @@ [documentation](https://docs.openstack.org/os-client-config/latest/user/configuration.html) for more information about `clouds.yaml` files. If omitted, the `OS_CLOUD` environment variable is used. + + diff --git a/website/content/partials/builder/openstack/AccessConfig-required.mdx b/website/content/partials/builder/openstack/AccessConfig-required.mdx index a1cbb90c3..b92f1116c 100644 --- a/website/content/partials/builder/openstack/AccessConfig-required.mdx +++ b/website/content/partials/builder/openstack/AccessConfig-required.mdx @@ -13,3 +13,5 @@ - `identity_endpoint` (string) - The URL to the OpenStack Identity service. If not specified, Packer will use the environment variables OS_AUTH_URL, if set. This is not required if using cloud.yaml. + + diff --git a/website/content/partials/builder/openstack/AccessConfig.mdx b/website/content/partials/builder/openstack/AccessConfig.mdx index 0508fd3b0..663a672b7 100644 --- a/website/content/partials/builder/openstack/AccessConfig.mdx +++ b/website/content/partials/builder/openstack/AccessConfig.mdx @@ -1,3 +1,5 @@ AccessConfig is for common configuration related to openstack access + + diff --git a/website/content/partials/builder/openstack/ImageConfig-not-required.mdx b/website/content/partials/builder/openstack/ImageConfig-not-required.mdx index d129abc2f..edc5b79c1 100644 --- a/website/content/partials/builder/openstack/ImageConfig-not-required.mdx +++ b/website/content/partials/builder/openstack/ImageConfig-not-required.mdx @@ -20,3 +20,5 @@ - `image_min_disk` (int) - Minimum disk size needed to boot image, in gigabytes. - `skip_create_image` (bool) - Skip creating the image. Useful for setting to `true` during a build test stage. Defaults to `false`. + + diff --git a/website/content/partials/builder/openstack/ImageConfig-required.mdx b/website/content/partials/builder/openstack/ImageConfig-required.mdx index ea4cb6e7d..b4d93248b 100644 --- a/website/content/partials/builder/openstack/ImageConfig-required.mdx +++ b/website/content/partials/builder/openstack/ImageConfig-required.mdx @@ -1,3 +1,5 @@ - `image_name` (string) - The name of the resulting image. + + diff --git a/website/content/partials/builder/openstack/ImageConfig.mdx b/website/content/partials/builder/openstack/ImageConfig.mdx index ba7828a09..f32129b98 100644 --- a/website/content/partials/builder/openstack/ImageConfig.mdx +++ b/website/content/partials/builder/openstack/ImageConfig.mdx @@ -1,3 +1,5 @@ ImageConfig is for common configuration related to creating Images. + + diff --git a/website/content/partials/builder/openstack/ImageFilter-not-required.mdx b/website/content/partials/builder/openstack/ImageFilter-not-required.mdx index 5c001b824..67922973d 100644 --- a/website/content/partials/builder/openstack/ImageFilter-not-required.mdx +++ b/website/content/partials/builder/openstack/ImageFilter-not-required.mdx @@ -6,3 +6,5 @@ - `most_recent` (bool) - Selects the newest created image when true. This is most useful for selecting a daily distro build. + + diff --git a/website/content/partials/builder/openstack/ImageFilterOptions-not-required.mdx b/website/content/partials/builder/openstack/ImageFilterOptions-not-required.mdx index 2913bb6c6..825e3ae4d 100644 --- a/website/content/partials/builder/openstack/ImageFilterOptions-not-required.mdx +++ b/website/content/partials/builder/openstack/ImageFilterOptions-not-required.mdx @@ -9,3 +9,5 @@ - `visibility` (string) - Visibility - `properties` (map[string]string) - Properties + + diff --git a/website/content/partials/builder/openstack/RunConfig-not-required.mdx b/website/content/partials/builder/openstack/RunConfig-not-required.mdx index 13a263272..db7698fdd 100644 --- a/website/content/partials/builder/openstack/RunConfig-not-required.mdx +++ b/website/content/partials/builder/openstack/RunConfig-not-required.mdx @@ -95,3 +95,5 @@ - `openstack_provider` (string) - Not really used, but here for BC - `use_floating_ip` (bool) - *Deprecated* use `floating_ip` or `floating_ip_pool` instead. + + diff --git a/website/content/partials/builder/openstack/RunConfig-required.mdx b/website/content/partials/builder/openstack/RunConfig-required.mdx index 7351dcd8b..9500023a3 100644 --- a/website/content/partials/builder/openstack/RunConfig-required.mdx +++ b/website/content/partials/builder/openstack/RunConfig-required.mdx @@ -60,3 +60,5 @@ - `flavor` (string) - The ID, name, or full URL for the desired flavor for the server to be created. + + diff --git a/website/content/partials/builder/openstack/RunConfig.mdx b/website/content/partials/builder/openstack/RunConfig.mdx index f8cb860cc..bced600f6 100644 --- a/website/content/partials/builder/openstack/RunConfig.mdx +++ b/website/content/partials/builder/openstack/RunConfig.mdx @@ -2,3 +2,5 @@ RunConfig contains configuration for running an instance from a source image and details on how to access that launched image. + + diff --git a/website/content/partials/builder/parallels/common/HWConfig-not-required.mdx b/website/content/partials/builder/parallels/common/HWConfig-not-required.mdx index 5dc41772e..7621832c2 100644 --- a/website/content/partials/builder/parallels/common/HWConfig-not-required.mdx +++ b/website/content/partials/builder/parallels/common/HWConfig-not-required.mdx @@ -11,3 +11,5 @@ - `usb` (bool) - Specifies whether to enable the USB bus when building the VM. Defaults to false. + + diff --git a/website/content/partials/builder/parallels/common/OutputConfig-not-required.mdx b/website/content/partials/builder/parallels/common/OutputConfig-not-required.mdx index 11c918433..8454fe870 100644 --- a/website/content/partials/builder/parallels/common/OutputConfig-not-required.mdx +++ b/website/content/partials/builder/parallels/common/OutputConfig-not-required.mdx @@ -6,3 +6,5 @@ is executed. This directory must not exist or be empty prior to running the builder. By default this is "output-BUILDNAME" where "BUILDNAME" is the name of the build. + + diff --git a/website/content/partials/builder/parallels/common/OutputConfig.mdx b/website/content/partials/builder/parallels/common/OutputConfig.mdx index a3f100f31..0f1b45d64 100644 --- a/website/content/partials/builder/parallels/common/OutputConfig.mdx +++ b/website/content/partials/builder/parallels/common/OutputConfig.mdx @@ -1,3 +1,5 @@ OutputConfig contains the configuration for builder's output. + + diff --git a/website/content/partials/builder/parallels/common/PrlctlConfig-not-required.mdx b/website/content/partials/builder/parallels/common/PrlctlConfig-not-required.mdx index ccf50199b..891274b3d 100644 --- a/website/content/partials/builder/parallels/common/PrlctlConfig-not-required.mdx +++ b/website/content/partials/builder/parallels/common/PrlctlConfig-not-required.mdx @@ -10,3 +10,5 @@ template, where the Name variable is replaced with the VM name. More details on how to use prlctl are below. + + diff --git a/website/content/partials/builder/parallels/common/PrlctlConfig.mdx b/website/content/partials/builder/parallels/common/PrlctlConfig.mdx index 8a41294e9..6d1f60e1d 100644 --- a/website/content/partials/builder/parallels/common/PrlctlConfig.mdx +++ b/website/content/partials/builder/parallels/common/PrlctlConfig.mdx @@ -2,3 +2,5 @@ PrlctlConfig contains the configuration for running "prlctl" commands before the VM start. + + diff --git a/website/content/partials/builder/parallels/common/PrlctlPostConfig-not-required.mdx b/website/content/partials/builder/parallels/common/PrlctlPostConfig-not-required.mdx index 1cf5952ae..f3282a3f3 100644 --- a/website/content/partials/builder/parallels/common/PrlctlPostConfig-not-required.mdx +++ b/website/content/partials/builder/parallels/common/PrlctlPostConfig-not-required.mdx @@ -3,3 +3,5 @@ - `prlctl_post` ([][]string) - Identical to prlctl, except that it is run after the virtual machine is shutdown, and before the virtual machine is exported. + + diff --git a/website/content/partials/builder/parallels/common/PrlctlPostConfig.mdx b/website/content/partials/builder/parallels/common/PrlctlPostConfig.mdx index 7e3be43d3..cb6ef5546 100644 --- a/website/content/partials/builder/parallels/common/PrlctlPostConfig.mdx +++ b/website/content/partials/builder/parallels/common/PrlctlPostConfig.mdx @@ -2,3 +2,5 @@ PrlctlPostConfig contains the configuration for running "prlctl" commands in the end of artifact build. + + diff --git a/website/content/partials/builder/parallels/common/PrlctlVersionConfig-not-required.mdx b/website/content/partials/builder/parallels/common/PrlctlVersionConfig-not-required.mdx index 55f3b9823..28098955f 100644 --- a/website/content/partials/builder/parallels/common/PrlctlVersionConfig-not-required.mdx +++ b/website/content/partials/builder/parallels/common/PrlctlVersionConfig-not-required.mdx @@ -5,3 +5,5 @@ the machine. This information can be useful for provisioning. By default this is ".prlctl_version", which will generally upload it into the home directory. + + diff --git a/website/content/partials/builder/parallels/common/PrlctlVersionConfig.mdx b/website/content/partials/builder/parallels/common/PrlctlVersionConfig.mdx index f21eccfdf..130b97b97 100644 --- a/website/content/partials/builder/parallels/common/PrlctlVersionConfig.mdx +++ b/website/content/partials/builder/parallels/common/PrlctlVersionConfig.mdx @@ -1,3 +1,5 @@ PrlctlVersionConfig contains the configuration for `prlctl` version. + + diff --git a/website/content/partials/builder/parallels/common/ToolsConfig-not-required.mdx b/website/content/partials/builder/parallels/common/ToolsConfig-not-required.mdx index 59b68cadb..975f1a930 100644 --- a/website/content/partials/builder/parallels/common/ToolsConfig-not-required.mdx +++ b/website/content/partials/builder/parallels/common/ToolsConfig-not-required.mdx @@ -14,3 +14,5 @@ be attached as a CD device to the virtual machine. If the mode is "upload" the Parallels Tools ISO will be uploaded to the path specified by parallels_tools_guest_path. The default value is "upload". + + diff --git a/website/content/partials/builder/parallels/common/ToolsConfig-required.mdx b/website/content/partials/builder/parallels/common/ToolsConfig-required.mdx index 6edd2e34c..2df82136a 100644 --- a/website/content/partials/builder/parallels/common/ToolsConfig-required.mdx +++ b/website/content/partials/builder/parallels/common/ToolsConfig-required.mdx @@ -4,3 +4,5 @@ install into the VM. Valid values are "win", "lin", "mac", "os2" and "other". This can be omitted only if parallels_tools_mode is "disable". + + diff --git a/website/content/partials/builder/parallels/common/ToolsConfig.mdx b/website/content/partials/builder/parallels/common/ToolsConfig.mdx index 2f77d9fde..25640cad8 100644 --- a/website/content/partials/builder/parallels/common/ToolsConfig.mdx +++ b/website/content/partials/builder/parallels/common/ToolsConfig.mdx @@ -1,3 +1,5 @@ ToolsConfig contains the builder configuration related to Parallels Tools. + + diff --git a/website/content/partials/builder/parallels/iso/Config-not-required.mdx b/website/content/partials/builder/parallels/iso/Config-not-required.mdx index 9de151840..d3790e124 100644 --- a/website/content/partials/builder/parallels/iso/Config-not-required.mdx +++ b/website/content/partials/builder/parallels/iso/Config-not-required.mdx @@ -37,3 +37,5 @@ - `vm_name` (string) - This is the name of the PVM directory for the new virtual machine, without the file extension. By default this is "packer-BUILDNAME", where "BUILDNAME" is the name of the build. + + diff --git a/website/content/partials/builder/parallels/pvm/Config-not-required.mdx b/website/content/partials/builder/parallels/pvm/Config-not-required.mdx index 94bd320d5..6795caa01 100644 --- a/website/content/partials/builder/parallels/pvm/Config-not-required.mdx +++ b/website/content/partials/builder/parallels/pvm/Config-not-required.mdx @@ -13,3 +13,5 @@ - `reassign_mac` (bool) - If this is "false" the MAC address of the first NIC will reused when imported else a new MAC address will be generated by Parallels. Defaults to "false". + + diff --git a/website/content/partials/builder/parallels/pvm/Config-required.mdx b/website/content/partials/builder/parallels/pvm/Config-required.mdx index 59e70325d..a943f454c 100644 --- a/website/content/partials/builder/parallels/pvm/Config-required.mdx +++ b/website/content/partials/builder/parallels/pvm/Config-required.mdx @@ -2,3 +2,5 @@ - `source_path` (string) - The path to a PVM directory that acts as the source of this build. + + diff --git a/website/content/partials/builder/parallels/pvm/Config.mdx b/website/content/partials/builder/parallels/pvm/Config.mdx index 8b1c70294..eca968b1e 100644 --- a/website/content/partials/builder/parallels/pvm/Config.mdx +++ b/website/content/partials/builder/parallels/pvm/Config.mdx @@ -1,3 +1,5 @@ Config is the configuration structure for the builder. + + diff --git a/website/content/partials/builder/qemu/CommConfig-not-required.mdx b/website/content/partials/builder/qemu/CommConfig-not-required.mdx index 5475a276f..b908939aa 100644 --- a/website/content/partials/builder/qemu/CommConfig-not-required.mdx +++ b/website/content/partials/builder/qemu/CommConfig-not-required.mdx @@ -11,3 +11,5 @@ - `skip_nat_mapping` (bool) - Defaults to false. When enabled, Packer does not setup forwarded port mapping for communicator (SSH or WinRM) requests and uses ssh_port or winrm_port on the host to communicate to the virtual machine. + + diff --git a/website/content/partials/builder/qemu/Config-not-required.mdx b/website/content/partials/builder/qemu/Config-not-required.mdx index 9242cc3c6..edff6ae59 100644 --- a/website/content/partials/builder/qemu/Config-not-required.mdx +++ b/website/content/partials/builder/qemu/Config-not-required.mdx @@ -321,3 +321,5 @@ Allowed values include any of `ide`, `scsi`, `virtio` or `virtio-scsi`. The Qemu builder uses `virtio` by default. Some ARM64 images require `virtio-scsi`. + + diff --git a/website/content/partials/builder/qemu/QemuImgArgs-not-required.mdx b/website/content/partials/builder/qemu/QemuImgArgs-not-required.mdx index 7507e54a0..ddac43643 100644 --- a/website/content/partials/builder/qemu/QemuImgArgs-not-required.mdx +++ b/website/content/partials/builder/qemu/QemuImgArgs-not-required.mdx @@ -5,3 +5,5 @@ - `create` ([]string) - Create - `resize` ([]string) - Resize + + diff --git a/website/content/partials/builder/scaleway/Config-not-required.mdx b/website/content/partials/builder/scaleway/Config-not-required.mdx index 0e5560984..4b302c429 100644 --- a/website/content/partials/builder/scaleway/Config-not-required.mdx +++ b/website/content/partials/builder/scaleway/Config-not-required.mdx @@ -41,3 +41,5 @@ or ams1). Consequently, this is the region where the snapshot will be available. Deprecated, use Zone instead + + diff --git a/website/content/partials/builder/scaleway/Config-required.mdx b/website/content/partials/builder/scaleway/Config-required.mdx index 4e63cf752..97163642a 100644 --- a/website/content/partials/builder/scaleway/Config-required.mdx +++ b/website/content/partials/builder/scaleway/Config-required.mdx @@ -25,3 +25,5 @@ - `commercial_type` (string) - The name of the server commercial type: C1, C2L, C2M, C2S, DEV1-S, DEV1-M, DEV1-L, DEV1-XL, GP1-XS, GP1-S, GP1-M, GP1-L, GP1-XL, RENDER-S + + diff --git a/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-not-required.mdx b/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-not-required.mdx index 4872b402d..7db360097 100644 --- a/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-not-required.mdx +++ b/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-not-required.mdx @@ -1,3 +1,5 @@ - `skip_region_validation` (bool) - Do not check region and zone when validate. + + diff --git a/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-required.mdx b/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-required.mdx index 7c4dd4c3b..ae3fc0b61 100644 --- a/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-required.mdx +++ b/website/content/partials/builder/tencentcloud/cvm/TencentCloudAccessConfig-required.mdx @@ -13,3 +13,5 @@ - `zone` (string) - The zone where your cvm will be launch. You should reference Region and Zone for parameter taking. + + diff --git a/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-not-required.mdx b/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-not-required.mdx index abfcab9e0..077fbb778 100644 --- a/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-not-required.mdx +++ b/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-not-required.mdx @@ -19,3 +19,5 @@ after your image created. - `skip_region_validation` (bool) - Do not check region and zone when validate. + + diff --git a/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-required.mdx b/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-required.mdx index 1114f7be4..2996e1a37 100644 --- a/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-required.mdx +++ b/website/content/partials/builder/tencentcloud/cvm/TencentCloudImageConfig-required.mdx @@ -3,3 +3,5 @@ - `image_name` (string) - The name you want to create your customize image, it should be composed of no more than 60 characters, of letters, numbers or minus sign. + + diff --git a/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-not-required.mdx b/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-not-required.mdx index ad800443d..c71bafbc8 100644 --- a/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-not-required.mdx +++ b/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-not-required.mdx @@ -69,3 +69,5 @@ will allow you to create those programatically. - `ssh_private_ip` (bool) - SSH Private Ip + + diff --git a/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-required.mdx b/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-required.mdx index 1a612ec47..b3cb818de 100644 --- a/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-required.mdx +++ b/website/content/partials/builder/tencentcloud/cvm/TencentCloudRunConfig-required.mdx @@ -3,3 +3,5 @@ - `instance_type` (string) - The instance type your cvm will be launched by. You should reference Instace Type for parameter taking. + + diff --git a/website/content/partials/builder/tencentcloud/cvm/tencentCloudDataDisk-not-required.mdx b/website/content/partials/builder/tencentcloud/cvm/tencentCloudDataDisk-not-required.mdx index 1a9bf1ec4..8cdd05455 100644 --- a/website/content/partials/builder/tencentcloud/cvm/tencentCloudDataDisk-not-required.mdx +++ b/website/content/partials/builder/tencentcloud/cvm/tencentCloudDataDisk-not-required.mdx @@ -5,3 +5,5 @@ - `disk_size` (int64) - Disk Size - `disk_snapshot_id` (string) - Snapshot Id + + diff --git a/website/content/partials/builder/triton/AccessConfig-not-required.mdx b/website/content/partials/builder/triton/AccessConfig-not-required.mdx index cd363b29e..c8959d2ce 100644 --- a/website/content/partials/builder/triton/AccessConfig-not-required.mdx +++ b/website/content/partials/builder/triton/AccessConfig-not-required.mdx @@ -17,3 +17,5 @@ of the Triton endpoint. It is useful when connecting to a temporary Triton installation such as Cloud-On-A-Laptop which does not generally use a certificate signed by a trusted root CA. The default is false. + + diff --git a/website/content/partials/builder/triton/AccessConfig-required.mdx b/website/content/partials/builder/triton/AccessConfig-required.mdx index e4850ba28..d8bb1bfcf 100644 --- a/website/content/partials/builder/triton/AccessConfig-required.mdx +++ b/website/content/partials/builder/triton/AccessConfig-required.mdx @@ -7,3 +7,5 @@ pair to use for authentication with the Triton Cloud API. If triton_key_material is not set, it is assumed that the SSH agent has the private key corresponding to this key ID loaded. + + diff --git a/website/content/partials/builder/triton/AccessConfig.mdx b/website/content/partials/builder/triton/AccessConfig.mdx index c4fccb741..59744abb8 100644 --- a/website/content/partials/builder/triton/AccessConfig.mdx +++ b/website/content/partials/builder/triton/AccessConfig.mdx @@ -1,3 +1,5 @@ AccessConfig is for common configuration related to Triton access + + diff --git a/website/content/partials/builder/triton/MachineImageFilter-not-required.mdx b/website/content/partials/builder/triton/MachineImageFilter-not-required.mdx index 1223e8708..221b52981 100644 --- a/website/content/partials/builder/triton/MachineImageFilter-not-required.mdx +++ b/website/content/partials/builder/triton/MachineImageFilter-not-required.mdx @@ -1,3 +1,5 @@ - `most_recent` (bool) - Most Recent + + diff --git a/website/content/partials/builder/triton/SourceMachineConfig-not-required.mdx b/website/content/partials/builder/triton/SourceMachineConfig-not-required.mdx index b9b1488b5..bb20f9603 100644 --- a/website/content/partials/builder/triton/SourceMachineConfig-not-required.mdx +++ b/website/content/partials/builder/triton/SourceMachineConfig-not-required.mdx @@ -40,3 +40,5 @@ - `source_machine_image_filter` (MachineImageFilter) - Filters used to populate the source_machine_image field. Example: + + diff --git a/website/content/partials/builder/triton/SourceMachineConfig-required.mdx b/website/content/partials/builder/triton/SourceMachineConfig-required.mdx index e0081fe05..b12e8346d 100644 --- a/website/content/partials/builder/triton/SourceMachineConfig-required.mdx +++ b/website/content/partials/builder/triton/SourceMachineConfig-required.mdx @@ -16,3 +16,5 @@ 70e3ae72-96b6-11e6-9056-9737fd4d0764 for version 16.3.1 of the 64bit SmartOS base image (a 'joyent' brand image). source_machine_image_filter can be used to populate this UUID. + + diff --git a/website/content/partials/builder/triton/SourceMachineConfig.mdx b/website/content/partials/builder/triton/SourceMachineConfig.mdx index c15cf7066..8ad46025e 100644 --- a/website/content/partials/builder/triton/SourceMachineConfig.mdx +++ b/website/content/partials/builder/triton/SourceMachineConfig.mdx @@ -2,3 +2,5 @@ SourceMachineConfig represents the configuration to run a machine using the SDC API in order for provisioning to take place. + + diff --git a/website/content/partials/builder/triton/TargetImageConfig-not-required.mdx b/website/content/partials/builder/triton/TargetImageConfig-not-required.mdx index 52ccab6d0..d67eaa44c 100644 --- a/website/content/partials/builder/triton/TargetImageConfig-not-required.mdx +++ b/website/content/partials/builder/triton/TargetImageConfig-not-required.mdx @@ -19,3 +19,5 @@ block containing a `name` and a `value` field. In HCL2 mode the [`dynamic_block`](/docs/templates/hcl_templates/expressions#dynamic-blocks) will allow you to create those programatically. + + diff --git a/website/content/partials/builder/triton/TargetImageConfig-required.mdx b/website/content/partials/builder/triton/TargetImageConfig-required.mdx index a84f6045e..6eba5af82 100644 --- a/website/content/partials/builder/triton/TargetImageConfig-required.mdx +++ b/website/content/partials/builder/triton/TargetImageConfig-required.mdx @@ -9,3 +9,5 @@ characters. Any string will do but a format of Major.Minor.Patch is strongly advised by Joyent. See Semantic Versioning for more information on the Major.Minor.Patch versioning format. + + diff --git a/website/content/partials/builder/triton/TargetImageConfig.mdx b/website/content/partials/builder/triton/TargetImageConfig.mdx index b506ce2a7..d4b68227d 100644 --- a/website/content/partials/builder/triton/TargetImageConfig.mdx +++ b/website/content/partials/builder/triton/TargetImageConfig.mdx @@ -2,3 +2,5 @@ TargetImageConfig represents the configuration for the image to be created from the source machine. + + diff --git a/website/content/partials/builder/ucloud/common/AccessConfig-not-required.mdx b/website/content/partials/builder/ucloud/common/AccessConfig-not-required.mdx index d9a466790..6e2ed6db4 100644 --- a/website/content/partials/builder/ucloud/common/AccessConfig-not-required.mdx +++ b/website/content/partials/builder/ucloud/common/AccessConfig-not-required.mdx @@ -8,3 +8,5 @@ - `shared_credentials_file` (string) - This is the path to the shared credentials file, it can also be sourced from the `UCLOUD_SHARED_CREDENTIAL_FILE` environment variables. If this is not set and a profile is specified, `~/.ucloud/credential.json` will be used. + + diff --git a/website/content/partials/builder/ucloud/common/AccessConfig-required.mdx b/website/content/partials/builder/ucloud/common/AccessConfig-required.mdx index fa9ba8283..8acbb67a7 100644 --- a/website/content/partials/builder/ucloud/common/AccessConfig-required.mdx +++ b/website/content/partials/builder/ucloud/common/AccessConfig-required.mdx @@ -11,3 +11,5 @@ - `project_id` (string) - This is the UCloud project id. It must be provided, but it can also be sourced from the `UCLOUD_PROJECT_ID` environment variables. + + diff --git a/website/content/partials/builder/ucloud/common/ImageConfig-not-required.mdx b/website/content/partials/builder/ucloud/common/ImageConfig-not-required.mdx index 156297395..a2d6c6c41 100644 --- a/website/content/partials/builder/ucloud/common/ImageConfig-not-required.mdx +++ b/website/content/partials/builder/ucloud/common/ImageConfig-not-required.mdx @@ -27,3 +27,5 @@ - `wait_image_ready_timeout` (int) - Timeout of creating image or copying image. The default timeout is 3600 seconds if this option is not set or is set to 0. + + diff --git a/website/content/partials/builder/ucloud/common/ImageConfig-required.mdx b/website/content/partials/builder/ucloud/common/ImageConfig-required.mdx index 0012649b4..90057b96e 100644 --- a/website/content/partials/builder/ucloud/common/ImageConfig-required.mdx +++ b/website/content/partials/builder/ucloud/common/ImageConfig-required.mdx @@ -2,3 +2,5 @@ - `image_name` (string) - The name of the user-defined image, which contains 1-63 characters and only support Chinese, English, numbers, '-\_,.:[]'. + + diff --git a/website/content/partials/builder/ucloud/common/ImageDestination-not-required.mdx b/website/content/partials/builder/ucloud/common/ImageDestination-not-required.mdx index 868db7e92..5ae2caddf 100644 --- a/website/content/partials/builder/ucloud/common/ImageDestination-not-required.mdx +++ b/website/content/partials/builder/ucloud/common/ImageDestination-not-required.mdx @@ -7,3 +7,5 @@ - `name` (string) - The copied image name. If not defined, builder will use `image_name` as default name. - `description` (string) - The copied image description. + + diff --git a/website/content/partials/builder/ucloud/common/RunConfig-not-required.mdx b/website/content/partials/builder/ucloud/common/RunConfig-not-required.mdx index f7e1e42b4..e548718f3 100644 --- a/website/content/partials/builder/ucloud/common/RunConfig-not-required.mdx +++ b/website/content/partials/builder/ucloud/common/RunConfig-not-required.mdx @@ -52,3 +52,5 @@ - `use_ssh_private_ip` (bool) - If this value is true, packer will connect to the created UHost instance via a private ip instead of allocating an EIP (elastic public ip).(Default: `false`). + + diff --git a/website/content/partials/builder/ucloud/common/RunConfig-required.mdx b/website/content/partials/builder/ucloud/common/RunConfig-required.mdx index 4c5a35ddd..837212bda 100644 --- a/website/content/partials/builder/ucloud/common/RunConfig-required.mdx +++ b/website/content/partials/builder/ucloud/common/RunConfig-required.mdx @@ -7,3 +7,5 @@ - `instance_type` (string) - The type of UHost instance. You may refer to [list of instance type](https://docs.ucloud.cn/compute/terraform/specification/instance) + + diff --git a/website/content/partials/builder/vagrant/Builder.mdx b/website/content/partials/builder/vagrant/Builder.mdx index e23466d3c..cbb742427 100644 --- a/website/content/partials/builder/vagrant/Builder.mdx +++ b/website/content/partials/builder/vagrant/Builder.mdx @@ -2,3 +2,5 @@ Builder implements packersdk.Builder and builds the actual VirtualBox images. + + diff --git a/website/content/partials/builder/vagrant/Config-not-required.mdx b/website/content/partials/builder/vagrant/Config-not-required.mdx index e5791d29e..0bc8c25e9 100644 --- a/website/content/partials/builder/vagrant/Config-not-required.mdx +++ b/website/content/partials/builder/vagrant/Config-not-required.mdx @@ -88,3 +88,5 @@ - `package_include` ([]string) - Equivalent to setting the [`--include`](https://www.vagrantup.com/docs/cli/package.html#include-x-y-z) option in `vagrant package`; defaults to unset + + diff --git a/website/content/partials/builder/vagrant/Config-required.mdx b/website/content/partials/builder/vagrant/Config-required.mdx index 8b4f6037c..b67058f38 100644 --- a/website/content/partials/builder/vagrant/Config-required.mdx +++ b/website/content/partials/builder/vagrant/Config-required.mdx @@ -14,3 +14,5 @@ global-status output. If you choose to use global_id instead of source_box, Packer will skip the Vagrant initialize and add steps, and simply launch the box directly using the global id. + + diff --git a/website/content/partials/builder/virtualbox/common/CommConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/CommConfig-not-required.mdx index 45e3ec08a..ae818daec 100644 --- a/website/content/partials/builder/virtualbox/common/CommConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/CommConfig-not-required.mdx @@ -11,3 +11,5 @@ - `skip_nat_mapping` (bool) - Defaults to false. When enabled, Packer does not setup forwarded port mapping for communicator (SSH or WinRM) requests and uses ssh_port or winrm_port on the host to communicate to the virtual machine. + + diff --git a/website/content/partials/builder/virtualbox/common/ExportConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/ExportConfig-not-required.mdx index 11337947e..93cfdc727 100644 --- a/website/content/partials/builder/virtualbox/common/ExportConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/ExportConfig-not-required.mdx @@ -56,3 +56,5 @@ -var "vm_version=${vm_version}" \ "packer_conf.json" ``` + + diff --git a/website/content/partials/builder/virtualbox/common/GuestAdditionsConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/GuestAdditionsConfig-not-required.mdx index a6e10b733..47d8467aa 100644 --- a/website/content/partials/builder/virtualbox/common/GuestAdditionsConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/GuestAdditionsConfig-not-required.mdx @@ -30,3 +30,5 @@ default, the VirtualBox builder will attempt to find the guest additions ISO on the local file system. If it is not available locally, the builder will download the proper guest additions ISO from the internet. + + diff --git a/website/content/partials/builder/virtualbox/common/HWConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/HWConfig-not-required.mdx index 01620a971..c00285778 100644 --- a/website/content/partials/builder/virtualbox/common/HWConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/HWConfig-not-required.mdx @@ -12,3 +12,5 @@ - `usb` (bool) - Specifies whether or not to enable the USB bus when building the VM. Defaults to false. + + diff --git a/website/content/partials/builder/virtualbox/common/OutputConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/OutputConfig-not-required.mdx index af1c3130d..b9ee868f5 100644 --- a/website/content/partials/builder/virtualbox/common/OutputConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/OutputConfig-not-required.mdx @@ -10,3 +10,5 @@ - `output_filename` (string) - This is the base name of the file (excluding the file extension) where the resulting virtual machine will be created. By default this is the `vm_name`. + + diff --git a/website/content/partials/builder/virtualbox/common/RunConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/RunConfig-not-required.mdx index 8d15a9f4e..00d6bd41a 100644 --- a/website/content/partials/builder/virtualbox/common/RunConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/RunConfig-not-required.mdx @@ -15,3 +15,5 @@ 6000. The minimum and maximum ports are inclusive. - `vrdp_port_max` (int) - VRDP Port Max + + diff --git a/website/content/partials/builder/virtualbox/common/ShutdownConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/ShutdownConfig-not-required.mdx index d018be75e..5b1489a2c 100644 --- a/website/content/partials/builder/virtualbox/common/ShutdownConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/ShutdownConfig-not-required.mdx @@ -27,3 +27,5 @@ - `acpi_shutdown` (bool) - If it's set to true, it will shutdown the VM via power button. It could be a good option when keeping the machine state is necessary after shutting it down. + + diff --git a/website/content/partials/builder/virtualbox/common/VBoxBundleConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/VBoxBundleConfig-not-required.mdx index c8d8b5098..0a243080a 100644 --- a/website/content/partials/builder/virtualbox/common/VBoxBundleConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/VBoxBundleConfig-not-required.mdx @@ -4,3 +4,5 @@ any attached ISO disc devices into the final virtual machine. Useful for some live distributions that require installation media to continue to be attached after installation. + + diff --git a/website/content/partials/builder/virtualbox/common/VBoxManageConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/VBoxManageConfig-not-required.mdx index 01b732a7b..01441878b 100644 --- a/website/content/partials/builder/virtualbox/common/VBoxManageConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/VBoxManageConfig-not-required.mdx @@ -32,3 +32,5 @@ - `vboxmanage_post` ([][]string) - Identical to vboxmanage, except that it is run after the virtual machine is shutdown, and before the virtual machine is exported. + + diff --git a/website/content/partials/builder/virtualbox/common/VBoxManageConfig.mdx b/website/content/partials/builder/virtualbox/common/VBoxManageConfig.mdx index 9a03bfc59..d324b7be4 100644 --- a/website/content/partials/builder/virtualbox/common/VBoxManageConfig.mdx +++ b/website/content/partials/builder/virtualbox/common/VBoxManageConfig.mdx @@ -5,3 +5,5 @@ define extra calls to `VBoxManage` to perform. [VBoxManage](https://www.virtualbox.org/manual/ch09.html) is the command-line interface to VirtualBox where you can completely control VirtualBox. It can be used to do things such as set RAM, CPUs, etc. + + diff --git a/website/content/partials/builder/virtualbox/common/VBoxVersionConfig-not-required.mdx b/website/content/partials/builder/virtualbox/common/VBoxVersionConfig-not-required.mdx index 0744b932f..cf1f6d808 100644 --- a/website/content/partials/builder/virtualbox/common/VBoxVersionConfig-not-required.mdx +++ b/website/content/partials/builder/virtualbox/common/VBoxVersionConfig-not-required.mdx @@ -6,3 +6,5 @@ this is .vbox_version, which will generally be upload it into the home directory. Set to an empty string to skip uploading this file, which can be useful when using the none communicator. + + diff --git a/website/content/partials/builder/virtualbox/iso/Config-not-required.mdx b/website/content/partials/builder/virtualbox/iso/Config-not-required.mdx index e928a4e29..646296d11 100644 --- a/website/content/partials/builder/virtualbox/iso/Config-not-required.mdx +++ b/website/content/partials/builder/virtualbox/iso/Config-not-required.mdx @@ -119,3 +119,5 @@ - `vm_name` (string) - This is the name of the OVF file for the new virtual machine, without the file extension. By default this is packer-BUILDNAME, where "BUILDNAME" is the name of the build. + + diff --git a/website/content/partials/builder/virtualbox/ovf/Config-not-required.mdx b/website/content/partials/builder/virtualbox/ovf/Config-not-required.mdx index a5bd3d5f9..0071a0830 100644 --- a/website/content/partials/builder/virtualbox/ovf/Config-not-required.mdx +++ b/website/content/partials/builder/virtualbox/ovf/Config-not-required.mdx @@ -22,3 +22,5 @@ - `skip_export` (bool) - Defaults to false. When enabled, Packer will not export the VM. Useful if the build output is not the resultant image, but created inside the VM. + + diff --git a/website/content/partials/builder/virtualbox/ovf/Config-required.mdx b/website/content/partials/builder/virtualbox/ovf/Config-required.mdx index 67a9f3d83..a52dd56bb 100644 --- a/website/content/partials/builder/virtualbox/ovf/Config-required.mdx +++ b/website/content/partials/builder/virtualbox/ovf/Config-required.mdx @@ -23,3 +23,5 @@ - `source_path` (string) - The filepath or URL to an OVF or OVA file that acts as the source of this build. + + diff --git a/website/content/partials/builder/virtualbox/ovf/Config.mdx b/website/content/partials/builder/virtualbox/ovf/Config.mdx index bfa64c4f8..bf8ad1a6b 100644 --- a/website/content/partials/builder/virtualbox/ovf/Config.mdx +++ b/website/content/partials/builder/virtualbox/ovf/Config.mdx @@ -1,3 +1,5 @@ Config is the configuration structure for the builder. + + diff --git a/website/content/partials/builder/virtualbox/vm/Config-not-required.mdx b/website/content/partials/builder/virtualbox/vm/Config-not-required.mdx index 2990f94a8..3504ad269 100644 --- a/website/content/partials/builder/virtualbox/vm/Config-not-required.mdx +++ b/website/content/partials/builder/virtualbox/vm/Config-not-required.mdx @@ -25,3 +25,5 @@ - `skip_export` (bool) - Defaults to `false`. When enabled, Packer will not export the VM. Useful if the builder should be applied again on the created target snapshot. + + diff --git a/website/content/partials/builder/virtualbox/vm/Config-required.mdx b/website/content/partials/builder/virtualbox/vm/Config-required.mdx index e766d714d..de27938dd 100644 --- a/website/content/partials/builder/virtualbox/vm/Config-required.mdx +++ b/website/content/partials/builder/virtualbox/vm/Config-required.mdx @@ -2,3 +2,5 @@ - `vm_name` (string) - This is the name of the virtual machine to which the builder shall attach. + + diff --git a/website/content/partials/builder/virtualbox/vm/Config.mdx b/website/content/partials/builder/virtualbox/vm/Config.mdx index c5617895c..46485ac7a 100644 --- a/website/content/partials/builder/virtualbox/vm/Config.mdx +++ b/website/content/partials/builder/virtualbox/vm/Config.mdx @@ -1,3 +1,5 @@ Config is the configuration structure for the builder. + + diff --git a/website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx b/website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx index 26c66f780..e02d5a8df 100644 --- a/website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/DiskConfig-not-required.mdx @@ -43,3 +43,5 @@ For more information, please consult the [Virtual Disk Manager User's Guide](https://www.vmware.com/pdf/VirtualDiskManager.pdf) for desktop VMware clients. For ESXi, refer to the proper ESXi documentation. + + diff --git a/website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx b/website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx index 5c3fd41db..a2939ce93 100644 --- a/website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/DriverConfig-not-required.mdx @@ -38,3 +38,5 @@ ovftool command to make sure that the remote_username and remote_password given are valid. If you set this flag to true, Packer will skip this validation. Default: false. + + diff --git a/website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx b/website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx index 43288200e..efe285b3b 100644 --- a/website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/ExportConfig-not-required.mdx @@ -33,3 +33,5 @@ you can disable compaction using this configuration value. Defaults to false. Default to true for ESXi when disk_type_id is not explicitly defined and false otherwise. + + diff --git a/website/content/partials/builder/vmware/common/HWConfig-not-required.mdx b/website/content/partials/builder/vmware/common/HWConfig-not-required.mdx index fca87b2e3..29e5f982c 100644 --- a/website/content/partials/builder/vmware/common/HWConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/HWConfig-not-required.mdx @@ -87,3 +87,5 @@ communication or `UNI` to specify unidirectional communication. * `NONE` - Specifies to not use a parallel port. (default) + + diff --git a/website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx b/website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx index 8ad2776dc..f65fada56 100644 --- a/website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/OutputConfig-not-required.mdx @@ -32,3 +32,5 @@ that do not currently exist. This option will be ignored unless you are building on a remote esx host. + + diff --git a/website/content/partials/builder/vmware/common/ParallelUnion.mdx b/website/content/partials/builder/vmware/common/ParallelUnion.mdx index f988ee08d..e0411af00 100644 --- a/website/content/partials/builder/vmware/common/ParallelUnion.mdx +++ b/website/content/partials/builder/vmware/common/ParallelUnion.mdx @@ -1,3 +1,5 @@ parallel port + + diff --git a/website/content/partials/builder/vmware/common/RunConfig-not-required.mdx b/website/content/partials/builder/vmware/common/RunConfig-not-required.mdx index dd096f7d1..7b754ab8e 100644 --- a/website/content/partials/builder/vmware/common/RunConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/RunConfig-not-required.mdx @@ -35,3 +35,5 @@ for these the `vnc_over_websocket` must be set to true. - `insecure_connection` (bool) - Do not validate VNC over websocket server's TLS certificate. Defaults to `false`. + + diff --git a/website/content/partials/builder/vmware/common/RunConfig.mdx b/website/content/partials/builder/vmware/common/RunConfig.mdx index 44e675944..0727ccdcf 100644 --- a/website/content/partials/builder/vmware/common/RunConfig.mdx +++ b/website/content/partials/builder/vmware/common/RunConfig.mdx @@ -1,3 +1,5 @@ ~> **Note:** If [vnc_over_websocket](#vnc_over_websocket) is set to true, any other VNC configuration will be ignored. + + diff --git a/website/content/partials/builder/vmware/common/SerialConfigPipe.mdx b/website/content/partials/builder/vmware/common/SerialConfigPipe.mdx index b95b6cfe5..b7135496a 100644 --- a/website/content/partials/builder/vmware/common/SerialConfigPipe.mdx +++ b/website/content/partials/builder/vmware/common/SerialConfigPipe.mdx @@ -1,3 +1,5 @@ serial conversions + + diff --git a/website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx b/website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx index 2beb38415..fd7bc011c 100644 --- a/website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/ToolsConfig-not-required.mdx @@ -14,3 +14,5 @@ - `tools_source_path` (string) - The path on your local machine to fetch the vmware tools from. If this is not set but the tools_upload_flavor is set, then Packer will try to load the VMWare tools from the VMWare installation directory. + + diff --git a/website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx b/website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx index 5b8ef9052..953369fe5 100644 --- a/website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx +++ b/website/content/partials/builder/vmware/common/VMXConfig-not-required.mdx @@ -20,3 +20,5 @@ set it in the "vmx_data" Packer option. This option is useful if you are chaining vmx builds and want to make sure that the display name of each step in the chain is unique. + + diff --git a/website/content/partials/builder/vmware/iso/Config-not-required.mdx b/website/content/partials/builder/vmware/iso/Config-not-required.mdx index a7980b1b8..18340b45f 100644 --- a/website/content/partials/builder/vmware/iso/Config-not-required.mdx +++ b/website/content/partials/builder/vmware/iso/Config-not-required.mdx @@ -38,3 +38,5 @@ This is for **advanced users only** as this can render the virtual machine non-functional. See below for more information. For basic VMX modifications, try `vmx_data` first. + + diff --git a/website/content/partials/builder/vmware/vmx/Config-not-required.mdx b/website/content/partials/builder/vmware/vmx/Config-not-required.mdx index bf5deb555..622717752 100644 --- a/website/content/partials/builder/vmware/vmx/Config-not-required.mdx +++ b/website/content/partials/builder/vmware/vmx/Config-not-required.mdx @@ -22,3 +22,5 @@ - `vm_name` (string) - This is the name of the VMX file for the new virtual machine, without the file extension. By default this is packer-BUILDNAME, where "BUILDNAME" is the name of the build. + + diff --git a/website/content/partials/builder/vmware/vmx/Config-required.mdx b/website/content/partials/builder/vmware/vmx/Config-required.mdx index acecbd4a0..acef042cf 100644 --- a/website/content/partials/builder/vmware/vmx/Config-required.mdx +++ b/website/content/partials/builder/vmware/vmx/Config-required.mdx @@ -2,3 +2,5 @@ - `source_path` (string) - Path to the source VMX file to clone. If remote_type is enabled then this specifies a path on the remote_host. + + diff --git a/website/content/partials/builder/vmware/vmx/Config.mdx b/website/content/partials/builder/vmware/vmx/Config.mdx index b312f9936..c9bda9b93 100644 --- a/website/content/partials/builder/vmware/vmx/Config.mdx +++ b/website/content/partials/builder/vmware/vmx/Config.mdx @@ -1,3 +1,5 @@ Config is the configuration structure for the builder. + + diff --git a/website/content/partials/builder/yandex/AccessConfig-not-required.mdx b/website/content/partials/builder/yandex/AccessConfig-not-required.mdx index 0ad451534..a2771795a 100644 --- a/website/content/partials/builder/yandex/AccessConfig-not-required.mdx +++ b/website/content/partials/builder/yandex/AccessConfig-not-required.mdx @@ -7,3 +7,5 @@ `YC_SERVICE_ACCOUNT_KEY_FILE`. - `max_retries` (int) - The maximum number of times an API request is being executed. + + diff --git a/website/content/partials/builder/yandex/AccessConfig-required.mdx b/website/content/partials/builder/yandex/AccessConfig-required.mdx index 80a11071d..73d451c0d 100644 --- a/website/content/partials/builder/yandex/AccessConfig-required.mdx +++ b/website/content/partials/builder/yandex/AccessConfig-required.mdx @@ -4,3 +4,5 @@ or [IAM token](https://cloud.yandex.com/docs/iam/concepts/authorization/iam-token) to use to authenticate to Yandex.Cloud. Alternatively you may set value by environment variable `YC_TOKEN`. + + diff --git a/website/content/partials/builder/yandex/AccessConfig.mdx b/website/content/partials/builder/yandex/AccessConfig.mdx index fa961dfd0..44928fce0 100644 --- a/website/content/partials/builder/yandex/AccessConfig.mdx +++ b/website/content/partials/builder/yandex/AccessConfig.mdx @@ -1,3 +1,5 @@ AccessConfig is for common configuration related to Yandex.Cloud API access + + diff --git a/website/content/partials/builder/yandex/CloudConfig-required.mdx b/website/content/partials/builder/yandex/CloudConfig-required.mdx index 75f93b60c..1f7c7cd17 100644 --- a/website/content/partials/builder/yandex/CloudConfig-required.mdx +++ b/website/content/partials/builder/yandex/CloudConfig-required.mdx @@ -4,3 +4,5 @@ Alternatively you may set value by environment variable `YC_FOLDER_ID`. To use a different folder for looking up the source image or saving the target image to check options 'source_image_folder_id' and 'target_image_folder_id'. + + diff --git a/website/content/partials/builder/yandex/CommonConfig-not-required.mdx b/website/content/partials/builder/yandex/CommonConfig-not-required.mdx index 65b117798..6da06e817 100644 --- a/website/content/partials/builder/yandex/CommonConfig-not-required.mdx +++ b/website/content/partials/builder/yandex/CommonConfig-not-required.mdx @@ -4,3 +4,5 @@ - `state_timeout` (duration string | ex: "1h5m2s") - The time to wait for instance state changes. Defaults to `5m`. + + diff --git a/website/content/partials/builder/yandex/Config-not-required.mdx b/website/content/partials/builder/yandex/Config-not-required.mdx index 756f30b4b..c7506a5ff 100644 --- a/website/content/partials/builder/yandex/Config-not-required.mdx +++ b/website/content/partials/builder/yandex/Config-not-required.mdx @@ -4,3 +4,5 @@ - `target_image_folder_id` (string) - The ID of the folder to save built image in. This defaults to value of 'folder_id'. + + diff --git a/website/content/partials/builder/yandex/DiskConfig-not-required.mdx b/website/content/partials/builder/yandex/DiskConfig-not-required.mdx index 0b3d2c910..35a49c432 100644 --- a/website/content/partials/builder/yandex/DiskConfig-not-required.mdx +++ b/website/content/partials/builder/yandex/DiskConfig-not-required.mdx @@ -8,3 +8,5 @@ - `disk_type` (string) - Specify disk type for the launched instance. Defaults to `network-ssd`. - `disk_labels` (map[string]string) - Key/value pair labels to apply to the disk. + + diff --git a/website/content/partials/builder/yandex/ImageConfig-not-required.mdx b/website/content/partials/builder/yandex/ImageConfig-not-required.mdx index f4347ecb2..69731efb4 100644 --- a/website/content/partials/builder/yandex/ImageConfig-not-required.mdx +++ b/website/content/partials/builder/yandex/ImageConfig-not-required.mdx @@ -14,3 +14,5 @@ Should be more or equal to `disk_size_gb`. - `image_product_ids` ([]string) - License IDs that indicate which licenses are attached to resulting image. + + diff --git a/website/content/partials/builder/yandex/InstanceConfig-not-required.mdx b/website/content/partials/builder/yandex/InstanceConfig-not-required.mdx index 816865a0e..fb33a206b 100644 --- a/website/content/partials/builder/yandex/InstanceConfig-not-required.mdx +++ b/website/content/partials/builder/yandex/InstanceConfig-not-required.mdx @@ -18,3 +18,5 @@ The values in this map are the paths to the content files for the corresponding metadata keys. - `preemptible` (bool) - Launch a preemptible instance. This defaults to `false`. + + diff --git a/website/content/partials/builder/yandex/NetworkConfig-not-required.mdx b/website/content/partials/builder/yandex/NetworkConfig-not-required.mdx index 2e61ed622..072696b9d 100644 --- a/website/content/partials/builder/yandex/NetworkConfig-not-required.mdx +++ b/website/content/partials/builder/yandex/NetworkConfig-not-required.mdx @@ -16,3 +16,5 @@ - `use_internal_ip` (bool) - If true, use the instance's internal IP address instead of its external IP during building. + + diff --git a/website/content/partials/builder/yandex/SourceImageConfig-not-required.mdx b/website/content/partials/builder/yandex/SourceImageConfig-not-required.mdx index 765626baa..448384bb9 100644 --- a/website/content/partials/builder/yandex/SourceImageConfig-not-required.mdx +++ b/website/content/partials/builder/yandex/SourceImageConfig-not-required.mdx @@ -6,3 +6,5 @@ - `source_image_name` (string) - The source image name to use to create the new image from. Name will be looked up in `source_image_folder_id`. + + diff --git a/website/content/partials/builder/yandex/SourceImageConfig-required.mdx b/website/content/partials/builder/yandex/SourceImageConfig-required.mdx index 54d314138..4f9ebd4de 100644 --- a/website/content/partials/builder/yandex/SourceImageConfig-required.mdx +++ b/website/content/partials/builder/yandex/SourceImageConfig-required.mdx @@ -3,3 +3,5 @@ - `source_image_family` (string) - The source image family to create the new image from. You can also specify source_image_id instead. Just one of a source_image_id or source_image_family must be specified. Example: `ubuntu-1804-lts`. + + diff --git a/website/content/partials/post-processor/alicloud-import/Config-not-required.mdx b/website/content/partials/post-processor/alicloud-import/Config-not-required.mdx index db93a68c7..6241bc081 100644 --- a/website/content/partials/post-processor/alicloud-import/Config-not-required.mdx +++ b/website/content/partials/post-processor/alicloud-import/Config-not-required.mdx @@ -31,3 +31,5 @@ existing image, it will delete the existing image and then create the target image, otherwise, the creation will fail. The default value is false. + + diff --git a/website/content/partials/post-processor/alicloud-import/Config-required.mdx b/website/content/partials/post-processor/alicloud-import/Config-required.mdx index c8f3fb4ec..6c4a66726 100644 --- a/website/content/partials/post-processor/alicloud-import/Config-required.mdx +++ b/website/content/partials/post-processor/alicloud-import/Config-required.mdx @@ -12,3 +12,5 @@ - `format` (string) - The format of the image for import, now alicloud only support RAW and VHD. + + diff --git a/website/content/partials/post-processor/alicloud-import/Config.mdx b/website/content/partials/post-processor/alicloud-import/Config.mdx index 0d7a7b85b..6a374107a 100644 --- a/website/content/partials/post-processor/alicloud-import/Config.mdx +++ b/website/content/partials/post-processor/alicloud-import/Config.mdx @@ -1,3 +1,5 @@ Configuration of this post processor + + diff --git a/website/content/partials/post-processor/googlecompute-export/Config-not-required.mdx b/website/content/partials/post-processor/googlecompute-export/Config-not-required.mdx index b7d12d3ba..8a6c8523f 100644 --- a/website/content/partials/post-processor/googlecompute-export/Config-not-required.mdx +++ b/website/content/partials/post-processor/googlecompute-export/Config-not-required.mdx @@ -32,3 +32,5 @@ - `vault_gcp_oauth_engine` (string) - Vault GCP Oauth Engine - `service_account_email` (string) - Service Account Email + + diff --git a/website/content/partials/post-processor/googlecompute-export/Config-required.mdx b/website/content/partials/post-processor/googlecompute-export/Config-required.mdx index a0bdc0e61..b7dc3c8b5 100644 --- a/website/content/partials/post-processor/googlecompute-export/Config-required.mdx +++ b/website/content/partials/post-processor/googlecompute-export/Config-required.mdx @@ -2,3 +2,5 @@ - `paths` ([]string) - A list of GCS paths where the image will be exported. For example `'gs://mybucket/path/to/file.tar.gz'` + + diff --git a/website/content/partials/post-processor/googlecompute-import/Config-not-required.mdx b/website/content/partials/post-processor/googlecompute-import/Config-not-required.mdx index 2e9929824..520cff241 100644 --- a/website/content/partials/post-processor/googlecompute-import/Config-not-required.mdx +++ b/website/content/partials/post-processor/googlecompute-import/Config-not-required.mdx @@ -34,3 +34,5 @@ - `image_signatures_db` ([]string) - A database of certificates that have been revoked and will cause the system to stop booting if a boot file is signed with one of them. You may specify single or multiple comma-separated values for this value. - `image_forbidden_signatures_db` ([]string) - A database of certificates that are trusted and can be used to sign boot files. You may specify single or multiple comma-separated values for this value. + + diff --git a/website/content/partials/post-processor/googlecompute-import/Config-required.mdx b/website/content/partials/post-processor/googlecompute-import/Config-required.mdx index 7e1d84835..18a864d2a 100644 --- a/website/content/partials/post-processor/googlecompute-import/Config-required.mdx +++ b/website/content/partials/post-processor/googlecompute-import/Config-required.mdx @@ -8,3 +8,5 @@ - `bucket` (string) - The name of the GCS bucket where the raw disk image will be uploaded. - `image_name` (string) - The unique name of the resulting image. + + diff --git a/website/content/partials/post-processor/manifest/Config-not-required.mdx b/website/content/partials/post-processor/manifest/Config-not-required.mdx index e3a345844..10f37a6b5 100644 --- a/website/content/partials/post-processor/manifest/Config-not-required.mdx +++ b/website/content/partials/post-processor/manifest/Config-not-required.mdx @@ -11,3 +11,5 @@ - `custom_data` (map[string]string) - Arbitrary data to add to the manifest. This is a [template engine](https://packer.io/docs/templates/legacy_json_templates/engine.html). Therefore, you may use user variables and template functions in this field. + + diff --git a/website/content/partials/post-processor/ucloud-import/Config-not-required.mdx b/website/content/partials/post-processor/ucloud-import/Config-not-required.mdx index 3fa292617..8d5a1aafa 100644 --- a/website/content/partials/post-processor/ucloud-import/Config-not-required.mdx +++ b/website/content/partials/post-processor/ucloud-import/Config-not-required.mdx @@ -12,3 +12,5 @@ - `image_description` (string) - The description of the image. - `wait_image_ready_timeout` (int) - Timeout of importing image. The default timeout is 3600 seconds if this option is not set or is set. + + diff --git a/website/content/partials/post-processor/ucloud-import/Config-required.mdx b/website/content/partials/post-processor/ucloud-import/Config-required.mdx index b075f37c3..e6db5dfb2 100644 --- a/website/content/partials/post-processor/ucloud-import/Config-required.mdx +++ b/website/content/partials/post-processor/ucloud-import/Config-required.mdx @@ -13,3 +13,5 @@ You may refer to [ucloud_api_docs](https://docs.ucloud.cn/api/uhost-api/import_custom_image) for detail. - `format` (string) - The format of the import image , Possible values are: `raw`, `vhd`, `vmdk`, or `qcow2`. + + diff --git a/website/content/partials/post-processor/ucloud-import/Config.mdx b/website/content/partials/post-processor/ucloud-import/Config.mdx index a427d0ef4..4e78d1466 100644 --- a/website/content/partials/post-processor/ucloud-import/Config.mdx +++ b/website/content/partials/post-processor/ucloud-import/Config.mdx @@ -1,3 +1,5 @@ Configuration of this post processor + + diff --git a/website/content/partials/post-processor/yandex-export/Config-not-required.mdx b/website/content/partials/post-processor/yandex-export/Config-not-required.mdx index a98773742..99ca19b12 100644 --- a/website/content/partials/post-processor/yandex-export/Config-not-required.mdx +++ b/website/content/partials/post-processor/yandex-export/Config-not-required.mdx @@ -15,3 +15,5 @@ Requires `losetup` utility on the instance. > **Careful!** Increases payment cost. > See [perfomance](https://cloud.yandex.com/docs/compute/concepts/disk#performance). + + diff --git a/website/content/partials/post-processor/yandex-export/Config-required.mdx b/website/content/partials/post-processor/yandex-export/Config-required.mdx index 1d3aa9f9f..3c5e07af4 100644 --- a/website/content/partials/post-processor/yandex-export/Config-required.mdx +++ b/website/content/partials/post-processor/yandex-export/Config-required.mdx @@ -5,3 +5,5 @@ Also this param support [build](/docs/templates/legacy_json_templates/engine) template function. Check available template data for [Yandex](/docs/builders/yandex#build-template-data) builder. Paths to Yandex Object Storage where exported image will be uploaded. + + diff --git a/website/content/partials/post-processor/yandex-export/ExchangeConfig-required.mdx b/website/content/partials/post-processor/yandex-export/ExchangeConfig-required.mdx index d80909b29..697cee962 100644 --- a/website/content/partials/post-processor/yandex-export/ExchangeConfig-required.mdx +++ b/website/content/partials/post-processor/yandex-export/ExchangeConfig-required.mdx @@ -2,3 +2,5 @@ - `service_account_id` (string) - Service Account ID with proper permission to modify an instance, create and attach disk and make upload to specific Yandex Object Storage paths. + + diff --git a/website/content/partials/post-processor/yandex-import/Config-not-required.mdx b/website/content/partials/post-processor/yandex-import/Config-not-required.mdx index 877c4ddac..c0aeaba08 100644 --- a/website/content/partials/post-processor/yandex-import/Config-not-required.mdx +++ b/website/content/partials/post-processor/yandex-import/Config-not-required.mdx @@ -13,3 +13,5 @@ - `skip_clean` (bool) - Whether skip removing the qcow2 file uploaded to Storage after the import process has completed. Possible values are: `true` to leave it in the bucket, `false` to remove it. Default is `false`. + + diff --git a/website/content/partials/provisioner/ansible-local/Config-not-required.mdx b/website/content/partials/provisioner/ansible-local/Config-not-required.mdx index 2fdbd702b..379d30798 100644 --- a/website/content/partials/provisioner/ansible-local/Config-not-required.mdx +++ b/website/content/partials/provisioner/ansible-local/Config-not-required.mdx @@ -120,3 +120,5 @@ - `galaxy_command` (string) - The command to invoke ansible-galaxy. By default, this is `ansible-galaxy`. + + diff --git a/website/content/partials/provisioner/ansible/Config-not-required.mdx b/website/content/partials/provisioner/ansible/Config-not-required.mdx index 02dc13f05..76c7e2dad 100644 --- a/website/content/partials/provisioner/ansible/Config-not-required.mdx +++ b/website/content/partials/provisioner/ansible/Config-not-required.mdx @@ -163,3 +163,5 @@ Currently, this defaults to `true` for all connection types. In the future, this option will be changed to default to `false` for SSH and WinRM connections where the provisioner has access to a host IP. + + diff --git a/website/content/partials/provisioner/ansible/Config-required.mdx b/website/content/partials/provisioner/ansible/Config-required.mdx index b9d422c51..dc067fd87 100644 --- a/website/content/partials/provisioner/ansible/Config-required.mdx +++ b/website/content/partials/provisioner/ansible/Config-required.mdx @@ -1,3 +1,5 @@ - `playbook_file` (string) - The playbook to be run by Ansible. + + diff --git a/website/content/partials/provisioner/file/Config-not-required.mdx b/website/content/partials/provisioner/file/Config-not-required.mdx index fddfbcefd..1d30c3558 100644 --- a/website/content/partials/provisioner/file/Config-not-required.mdx +++ b/website/content/partials/provisioner/file/Config-not-required.mdx @@ -17,3 +17,5 @@ dependent on system state. We would prefer you generate your files before the Packer run, but realize that there are situations where this may be unavoidable. + + diff --git a/website/content/partials/provisioner/file/Config-required.mdx b/website/content/partials/provisioner/file/Config-required.mdx index 86f9016eb..7f85b07be 100644 --- a/website/content/partials/provisioner/file/Config-required.mdx +++ b/website/content/partials/provisioner/file/Config-required.mdx @@ -16,3 +16,5 @@ to use the source's basename in the final upload path. Failure to do so may cause Packer to fail on file uploads. If the destination file already exists, it will be overwritten. + +