From 00e4e0c7a7c5a4038a378e4b450a604947fe9b62 Mon Sep 17 00:00:00 2001 From: Gennady Lipenkov Date: Wed, 25 Sep 2019 14:27:24 +0300 Subject: [PATCH 1/3] Add description of field in config struct Signed-off-by: Gennady Lipenkov --- builder/yandex/config.go | 8 +- website/source/docs/builders/yandex.html.md | 5 +- .../yandex/_Config-not-required.html.md | 77 +++++++++++++++++++ .../builder/yandex/_Config-required.html.md | 12 +++ 4 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 website/source/partials/builder/yandex/_Config-not-required.html.md create mode 100644 website/source/partials/builder/yandex/_Config-required.html.md diff --git a/builder/yandex/config.go b/builder/yandex/config.go index d9d25a221..b5bad16ee 100644 --- a/builder/yandex/config.go +++ b/builder/yandex/config.go @@ -1,3 +1,4 @@ +//go:generate struct-markdown package yandex import ( @@ -62,7 +63,7 @@ type Config struct { ImageProductIDs []string `mapstructure:"image_product_ids" required:"false"` // The number of cores available to the instance. InstanceCores int `mapstructure:"instance_cores" required:"false"` - // + // The number of GPU available to the instance. InstanceGpus int `mapstructure:"instance_gpus"` // The amount of memory available to the instance, specified in gigabytes. InstanceMemory int `mapstructure:"instance_mem_gb" required:"false"` @@ -92,7 +93,8 @@ type Config struct { // The source image ID to use to create the new image // from. SourceImageID string `mapstructure:"source_image_id" required:"false"` - // + // The source image name to use to create the new image + // from. Name will be looked up in `source_image_folder_id`. SourceImageName string `mapstructure:"source_image_name"` // The Yandex VPC subnet id to use for // the launched instance. Note, the zone of the subnet must match the @@ -103,7 +105,7 @@ type Config struct { UseIPv4Nat bool `mapstructure:"use_ipv4_nat" required:"false"` // Set to true to enable IPv6 for the instance being // created. This defaults to false, or not enabled. - // -> Note: ~> Usage of IPv6 will be available in the future. + // -> Note: Usage of IPv6 will be available in the future. UseIPv6 bool `mapstructure:"use_ipv6" required:"false"` // If true, use the instance's internal IP address // instead of its external IP during building. diff --git a/website/source/docs/builders/yandex.html.md b/website/source/docs/builders/yandex.html.md index 32dafbf19..15ec3c14f 100644 --- a/website/source/docs/builders/yandex.html.md +++ b/website/source/docs/builders/yandex.html.md @@ -133,7 +133,8 @@ can be configured for this builder. - `use_ipv6` (boolean) - Set to `true` to enable IPv6 for the instance being created. This defaults to `false`, or not enabled. --> **Note:** ~> Usage of IPv6 will be available in the future. + + \~> **Note:** Usage of IPv6 will be available in the future. - `source_image_folder_id` (string) - The ID of the folder containing the source image. @@ -141,7 +142,7 @@ can be configured for this builder. from. - `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`. + from. Name will be looked up in `source_image_folder_id`. - `state_timeout` (string) - The time to wait for instance state changes. Defaults to `5m`. diff --git a/website/source/partials/builder/yandex/_Config-not-required.html.md b/website/source/partials/builder/yandex/_Config-not-required.html.md new file mode 100644 index 000000000..a1783aa93 --- /dev/null +++ b/website/source/partials/builder/yandex/_Config-not-required.html.md @@ -0,0 +1,77 @@ + + +- `endpoint` (string) - Non standard api endpoint URL. + +- `service_account_key_file` (string) - Path to file with Service Account key in json format. This + is an alternative method to authenticate to Yandex.Cloud. Alternatively you may set environment variable + YC_SERVICE_ACCOUNT_KEY_FILE. + +- `disk_name` (string) - The name of the disk, if unset the instance name + will be used. + +- `disk_size_gb` (int) - The size of the disk in GB. This defaults to 10, which is 10GB. + +- `disk_type` (string) - Specify disk type for the launched instance. Defaults to network-hdd. + +- `image_description` (string) - The description of the resulting image. + +- `image_family` (string) - The family name of the resulting image. + +- `image_labels` (map[string]string) - Key/value pair labels to + apply to the created image. + +- `image_name` (string) - The unique name of the resulting image. Defaults to + packer-{{timestamp}}. + +- `image_product_ids` ([]string) - License IDs that indicate which licenses are attached to resulting image. + +- `instance_cores` (int) - The number of cores available to the instance. + +- `instance_gpus` (int) - The number of GPU available to the instance. + +- `instance_mem_gb` (int) - The amount of memory available to the instance, specified in gigabytes. + +- `instance_name` (string) - The name assigned to the instance. + +- `labels` (map[string]string) - Key/value pair labels to apply to + the launched instance. + +- `platform_id` (string) - Identifier of the hardware platform configuration for the instance. This defaults to standard-v1. + +- `max_retries` (int) - The maximum number of times an API request is being executed + +- `metadata` (map[string]string) - Metadata applied to the launched instance. + +- `metadata_from_file` (map[string]string) - Metadata applied to the launched instance. Value are file paths. + +- `preemptible` (bool) - Launch a preemptible instance. This defaults to `false`. + +- `serial_log_file` (string) - File path to save serial port output of the launched instance. + +- `source_image_folder_id` (string) - The ID of the folder containing the source image. + +- `source_image_id` (string) - The source image ID to use to create the new image + from. + +- `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`. + +- `subnet_id` (string) - The Yandex VPC subnet id to use for + the launched instance. Note, the zone of the subnet must match the + zone in which the VM is launched. + +- `use_ipv4_nat` (bool) - If set to true, then launched instance will have external internet + access. + +- `use_ipv6` (bool) - Set to true to enable IPv6 for the instance being + created. This defaults to false, or not enabled. + -> Note: Usage of IPv6 will be available in the future. + +- `use_internal_ip` (bool) - If true, use the instance's internal IP address + instead of its external IP during building. + +- `zone` (string) - The name of the zone to launch the instance. This defaults to ru-central1-a. + +- `state_timeout` (time.Duration) - The time to wait for instance state changes. + Defaults to 5m. + \ No newline at end of file diff --git a/website/source/partials/builder/yandex/_Config-required.html.md b/website/source/partials/builder/yandex/_Config-required.html.md new file mode 100644 index 000000000..9d65be8ae --- /dev/null +++ b/website/source/partials/builder/yandex/_Config-required.html.md @@ -0,0 +1,12 @@ + + +- `folder_id` (string) - The folder ID that will be used to launch instances and store images. + Alternatively you may set value by environment variable YC_FOLDER_ID. + +- `token` (string) - OAuth token to use to authenticate to Yandex.Cloud. Alternatively you may set + value by environment variable YC_TOKEN. + +- `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 + \ No newline at end of file From d070b4868ab224920e33b05a6e91097a4637824e Mon Sep 17 00:00:00 2001 From: Gennady Lipenkov Date: Wed, 25 Sep 2019 16:03:18 +0300 Subject: [PATCH 2/3] Wrap values with backticks Signed-off-by: Gennady Lipenkov --- builder/yandex/config.go | 19 ++++++++++--------- website/source/docs/builders/yandex.html.md | 2 +- .../yandex/_Config-not-required.html.md | 17 +++++++++-------- .../builder/yandex/_Config-required.html.md | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/builder/yandex/config.go b/builder/yandex/config.go index b5bad16ee..39d29e761 100644 --- a/builder/yandex/config.go +++ b/builder/yandex/config.go @@ -45,9 +45,9 @@ type Config struct { // The name of the disk, if unset the instance name // will be used. DiskName string `mapstructure:"disk_name" required:"false"` - // The size of the disk in GB. This defaults to 10, which is 10GB. + // The size of the disk in GB. This defaults to `10`, which is 10GB. DiskSizeGb int `mapstructure:"disk_size_gb" required:"false"` - // Specify disk type for the launched instance. Defaults to network-hdd. + // Specify disk type for the launched instance. Defaults to `network-hdd`. DiskType string `mapstructure:"disk_type" required:"false"` // The description of the resulting image. ImageDescription string `mapstructure:"image_description" required:"false"` @@ -57,7 +57,7 @@ type Config struct { // apply to the created image. ImageLabels map[string]string `mapstructure:"image_labels" required:"false"` // The unique name of the resulting image. Defaults to - // packer-{{timestamp}}. + // `packer-{{timestamp}}`. ImageName string `mapstructure:"image_name" required:"false"` // License IDs that indicate which licenses are attached to resulting image. ImageProductIDs []string `mapstructure:"image_product_ids" required:"false"` @@ -72,7 +72,7 @@ type Config struct { // Key/value pair labels to apply to // the launched instance. Labels map[string]string `mapstructure:"labels" required:"false"` - // Identifier of the hardware platform configuration for the instance. This defaults to standard-v1. + // Identifier of the hardware platform configuration for the instance. This defaults to `standard-v1`. PlatformID string `mapstructure:"platform_id" required:"false"` // The maximum number of times an API request is being executed MaxRetries int `mapstructure:"max_retries"` @@ -86,7 +86,7 @@ type Config struct { SerialLogFile string `mapstructure:"serial_log_file" required:"false"` // 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 + // source_image_family must be specified. Example: `ubuntu-1804-lts` SourceImageFamily string `mapstructure:"source_image_family" required:"true"` // The ID of the folder containing the source image. SourceImageFolderID string `mapstructure:"source_image_folder_id" required:"false"` @@ -104,18 +104,19 @@ type Config struct { // access. UseIPv4Nat bool `mapstructure:"use_ipv4_nat" required:"false"` // Set to true to enable IPv6 for the instance being - // created. This defaults to false, or not enabled. - // -> Note: Usage of IPv6 will be available in the future. + // created. This defaults to `false`, or not enabled. + // + // -> **Note**: Usage of IPv6 will be available in the future. UseIPv6 bool `mapstructure:"use_ipv6" required:"false"` // If true, use the instance's internal IP address // instead of its external IP during building. UseInternalIP bool `mapstructure:"use_internal_ip" required:"false"` - // The name of the zone to launch the instance. This defaults to ru-central1-a. + // The name of the zone to launch the instance. This defaults to `ru-central1-a`. Zone string `mapstructure:"zone" required:"false"` ctx interpolate.Context // The time to wait for instance state changes. - // Defaults to 5m. + // Defaults to `5m`. StateTimeout time.Duration `mapstructure:"state_timeout" required:"false"` } diff --git a/website/source/docs/builders/yandex.html.md b/website/source/docs/builders/yandex.html.md index 15ec3c14f..78dfc8325 100644 --- a/website/source/docs/builders/yandex.html.md +++ b/website/source/docs/builders/yandex.html.md @@ -134,7 +134,7 @@ can be configured for this builder. - `use_ipv6` (boolean) - Set to `true` to enable IPv6 for the instance being created. This defaults to `false`, or not enabled. - \~> **Note:** Usage of IPv6 will be available in the future. + \-> **Note:** Usage of IPv6 will be available in the future. - `source_image_folder_id` (string) - The ID of the folder containing the source image. diff --git a/website/source/partials/builder/yandex/_Config-not-required.html.md b/website/source/partials/builder/yandex/_Config-not-required.html.md index a1783aa93..18c4e4ff6 100644 --- a/website/source/partials/builder/yandex/_Config-not-required.html.md +++ b/website/source/partials/builder/yandex/_Config-not-required.html.md @@ -9,9 +9,9 @@ - `disk_name` (string) - The name of the disk, if unset the instance name will be used. -- `disk_size_gb` (int) - The size of the disk in GB. This defaults to 10, which is 10GB. +- `disk_size_gb` (int) - The size of the disk in GB. This defaults to `10`, which is 10GB. -- `disk_type` (string) - Specify disk type for the launched instance. Defaults to network-hdd. +- `disk_type` (string) - Specify disk type for the launched instance. Defaults to `network-hdd`. - `image_description` (string) - The description of the resulting image. @@ -21,7 +21,7 @@ apply to the created image. - `image_name` (string) - The unique name of the resulting image. Defaults to - packer-{{timestamp}}. + `packer-{{timestamp}}`. - `image_product_ids` ([]string) - License IDs that indicate which licenses are attached to resulting image. @@ -36,7 +36,7 @@ - `labels` (map[string]string) - Key/value pair labels to apply to the launched instance. -- `platform_id` (string) - Identifier of the hardware platform configuration for the instance. This defaults to standard-v1. +- `platform_id` (string) - Identifier of the hardware platform configuration for the instance. This defaults to `standard-v1`. - `max_retries` (int) - The maximum number of times an API request is being executed @@ -64,14 +64,15 @@ access. - `use_ipv6` (bool) - Set to true to enable IPv6 for the instance being - created. This defaults to false, or not enabled. - -> Note: Usage of IPv6 will be available in the future. + created. This defaults to `false`, or not enabled. + + -> **Note**: Usage of IPv6 will be available in the future. - `use_internal_ip` (bool) - If true, use the instance's internal IP address instead of its external IP during building. -- `zone` (string) - The name of the zone to launch the instance. This defaults to ru-central1-a. +- `zone` (string) - The name of the zone to launch the instance. This defaults to `ru-central1-a`. - `state_timeout` (time.Duration) - The time to wait for instance state changes. - Defaults to 5m. + Defaults to `5m`. \ No newline at end of file diff --git a/website/source/partials/builder/yandex/_Config-required.html.md b/website/source/partials/builder/yandex/_Config-required.html.md index 9d65be8ae..c9dba971c 100644 --- a/website/source/partials/builder/yandex/_Config-required.html.md +++ b/website/source/partials/builder/yandex/_Config-required.html.md @@ -8,5 +8,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 + source_image_family must be specified. Example: `ubuntu-1804-lts` \ No newline at end of file From ad7feedb081f878f2f45b6745e696366ba000c5f Mon Sep 17 00:00:00 2001 From: Gennady Lipenkov Date: Wed, 25 Sep 2019 16:27:01 +0300 Subject: [PATCH 3/3] Remove 'yandex.html.md', 'yandex.html.md.erb' would be used Signed-off-by: Gennady Lipenkov --- website/source/docs/builders/yandex.html.md | 150 -------------------- 1 file changed, 150 deletions(-) delete mode 100644 website/source/docs/builders/yandex.html.md diff --git a/website/source/docs/builders/yandex.html.md b/website/source/docs/builders/yandex.html.md deleted file mode 100644 index 78dfc8325..000000000 --- a/website/source/docs/builders/yandex.html.md +++ /dev/null @@ -1,150 +0,0 @@ ---- -description: | - The yandex Packer builder is able to create images for use with - Yandex.Cloud based on existing images. -layout: docs -page_title: 'Yandex Compute - Builders' -sidebar_current: 'docs-builders-yandex' ---- - -# Yandex Compute Builder - -Type: `yandex` - -The `yandex` Packer builder is able to create -[images](https://cloud.yandex.com/docs/compute/concepts/images) for use with -[Yandex Compute Cloud](https://cloud.yandex.com/docs/compute/) -based on existing images. - -## Authentication - -Yandex.Cloud services authentication requires one of the following security credentials: - -- OAuth token -- File with Service Account Key - - -### Authentication Using Token - -To authenticate with an OAuth token only `token` config key is needed. -Or use the `YC_TOKEN` environment variable. - - -### Authentication Using Service Account Key File - -To authenticate with a service account credential, only `service_account_key_file` is needed. -Or use the `YC_SERVICE_ACCOUNT_KEY_FILE` environment variable. - - -## Basic Example - -``` json -{ - "type": "yandex", - "token": "YOUR OAUTH TOKEN", - "folder_id": "YOUR FOLDER ID", - "source_image_family": "ubuntu-1804-lts", - "ssh_username": "ubuntu", - "use_ipv4_nat": "true" -} -``` - -## Configuration Reference - -Configuration options are organized below into two categories: required and -optional. Within each category, the available options are alphabetized and -described. - -In addition to the options listed here, a [communicator](/docs/templates/communicator.html) -can be configured for this builder. - -### Required: - -- `folder_id` (string) - The folder ID that will be used to launch instances and store images. - Alternatively you may set value by environment variable `YC_FOLDER_ID`. - -- `token` (string) - OAuth token to use to authenticate to Yandex.Cloud. Alternatively you may set - value by environment variable `YC_TOKEN`. - -- `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` - -### Optional: - -- `endpoint` (string) - Non standard api endpoint URL. - -- `instance_cores` (number) - The number of cores available to the instance. - -- `instance_gpus` (number) - The number of GPU available to the instance. - -- `instance_mem_gb` (number) - The amount of memory available to the instance, specified in gigabytes. - -- `disk_name` (string) - The name of the disk, if unset the instance name - will be used. - -- `disk_size_gb` (number) - The size of the disk in GB. This defaults to `10`, which is 10GB. - -- `disk_type` (string) - Specify disk type for the launched instance. Defaults to `network-hdd`. - -- `image_description` (string) - The description of the resulting image. - -- `image_family` (string) - The family name of the resulting image. - -- `image_labels` (object of key/value strings) - Key/value pair labels to - apply to the created image. - -- `image_name` (string) - The unique name of the resulting image. Defaults to - `packer-{{timestamp}}`. - -- `image_product_ids` (list) - License IDs that indicate which licenses are attached to resulting image. - -- `instance_name` (string) - The name assigned to the instance. - -- `labels` (object of key/value strings) - Key/value pair labels to apply to - the launched instance. - -- `platform_id` (string) - Identifier of the hardware platform configuration for the instance. This defaults to `standard-v1`. - -- `max_retries` (number) - The maximum number of times an API request is being executed. - -- `metadata` (object of key/value strings) - Metadata applied to the launched - instance. - -- `serial_log_file` (string) - File path to save serial port output of the launched instance. - -- `service_account_key_file` (string) - Path to file with Service Account key in json format. This - is an alternative method to authenticate to Yandex.Cloud. Alternatively you may set environment variable - `YC_SERVICE_ACCOUNT_KEY_FILE`. - -- `source_image_family` (string) - The source image family to create - the new image from. The image family always returns its latest image that - is not deprecated. Example: `ubuntu-1804-lts`. - -- `subnet_id` (string) - The Yandex VPC subnet id to use for - the launched instance. Note, the zone of the subnet must match the - `zone` in which the VM is launched. - -- `use_internal_ip` (boolean) - If true, use the instance's internal IP address - instead of its external IP during building. - -- `use_ipv4_nat` (boolean) - If set to `true`, then launched instance will have external internet - access. - -- `use_ipv6` (boolean) - Set to `true` to enable IPv6 for the instance being - created. This defaults to `false`, or not enabled. - - \-> **Note:** Usage of IPv6 will be available in the future. - -- `source_image_folder_id` (string) - The ID of the folder containing the source image. - -- `source_image_id` (string) - The source image ID to use to create the new image - from. - -- `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`. - -- `state_timeout` (string) - The time to wait for instance state changes. - Defaults to `5m`. - -- `zone` (string) - The name of the zone to launch the instance. This defaults to `ru-central1-a`.