Commit Graph

109 Commits

Author SHA1 Message Date
Kerim Satirli 3e2db82cab
fixes typo (#10894) 2021-04-09 11:59:08 +02:00
Chris Roberts 4ea4c0570f Add test coverage for direct upload file size limits 2021-03-24 10:54:11 -07:00
Chris Roberts a665e6b822 Always include all upload steps regardless of configuration 2021-03-24 10:53:38 -07:00
Chris Roberts 2de91e4862 Check configuration before running callback for upload confirmation 2021-03-24 10:52:56 -07:00
Chris Roberts 3a11820a41 Adjust upload limit value and fix error value stored in state bag 2021-03-24 10:51:10 -07:00
sophia 9b641c9bfd Force NoDirectUpload for vagrantcloud if asset size > 5 GB 2021-03-18 17:22:27 -05:00
Megan Marsh 88b7b0e14a remove sdk 2020-12-17 13:29:25 -08:00
Megan Marsh 5f34bbd56e add extra line before package declaration so this line does not become the synopsis of a package for godoc 2020-12-16 15:14:43 -08:00
Megan Marsh b69d69095e move postprocessor to sdk, fix generation code 2020-12-01 14:48:55 -08:00
Megan Marsh d5971ca25e fix tests by moving mock hooks and communicators, and BasicUi definition, into SDK 2020-11-30 14:30:30 -08:00
Megan Marsh 14bdb9516c move Artifact and artifact mock to the sdk 2020-11-30 14:29:52 -08:00
Megan Marsh c70870cb83 move multierror and multierrorappend into sdk 2020-11-30 14:29:06 -08:00
Megan Marsh 001886670d move Ui definition into the packer plugin sdk. 2020-11-30 14:26:54 -08:00
Megan Marsh f8f1ebf0c7 move version and useragent definitions into sdk 2020-11-18 11:42:02 -08:00
Megan Marsh 9e47696dff move helper/config to bundle with the other template definitions 2020-11-18 10:34:59 -08:00
Megan Marsh 3f6deb8828 move multistep into the plugin sdk 2020-11-17 16:31:03 -08:00
Megan Marsh 7d658149ea update tests and website and generated partials to reflect new package format 2020-11-17 10:36:01 -08:00
Megan Marsh e04eaa89e6 move steps and step configs from packer/common to packer/common/commonsteps 2020-11-13 11:15:04 -08:00
Megan Marsh 6402362018 create packer-plugin-sdk directory and begin moving the relevant folders into it. 2020-11-13 10:47:36 -08:00
Megan Marsh 2167118126 add version files for all postprocessors 2020-11-10 14:55:45 -08:00
Megan Marsh 8ecd16db81 regenerate code 2020-11-10 08:16:59 -08:00
Megan Marsh efc117fb55
Merge pull request #10218 from hashicorp/clean_plugin_sdk
Clean plugin sdk
2020-11-06 12:35:23 -08:00
Chris Roberts d8222b1656
Add support for uploading directly to storage on Vagrant Cloud (#10193)
Vagrant Cloud provides support for uploading directly to the backend
storage instead of streaming through Vagrant Cloud. This adds support
for direct to storage uploads and sets it as the default upload method.
A new option has been added to disable this behavior and revert back
to streaming upload via Vagrant Cloud (`no_direct_upload`).

This default for uploading directly to the backend storage also matches
up with changes being added to Vagrant proper for box upload behavior:
hashicorp/vagrant#11916
2020-11-05 20:01:55 -05:00
Megan Marsh 45b5f0c2ee move custom http client creation with env proxy args into same package as other network related helpers 2020-11-04 14:51:14 -08:00
Megan Marsh c0ce8a9414 rework fixer deprecation code so we know what plugins they relate to 2020-10-21 15:28:59 -07:00
zhsj e2cbe0de48
post-processor/vagrant-cloud: missing vagrant_cloud_url in test (#9572) 2020-07-14 10:29:28 +02:00
Adrien Delorme 40947c2bf6
HCL2: generate hcl tags with go-cty tags too (#9306)
This will allow to generate the config files:

```go
package main

import (
	"fmt"

	"github.com/hashicorp/hcl/v2/gohcl"
	"github.com/hashicorp/hcl/v2/hclwrite"
	"github.com/hashicorp/packer/builder/alicloud/ecs"
)

func main() {
	name := "name"
	app := ecs.FlatConfig{
		AlicloudImageName: &name,
		ECSSystemDiskMapping: &ecs.FlatAlicloudDiskDevice{
			DiskName: &name,
		},
	}

	f := hclwrite.NewEmptyFile()
	block := gohcl.EncodeAsBlock(&app, `source "something" "something"`)
	f.Body().AppendBlock(block)
	fmt.Printf("%s", f.Bytes())
}

```

Will output:

```
source "something" "something" {
  packer_user_variables      = null
  packer_sensitive_variables = null
  image_name                 = "name"
  image_share_account        = null
  image_unshare_account      = null
  image_copy_regions         = null
  image_copy_names           = null
  tags                       = null
  tag                        = null
  system_disk_mapping        = { disk_category = null, disk_delete_with_instance = null, disk_descri
ption = null, disk_device = null, disk_encrypted = null, disk_name = "name", disk_size = null, disk_
snapshot_id = null }
  image_disk_mappings        = null
  ssh_remote_tunnels         = null
  ssh_local_tunnels          = null
  ssh_public_key             = null
  ssh_private_key            = null
}
```

This is a good first step for #9015 and #9282 

fix #9304
2020-05-28 11:19:00 +02:00
Megan Marsh b982d987a7 Add Artifice postprocessor ID to valid artifacts for postprocessors that perform artifact type validation 2020-05-15 13:13:43 -07:00
Adrien Delorme 840e67f775
HCL2: when we see a map generate an attribute spec instead of a block spec (#9035)
* mapstructure-to-hcl2: when we see a map generate an attribute spec and not a block spec

this will alow to do

tags = {
 key = "value"
}

instead of

tags {
  key = "value"
}

This will also enable using variables directly for those tags

* generate code

* update tests
2020-04-14 16:05:13 +02:00
Sylvia Moss dc31bad539
Sharing info with post-processors via artifact (#8632) 2020-01-30 11:27:58 +01:00
nywilken 5a54c99e98 post-processor/vagrant-cloud: Update error handling for VagrantCloud API responses
This change updates the underlying type of VagrantCloudErrors.Errors to match the expected errors response type and adds a simple test to verify the parsing of various error responses.
Tests before change

```
--- FAIL: TestVagranCloudErrors (0.00s)
    client_test.go:23: failed to decode error response: json: cannot unmarshal array into Go struct field VagrantCloudErrors.errors of type map[string][]string
    client_test.go:23: failed to decode error response: json: cannot unmarshal array into Go struct field VagrantCloudErrors.errors of type map[string][]string
    client_test.go:26: failed to get expected response; expected "", got "error1. error2"
    client_test.go:23: failed to decode error response: json: cannot unmarshal array into Go struct field VagrantCloudErrors.errors of type map[string][]string
    client_test.go:26: failed to get expected response; expected "", got "message Bad credentials"

```

Test after change
```
--- PASS: TestVagranCloudErrors (0.00s)

```
2020-01-13 11:55:53 -05:00
Megan Marsh b23425f637 use pointer to config rather than config 2019-12-19 11:27:21 -08:00
Adrien Delorme 0785c2f6fc
build using HCL2 (#8423)
This follows #8232 which added the code to generate the code required to parse
HCL files for each packer component.

All old config files of packer will keep on working the same. Packer takes one
argument. When a directory is passed, all files in the folder with a name
ending with  “.pkr.hcl” or “.pkr.json” will be parsed using the HCL2 format.
When a file ending with “.pkr.hcl” or “.pkr.json” is passed it will be parsed
using the HCL2 format. For every other case; the old packer style will be used.

## 1. the hcl2template pkg can create a packer.Build from a set of HCL (v2) files

I had to make the packer.coreBuild (which is our one and only packer.Build ) a public struct with public fields

## 2. Components interfaces get a new ConfigSpec Method to read a file from an HCL file.

  This is a breaking change for packer plugins.

a packer component can be a: builder/provisioner/post-processor

each component interface now gets a `ConfigSpec() hcldec.ObjectSpec`
which allows packer to tell what is the layout of the hcl2 config meant
to configure that specific component.

This ObjectSpec is sent through the wire (RPC) and a cty.Value is now
sent through the already existing configuration entrypoints:

 Provisioner.Prepare(raws ...interface{}) error
 Builder.Prepare(raws ...interface{}) ([]string, error)
 PostProcessor.Configure(raws ...interface{}) error

close #1768


Example hcl files:

```hcl
// file amazon-ebs-kms-key/run.pkr.hcl
build {
    sources = [
        "source.amazon-ebs.first",
    ]

    provisioner "shell" {
        inline = [
            "sleep 5"
        ]
    }

    post-processor "shell-local" {
        inline = [
            "sleep 5"
        ]
    }
}

// amazon-ebs-kms-key/source.pkr.hcl

source "amazon-ebs" "first" {

    ami_name = "hcl2-test"
    region = "us-east-1"
    instance_type = "t2.micro"

    kms_key_id = "c729958f-c6ba-44cd-ab39-35ab68ce0a6c"
    encrypt_boot = true
    source_ami_filter {
        filters {
          virtualization-type = "hvm"
          name =  "amzn-ami-hvm-????.??.?.????????-x86_64-gp2"
          root-device-type = "ebs"
        }
        most_recent = true
        owners = ["amazon"]
    }
    launch_block_device_mappings {
        device_name = "/dev/xvda"
        volume_size = 20
        volume_type = "gp2"
        delete_on_termination = "true"
    }
    launch_block_device_mappings {
        device_name = "/dev/xvdf"
        volume_size = 500
        volume_type = "gp2"
        delete_on_termination = true
        encrypted = true
    }

    ami_regions = ["eu-central-1"]
    run_tags {
        Name = "packer-solr-something"
        stack-name = "DevOps Tools"
    }
    
    communicator = "ssh"
    ssh_pty = true
    ssh_username = "ec2-user"
    associate_public_ip_address = true
}
```
2019-12-17 11:25:56 +01:00
Lars Lehtonen 2e7ba19d8c post-processor/vagrant-cloud: fix dropped test errors 2019-11-15 11:44:33 +01:00
Adrien Delorme 078ba7c8c3 commit old code generation tool
for history
2019-10-15 12:56:42 +02:00
Lars Lehtonen 21f2e67462
post-processor/vagrant-cloud: fix dropped errors 2019-09-26 09:23:09 -07:00
Brian Fox 331babc2ce allow blank access_token (no auth) for private vagrant box hosting 2019-09-12 12:37:53 +02:00
DanHam ca9b500e76
Fix test output: Correct copy/paste errors and make message clearer 2019-08-22 09:48:32 +01:00
DanHam 7770ade74c
Clearer error message for artifice users. OCD nits and logging 2019-08-21 14:32:26 +01:00
DanHam e9ab2203ba
Should return provider correctly with artifacts from other builders or pp's 2019-08-21 14:32:25 +01:00
DanHam e8336039d9
Should return provider correctly with good box and artifice pp 2019-08-21 14:32:25 +01:00
DanHam aee400836f
Should return an error if the provider kv pair is not in the metadata file 2019-08-21 14:32:25 +01:00
DanHam a7603f63c7
Should return an error if the metadata file has badly formatted JSON 2019-08-21 14:32:25 +01:00
DanHam 57137c6e33
Should return an error if the value of the provider key is empty 2019-08-21 14:32:25 +01:00
DanHam d1327fe422
Should return an error if the metadata file is empty 2019-08-21 14:32:24 +01:00
DanHam a9e22a6bb2
Should return the provider by parsing the json in the box metadata file 2019-08-21 14:32:24 +01:00
DanHam 0bf0e7c078
Should return an error when the metadata file is not in the box tar archive
Split out box creation into new helper function
2019-08-21 14:32:24 +01:00
DanHam 063e4bd3e5
Should return an error if the box tar archive is empty 2019-08-21 14:32:24 +01:00
DanHam 9c6b355088
Should return an error if the box is a plain gzip file 2019-08-21 14:32:24 +01:00
DanHam 35d326de39
Add basic workings to function. Return an error if box file is empty 2019-08-21 14:32:23 +01:00