Merge pull request #8153 from yandex-cloud/fix-docs

Add description for some fields in config struct
This commit is contained in:
Adrien Delorme 2019-09-25 16:37:57 +02:00 committed by GitHub
commit 1873ef23de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 160 deletions

View File

@ -1,3 +1,4 @@
//go:generate struct-markdown
package yandex package yandex
import ( import (
@ -44,9 +45,9 @@ type Config struct {
// The name of the disk, if unset the instance name // The name of the disk, if unset the instance name
// will be used. // will be used.
DiskName string `mapstructure:"disk_name" required:"false"` 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"` 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"` DiskType string `mapstructure:"disk_type" required:"false"`
// The description of the resulting image. // The description of the resulting image.
ImageDescription string `mapstructure:"image_description" required:"false"` ImageDescription string `mapstructure:"image_description" required:"false"`
@ -56,13 +57,13 @@ type Config struct {
// apply to the created image. // apply to the created image.
ImageLabels map[string]string `mapstructure:"image_labels" required:"false"` ImageLabels map[string]string `mapstructure:"image_labels" required:"false"`
// The unique name of the resulting image. Defaults to // The unique name of the resulting image. Defaults to
// packer-{{timestamp}}. // `packer-{{timestamp}}`.
ImageName string `mapstructure:"image_name" required:"false"` ImageName string `mapstructure:"image_name" required:"false"`
// License IDs that indicate which licenses are attached to resulting image. // License IDs that indicate which licenses are attached to resulting image.
ImageProductIDs []string `mapstructure:"image_product_ids" required:"false"` ImageProductIDs []string `mapstructure:"image_product_ids" required:"false"`
// The number of cores available to the instance. // The number of cores available to the instance.
InstanceCores int `mapstructure:"instance_cores" required:"false"` InstanceCores int `mapstructure:"instance_cores" required:"false"`
// // The number of GPU available to the instance.
InstanceGpus int `mapstructure:"instance_gpus"` InstanceGpus int `mapstructure:"instance_gpus"`
// The amount of memory available to the instance, specified in gigabytes. // The amount of memory available to the instance, specified in gigabytes.
InstanceMemory int `mapstructure:"instance_mem_gb" required:"false"` InstanceMemory int `mapstructure:"instance_mem_gb" required:"false"`
@ -71,7 +72,7 @@ type Config struct {
// Key/value pair labels to apply to // Key/value pair labels to apply to
// the launched instance. // the launched instance.
Labels map[string]string `mapstructure:"labels" required:"false"` 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"` PlatformID string `mapstructure:"platform_id" required:"false"`
// The maximum number of times an API request is being executed // The maximum number of times an API request is being executed
MaxRetries int `mapstructure:"max_retries"` MaxRetries int `mapstructure:"max_retries"`
@ -85,14 +86,15 @@ type Config struct {
SerialLogFile string `mapstructure:"serial_log_file" required:"false"` SerialLogFile string `mapstructure:"serial_log_file" required:"false"`
// The source image family to create the new image // 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 // 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"` SourceImageFamily string `mapstructure:"source_image_family" required:"true"`
// The ID of the folder containing the source image. // The ID of the folder containing the source image.
SourceImageFolderID string `mapstructure:"source_image_folder_id" required:"false"` SourceImageFolderID string `mapstructure:"source_image_folder_id" required:"false"`
// The source image ID to use to create the new image // The source image ID to use to create the new image
// from. // from.
SourceImageID string `mapstructure:"source_image_id" required:"false"` 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"` SourceImageName string `mapstructure:"source_image_name"`
// The Yandex VPC subnet id to use for // The Yandex VPC subnet id to use for
// the launched instance. Note, the zone of the subnet must match the // the launched instance. Note, the zone of the subnet must match the
@ -102,18 +104,19 @@ type Config struct {
// access. // access.
UseIPv4Nat bool `mapstructure:"use_ipv4_nat" required:"false"` UseIPv4Nat bool `mapstructure:"use_ipv4_nat" required:"false"`
// Set to true to enable IPv6 for the instance being // Set to true to enable IPv6 for the instance being
// created. This defaults to false, or not enabled. // 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"` UseIPv6 bool `mapstructure:"use_ipv6" required:"false"`
// If true, use the instance's internal IP address // If true, use the instance's internal IP address
// instead of its external IP during building. // instead of its external IP during building.
UseInternalIP bool `mapstructure:"use_internal_ip" required:"false"` 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"` Zone string `mapstructure:"zone" required:"false"`
ctx interpolate.Context ctx interpolate.Context
// The time to wait for instance state changes. // The time to wait for instance state changes.
// Defaults to 5m. // Defaults to `5m`.
StateTimeout time.Duration `mapstructure:"state_timeout" required:"false"` StateTimeout time.Duration `mapstructure:"state_timeout" required:"false"`
} }

View File

@ -1,149 +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`.

View File

@ -0,0 +1,78 @@
<!-- Code generated from the comments of the Config struct in builder/yandex/config.go; DO NOT EDIT MANUALLY -->
- `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`.

View File

@ -0,0 +1,12 @@
<!-- Code generated from the comments of the Config struct in builder/yandex/config.go; DO NOT EDIT MANUALLY -->
- `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`