Hey guys,
I have the following YAML config. Here I have some repositories (repo1, repo2) and distributions (wheezy-test, centos7 etc)
repos:
repo1:
centos6-test:
type: rpm
path: /repo/centos/repo1/centos6-test/x86_64
centos7:
type: rpm
sign: 'Secret123'
path: /repo/centos/repo1/centos7/x86_64
repo2:
wheezy-test:
origin: EvilCorp
label: EvilCorp
path: /repo/debian/repo2/wheezy-test
blacklist:
- -dbg
centos7:
type: rpm
sign: 'Secret123'
path: /repo/debian/repo2/7/1.1/x86_64
blacklist:
- -debuginfo
I assume to parse this config I have to apply something like that:
type RepoConf struct {
Repos Repos `yaml:"repos"`
}
type Repos struct {
Repo1 Repo1 `yaml:"repo1"`
Repo2 Repo2 `yaml:"repo2"`
}
type Repo1 struct {
Centos6Test Centos6Test `yaml:"centos6-test"`
Centos7 Centos7 `yaml:"centos7"`
}
type Repo2 struct {
WheezyTest WheezyTest `yaml:"wheezy-test"`
Centos7 Centos7 `yaml:"centos7"`
}
type Centos6Test struct {
Type string `yaml:"type"`
Path string `yaml:"path"`
}
type Centos7 struct {
Type string `yaml:"type"`
Sign string `yaml:"sign"`
Path string `yaml:"path"`
}
..........
But I have too many variations of the “repoN” and distros (wheezy-test, wheezy, centos6/7/8, and so on).
Is it possible to parse this YAML config without creating a different structure for each repo and distro? Or I have to reconstruct my YAML config to have something like that:
repos:
- repo1:
- name: wheezy
sign: ABC
origin: EvilCorp
label: EvilCorp
path: /somepath/bla1
blacklist:
- bla
- name: wheezy-test
sign: ABC
origin: EvilCorp
label: EvilCorp
path: /somepath/bla2
blacklist:
- lib
- repo2:
- name: centos7
sign: '72B865FD'
path: /somepath/bla3
blacklist:
- lib
I appreciate any suggestion
Regards,
Pasha