Skip to content

Commit

Permalink
Merge pull request #2795 from harrisonliu5/fix/secrets-image-repo
Browse files Browse the repository at this point in the history
fix: Fix the url is http need annotations in docker repo secret
  • Loading branch information
ks-ci-bot authored Dec 9, 2021
2 parents 9aa9a43 + 05079fc commit 7645b31
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>.
*/

import { get, debounce } from 'lodash'
import { get, debounce, set, has } from 'lodash'
import React, { Component } from 'react'
import { observer } from 'mobx-react'

Expand Down Expand Up @@ -65,6 +65,7 @@ export default class ImageRegistry extends Component {

this.setState({ errorMsg: '' })
if (url && username && password) {
this.handleAnnotationsByUrl(url)
onChange(
JSON.stringify({
auths: {
Expand All @@ -88,6 +89,38 @@ export default class ImageRegistry extends Component {
return true
}

handleAnnotationsByUrl = url => {
const registryUrl = url
.replace(/^(http(s)?:\/\/)?(.*)$/, '$1')
.replace('://', '')

if (registryUrl === 'http') {
const annotations = get(
this.props.fedFormTemplate,
'metadata.annotations',
{}
)
set(this.props.fedFormTemplate, 'metadata.annotations', {
...annotations,
'secret.kubesphere.io/force-insecure': 'true',
})
} else {
const annotations = get(
this.props.fedFormTemplate,
'metadata.annotations',
{}
)

if (has(annotations, 'secret.kubesphere.io/force-insecure')) {
delete annotations['secret.kubesphere.io/force-insecure']
}

set(this.props.fedFormTemplate, 'metadata.annotations', {
...annotations,
})
}
}

handleValidate = async () => {
const { cluster, isFederated, namespace, screatName } = this.props

Expand Down

0 comments on commit 7645b31

Please sign in to comment.