Skip to content

Commit

Permalink
Merge pull request #387 from hangscer8/fix_localServer_yumRepo
Browse files Browse the repository at this point in the history
Fix local Service yum repo
  • Loading branch information
ErikJiang authored Dec 8, 2022
2 parents c3201fb + 475546a commit 8ff6b71
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 26 deletions.
2 changes: 1 addition & 1 deletion api/apis/manifest/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type LocalService struct {
// +optional
FilesRepo string `json:"filesRepo,omitempty" yaml:"filesRepo,omitempty"`
// +optional
YumRepo []string `json:"yumRepo,omitempty" yaml:"yumRepo,omitempty"`
YumRepos map[string][]string `json:"yumRepos,omitempty" yaml:"yumRepos,omitempty"`
// +optional
HostsMap []*HostsMap `json:"hostsMap,omitempty" yaml:"hostsMap,omitempty"`
}
Expand Down
18 changes: 14 additions & 4 deletions api/apis/manifest/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions api/charts/crds/kubean.io_manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ spec:
additionalProperties:
type: string
type: object
yumRepo:
items:
type: string
type: array
yumRepos:
additionalProperties:
items:
type: string
type: array
type: object
type: object
type: object
status:
Expand Down
10 changes: 6 additions & 4 deletions charts/kubean/crds/kubean.io_manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ spec:
additionalProperties:
type: string
type: object
yumRepo:
items:
type: string
type: array
yumRepos:
additionalProperties:
items:
type: string
type: array
type: object
type: object
type: object
status:
Expand Down
84 changes: 76 additions & 8 deletions pkg/controllers/infomanifest/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,25 @@ func Test_ParseConfigMapToLocalService(t *testing.T) {
ClientSet: clientsetfake.NewSimpleClientset(),
InfoManifestClientSet: manifestv1alpha1fake.NewSimpleClientset(),
}
localServiceData := `
imageRepo:
kubeImageRepo: "temp-registry.daocloud.io:5000/registry.k8s.io"
gcrImageRepo: "temp-registry.daocloud.io:5000/gcr.io"
githubImageRepo: "a"
dockerImageRepo: "b"
quayImageRepo: "c"
filesRepo: 'http://temp-registry.daocloud.io:9000'
yumRepos:
aRepo:
- 'aaa1'
- 'aaa2'
bRepo:
- 'bbb1'
- 'bbb2'
hostsMap:
- domain: temp-registry.daocloud.io
address: 'a.b.c.d'
`
tests := []struct {
name string
arg *corev1.ConfigMap
Expand All @@ -169,7 +188,7 @@ func Test_ParseConfigMapToLocalService(t *testing.T) {
},
{
name: "good string data",
arg: &corev1.ConfigMap{Data: map[string]string{"localService": " imageRepo: \n kubeImageRepo: \"temp-registry.daocloud.io:5000/registry.k8s.io\"\n gcrImageRepo: \"temp-registry.daocloud.io:5000/gcr.io\"\n githubImageRepo: \"a\"\n dockerImageRepo: \"b\"\n quayImageRepo: \"c\"\n filesRepo: 'http://temp-registry.daocloud.io:9000'\n yumRepo:\n - 'http://temp-registry.daocloud.io:9000/kubean/centos-iso/\\$releasever/os/\\$basearch'\n - 'http://temp-registry.daocloud.io:9000/centos/\\$releasever/os/\\$basearch'\n hostsMap:\n - domain: temp-registry.daocloud.io\n address: 'a.b.c.d'\n"}},
arg: &corev1.ConfigMap{Data: map[string]string{"localService": localServiceData}},
want: &manifestv1alpha1.LocalService{
ImageRepo: map[manifestv1alpha1.ImageRepoType]string{
"kubeImageRepo": "temp-registry.daocloud.io:5000/registry.k8s.io",
Expand All @@ -179,7 +198,10 @@ func Test_ParseConfigMapToLocalService(t *testing.T) {
"quayImageRepo": "c",
},
FilesRepo: "http://temp-registry.daocloud.io:9000",
YumRepo: []string{"http://temp-registry.daocloud.io:9000/kubean/centos-iso/\\$releasever/os/\\$basearch", "http://temp-registry.daocloud.io:9000/centos/\\$releasever/os/\\$basearch"},
YumRepos: map[string][]string{
"aRepo": {"aaa1", "aaa2"},
"bRepo": {"bbb1", "bbb2"},
},
HostsMap: []*manifestv1alpha1.HostsMap{
{Domain: "temp-registry.daocloud.io", Address: "a.b.c.d"},
},
Expand Down Expand Up @@ -316,7 +338,25 @@ func Test_UpdateGlobalLocalService1(t *testing.T) {
Name: LocalServiceConfigMap,
Namespace: "default",
},
Data: map[string]string{"localService": " imageRepo: \n kubeImageRepo: \"temp-registry.daocloud.io:5000/registry.k8s.io\"\n gcrImageRepo: \"temp-registry.daocloud.io:5000/gcr.io\"\n githubImageRepo: \"a\"\n dockerImageRepo: \"b\"\n quayImageRepo: \"c\"\n filesRepo: 'http://temp-registry.daocloud.io:9000'\n yumRepo:\n - 'http://temp-registry.daocloud.io:9000/kubean/centos-iso/\\$releasever/os/\\$basearch'\n - 'http://temp-registry.daocloud.io:9000/centos/\\$releasever/os/\\$basearch'\n hostsMap: \n - domain: temp-registry.daocloud.io\n address: 'a.b.c.d'"},
Data: map[string]string{"localService": `
imageRepo:
kubeImageRepo: "temp-registry.daocloud.io:5000/registry.k8s.io"
gcrImageRepo: "temp-registry.daocloud.io:5000/gcr.io"
githubImageRepo: "a"
dockerImageRepo: "b"
quayImageRepo: "c"
filesRepo: 'http://temp-registry.daocloud.io:9000'
yumRepos:
aRepo:
- 'aaa1'
- 'aaa2'
bRepo:
- 'bbb1'
- 'bbb2'
hostsMap:
- domain: temp-registry.daocloud.io
address: 'a.b.c.d'
`},
}
addLocalArtifactSet(controller)
controller.ClientSet.CoreV1().ConfigMaps("default").Create(context.Background(), configMap, metav1.CreateOptions{})
Expand All @@ -333,7 +373,10 @@ func Test_UpdateGlobalLocalService1(t *testing.T) {
"quayImageRepo": "c",
},
FilesRepo: "http://temp-registry.daocloud.io:9000",
YumRepo: []string{"http://temp-registry.daocloud.io:9000/kubean/centos-iso/\\$releasever/os/\\$basearch", "http://temp-registry.daocloud.io:9000/centos/\\$releasever/os/\\$basearch"},
YumRepos: map[string][]string{
"aRepo": {"aaa1", "aaa2"},
"bRepo": {"bbb1", "bbb2"},
},
HostsMap: []*manifestv1alpha1.HostsMap{
{
Domain: "temp-registry.daocloud.io",
Expand Down Expand Up @@ -363,7 +406,25 @@ func Test_UpdateGlobalLocalService1(t *testing.T) {
Name: LocalServiceConfigMap,
Namespace: "default",
},
Data: map[string]string{"localService": " imageRepo: \n kubeImageRepo: \"temp-registry.daocloud.io:5000/registry.k8s.io\"\n gcrImageRepo: \"temp-registry.daocloud.io:5000/gcr.io\"\n githubImageRepo: \"a\"\n dockerImageRepo: \"b\"\n quayImageRepo: \"c\"\n filesRepo: 'http://temp-registry.daocloud.io:9000'\n yumRepo:\n - 'http://temp-registry.daocloud.io:9000/kubean/centos-iso/\\$releasever/os/\\$basearch'\n - 'http://temp-registry.daocloud.io:9000/centos/\\$releasever/os/\\$basearch'\n hostsMap: \n - domain: temp-registry.daocloud.io\n address: 'a.b.c.d1'"},
Data: map[string]string{"localService": `
imageRepo:
kubeImageRepo: "temp-registry.daocloud.io:5000/registry.k8s.io"
gcrImageRepo: "temp-registry.daocloud.io:5000/gcr.io"
githubImageRepo: "a"
dockerImageRepo: "b"
quayImageRepo: "c"
filesRepo: 'http://temp-registry.daocloud.io:9000'
yumRepos:
aRepo:
- 'aaa1'
- 'aaa2'
bRepo:
- 'bbb1'
- 'bbb2'
hostsMap:
- domain: temp-registry.daocloud.io
address: 'a.b.c.d1'
`},
}
addLocalArtifactSet(controller)
controller.ClientSet.CoreV1().ConfigMaps("default").Update(context.Background(), configMap, metav1.UpdateOptions{})
Expand All @@ -380,7 +441,10 @@ func Test_UpdateGlobalLocalService1(t *testing.T) {
"quayImageRepo": "c",
},
FilesRepo: "http://temp-registry.daocloud.io:9000",
YumRepo: []string{"http://temp-registry.daocloud.io:9000/kubean/centos-iso/\\$releasever/os/\\$basearch", "http://temp-registry.daocloud.io:9000/centos/\\$releasever/os/\\$basearch"},
YumRepos: map[string][]string{
"aRepo": {"aaa1", "aaa2"},
"bRepo": {"bbb1", "bbb2"},
},
HostsMap: []*manifestv1alpha1.HostsMap{
{
Domain: "temp-registry.daocloud.io",
Expand Down Expand Up @@ -502,7 +566,9 @@ func TestNewGlobalInfoManifest(t *testing.T) {
"dockerImageRepo": "abc.io",
},
FilesRepo: "abc.io",
YumRepo: []string{"abc.io"},
YumRepos: map[string][]string{
"a": {"aa"},
},
},
KubesprayVersion: "v2.0.0",
KubeanVersion: "v1.0.0",
Expand All @@ -524,7 +590,9 @@ func TestNewGlobalInfoManifest(t *testing.T) {
"dockerImageRepo": "abc.io",
},
FilesRepo: "abc.io",
YumRepo: []string{"abc.io"},
YumRepos: map[string][]string{
"a": {"aa"},
},
},
KubesprayVersion: "v2.0.0",
KubeanVersion: "v1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion vendor/kubean.io/api/apis/manifest/v1alpha1/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8ff6b71

Please sign in to comment.