mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-13 10:40:05 -04:00
* Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at https://hashi.co/license-faq, and details of the license at www.hashicorp.com/bsl. * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
38 lines
963 B
Go
38 lines
963 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
//go:generate packer-sdc mapstructure-to-hcl2 -type Provisioner
|
|
|
|
package sleep
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/hashicorp/hcl/v2/hcldec"
|
|
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
|
"github.com/hashicorp/packer-plugin-sdk/template/config"
|
|
)
|
|
|
|
type Provisioner struct {
|
|
Duration time.Duration
|
|
}
|
|
|
|
var _ packersdk.Provisioner = new(Provisioner)
|
|
|
|
func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.FlatMapstructure().HCL2Spec() }
|
|
|
|
func (p *Provisioner) FlatConfig() interface{} { return p.FlatMapstructure() }
|
|
|
|
func (p *Provisioner) Prepare(raws ...interface{}) error {
|
|
return config.Decode(&p, &config.DecodeOpts{}, raws...)
|
|
}
|
|
|
|
func (p *Provisioner) Provision(ctx context.Context, _ packersdk.Ui, _ packersdk.Communicator, _ map[string]interface{}) error {
|
|
select {
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
case <-time.After(p.Duration):
|
|
return nil
|
|
}
|
|
}
|