跳至主要内容

命令:providers schema

tofu providers schema 命令用于打印当前配置中使用的提供程序的详细模式。

用法

用法:tofu providers schema [options]

以下标志可用

  • -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 输出格式由以下对象和子对象组成

提供程序模式表示

代码块
{
"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>,
}
},
"example_provider_two": {}
}
}

模式表示

模式表示将提供程序或资源模式(在“块”中)与其模式的版本配对。

代码块
{
// "version" is the schema version, not the provider version
"version": int64,
"block": <block-representation>
}

块表示

块表示包含“属性”和“block_types”(表示嵌套块)。

代码块
{
// "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",

// "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
},
},
// "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
}
}