简体   繁体   English

如何将现有 GCP 数据存储索引导入 index.yaml

[英]How to import existing GCP datastore indexes to index.yaml

I couldn't find any direct way to export existing indexes apart from gcloud datastore indexes list除了gcloud datastore indexes list之外,我找不到任何直接导出现有索引的方法

gcloud-list.yaml gcloud-list.yaml

---                   
ancestor: NONE   
indexId: CICAgOi36pgK 
kind: Session    
projectId: self-serve-dev-261801
properties:      
- direction: ASCENDING
  name: identityId        
- direction: ASCENDING                                                             
  name: endTime                                                                
state: READY                         
---     
ancestor: NONE                                     
indexId: CICAgJj7z4EL                           
kind: Feedback       
projectId: self-serve-dev-261801
properties:          
- direction: ASCENDING
  name: id           
- direction: ASCENDING
  name: entity       
- direction: ASCENDING
  name: value          
- direction: ASCENDING
  name: submitter    
- direction: ASCENDING
  name: createdOn    
- direction: ASCENDING
  name: updatedOn    

index.yaml索引.yaml

indexes:

- kind: Task
  ancestor: no
  properties:
  - name: done
  - name: priority
    direction: desc

- kind: Task
  properties:
  - name: collaborators
    direction: asc
  - name: created
    direction: desc

- kind: TaskList
  ancestor: yes
  properties:
  - name: percent_complete
    direction: asc
  - name: type
    direction: asc

It's output contains IndexId which is not found in actual index.yaml samples.它是IndexId包含在实际索引中找不到的 IndexId。yaml 示例。

I want to create a datastore and import this indexes to it using a Terraform module.我想创建一个数据存储并使用 Terraform 模块将此索引导入其中。 I don't know whether the list output conflicts if we try to import it from the gcloud cli output as such.我不知道如果我们尝试从 gcloud cli output 导入list output 是否会发生冲突。

Also values are different NONE -> no , ASCENDING -> asc .值也不同NONE -> noASCENDING -> asc

I could write a script to convert it to the proper format.我可以编写一个脚本将其转换为正确的格式。 Is that the only way?这是唯一的方法吗?

You can make use of this repo for generating index.yaml file for GCP datastore.您可以使用此存储库为 GCP 数据存储生成 index.yaml 文件。 https://github.com/ArunMuthuram/gcpDatastoreIndexYamlGenerator https://github.com/ArunMuthuram/gcpDatastoreIndexYamlGenerator

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM