Skip to content

Commit

Permalink
fix: Fix the url is http need annotations in docker repo secret
Browse files Browse the repository at this point in the history
Signed-off-by: harrisonliu5 <harrisonliu@kubesphere.io>
  • Loading branch information
harrisonliu5 committed Dec 8, 2021
1 parent 5bf97ae commit 05079fc
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 05079fc

Please sign in to comment.