Skip to content

Commit

Permalink
Merge pull request #20 from fuchunlan/fix-3470-1
Browse files Browse the repository at this point in the history
fix constraints bug
  • Loading branch information
wansir authored Apr 2, 2024
2 parents b1720f4 + 15f6a21 commit 3c9438f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/gatekeeper/charts/extension/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/web/extensions/gatekeeper/dist/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ const CreateConstraintForm = ({

const handleChange = () => {
const formData = form.getFieldsValue()

onChange(formData)
onChange({...formData,apiVersion: 'constraints.gatekeeper.sh/v1beta1',})
}

const checkItemValid = item => {
Expand Down Expand Up @@ -88,7 +87,7 @@ const CreateConstraintForm = ({
}
const { kind } = form.getFieldsValue()
if(value){
const res = await store.checkName({ name: value, kind: kind.toLowerCase(), cluster })
const res = await store.checkNameFn({ name: value, kind, cluster })
if (res.exist) {
return Promise.reject({ message: t('NAME_EXIST_DESC') })
}
Expand Down
6 changes: 3 additions & 3 deletions modules/web/extensions/gatekeeper/src/store/constraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ const fetchConstraintKind = async (params) => {

const checkNameFn = async ({ name, kind,cluster }) => {
if (kind) {
const url = `${API_VERSIONS[module]}${getPath({cluster})}/${module}`
const url = `kapis/constraints.gatekeeper.sh/v1beta1${getPath({cluster})}/${module}`
const result = await request.get(url)
const items = get(result, 'items', [])
return isEmpty(find(items, { 'metadata.name': name, kind }))
return {exist:!isEmpty(find(items, (item)=>item.metadata.name===name&&item.kind===kind))}
}
return false
return {exist:false}
}


Expand Down

0 comments on commit 3c9438f

Please sign in to comment.