Spec-Zone.ru › OpenTofu 1.12

Команда: providers schema

Команда tofu providers schema используется для вывода подробных схем провайдеров, используемых в текущей конфигурации.

Использование​

Использование: tofu providers schema [options]

Примечание

Использование переменных в источниках модулей, конфигурации бэкенда или блоке шифрования требует присваивания значений переменным корневого модуля при запуске tofu providers schema.

Доступны следующие флаги:

  • -json - Выводит схемы в машиночитаемом формате JSON. Эта команда соответствует спецификации вывода необработанного JSON.

  • -var 'NAME=VALUE' - Задает значение для одной входной переменной, объявленной в корневом модуле конфигурации. Используйте этот параметр несколько раз, чтобы задать значения для нескольких переменных. Подробнее см. в разделе Входные переменные в командной строке.

  • -var-file=FILENAME - Задает значения для произвольного количества входных переменных, объявленных в корневом модуле конфигурации, используя определения из файла «tfvars». Используйте этот параметр несколько раз, чтобы подключить значения из нескольких файлов.

Помимо параметров -var и -var-file есть несколько других способов задать значения входных переменных корневого модуля. Подробнее см. в разделе Присваивание значений переменным корневого модуля.

Обратите внимание, что в настоящее время флаг -json является обязательным. В будущих выпусках эта команда будет дополнена другими параметрами.

Вывод содержит ключ format_version со значением "1.0". Семантика этой версии:

  • Для обратно совместимых изменений и дополнений мы будем увеличивать младшую версию, например "1.1". Чтобы сохранить совместимость с будущими младшими версиями, игнорируйте свойства объектов с неизвестными именами.
  • Для несовместимых изменений мы будем увеличивать старшую версию, например "2.0". Отклоняйте любые входные данные, в которых указана неподдерживаемая старшая версия.

Новые старшие версии будут появляться только в рамках гарантий совместимости OpenTofu 1.0.

Краткое описание формата​

В следующих разделах на примерах описан формат вывода JSON с использованием псевдонотации JSON. Важные элементы поясняются комментариями, начинающимися с //. Чтобы избежать излишних повторов, мы разделили полный формат на несколько отдельных подобъектов, описанных в соответствующих разделах. Элементы в угловых скобках (например, <block-representation>) являются заполнителями, которые в реальном выводе заменяются экземпляром указанного подобъекта.

Формат вывода JSON состоит из следующих объектов и подобъектов:

  • Представление схемы провайдеров - объект верхнего уровня, возвращаемый командой tofu providers schema -json
  • Представление схемы - подобъект провайдеров, ресурсов и источников данных, описывающий их схемы
  • Представление блока - подобъект схем, описывающий атрибуты и вложенные блоки
  • Представление схемы идентификаторов ресурсов - подобъект, описывающий схему идентификаторов типа ресурса

Представление схемы провайдеров​

Блок кода
{
  "format_version": "1.0",

  // "provider_schemas" describes the provider schemas for all
  // providers throughout the configuration tree.
  "provider_schemas": {
    // keys in this map are the provider type, such as "random"
    "example_provider_name": {
      // "provider" is the schema for the provider configuration
      "provider": <schema-representation>,

      // "resource_schemas" map the resource type name to the resource's schema
      "resource_schemas": {
        "example_resource_name": <schema-representation>
      },

      // "data_source_schemas" map the data source type name to the
      // data source's schema
      "data_source_schemas": {
        "example_datasource_name": <schema-representation>,
      },

      // "resource_identity_schemas" map the resource type name to the
      // resource's identity schema, if it supports identity-based import.
      // Only resource types that define an identity schema are included.
      "resource_identity_schemas": {
        "example_resource_name": <resource-identity-schema-representation>
      }
    },
    "example_provider_two": { … }
  }
}

Представление схемы​

Представление схемы объединяет схему провайдера или ресурса (в виде «блока») с версией этой схемы.

Блок кода
{
  // "version" is the schema version, not the provider version
  "version": int64,
  "block": <block-representation>
}

Представление блока​

Представление блока содержит «атрибуты» и «типы_блоков» (представляющие вложенные блоки).

Блок кода
{
  // "attributes" describes any attributes that appear directly inside the
  // block. Keys in this map are the attribute names.
  "attributes":  {
    "example_attribute_name": {
      // "type" is a representation of a type specification
      // that the attribute's value must conform to.
      "type": "string",

      // Some attributes use "nested_type" instead of "type",
      // describing an object type or a collection of an object type
      // in a similar way as for nested block types. This should take
      // priority over "type" if both are present, but for most
      // providers only one of the two attributes is returned.
      "nested_type": {
        // "nesting_mode" describes the nesting mode for the
        // attribute value, with the same values as for
        // the corresponding property in "block_types" below.
        "nesting_mode": "list",

        // "attributes" describes the attributes that are
        // expected for each nested object, using the same
        // structure as the top-level "attributes" property.
        "attributes": {
          // ...
        }
      },

      // "description" is an English-language description of
      // the purpose and usage of the attribute.
      "description": "string",

      // "required", if set to true, specifies that an
      // omitted or null value is not permitted.
      "required": bool,

      // "optional", if set to true, specifies that an
      // omitted or null value is permitted.
      "optional": bool,

      // "computed", if set to true, indicates that the
      // value comes from the provider rather than the
      // configuration.
      "computed": bool,

      // "sensitive", if set to true, indicates that the
      // attribute may contain sensitive information.
      "sensitive": bool

      // "deprecated", if set to true, indicates that the
      // attribute is deprecated
      "deprecated": bool

      // "deprecation_message" is the description provided
      // detailing why an attribute has been deprecated.
      "deprecation_message": "string"
    },
  },
  // "block_types" describes any nested blocks that appear directly
  // inside the block.
  // Keys in this map are the names of the block_type.
  "block_types": {
    "example_block_name": {
      // "nesting_mode" describes the nesting mode for the
      // child block, and can be one of the following:
      // 	single
      // 	list
      // 	set
      // 	map
    "nesting_mode": "list",
    "block": <block-representation>,

    // "min_items" and "max_items" set lower and upper
    // limits on the number of child blocks allowed for
    // the list and set modes. These are
    // omitted for other modes.
    "min_items": 1,
    "max_items": 3
  }

  // "deprecated", if set to true, indicates that the
  // attribute is deprecated
  "deprecated": bool

  // "deprecation_message" is the description provided
  // detailing why an attribute has been deprecated.
  "deprecation_message": "string"
}

Представление схемы идентификаторов ресурсов​

Представление схемы идентификаторов ресурсов описывает атрибуты, однозначно идентифицирующие экземпляр ресурса и используемые для импорта по идентификатору. Запись в resource_identity_schemas есть только для типов ресурсов, поддерживающих импорт по идентификатору.

Блок кода
{
  // "version" is the version of the identity schema. OpenTofu uses this to
  // detect when stored identity data needs to be upgraded via the provider.
  "version": uint64,

  // "attributes" describes the attributes that together form the identity of
  // a resource instance. Keys in this map are the attribute names.
  "attributes": {
    "example_attribute_name": {
      // "type" is a representation of a type specification
      // that the attribute's value must conform to.
      "type": "string",

      // "description" is an English-language description of
      // the purpose and usage of the attribute.
      "description": "string",

      // "required_for_import", if set to true, specifies that this
      // attribute must be provided when performing an identity-based import.
      "required_for_import": bool,

      // "optional_for_import", if set to true, specifies that this
      // attribute may optionally be provided when performing an identity-based import.
      "optional_for_import": bool
    },
  },
}

Copyright (c) The OpenTofu Authors
Copyright (c) 2014 HashiCorp, Inc.
Mozilla Public License, version 2.0
https://opentofu.org/docs/v1.12/cli/commands/providers/schema/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API