Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a command to show all plugins #11092

Closed
wangjiaxi90 opened this issue Jun 15, 2021 · 8 comments
Closed

Need a command to show all plugins #11092

wangjiaxi90 opened this issue Jun 15, 2021 · 8 comments

Comments

@wangjiaxi90
Copy link

Hello,

I hope  packer could have a command which likes ‘packer plugins’.

At the top of shown ,I hope it can be the third-party plugins , and then display inner plugins.

The reason for this demand is that I installed a third-party plug-in, but when I configure the type field in build.json, Unknown builder is displayed. I am pretty sure that my plug-in is successfully installed after I execute packer init, and I There is this plugin in the .packer.d directory. I suspect that there is a problem with my type field parameter, but I am not sure.

Here is the link of my packer-plugin : https://github.com/wangjiaxi90/packer-plugin-qingwang

Thanks

@SwampDragons
Copy link
Contributor

Hi, thanks for reaching out! This is a good idea. For now, can you share the HCL template you're using that is failing? We can help you debug.

@wangjiaxi90
Copy link
Author

Thanks for your reply, here is my packer init script

packer {
required_plugins {
docker = {
version = ">=0.0.1"
source = "github.com/hashicorp/docker"
}
qingwang = {
version = ">=0.0.3"
source = "github.com/wangjiaxi90/qingwang"
}
qingcloud = {
version = ">=0.0.1"
source = "github.com/wangjiaxi90/qingcloud"
}
}
}

And here is my build.json

{
"variables": {},
"builders": [
{
"type":"qingwang",
"base_image_id": "xenial3x64",
"api_key": "mock_api_key",
"api_secret": "mock_api_secret",
"zone": "pek3a",
"protocol": "https",
"host": "api.qingcloud.com",
"port": "443",
"uri": "/iaas",
"log_level": "info",
"yxnet_id": "vxnet-0",
"eip_id": "",
"securitygroup_id": "",
"keypair_id": "",
"image_id": "",
"image_name": "",
"cpu": "1",
"memory": "1024",
"instance_class": ""
},
{
"type":"qingcloud"
},
{
"type":"docker"
}
],
"post-processors": []
}

image

image

@sylviamoss
Copy link
Contributor

Hey there, I believe there are two problems with your configuration.

The first one is that both plugins qingcloud and qingwang didn't register the build with the plugin.DEFAULT_NAME variable. That means when using them you must use qingcloud-qingcloud and qingwang-qingcloud

Here's the code:
https://github.com/wangjiaxi90/packer-plugin-qingcloud/blob/master/main.go#L14
https://github.com/wangjiaxi90/packer-plugin-qingwang/blob/master/main.go

The other issue is that, in order to build a template initialized with packer init ., the template must include the packer.required_plugins block. That said, your template has to be an HCL2 template. I've upgraded the one you provided with our hcl2_upgrade command and here it goes:

packer {
  required_plugins {
    docker = {
      version = ">=0.0.1"
      source = "github.com/hashicorp/docker"
    }
    qingwang = {
      version = ">=0.0.3"
      source = "github.com/wangjiaxi90/qingwang"
    }
    qingcloud = {
      version = ">=0.0.1"
      source = "github.com/wangjiaxi90/qingcloud"
    }
  }
}


source "qingwang-qingcloud" "example" {
  api_key          = "mock_api_key"
  api_secret       = "mock_api_secret"
  base_image_id    = "xenial3x64"
  cpu              = "1"
  eip_id           = ""
  host             = "api.qingcloud.com"
  image_id         = ""
  image_name       = ""
  instance_class   = ""
  keypair_id       = ""
  log_level        = "info"
  memory           = "1024"
  port             = "443"
  protocol         = "https"
  securitygroup_id = ""
  uri              = "/iaas"
  yxnet_id         = "vxnet-0"
  zone             = "pek3a"
}

build {
  sources = ["source.qingwang-qingcloud.example"]
}

@sylviamoss
Copy link
Contributor

Here you can find about the plugin.DEFAULT_NAME I'm talking about
https://www.packer.io/docs/plugins/creation#plugin-development-basics

@wangjiaxi90
Copy link
Author

Thank you very much!
I will test it now!
Thanks again for your reply!

@wangjiaxi90
Copy link
Author

wangjiaxi90 commented Jun 19, 2021

Hi everyone, my plugin has been successfully built.
And then I conceived it in detail.

$ packer plugins

[show all plugins in simplfy info]

$ packer plugins [--sort=param1] [--source=param2]

param1 = “install_time” (defult desc)
= “organization”

Example: $ packer plugins --sort=install_time

param2 is a string to filter the domain

Example : $ packer plugins --source=github.wangjiaxi90

$ packer plugins <plugin name>

[show the details of ‘plugin name’]

Example: $ packer plugins qingcloud-qingcloud

$ packer plugins <plugin name> [--conf]

[show all configurations of ‘plugin name’ and list each one type and is required]

Example: $ packer plugins qingcloud-qingcloud --conf

$ packer plugins [plugin name] [--demo_hcl]

[show the demo hcl whitch may in docs folder or according the conf to generate a demo]

Example: $ packer plugins qingcloud-qingcloud --demo_hcl

@azr azr added this to the 1.7.8 milestone Oct 6, 2021
@nywilken nywilken modified the milestones: 1.7.8, 1.7.9 Oct 6, 2021
@azr azr self-assigned this Feb 1, 2022
@azr
Copy link
Contributor

azr commented Feb 11, 2022

Hello there #11553 added support for this ! This will be available to test in the next nightly release soon, or in the PR's artifacts binaries. Feel free to drop some feedback !

@azr azr closed this as completed Feb 11, 2022
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants