Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypt Yaml List Value #103

Open
emoshaya opened this issue Apr 19, 2023 · 2 comments
Open

Decrypt Yaml List Value #103

emoshaya opened this issue Apr 19, 2023 · 2 comments

Comments

@emoshaya
Copy link

emoshaya commented Apr 19, 2023

I have the following file.yaml

sites:
  - url: ENC[AES256_GCM,data:x/wCj4a2uyjKexk5tqXRyFQDir5YS0wgr94mBC7O,iv:GNd28uJ4U9x34kIf92v8au3UZxd57xOASXZW1M4FhBQ=,tag:04DBK6v5IsLPWMlmWG+YxA==,type:str]
    secret: ENC[AES256_GCM,data:e5y1tm95QFuNmBBV7hK2FqhO/6cnYeW02YUcJLr1qiHbofiACcGCMCVY0ZLGaOpeNCy+UJdWuoyHpPI2QglHX+8+sCXikuVS24VLME7GmI8VDZiRTr7XlCWnS5VBo1ZBQbRuEm5+E6bkdaqRSH5vgpOoFqsP5JIPltNsCzePw2w=,iv:Ale015rSC+ekGSynn1eaU7YbVBLm/Ma7Q6F76uh2LkA=,tag:LpLj95062vam4Gi0Sb3RZQ==,type:str]
  - url: ENC[AES256_GCM,data:itTbUvKlQsllvoy2jSySWAd66bhHFQ6hikB/P0Vx,iv:t9VS6fPGA4Yxgcp1XXqzqOZHXd7ID6ioOxnVHkM06Mc=,tag:edOPTAJZ88A+opw7lqUBgw==,type:str]
    secret: ENC[AES256_GCM,data:pxFTGoR3H3Pct/K0X4CqPbSgKyMC2sJ6vgkMQNE/XHXYfm0S2lMkJ9ziJp8XvKLkHXhuKxXbvBM+olBU8D6Z7QVwBw70mq+zySS+D5GgM/HigpU7ZKpjFtvkjQK25zd5rNdh5VKuUJpG33vz0/2DM7W1aGBuGIRGlAARo3zSMEg=,iv:s+YgJTqHCQnq43wc49fcCwp1Mkmy7xL5C3Hqi4SNwcM=,tag:04GpEUXnXBlCMD5rPlzjlg==,type:str]

I would like to decrypt the whole list. but when I try data.sops_file.this.data["sites"]

I get the following error:

The given key does not identify an element in this collection value

How can I decrypt the whole list?

@vaclav-stummer
Copy link

Same problem. It looks like that this plugin can't parse yaml lists:

client_callbacks:
  - some_calback
  - some_other_calback

@carlpett
Copy link
Owner

Hi,
Apologies for the delayed answer. It is possible to use lists, however the syntax is index-based, for example data.sops_file.this.data.sites.0.url.

This is tested here:

func TestDataSourceSopsFile_complexlist(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
config := fmt.Sprintf(configTestDataSourceSopsFile_complexlist, wd)
resource.UnitTest(t, resource.TestCase{
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.sops_file.test_list", "data.a_list.0.name", "foo"),
resource.TestCheckResourceAttr("data.sops_file.test_list", "data.a_list.0.index", "0"),
resource.TestCheckResourceAttr("data.sops_file.test_list", "data.a_list.0.value", "null"),
resource.TestCheckResourceAttr("data.sops_file.test_list", "data.a_list.1.name", "bar"),
resource.TestCheckResourceAttr("data.sops_file.test_list", "data.a_list.1.index", "1"),
),
},
},
})
}

Would be good with some proper documentation though, would much appreciate contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants