You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/05/16 08:19:49 UTC

[GitHub] [dolphinscheduler] tongwl commented on a diff in pull request #9425: [Feature][plugin] Add k8s task in task plugin

tongwl commented on code in PR #9425:
URL: https://github.com/apache/dolphinscheduler/pull/9425#discussion_r873449610


##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-k8s.ts:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { useCustomParams } from '.'
+import type { IJsonItem } from '../types'
+import { useI18n } from 'vue-i18n'
+import { onMounted, ref, VNodeChild } from 'vue'
+import { queryNamespaceListPaging } from '@/service/modules/k8s-namespace'
+import { SelectOption } from 'naive-ui'
+
+export function useK8s(model: { [field: string]: any }): IJsonItem[] {
+  const { t } = useI18n()
+
+  const options = ref([])
+  const loading = ref(false)
+
+  const getNamespaceList = async () => {
+    if (loading.value) return
+    loading.value = true
+    const { totalList = [] } = await queryNamespaceListPaging({
+      pageNo: 1,
+      pageSize: 2147483647
+    })
+    options.value = totalList.map(
+      (item: { id: string; namespace: string; k8s: string }) => ({
+        label: `${item.namespace}(${item.k8s})`,
+        value: JSON.stringify({
+          name: item.namespace,
+          cluster: item.k8s
+        })
+      })
+    )
+    loading.value = false
+  }
+
+  onMounted(() => {
+    getNamespaceList()
+  })
+
+  const renderLabel = (option: SelectOption): VNodeChild => {
+    if (option.type === 'group') return option.label as string
+    return [option.label as string]
+  }
+
+  return [
+    {
+      type: 'select',
+      field: 'namespace',
+      name: t('project.node.namespace_cluster'),
+      props: {
+        loading,
+        'render-label': renderLabel
+      },
+      options: [
+        {
+          type: 'group',
+          label: t('project.node.namespace_cluster'),
+          key: t('project.node.namespace_cluster'),
+          children: options as any
+        }
+      ]
+    },
+    {
+      type: 'input-number',
+      field: 'minCpuCores',
+      span: 12,
+      name: t('project.node.min_cpu'),
+      slots: {
+        suffix: () => t('project.node.cores')
+      }
+    },
+    {
+      type: 'input-number',
+      field: 'minMemorySpace',
+      span: 12,
+      name: t('project.node.min_memory'),
+      slots: {
+        suffix: () => t('project.node.mb')
+      }
+    },
+    {
+      type: 'input',
+      field: 'image',
+      name: t('project.node.image'),
+      props: {
+        placeholder: t('project.node.image_tips')
+      },
+      validate: {
+        trigger: ['input', 'blur'],
+        message: t('project.node.min_memory_tips')

Review Comment:
   Yes, thank you for the nice reminder, bug fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org