github.com/yoctocloud/packer@v0.6.2-0.20160520224004-e11a0a18423f/plugin/example/main.go (about)

     1  // This is an example plugin. In packer 0.9.0 and up, core plugins are compiled
     2  // into the main binary so these files are no longer necessary for the packer
     3  // project.
     4  //
     5  // However, it is still possible to create a third-party plugin for packer that
     6  // is distributed independently from the packer distribution. These continue to
     7  // work in the same way. They will be loaded from the same directory as packer
     8  // by looking for packer-[builder|provisioner|post-processor]-plugin-name. For
     9  // example:
    10  //
    11  //    packer-builder-docker
    12  //
    13  // Look at command/plugin.go to see how the core plugins are loaded now, but the
    14  // format below was used for packer <= 0.8.6 and is forward-compatible.
    15  package main
    16  
    17  import (
    18  	"github.com/mitchellh/packer/builder/amazon/chroot"
    19  	"github.com/mitchellh/packer/packer/plugin"
    20  	"github.com/mitchellh/packer/post-processor/docker-push"
    21  	"github.com/mitchellh/packer/provisioner/powershell"
    22  )
    23  
    24  func main() {
    25  	server, err := plugin.Server()
    26  	if err != nil {
    27  		panic(err)
    28  	}
    29  	// Choose the appropriate type of plugin. You should only use one of these
    30  	// at a time, which means you will have a separate plugin for each builder,
    31  	// provisioner, or post-processor.
    32  	server.RegisterBuilder(new(chroot.Builder))
    33  	server.RegisterPostProcessor(new(dockerpush.PostProcessor))
    34  	server.RegisterProvisioner(new(powershell.Provisioner))
    35  	server.Serve()
    36  }