當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Interface.Batch方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/client/clientset_generated/clientset.Interface.Batch方法的典型用法代碼示例。如果您正苦於以下問題:Golang Interface.Batch方法的具體用法?Golang Interface.Batch怎麽用?Golang Interface.Batch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/client/clientset_generated/clientset.Interface的用法示例。


在下文中一共展示了Interface.Batch方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: waitForJobsAtLeast

// waitForJobsAtLeast waits for at least a number of jobs to appear.
func waitForJobsAtLeast(c clientset.Interface, ns string, atLeast int) error {
	return wait.Poll(framework.Poll, cronJobTimeout, func() (bool, error) {
		jobs, err := c.Batch().Jobs(ns).List(v1.ListOptions{})
		if err != nil {
			return false, err
		}
		return len(jobs.Items) >= atLeast, nil
	})
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:10,代碼來源:cronjob.go

示例2: waitForJobFinish

// Wait for job to reach completions.
func waitForJobFinish(c clientset.Interface, ns, jobName string, completions int32) error {
	return wait.Poll(framework.Poll, jobTimeout, func() (bool, error) {
		curr, err := c.Batch().Jobs(ns).Get(jobName, metav1.GetOptions{})
		if err != nil {
			return false, err
		}
		return curr.Status.Succeeded == completions, nil
	})
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:10,代碼來源:job.go

示例3: waitForAnyFinishedJob

// waitForAnyFinishedJob waits for any completed job to appear.
func waitForAnyFinishedJob(c clientset.Interface, ns string) error {
	return wait.Poll(framework.Poll, cronJobTimeout, func() (bool, error) {
		jobs, err := c.Batch().Jobs(ns).List(v1.ListOptions{})
		if err != nil {
			return false, err
		}
		for i := range jobs.Items {
			if job.IsJobFinished(&jobs.Items[i]) {
				return true, nil
			}
		}
		return false, nil
	})
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:15,代碼來源:cronjob.go

示例4: waitForJobFail

// Wait for job fail.
func waitForJobFail(c clientset.Interface, ns, jobName string, timeout time.Duration) error {
	return wait.Poll(framework.Poll, timeout, func() (bool, error) {
		curr, err := c.Batch().Jobs(ns).Get(jobName, metav1.GetOptions{})
		if err != nil {
			return false, err
		}
		for _, c := range curr.Status.Conditions {
			if c.Type == batch.JobFailed && c.Status == v1.ConditionTrue {
				return true, nil
			}
		}
		return false, nil
	})
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:15,代碼來源:job.go

示例5: waitForJobReplaced

// Wait for a job to be replaced with a new one.
func waitForJobReplaced(c clientset.Interface, ns, previousJobName string) error {
	return wait.Poll(framework.Poll, cronJobTimeout, func() (bool, error) {
		jobs, err := c.Batch().Jobs(ns).List(v1.ListOptions{})
		if err != nil {
			return false, err
		}
		if len(jobs.Items) > 1 {
			return false, fmt.Errorf("More than one job is running %+v", jobs.Items)
		} else if len(jobs.Items) == 0 {
			framework.Logf("Warning: Found 0 jobs in namespace %v", ns)
			return false, nil
		}
		return jobs.Items[0].Name != previousJobName, nil
	})
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:16,代碼來源:cronjob.go

示例6: NewJobInformer

// NewJobInformer returns a SharedIndexInformer that lists and watches all jobs
func NewJobInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
	sharedIndexInformer := cache.NewSharedIndexInformer(
		&cache.ListWatch{
			ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
				return client.Batch().Jobs(v1.NamespaceAll).List(options)
			},
			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
				return client.Batch().Jobs(v1.NamespaceAll).Watch(options)
			},
		},
		&batch.Job{},
		resyncPeriod,
		cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
	)

	return sharedIndexInformer
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:18,代碼來源:batch.go

示例7: deleteJob

func deleteJob(c clientset.Interface, ns, name string) error {
	return c.Batch().Jobs(ns).Delete(name, nil)
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:3,代碼來源:job.go

示例8: updateJob

func updateJob(c clientset.Interface, ns string, job *batch.Job) (*batch.Job, error) {
	return c.Batch().Jobs(ns).Update(job)
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:3,代碼來源:job.go

示例9: getJob

func getJob(c clientset.Interface, ns, name string) (*batch.Job, error) {
	return c.Batch().Jobs(ns).Get(name, metav1.GetOptions{})
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:3,代碼來源:job.go

示例10: deleteV1Job

func deleteV1Job(c clientset.Interface, ns, name string) error {
	return c.Batch().Jobs(ns).Delete(name, v1.NewDeleteOptions(0))
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:3,代碼來源:batch_v1_jobs.go

示例11: createV1Job

func createV1Job(c clientset.Interface, ns string, job *batch.Job) (*batch.Job, error) {
	return c.Batch().Jobs(ns).Create(job)
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:3,代碼來源:batch_v1_jobs.go


注:本文中的k8s/io/kubernetes/pkg/client/clientset_generated/clientset.Interface.Batch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。