Repository: kubean-io/kubean
Pull request #502 (2023-02-09 08:06:05)

support imageRepo with password
<!--  

Thanks for sending a pull request!  Here are some tips for you:

* make sure your commit is signed off

-->

**What type of PR is this?**
<!-- 
Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
-->

/kind feature

**What this PR does / why we need it**:

**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #

**Special notes for your reviewer**:




Patch:
diff --git a/api/apis/manifest/v1alpha1/types.go b/api/apis/manifest/v1alpha1/types.go
index 23017f8ed..d8aa149e5 100644
--- a/api/apis/manifest/v1alpha1/types.go
+++ b/api/apis/manifest/v1alpha1/types.go
@@ -41,10 +41,21 @@ type Spec struct {
 	Docker []*DockerInfo `json:"docker,omitempty"`
 }
 
+type ImageRepoPasswordAuth struct {
+	// +optional
+	ImageRepoAddress string `json:"imageRepoAddress" yaml:"imageRepoAddress"`
+	// +optional
+	UserName string `json:"userName" yaml:"userName"`
+	// +optional
+	PasswordBase64 string `json:"passwordBase64" yaml:"passwordBase64"`
+}
+
 type LocalService struct {
 	// +optional
 	ImageRepo map[ImageRepoType]string `json:"imageRepo" yaml:"imageRepo"`
 	// +optional
+	ImageRepoAuth []ImageRepoPasswordAuth `json:"imageRepoAuth,omitempty" yaml:"imageRepoAuth,omitempty"`
+	// +optional
 	FilesRepo string `json:"filesRepo,omitempty" yaml:"filesRepo,omitempty"`
 	// +optional
 	YumRepos map[string][]string `json:"yumRepos,omitempty" yaml:"yumRepos,omitempty"`
diff --git a/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go b/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go
index e4e74d742..7d97989c5 100644
--- a/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go
+++ b/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go
@@ -67,6 +67,22 @@ func (in *HostsMap) DeepCopy() *HostsMap {
 	return out
 }
 
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ImageRepoPasswordAuth) DeepCopyInto(out *ImageRepoPasswordAuth) {
+	*out = *in
+	return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageRepoPasswordAuth.
+func (in *ImageRepoPasswordAuth) DeepCopy() *ImageRepoPasswordAuth {
+	if in == nil {
+		return nil
+	}
+	out := new(ImageRepoPasswordAuth)
+	in.DeepCopyInto(out)
+	return out
+}
+
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *LocalAvailable) DeepCopyInto(out *LocalAvailable) {
 	*out = *in
@@ -115,6 +131,11 @@ func (in *LocalService) DeepCopyInto(out *LocalService) {
 			(*out)[key] = val
 		}
 	}
+	if in.ImageRepoAuth != nil {
+		in, out := &in.ImageRepoAuth, &out.ImageRepoAuth
+		*out = make([]ImageRepoPasswordAuth, len(*in))
+		copy(*out, *in)
+	}
 	if in.YumRepos != nil {
 		in, out := &in.YumRepos, &out.YumRepos
 		*out = make(map[string][]string, len(*in))
diff --git a/api/charts/crds/kubean.io_manifests.yaml b/api/charts/crds/kubean.io_manifests.yaml
index ba91b1323..0f9137f62 100644
--- a/api/charts/crds/kubean.io_manifests.yaml
+++ b/api/charts/crds/kubean.io_manifests.yaml
@@ -90,6 +90,17 @@ spec:
                     additionalProperties:
                       type: string
                     type: object
+                  imageRepoAuth:
+                    items:
+                      properties:
+                        imageRepoAddress:
+                          type: string
+                        passwordBase64:
+                          type: string
+                        userName:
+                          type: string
+                      type: object
+                    type: array
                   yumRepos:
                     additionalProperties:
                       items:
diff --git a/charts/kubean/crds/kubean.io_manifests.yaml b/charts/kubean/crds/kubean.io_manifests.yaml
index ba91b1323..0f9137f62 100644
--- a/charts/kubean/crds/kubean.io_manifests.yaml
+++ b/charts/kubean/crds/kubean.io_manifests.yaml
@@ -90,6 +90,17 @@ spec:
                     additionalProperties:
                       type: string
                     type: object
+                  imageRepoAuth:
+                    items:
+                      properties:
+                        imageRepoAddress:
+                          type: string
+                        passwordBase64:
+                          type: string
+                        userName:
+                          type: string
+                      type: object
+                    type: array
                   yumRepos:
                     additionalProperties:
                       items:
diff --git a/vendor/kubean.io/api/apis/manifest/v1alpha1/types.go b/vendor/kubean.io/api/apis/manifest/v1alpha1/types.go
index 23017f8ed..d8aa149e5 100644
--- a/vendor/kubean.io/api/apis/manifest/v1alpha1/types.go
+++ b/vendor/kubean.io/api/apis/manifest/v1alpha1/types.go
@@ -41,10 +41,21 @@ type Spec struct {
 	Docker []*DockerInfo `json:"docker,omitempty"`
 }
 
+type ImageRepoPasswordAuth struct {
+	// +optional
+	ImageRepoAddress string `json:"imageRepoAddress" yaml:"imageRepoAddress"`
+	// +optional
+	UserName string `json:"userName" yaml:"userName"`
+	// +optional
+	PasswordBase64 string `json:"passwordBase64" yaml:"passwordBase64"`
+}
+
 type LocalService struct {
 	// +optional
 	ImageRepo map[ImageRepoType]string `json:"imageRepo" yaml:"imageRepo"`
 	// +optional
+	ImageRepoAuth []ImageRepoPasswordAuth `json:"imageRepoAuth,omitempty" yaml:"imageRepoAuth,omitempty"`
+	// +optional
 	FilesRepo string `json:"filesRepo,omitempty" yaml:"filesRepo,omitempty"`
 	// +optional
 	YumRepos map[string][]string `json:"yumRepos,omitempty" yaml:"yumRepos,omitempty"`
diff --git a/vendor/kubean.io/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go b/vendor/kubean.io/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go
index e4e74d742..7d97989c5 100644
--- a/vendor/kubean.io/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go
+++ b/vendor/kubean.io/api/apis/manifest/v1alpha1/zz_generated.deepcopy.go
@@ -67,6 +67,22 @@ func (in *HostsMap) DeepCopy() *HostsMap {
 	return out
 }
 
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ImageRepoPasswordAuth) DeepCopyInto(out *ImageRepoPasswordAuth) {
+	*out = *in
+	return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageRepoPasswordAuth.
+func (in *ImageRepoPasswordAuth) DeepCopy() *ImageRepoPasswordAuth {
+	if in == nil {
+		return nil
+	}
+	out := new(ImageRepoPasswordAuth)
+	in.DeepCopyInto(out)
+	return out
+}
+
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *LocalAvailable) DeepCopyInto(out *LocalAvailable) {
 	*out = *in
@@ -115,6 +131,11 @@ func (in *LocalService) DeepCopyInto(out *LocalService) {
 			(*out)[key] = val
 		}
 	}
+	if in.ImageRepoAuth != nil {
+		in, out := &in.ImageRepoAuth, &out.ImageRepoAuth
+		*out = make([]ImageRepoPasswordAuth, len(*in))
+		copy(*out, *in)
+	}
 	if in.YumRepos != nil {
 		in, out := &in.YumRepos, &out.YumRepos
 		*out = make(map[string][]string, len(*in))


Test patch:
diff --git a/pkg/controllers/infomanifest/controller_test.go b/pkg/controllers/infomanifest/controller_test.go
index 1e82c1d13..21e6b2c26 100644
--- a/pkg/controllers/infomanifest/controller_test.go
+++ b/pkg/controllers/infomanifest/controller_test.go
@@ -159,6 +159,10 @@ func Test_ParseConfigMapToLocalService(t *testing.T) {
         githubImageRepo: "a"
         dockerImageRepo: "b"
         quayImageRepo: "c"
+      imageRepoAuth:
+        - imageRepoAddress: temp-registry.daocloud.io:5000
+          userName: admin
+          passwordBase64: SGFyYm9yMTIzNDUK
       filesRepo: 'http://temp-registry.daocloud.io:9000'
       yumRepos:
         aRepo: 
@@ -197,6 +201,13 @@ func Test_ParseConfigMapToLocalService(t *testing.T) {
 					"dockerImageRepo": "b",
 					"quayImageRepo":   "c",
 				},
+				ImageRepoAuth: []manifestv1alpha1.ImageRepoPasswordAuth{
+					{
+						ImageRepoAddress: "temp-registry.daocloud.io:5000",
+						UserName:         "admin",
+						PasswordBase64:   "SGFyYm9yMTIzNDUK",
+					},
+				},
 				FilesRepo: "http://temp-registry.daocloud.io:9000",
 				YumRepos: map[string][]string{
 					"aRepo": {"aaa1", "aaa2"},