From fc416be13612d33db01d7d44b8037e7f73929a90 Mon Sep 17 00:00:00 2001 From: Xiang Dai Date: Fri, 22 May 2020 20:28:16 +0800 Subject: [PATCH] Lint: fix godot issue Signed-off-by: Xiang Dai --- .golangci.yml | 22 +++++++++++++++++ cmd/cli/util/util.go | 2 +- cmd/controller-manager/app/options/options.go | 4 ++-- cmd/controller-manager/app/server.go | 2 +- cmd/scheduler/app/options/options.go | 8 +++---- cmd/scheduler/app/server.go | 2 +- cmd/webhook-manager/app/options/options.go | 6 ++--- cmd/webhook-manager/app/util.go | 4 ++-- pkg/apis/batch/v1alpha1/job.go | 16 ++++++------- pkg/apis/bus/v1alpha1/commands.go | 4 ++-- pkg/apis/helpers/helpers.go | 24 ++++++++++--------- pkg/apis/scheduling/scheme/scheme.go | 2 +- pkg/apis/scheduling/types.go | 4 ++-- pkg/apis/scheduling/v1beta1/types.go | 4 ++-- pkg/cli/job/delete.go | 4 ++-- pkg/cli/job/list.go | 6 ++--- pkg/cli/job/resume.go | 4 ++-- pkg/cli/job/run.go | 4 ++-- pkg/cli/job/suspend.go | 4 ++-- pkg/cli/job/util.go | 2 +- pkg/cli/job/view.go | 14 +++++------ pkg/cli/queue/create.go | 4 ++-- pkg/cli/queue/delete.go | 4 ++-- pkg/cli/queue/get.go | 6 ++--- pkg/cli/queue/list.go | 6 ++--- pkg/cli/util/util.go | 14 +++++------ pkg/cli/vcancel/cancel.go | 4 ++-- pkg/cli/vjobs/view.go | 16 ++++++------- pkg/cli/vqueues/get.go | 10 ++++---- pkg/cli/vresume/resume.go | 4 ++-- pkg/cli/vsub/run.go | 4 ++-- pkg/cli/vsuspend/suspend.go | 4 ++-- .../versioned/typed/bus/v1alpha1/command.go | 4 ++-- .../internalinterfaces/factory_interfaces.go | 2 +- pkg/controllers/apis/job_info.go | 12 +++++----- pkg/controllers/apis/request.go | 4 ++-- pkg/controllers/cache/cache.go | 8 +++---- pkg/controllers/cache/interface.go | 2 +- .../garbagecollector/garbagecollector.go | 2 +- pkg/controllers/job/constant.go | 2 +- pkg/controllers/job/helpers/helpers.go | 10 ++++---- pkg/controllers/job/job_controller.go | 6 ++--- pkg/controllers/job/job_controller_util.go | 6 ++--- pkg/controllers/job/plugins/env/env.go | 2 +- pkg/controllers/job/plugins/factory.go | 8 +++---- .../job/plugins/interface/interface.go | 4 ++-- pkg/controllers/job/plugins/svc/svc.go | 4 ++-- pkg/controllers/job/state/factory.go | 8 +++---- pkg/controllers/job/state/util.go | 2 +- pkg/controllers/podgroup/pg_controller.go | 6 ++--- pkg/controllers/queue/queue_controller.go | 4 ++-- .../queue/queue_controller_util.go | 2 +- pkg/controllers/queue/state/factory.go | 6 ++--- pkg/kube/config.go | 4 ++-- pkg/version/version.go | 4 ++-- .../admission/jobs/mutate/mutate_job.go | 2 +- .../admission/jobs/validate/admit_job.go | 2 +- pkg/webhooks/admission/jobs/validate/util.go | 6 ++--- pkg/webhooks/admission/pods/admit_pod.go | 12 ++++++---- .../admission/queues/mutate/mutate_queue.go | 2 +- .../queues/validate/validate_queue.go | 2 +- pkg/webhooks/router/interface.go | 2 +- pkg/webhooks/router/server.go | 6 ++--- pkg/webhooks/schema/schema.go | 4 ++-- pkg/webhooks/util/util.go | 2 +- test/e2e/cli_util.go | 12 +++++----- test/e2e/util.go | 4 ++-- 67 files changed, 206 insertions(+), 180 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 261d25587d3..dbe9f242245 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -70,6 +70,27 @@ issues: - gomnd - dupl - path: v1beta1 + linters: + - golint + - path: pkg/scheduler + linters: + - godot + - path: clientset + linters: + - godot + - path: informers + linters: + - godot + - path: pkg/cli/queue/operate.go + linters: + - godot + - path: pkg/controllers/job/plugins/ssh/ssh.go + linters: + - godot + - path: v1alpha1 + linters: + - godot + - path: generated linters: - golint - deadcode @@ -77,3 +98,4 @@ issues: linters: - golint - deadcode + - godot diff --git a/cmd/cli/util/util.go b/cmd/cli/util/util.go index 7b464701e92..a1058841d9c 100644 --- a/cmd/cli/util/util.go +++ b/cmd/cli/util/util.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" ) -// CheckError prints the error of commands +// CheckError prints the error of commands. func CheckError(cmd *cobra.Command, err error) { if err != nil { msg := "Failed to" diff --git a/cmd/controller-manager/app/options/options.go b/cmd/controller-manager/app/options/options.go index f8612a130a1..fde6485a692 100644 --- a/cmd/controller-manager/app/options/options.go +++ b/cmd/controller-manager/app/options/options.go @@ -54,7 +54,7 @@ func NewServerOption() *ServerOption { return &s } -// AddFlags adds flags for a specific CMServer to the specified FlagSet +// AddFlags adds flags for a specific CMServer to the specified FlagSet. func (s *ServerOption) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.KubeClientOptions.Master, "master", s.KubeClientOptions.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)") fs.StringVar(&s.KubeClientOptions.KubeConfig, "kubeconfig", s.KubeClientOptions.KubeConfig, "Path to kubeconfig file with authorization and master location information.") @@ -69,7 +69,7 @@ func (s *ServerOption) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.SchedulerName, "scheduler-name", defaultSchedulerName, "Volcano will handle pods whose .spec.SchedulerName is same as scheduler-name") } -// CheckOptionOrDie checks the LockObjectNamespace +// CheckOptionOrDie checks the LockObjectNamespace. func (s *ServerOption) CheckOptionOrDie() error { if s.EnableLeaderElection && s.LockObjectNamespace == "" { return fmt.Errorf("lock-object-namespace must not be nil when LeaderElection is enabled") diff --git a/cmd/controller-manager/app/server.go b/cmd/controller-manager/app/server.go index eab79f4f8c3..1f59aedb66c 100644 --- a/cmd/controller-manager/app/server.go +++ b/cmd/controller-manager/app/server.go @@ -50,7 +50,7 @@ const ( retryPeriod = 5 * time.Second ) -// Run the controller +// Run the controller. func Run(opt *options.ServerOption) error { config, err := kube.BuildConfig(opt.KubeClientOptions) if err != nil { diff --git a/cmd/scheduler/app/options/options.go b/cmd/scheduler/app/options/options.go index e6df9a36099..9030c2e2fb8 100644 --- a/cmd/scheduler/app/options/options.go +++ b/cmd/scheduler/app/options/options.go @@ -62,7 +62,7 @@ type ServerOption struct { PercentageOfNodesToFind int32 } -// ServerOpts server options +// ServerOpts server options. var ServerOpts *ServerOption // NewServerOption creates a new CMServer with a default config. @@ -73,7 +73,7 @@ func NewServerOption() *ServerOption { return &s } -// AddFlags adds flags for a specific CMServer to the specified FlagSet +// AddFlags adds flags for a specific CMServer to the specified FlagSet. func (s *ServerOption) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.KubeClientOptions.Master, "master", s.KubeClientOptions.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)") fs.StringVar(&s.KubeClientOptions.KubeConfig, "kubeconfig", s.KubeClientOptions.KubeConfig, "Path to kubeconfig file with authorization and master location information") @@ -103,7 +103,7 @@ func (s *ServerOption) AddFlags(fs *pflag.FlagSet) { fs.Int32Var(&s.PercentageOfNodesToFind, "percentage-nodes-to-find", defaultPercentageOfNodesToFind, "The percentage of nodes to find and score, if <=0 will be calcuated based on the cluster size") } -// CheckOptionOrDie check lock-object-namespace when LeaderElection is enabled +// CheckOptionOrDie check lock-object-namespace when LeaderElection is enabled. func (s *ServerOption) CheckOptionOrDie() error { if s.EnableLeaderElection && s.LockObjectNamespace == "" { return fmt.Errorf("lock-object-namespace must not be nil when LeaderElection is enabled") @@ -112,7 +112,7 @@ func (s *ServerOption) CheckOptionOrDie() error { return nil } -// RegisterOptions registers options +// RegisterOptions registers options. func (s *ServerOption) RegisterOptions() { ServerOpts = s } diff --git a/cmd/scheduler/app/server.go b/cmd/scheduler/app/server.go index a78fc5f05ce..49a41a7c6a3 100644 --- a/cmd/scheduler/app/server.go +++ b/cmd/scheduler/app/server.go @@ -52,7 +52,7 @@ const ( retryPeriod = 5 * time.Second ) -// Run the volcano scheduler +// Run the volcano scheduler. func Run(opt *options.ServerOption) error { if opt.PrintVersion { version.PrintVersionAndExit() diff --git a/cmd/webhook-manager/app/options/options.go b/cmd/webhook-manager/app/options/options.go index 2bc9b2fe9d3..913bef94eb8 100644 --- a/cmd/webhook-manager/app/options/options.go +++ b/cmd/webhook-manager/app/options/options.go @@ -44,13 +44,13 @@ type Config struct { WebhookURL string } -// NewConfig create new config +// NewConfig create new config. func NewConfig() *Config { c := Config{} return &c } -// AddFlags add flags +// AddFlags add flags. func (c *Config) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&c.KubeClientOptions.Master, "master", c.KubeClientOptions.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)") fs.StringVar(&c.KubeClientOptions.KubeConfig, "kubeconfig", c.KubeClientOptions.KubeConfig, "Path to kubeconfig file with authorization and master location information.") @@ -71,7 +71,7 @@ func (c *Config) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&c.SchedulerName, "scheduler-name", defaultSchedulerName, "Volcano will handle pods whose .spec.SchedulerName is same as scheduler-name") } -// CheckPortOrDie check valid port range +// CheckPortOrDie check valid port range. func (c *Config) CheckPortOrDie() error { if c.Port < 1 || c.Port > 65535 { return fmt.Errorf("the port should be in the range of 1 and 65535") diff --git a/cmd/webhook-manager/app/util.go b/cmd/webhook-manager/app/util.go index d391bf1d257..0106c1578b4 100644 --- a/cmd/webhook-manager/app/util.go +++ b/cmd/webhook-manager/app/util.go @@ -90,7 +90,7 @@ func getKubeClient(restConfig *rest.Config) *kubernetes.Clientset { return clientset } -// GetVolcanoClient get a clientset for volcano +// GetVolcanoClient get a clientset for volcano. func getVolcanoClient(restConfig *rest.Config) *versioned.Clientset { clientset, err := versioned.NewForConfig(restConfig) if err != nil { @@ -101,7 +101,7 @@ func getVolcanoClient(restConfig *rest.Config) *versioned.Clientset { // configTLS is a helper function that generate tls certificates from directly defined tls config or kubeconfig // These are passed in as command line for cluster certification. If tls config is passed in, we use the directly -// defined tls config, else use that defined in kubeconfig +// defined tls config, else use that defined in kubeconfig. func configTLS(config *options.Config, restConfig *rest.Config) *tls.Config { if len(config.CertFile) != 0 && len(config.KeyFile) != 0 { sCert, err := tls.LoadX509KeyPair(config.CertFile, config.KeyFile) diff --git a/pkg/apis/batch/v1alpha1/job.go b/pkg/apis/batch/v1alpha1/job.go index e8e95ba990f..29ee2358570 100644 --- a/pkg/apis/batch/v1alpha1/job.go +++ b/pkg/apis/batch/v1alpha1/job.go @@ -25,7 +25,7 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// Job defines the volcano job +// Job defines the volcano job. type Job struct { metav1.TypeMeta `json:",inline"` @@ -42,7 +42,7 @@ type Job struct { Status JobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } -// JobSpec describes how the job execution will look like and when it will actually run +// JobSpec describes how the job execution will look like and when it will actually run. type JobSpec struct { // SchedulerName is the default value of `tasks.template.spec.schedulerName`. // +optional @@ -92,7 +92,7 @@ type JobSpec struct { PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,10,opt,name=priorityClassName"` } -// VolumeSpec defines the specification of Volume, e.g. PVC +// VolumeSpec defines the specification of Volume, e.g. PVC. type VolumeSpec struct { // Path within the container at which the volume should be mounted. Must // not contain ':'. @@ -107,7 +107,7 @@ type VolumeSpec struct { VolumeClaim *v1.PersistentVolumeClaimSpec `json:"volumeClaim,omitempty" protobuf:"bytes,3,opt,name=volumeClaim"` } -// JobEvent job event +// JobEvent job event. type JobEvent string const ( @@ -155,7 +155,7 @@ type LifecyclePolicy struct { Timeout *metav1.Duration `json:"timeout,omitempty" protobuf:"bytes,4,opt,name=timeout"` } -// TaskSpec specifies the task specification of Job +// TaskSpec specifies the task specification of Job. type TaskSpec struct { // Name specifies the name of tasks // +optional @@ -175,7 +175,7 @@ type TaskSpec struct { Policies []LifecyclePolicy `json:"policies,omitempty" protobuf:"bytes,4,opt,name=policies"` } -// JobPhase defines the phase of the job +// JobPhase defines the phase of the job. type JobPhase string const ( @@ -220,7 +220,7 @@ type JobState struct { LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"` } -// JobStatus represents the current status of a Job +// JobStatus represents the current status of a Job. type JobStatus struct { // Current state of Job. // +optional @@ -269,7 +269,7 @@ type JobStatus struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// JobList defines the list of jobs +// JobList defines the list of jobs. type JobList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` diff --git a/pkg/apis/bus/v1alpha1/commands.go b/pkg/apis/bus/v1alpha1/commands.go index d7c15434927..12c73f4d8b4 100644 --- a/pkg/apis/bus/v1alpha1/commands.go +++ b/pkg/apis/bus/v1alpha1/commands.go @@ -7,7 +7,7 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// Command defines command structure +// Command defines command structure. type Command struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` @@ -29,7 +29,7 @@ type Command struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// CommandList defines list of commands +// CommandList defines list of commands. type CommandList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` diff --git a/pkg/apis/helpers/helpers.go b/pkg/apis/helpers/helpers.go index 1825178f1d1..faa62f49f03 100644 --- a/pkg/apis/helpers/helpers.go +++ b/pkg/apis/helpers/helpers.go @@ -41,18 +41,20 @@ import ( schedulerv1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" ) -// JobKind creates job GroupVersionKind +// JobKind creates job GroupVersionKind. var JobKind = vcbatch.SchemeGroupVersion.WithKind("Job") -// CommandKind creates command GroupVersionKind +// CommandKind creates command GroupVersionKind. var CommandKind = vcbus.SchemeGroupVersion.WithKind("Command") -// V1beta1QueueKind is queue kind with v1alpha2 version +// V1beta1QueueKind is queue kind with v1alpha2 version. var V1beta1QueueKind = schedulerv1beta1.SchemeGroupVersion.WithKind("Queue") -// CreateOrUpdateConfigMap : -// 1. creates config map resource if not present -// 2. updates config map is necessary +/* +CreateOrUpdateConfigMap : +1. creates config map resource if not present +2. updates config map is necessary. +*/ func CreateOrUpdateConfigMap(job *vcbatch.Job, kubeClients kubernetes.Interface, data map[string]string, cmName string) error { // If ConfigMap does not exist, create one for Job. cmOld, err := kubeClients.CoreV1().ConfigMaps(job.Namespace).Get(cmName, metav1.GetOptions{}) @@ -97,7 +99,7 @@ func CreateOrUpdateConfigMap(job *vcbatch.Job, kubeClients kubernetes.Interface, return nil } -// CreateSecret create secret +// CreateSecret create secret. func CreateSecret(job *vcbatch.Job, kubeClients kubernetes.Interface, data map[string][]byte, secretName string) error { secret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -118,7 +120,7 @@ func CreateSecret(job *vcbatch.Job, kubeClients kubernetes.Interface, data map[s return err } -// DeleteConfigmap deletes the config map resource +// DeleteConfigmap deletes the config map resource. func DeleteConfigmap(job *vcbatch.Job, kubeClients kubernetes.Interface, cmName string) error { if _, err := kubeClients.CoreV1().ConfigMaps(job.Namespace).Get(cmName, metav1.GetOptions{}); err != nil { if !apierrors.IsNotFound(err) { @@ -141,7 +143,7 @@ func DeleteConfigmap(job *vcbatch.Job, kubeClients kubernetes.Interface, cmName return nil } -// DeleteSecret delete secret +// DeleteSecret delete secret. func DeleteSecret(job *vcbatch.Job, kubeClients kubernetes.Interface, secretName string) error { err := kubeClients.CoreV1().Secrets(job.Namespace).Delete(secretName, nil) if err != nil && true == apierrors.IsNotFound(err) { @@ -151,7 +153,7 @@ func DeleteSecret(job *vcbatch.Job, kubeClients kubernetes.Interface, secretName return err } -// GeneratePodgroupName generate podgroup name of normal pod +// GeneratePodgroupName generate podgroup name of normal pod. func GeneratePodgroupName(pod *v1.Pod) string { pgName := vcbatch.PodgroupNamePrefix @@ -169,7 +171,7 @@ func GeneratePodgroupName(pod *v1.Pod) string { return pgName } -// StartHealthz register healthz interface +// StartHealthz register healthz interface. func StartHealthz(healthzBindAddress, name string) error { listener, err := net.Listen("tcp", healthzBindAddress) if err != nil { diff --git a/pkg/apis/scheduling/scheme/scheme.go b/pkg/apis/scheduling/scheme/scheme.go index 533f6155992..0b037c15446 100644 --- a/pkg/apis/scheduling/scheme/scheme.go +++ b/pkg/apis/scheduling/scheme/scheme.go @@ -35,7 +35,7 @@ func init() { Install(Scheme) } -// Install registers the API group and adds types to a scheme +// Install registers the API group and adds types to a scheme. func Install(scheme *runtime.Scheme) { v1beta1.AddToScheme(scheme) scheduling.AddToScheme(scheme) diff --git a/pkg/apis/scheduling/types.go b/pkg/apis/scheduling/types.go index ec74fe6b7d9..b38f733375e 100644 --- a/pkg/apis/scheduling/types.go +++ b/pkg/apis/scheduling/types.go @@ -24,7 +24,7 @@ import ( // PodGroupPhase is the phase of a pod group at the current time. type PodGroupPhase string -// QueueState is state type of queue +// QueueState is state type of queue. type QueueState string const ( @@ -113,7 +113,7 @@ const ( NotEnoughPodsReason string = "NotEnoughTasks" ) -// QueueEvent represent the phase of queue +// QueueEvent represent the phase of queue. type QueueEvent string const ( diff --git a/pkg/apis/scheduling/v1beta1/types.go b/pkg/apis/scheduling/v1beta1/types.go index 9cb0def4df2..78ff2a09dd4 100644 --- a/pkg/apis/scheduling/v1beta1/types.go +++ b/pkg/apis/scheduling/v1beta1/types.go @@ -24,7 +24,7 @@ import ( // PodGroupPhase is the phase of a pod group at the current time. type PodGroupPhase string -// QueueState is state type of queue +// QueueState is state type of queue. type QueueState string const ( @@ -113,7 +113,7 @@ const ( NotEnoughPodsReason string = "NotEnoughTasks" ) -// QueueEvent represent the phase of queue +// QueueEvent represent the phase of queue. type QueueEvent string const ( diff --git a/pkg/cli/job/delete.go b/pkg/cli/job/delete.go index 99d06d9ab74..f51549c2247 100644 --- a/pkg/cli/job/delete.go +++ b/pkg/cli/job/delete.go @@ -36,7 +36,7 @@ type deleteFlags struct { var deleteJobFlags = &deleteFlags{} -// InitDeleteFlags init the delete command flags +// InitDeleteFlags init the delete command flags. func InitDeleteFlags(cmd *cobra.Command) { initFlags(cmd, &deleteJobFlags.commonFlags) @@ -44,7 +44,7 @@ func InitDeleteFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&deleteJobFlags.JobName, "name", "N", "", "the name of job") } -// DeleteJob delete the job +// DeleteJob delete the job. func DeleteJob() error { config, err := util.BuildConfig(deleteJobFlags.Master, deleteJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/job/list.go b/pkg/cli/job/list.go index d8e2635fc38..a5ce04b0dae 100644 --- a/pkg/cli/job/list.go +++ b/pkg/cli/job/list.go @@ -78,7 +78,7 @@ const ( var listJobFlags = &listFlags{} -// InitListFlags init list command flags +// InitListFlags init list command flags. func InitListFlags(cmd *cobra.Command) { initFlags(cmd, &listJobFlags.commonFlags) @@ -88,7 +88,7 @@ func InitListFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&listJobFlags.selector, "selector", "", "", "fuzzy matching jobName") } -// ListJobs lists all jobs details +// ListJobs lists all jobs details. func ListJobs() error { config, err := util.BuildConfig(listJobFlags.Master, listJobFlags.Kubeconfig) if err != nil { @@ -112,7 +112,7 @@ func ListJobs() error { return nil } -// PrintJobs prints all jobs details +// PrintJobs prints all jobs details. func PrintJobs(jobs *v1alpha1.JobList, writer io.Writer) { maxLenInfo := getMaxLen(jobs) diff --git a/pkg/cli/job/resume.go b/pkg/cli/job/resume.go index 3230dc8c709..9fb8c6fba8c 100644 --- a/pkg/cli/job/resume.go +++ b/pkg/cli/job/resume.go @@ -34,7 +34,7 @@ type resumeFlags struct { var resumeJobFlags = &resumeFlags{} -// InitResumeFlags init resume command flags +// InitResumeFlags init resume command flags. func InitResumeFlags(cmd *cobra.Command) { initFlags(cmd, &resumeJobFlags.commonFlags) @@ -42,7 +42,7 @@ func InitResumeFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&resumeJobFlags.JobName, "name", "N", "", "the name of job") } -// ResumeJob resumes the job +// ResumeJob resumes the job. func ResumeJob() error { config, err := util.BuildConfig(resumeJobFlags.Master, resumeJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/job/run.go b/pkg/cli/job/run.go index b579844fffe..c0cfbce9b1e 100644 --- a/pkg/cli/job/run.go +++ b/pkg/cli/job/run.go @@ -49,7 +49,7 @@ type runFlags struct { var launchJobFlags = &runFlags{} -// InitRunFlags init the run flags +// InitRunFlags init the run flags. func InitRunFlags(cmd *cobra.Command) { initFlags(cmd, &launchJobFlags.commonFlags) @@ -66,7 +66,7 @@ func InitRunFlags(cmd *cobra.Command) { var jobName = "job.volcano.sh" -// RunJob creates the job +// RunJob creates the job. func RunJob() error { config, err := util.BuildConfig(launchJobFlags.Master, launchJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/job/suspend.go b/pkg/cli/job/suspend.go index aa6e76d4b91..8dc7c90987b 100644 --- a/pkg/cli/job/suspend.go +++ b/pkg/cli/job/suspend.go @@ -34,7 +34,7 @@ type suspendFlags struct { var suspendJobFlags = &suspendFlags{} -// InitSuspendFlags init suspend related flags +// InitSuspendFlags init suspend related flags. func InitSuspendFlags(cmd *cobra.Command) { initFlags(cmd, &suspendJobFlags.commonFlags) @@ -42,7 +42,7 @@ func InitSuspendFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&suspendJobFlags.JobName, "name", "N", "", "the name of job") } -// SuspendJob suspends the job +// SuspendJob suspends the job. func SuspendJob() error { config, err := util.BuildConfig(suspendJobFlags.Master, suspendJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/job/util.go b/pkg/cli/job/util.go index 345b999c746..202bbdaf4f7 100644 --- a/pkg/cli/job/util.go +++ b/pkg/cli/job/util.go @@ -100,7 +100,7 @@ func translateTimestampSince(timestamp metav1.Time) string { return HumanDuration(time.Since(timestamp.Time)) } -// HumanDuration translate time.Duration to human readable time string +// HumanDuration translate time.Duration to human readable time string. func HumanDuration(d time.Duration) string { // Allow deviation no more than 2 seconds(excluded) to tolerate machine time // inconsistence, it can be considered as almost now. diff --git a/pkg/cli/job/view.go b/pkg/cli/job/view.go index 362ce1fe5bb..de86bb8eb34 100644 --- a/pkg/cli/job/view.go +++ b/pkg/cli/job/view.go @@ -42,7 +42,7 @@ type viewFlags struct { JobName string } -// level of print indent +// level of print indent. const ( Level0 = iota Level1 @@ -51,7 +51,7 @@ const ( var viewJobFlags = &viewFlags{} -// InitViewFlags init the view command flags +// InitViewFlags init the view command flags. func InitViewFlags(cmd *cobra.Command) { initFlags(cmd, &viewJobFlags.commonFlags) @@ -59,7 +59,7 @@ func InitViewFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&viewJobFlags.JobName, "name", "N", "", "the name of job") } -// ViewJob gives full details of the job +// ViewJob gives full details of the job. func ViewJob() error { config, err := util.BuildConfig(viewJobFlags.Master, viewJobFlags.Kubeconfig) if err != nil { @@ -84,7 +84,7 @@ func ViewJob() error { return nil } -// PrintJobInfo print the job detailed info into writer +// PrintJobInfo print the job detailed info into writer. func PrintJobInfo(job *v1alpha1.Job, writer io.Writer) { WriteLine(writer, Level0, "Name: \t%s\n", job.Name) WriteLine(writer, Level0, "Namespace: \t%s\n", job.Namespace) @@ -198,7 +198,7 @@ func PrintJobInfo(job *v1alpha1.Job, writer io.Writer) { } } -// PrintEvents print event info to writer +// PrintEvents print event info to writer. func PrintEvents(events []coreV1.Event, writer io.Writer) { if len(events) > 0 { WriteLine(writer, Level0, "%s:\n%-15s\t%-40s\t%-30s\t%-40s\t%s\n", "Events", "Type", "Reason", "Age", "Form", "Message") @@ -228,7 +228,7 @@ func PrintEvents(events []coreV1.Event, writer io.Writer) { } -// GetEvents get the job event by config +// GetEvents get the job event by config. func GetEvents(config *rest.Config, job *v1alpha1.Job) []coreV1.Event { kubernetes, err := kubernetes.NewForConfig(config) if err != nil { @@ -245,7 +245,7 @@ func GetEvents(config *rest.Config, job *v1alpha1.Job) []coreV1.Event { return jobEvents } -// WriteLine write lines with specified indent +// WriteLine write lines with specified indent. func WriteLine(writer io.Writer, spaces int, content string, params ...interface{}) { prefix := "" for i := 0; i < spaces; i++ { diff --git a/pkg/cli/queue/create.go b/pkg/cli/queue/create.go index 2ff74a17c39..c2babd2248e 100644 --- a/pkg/cli/queue/create.go +++ b/pkg/cli/queue/create.go @@ -36,7 +36,7 @@ type createFlags struct { var createQueueFlags = &createFlags{} -// InitCreateFlags is used to init all flags during queue creating +// InitCreateFlags is used to init all flags during queue creating. func InitCreateFlags(cmd *cobra.Command) { initFlags(cmd, &createQueueFlags.commonFlags) @@ -46,7 +46,7 @@ func InitCreateFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&createQueueFlags.State, "state", "S", "Open", "the state of queue") } -// CreateQueue create queue +// CreateQueue create queue. func CreateQueue() error { config, err := buildConfig(createQueueFlags.Master, createQueueFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/queue/delete.go b/pkg/cli/queue/delete.go index 7c7a52cb193..36af775162f 100644 --- a/pkg/cli/queue/delete.go +++ b/pkg/cli/queue/delete.go @@ -35,14 +35,14 @@ type deleteFlags struct { var deleteQueueFlags = &deleteFlags{} -// InitDeleteFlags is used to init all flags during queue deleting +// InitDeleteFlags is used to init all flags during queue deleting. func InitDeleteFlags(cmd *cobra.Command) { initFlags(cmd, &deleteQueueFlags.commonFlags) cmd.Flags().StringVarP(&deleteQueueFlags.Name, "name", "n", "", "the name of queue") } -// DeleteQueue delete queue +// DeleteQueue delete queue. func DeleteQueue() error { config, err := buildConfig(deleteQueueFlags.Master, deleteQueueFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/queue/get.go b/pkg/cli/queue/get.go index 011b3df04f9..486c1d5c302 100644 --- a/pkg/cli/queue/get.go +++ b/pkg/cli/queue/get.go @@ -37,7 +37,7 @@ type getFlags struct { var getQueueFlags = &getFlags{} -// InitGetFlags is used to init all flags +// InitGetFlags is used to init all flags. func InitGetFlags(cmd *cobra.Command) { initFlags(cmd, &getQueueFlags.commonFlags) @@ -45,7 +45,7 @@ func InitGetFlags(cmd *cobra.Command) { } -// GetQueue gets a queue +// GetQueue gets a queue. func GetQueue() error { config, err := buildConfig(getQueueFlags.Master, getQueueFlags.Kubeconfig) if err != nil { @@ -68,7 +68,7 @@ func GetQueue() error { return nil } -// PrintQueue prints queue information +// PrintQueue prints queue information. func PrintQueue(queue *v1beta1.Queue, writer io.Writer) { _, err := fmt.Fprintf(writer, "%-25s%-8s%-8s%-8s%-8s%-8s%-8s\n", Name, Weight, State, Inqueue, Pending, Running, Unknown) diff --git a/pkg/cli/queue/list.go b/pkg/cli/queue/list.go index 8807cad00a9..a212d651639 100644 --- a/pkg/cli/queue/list.go +++ b/pkg/cli/queue/list.go @@ -58,12 +58,12 @@ const ( var listQueueFlags = &listFlags{} -// InitListFlags inits all flags +// InitListFlags inits all flags. func InitListFlags(cmd *cobra.Command) { initFlags(cmd, &listQueueFlags.commonFlags) } -// ListQueue lists all the queue +// ListQueue lists all the queue. func ListQueue() error { config, err := buildConfig(listQueueFlags.Master, listQueueFlags.Kubeconfig) if err != nil { @@ -85,7 +85,7 @@ func ListQueue() error { return nil } -// PrintQueues prints queue information +// PrintQueues prints queue information. func PrintQueues(queues *v1beta1.QueueList, writer io.Writer) { _, err := fmt.Fprintf(writer, "%-25s%-8s%-8s%-8s%-8s%-8s%-8s\n", Name, Weight, State, Inqueue, Pending, Running, Unknown) diff --git a/pkg/cli/util/util.go b/pkg/cli/util/util.go index 8eda8bb2803..15ae87467a8 100644 --- a/pkg/cli/util/util.go +++ b/pkg/cli/util/util.go @@ -36,13 +36,13 @@ import ( "volcano.sh/volcano/pkg/client/clientset/versioned" ) -// CommonFlags are the flags that most command lines have +// CommonFlags are the flags that most command lines have. type CommonFlags struct { Master string Kubeconfig string } -// InitFlags initializes the common flags for most command lines +// InitFlags initializes the common flags for most command lines. func InitFlags(cmd *cobra.Command, cf *CommonFlags) { cmd.Flags().StringVarP(&cf.Master, "master", "s", "", "the address of apiserver") @@ -55,7 +55,7 @@ func InitFlags(cmd *cobra.Command, cf *CommonFlags) { cmd.Flags().StringVarP(&cf.Kubeconfig, "kubeconfig", "k", kubeConfFile, "(optional) absolute path to the kubeconfig file") } -// HomeDir gets the env $HOME +// HomeDir gets the env $HOME. func HomeDir() string { if h := os.Getenv("HOME"); h != "" { return h @@ -63,7 +63,7 @@ func HomeDir() string { return os.Getenv("USERPROFILE") // windows } -// BuildConfig builds the configure file for command lines +// BuildConfig builds the configure file for command lines. func BuildConfig(master, kubeconfig string) (*rest.Config, error) { return clientcmd.BuildConfigFromFlags(master, kubeconfig) } @@ -92,7 +92,7 @@ func PopulateResourceListV1(spec string) (v1.ResourceList, error) { return result, nil } -// CreateJobCommand executes a command such as resume/suspend +// CreateJobCommand executes a command such as resume/suspend. func CreateJobCommand(config *rest.Config, ns, name string, action vcbus.Action) error { jobClient := versioned.NewForConfigOrDie(config) job, err := jobClient.BatchV1alpha1().Jobs(ns).Get(name, metav1.GetOptions{}) @@ -121,7 +121,7 @@ func CreateJobCommand(config *rest.Config, ns, name string, action vcbus.Action) return nil } -// TranslateTimestampSince translates the time stamp +// TranslateTimestampSince translates the time stamp. func TranslateTimestampSince(timestamp metav1.Time) string { if timestamp.IsZero() { return "" @@ -129,7 +129,7 @@ func TranslateTimestampSince(timestamp metav1.Time) string { return HumanDuration(time.Since(timestamp.Time)) } -// HumanDuration translate time.Duration to human readable time string +// HumanDuration translate time.Duration to human readable time string. func HumanDuration(d time.Duration) string { // Allow deviation no more than 2 seconds(excluded) to tolerate machine time // inconsistence, it can be considered as almost now. diff --git a/pkg/cli/vcancel/cancel.go b/pkg/cli/vcancel/cancel.go index 1bebad6c069..bddeadd6da6 100644 --- a/pkg/cli/vcancel/cancel.go +++ b/pkg/cli/vcancel/cancel.go @@ -36,7 +36,7 @@ type cancelFlags struct { var cancelJobFlags = &cancelFlags{} -// InitCancelFlags init the cancel command flags +// InitCancelFlags init the cancel command flags. func InitCancelFlags(cmd *cobra.Command) { util.InitFlags(cmd, &cancelJobFlags.CommonFlags) @@ -44,7 +44,7 @@ func InitCancelFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&cancelJobFlags.JobName, "name", "n", "", "the name of job") } -// CancelJob cancel the job +// CancelJob cancel the job. func CancelJob() error { config, err := util.BuildConfig(cancelJobFlags.Master, cancelJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/vjobs/view.go b/pkg/cli/vjobs/view.go index 4085386dd26..acfc5069eb9 100644 --- a/pkg/cli/vjobs/view.go +++ b/pkg/cli/vjobs/view.go @@ -89,7 +89,7 @@ const ( var viewJobFlags = &viewFlags{} -// InitViewFlags init the view command flags +// InitViewFlags init the view command flags. func InitViewFlags(cmd *cobra.Command) { util.InitFlags(cmd, &viewJobFlags.CommonFlags) @@ -100,7 +100,7 @@ func InitViewFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&viewJobFlags.selector, "selector", "", "", "fuzzy matching jobName") } -// ViewJob gives full details of the job +// ViewJob gives full details of the job. func ViewJob() error { config, err := util.BuildConfig(viewJobFlags.Master, viewJobFlags.Kubeconfig) if err != nil { @@ -125,7 +125,7 @@ func ViewJob() error { return nil } -// PrintJobInfo print the job detailed info into writer +// PrintJobInfo print the job detailed info into writer. func PrintJobInfo(job *v1alpha1.Job, writer io.Writer) { WriteLine(writer, Level0, "Name: \t%s\n", job.Name) WriteLine(writer, Level0, "Namespace: \t%s\n", job.Namespace) @@ -239,7 +239,7 @@ func PrintJobInfo(job *v1alpha1.Job, writer io.Writer) { } } -// PrintEvents print event info to writer +// PrintEvents print event info to writer. func PrintEvents(events []coreV1.Event, writer io.Writer) { if len(events) > 0 { WriteLine(writer, Level0, "%s:\n%-15s\t%-40s\t%-30s\t%-40s\t%s\n", "Events", "Type", "Reason", "Age", "Form", "Message") @@ -269,7 +269,7 @@ func PrintEvents(events []coreV1.Event, writer io.Writer) { } -// GetEvents get the job event by config +// GetEvents get the job event by config. func GetEvents(config *rest.Config, job *v1alpha1.Job) []coreV1.Event { kubernetes, err := kubernetes.NewForConfig(config) if err != nil { @@ -286,7 +286,7 @@ func GetEvents(config *rest.Config, job *v1alpha1.Job) []coreV1.Event { return jobEvents } -// WriteLine write lines with specified indent +// WriteLine write lines with specified indent. func WriteLine(writer io.Writer, spaces int, content string, params ...interface{}) { prefix := "" for i := 0; i < spaces; i++ { @@ -295,7 +295,7 @@ func WriteLine(writer io.Writer, spaces int, content string, params ...interface fmt.Fprintf(writer, prefix+content, params...) } -// ListJobs lists all jobs details +// ListJobs lists all jobs details. func ListJobs() error { config, err := util.BuildConfig(viewJobFlags.Master, viewJobFlags.Kubeconfig) if err != nil { @@ -319,7 +319,7 @@ func ListJobs() error { return nil } -// PrintJobs prints all jobs details +// PrintJobs prints all jobs details. func PrintJobs(jobs *v1alpha1.JobList, writer io.Writer) { maxLenInfo := getMaxLen(jobs) diff --git a/pkg/cli/vqueues/get.go b/pkg/cli/vqueues/get.go index 2f9cc0b12e9..ef137b7e3a7 100644 --- a/pkg/cli/vqueues/get.go +++ b/pkg/cli/vqueues/get.go @@ -61,7 +61,7 @@ const ( var getQueueFlags = &getFlags{} -// InitGetFlags is used to init all flags +// InitGetFlags is used to init all flags. func InitGetFlags(cmd *cobra.Command) { util.InitFlags(cmd, &getQueueFlags.CommonFlags) @@ -69,7 +69,7 @@ func InitGetFlags(cmd *cobra.Command) { } -// ListQueue lists all the queue +// ListQueue lists all the queue. func ListQueue() error { config, err := util.BuildConfig(getQueueFlags.Master, getQueueFlags.Kubeconfig) if err != nil { @@ -91,7 +91,7 @@ func ListQueue() error { return nil } -// PrintQueues prints queue information +// PrintQueues prints queue information. func PrintQueues(queues *v1beta1.QueueList, writer io.Writer) { _, err := fmt.Fprintf(writer, "%-25s%-8s%-8s%-8s%-8s%-8s%-8s\n", Name, Weight, State, Inqueue, Pending, Running, Unknown) @@ -109,7 +109,7 @@ func PrintQueues(queues *v1beta1.QueueList, writer io.Writer) { } -// GetQueue gets a queue +// GetQueue gets a queue. func GetQueue() error { config, err := util.BuildConfig(getQueueFlags.Master, getQueueFlags.Kubeconfig) if err != nil { @@ -132,7 +132,7 @@ func GetQueue() error { return nil } -// PrintQueue prints queue information +// PrintQueue prints queue information. func PrintQueue(queue *v1beta1.Queue, writer io.Writer) { _, err := fmt.Fprintf(writer, "%-25s%-8s%-8s%-8s%-8s%-8s%-8s\n", Name, Weight, State, Inqueue, Pending, Running, Unknown) diff --git a/pkg/cli/vresume/resume.go b/pkg/cli/vresume/resume.go index abe0a1b0b64..723fca555d6 100644 --- a/pkg/cli/vresume/resume.go +++ b/pkg/cli/vresume/resume.go @@ -34,7 +34,7 @@ type resumeFlags struct { var resumeJobFlags = &resumeFlags{} -// InitResumeFlags init resume command flags +// InitResumeFlags init resume command flags. func InitResumeFlags(cmd *cobra.Command) { util.InitFlags(cmd, &resumeJobFlags.CommonFlags) @@ -42,7 +42,7 @@ func InitResumeFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&resumeJobFlags.JobName, "name", "n", "", "the name of job") } -// ResumeJob resumes the job +// ResumeJob resumes the job. func ResumeJob() error { config, err := util.BuildConfig(resumeJobFlags.Master, resumeJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/vsub/run.go b/pkg/cli/vsub/run.go index 8314b896c86..3e73fc1c150 100644 --- a/pkg/cli/vsub/run.go +++ b/pkg/cli/vsub/run.go @@ -64,7 +64,7 @@ const ( defaultJobNamespace = "default" ) -// InitRunFlags init the run flags +// InitRunFlags init the run flags. func InitRunFlags(cmd *cobra.Command) { util.InitFlags(cmd, &launchJobFlags.CommonFlags) @@ -121,7 +121,7 @@ func setDefaultArgs() { var jobName = "job.volcano.sh" -// RunJob creates the job +// RunJob creates the job. func RunJob() error { config, err := util.BuildConfig(launchJobFlags.Master, launchJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/cli/vsuspend/suspend.go b/pkg/cli/vsuspend/suspend.go index 1779cfa648e..2fdd43af421 100644 --- a/pkg/cli/vsuspend/suspend.go +++ b/pkg/cli/vsuspend/suspend.go @@ -34,7 +34,7 @@ type suspendFlags struct { var suspendJobFlags = &suspendFlags{} -// InitSuspendFlags init suspend related flags +// InitSuspendFlags init suspend related flags. func InitSuspendFlags(cmd *cobra.Command) { util.InitFlags(cmd, &suspendJobFlags.CommonFlags) @@ -42,7 +42,7 @@ func InitSuspendFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&suspendJobFlags.JobName, "name", "n", "", "the name of job") } -// SuspendJob suspends the job +// SuspendJob suspends the job. func SuspendJob() error { config, err := util.BuildConfig(suspendJobFlags.Master, suspendJobFlags.Kubeconfig) if err != nil { diff --git a/pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go b/pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go index 52fdd0793f7..a0618498532 100644 --- a/pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go +++ b/pkg/client/clientset/versioned/typed/bus/v1alpha1/command.go @@ -48,13 +48,13 @@ type CommandInterface interface { CommandExpansion } -// commands implements CommandInterface +// commands implements CommandInterface. type commands struct { client rest.Interface ns string } -// newCommands returns a Commands +// newCommands returns a Commands. func newCommands(c *BusV1alpha1Client, namespace string) *commands { return &commands{ client: c.RESTClient(), diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go index 9e76ae288ea..ea9a407ff70 100644 --- a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -30,7 +30,7 @@ import ( // NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle. type SharedInformerFactory interface { Start(stopCh <-chan struct{}) InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer diff --git a/pkg/controllers/apis/job_info.go b/pkg/controllers/apis/job_info.go index 88f41223af3..f68cab47a8a 100644 --- a/pkg/controllers/apis/job_info.go +++ b/pkg/controllers/apis/job_info.go @@ -24,7 +24,7 @@ import ( batch "volcano.sh/volcano/pkg/apis/batch/v1alpha1" ) -//JobInfo struct +//JobInfo struct. type JobInfo struct { Namespace string Name string @@ -33,7 +33,7 @@ type JobInfo struct { Pods map[string]map[string]*v1.Pod } -//Clone function clones the k8s pod values to the JobInfo struct +//Clone function clones the k8s pod values to the JobInfo struct. func (ji *JobInfo) Clone() *JobInfo { job := &JobInfo{ Namespace: ji.Namespace, @@ -53,7 +53,7 @@ func (ji *JobInfo) Clone() *JobInfo { return job } -//SetJob sets the volcano jobs values to the JobInfo struct +//SetJob sets the volcano jobs values to the JobInfo struct. func (ji *JobInfo) SetJob(job *batch.Job) { ji.Name = job.Name ji.Namespace = job.Namespace @@ -61,7 +61,7 @@ func (ji *JobInfo) SetJob(job *batch.Job) { } //AddPod adds the k8s pod object values to the Pods field -//of JobStruct if it doesn't exist. Otherwise it throws error +//of JobStruct if it doesn't exist. Otherwise it throws error. func (ji *JobInfo) AddPod(pod *v1.Pod) error { taskName, found := pod.Annotations[batch.TaskSpecKey] if !found { @@ -86,7 +86,7 @@ func (ji *JobInfo) AddPod(pod *v1.Pod) error { return nil } -//UpdatePod updates the k8s pod object values to the existing pod +//UpdatePod updates the k8s pod object values to the existing pod. func (ji *JobInfo) UpdatePod(pod *v1.Pod) error { taskName, found := pod.Annotations[batch.TaskSpecKey] if !found { @@ -111,7 +111,7 @@ func (ji *JobInfo) UpdatePod(pod *v1.Pod) error { return nil } -//DeletePod deletes the given k8s pod from the JobInfo struct +//DeletePod deletes the given k8s pod from the JobInfo struct. func (ji *JobInfo) DeletePod(pod *v1.Pod) error { taskName, found := pod.Annotations[batch.TaskSpecKey] if !found { diff --git a/pkg/controllers/apis/request.go b/pkg/controllers/apis/request.go index 7e741d77215..6254b21918e 100644 --- a/pkg/controllers/apis/request.go +++ b/pkg/controllers/apis/request.go @@ -21,7 +21,7 @@ import ( "volcano.sh/volcano/pkg/apis/bus/v1alpha1" ) -//Request struct +//Request struct. type Request struct { Namespace string JobName string @@ -34,7 +34,7 @@ type Request struct { JobVersion int32 } -//String function returns the request in string format +// String function returns the request in string format. func (r Request) String() string { return fmt.Sprintf( "Queue: %s, Job: %s/%s, Task:%s, Event:%s, ExitCode:%d, Action:%s, JobVersion: %d", diff --git a/pkg/controllers/cache/cache.go b/pkg/controllers/cache/cache.go index c2d45eaa760..4d56ff3b8cf 100644 --- a/pkg/controllers/cache/cache.go +++ b/pkg/controllers/cache/cache.go @@ -43,17 +43,17 @@ func keyFn(ns, name string) string { return fmt.Sprintf("%s/%s", ns, name) } -//JobKeyByName gets the key for the job name +//JobKeyByName gets the key for the job name. func JobKeyByName(namespace string, name string) string { return keyFn(namespace, name) } -//JobKeyByReq gets the key for the job request +//JobKeyByReq gets the key for the job request. func JobKeyByReq(req *apis.Request) string { return keyFn(req.Namespace, req.JobName) } -//JobKey gets the "ns"/"name" format of the given job +//JobKey gets the "ns"/"name" format of the given job. func JobKey(job *v1alpha1.Job) string { return keyFn(job.Namespace, job.Name) } @@ -72,7 +72,7 @@ func jobKeyOfPod(pod *v1.Pod) (string, error) { return keyFn(pod.Namespace, jobName), nil } -//New gets the job Cache +// New gets the job Cache. func New() Cache { queue := workqueue.NewMaxOfRateLimiter( workqueue.NewItemExponentialFailureRateLimiter(5*time.Millisecond, 180*time.Second), diff --git a/pkg/controllers/cache/interface.go b/pkg/controllers/cache/interface.go index 6730ef6177b..60c83453a46 100644 --- a/pkg/controllers/cache/interface.go +++ b/pkg/controllers/cache/interface.go @@ -23,7 +23,7 @@ import ( "volcano.sh/volcano/pkg/controllers/apis" ) -// Cache Interface +// Cache Interface. type Cache interface { Run(stopCh <-chan struct{}) diff --git a/pkg/controllers/garbagecollector/garbagecollector.go b/pkg/controllers/garbagecollector/garbagecollector.go index 187c978ff50..06ce9bdd134 100644 --- a/pkg/controllers/garbagecollector/garbagecollector.go +++ b/pkg/controllers/garbagecollector/garbagecollector.go @@ -56,7 +56,7 @@ type GarbageCollector struct { queue workqueue.RateLimitingInterface } -// NewGarbageCollector creates an instance of GarbageCollector +// NewGarbageCollector creates an instance of GarbageCollector. func NewGarbageCollector(vkClient vcclientset.Interface) *GarbageCollector { jobInformer := informerfactory.NewSharedInformerFactory(vkClient, 0).Batch().V1alpha1().Jobs() diff --git a/pkg/controllers/job/constant.go b/pkg/controllers/job/constant.go index a674d139eb0..2c9fe5e07fa 100644 --- a/pkg/controllers/job/constant.go +++ b/pkg/controllers/job/constant.go @@ -16,7 +16,7 @@ limitations under the License. package job -// Reasons for pod events +// Reasons for pod events. const ( // FailedCreatePodReason is added in an event and in a replica set condition // when a pod for a replica set is failed to be created. diff --git a/pkg/controllers/job/helpers/helpers.go b/pkg/controllers/job/helpers/helpers.go index 207c164c45c..ec9b72c6d9e 100644 --- a/pkg/controllers/job/helpers/helpers.go +++ b/pkg/controllers/job/helpers/helpers.go @@ -34,7 +34,7 @@ const ( persistentVolumeClaimFmt = "%s-pvc-%s" ) -// GetTaskIndex returns task Index +// GetTaskIndex returns task Index. func GetTaskIndex(pod *v1.Pod) string { num := strings.Split(pod.Name, "-") if len(num) >= 3 { @@ -44,12 +44,12 @@ func GetTaskIndex(pod *v1.Pod) string { return "" } -// MakePodName creates pod name +// MakePodName creates pod name. func MakePodName(jobName string, taskName string, index int) string { return fmt.Sprintf(PodNameFmt, jobName, taskName, index) } -// GenRandomStr generate random str with specified length l +// GenRandomStr generate random str with specified length l. func GenRandomStr(l int) string { str := "0123456789abcdefghijklmnopqrstuvwxyz" bytes := []byte(str) @@ -61,12 +61,12 @@ func GenRandomStr(l int) string { return string(result) } -// GenPVCName generates pvc name with job name +// GenPVCName generates pvc name with job name. func GenPVCName(jobName string) string { return fmt.Sprintf(persistentVolumeClaimFmt, jobName, GenRandomStr(12)) } -// GetJobKeyByReq gets the key for the job request +// GetJobKeyByReq gets the key for the job request. func GetJobKeyByReq(req *apis.Request) string { return fmt.Sprintf("%s/%s", req.Namespace, req.JobName) } diff --git a/pkg/controllers/job/job_controller.go b/pkg/controllers/job/job_controller.go index 446b978e6a0..2f307e26c3a 100644 --- a/pkg/controllers/job/job_controller.go +++ b/pkg/controllers/job/job_controller.go @@ -63,7 +63,7 @@ const ( maxRetries = 15 ) -// Controller the Job Controller type +// Controller the Job Controller type. type Controller struct { kubeClient kubernetes.Interface vcClient vcclientset.Interface @@ -114,7 +114,7 @@ type Controller struct { workers uint32 } -// NewJobController create new Job Controller +// NewJobController create new Job Controller. func NewJobController( kubeClient kubernetes.Interface, vcClient vcclientset.Interface, @@ -219,7 +219,7 @@ func NewJobController( return cc } -// Run start JobController +// Run start JobController. func (cc *Controller) Run(stopCh <-chan struct{}) { go cc.jobInformer.Informer().Run(stopCh) diff --git a/pkg/controllers/job/job_controller_util.go b/pkg/controllers/job/job_controller_util.go index 115f61a43bb..c33294d462b 100644 --- a/pkg/controllers/job/job_controller_util.go +++ b/pkg/controllers/job/job_controller_util.go @@ -32,7 +32,7 @@ import ( jobhelpers "volcano.sh/volcano/pkg/controllers/job/helpers" ) -//MakePodName append podname,jobname,taskName and index and returns the string +// MakePodName append podname,jobname,taskName and index and returns the string. func MakePodName(jobName string, taskName string, index int) string { return fmt.Sprintf(jobhelpers.PodNameFmt, jobName, taskName, index) } @@ -203,14 +203,14 @@ func addResourceList(list, req, limit v1.ResourceList) { } } -//TaskPriority structure +// TaskPriority structure. type TaskPriority struct { priority int32 batch.TaskSpec } -//TasksPriority is a slice of TaskPriority +// TasksPriority is a slice of TaskPriority. type TasksPriority []TaskPriority func (p TasksPriority) Len() int { return len(p) } diff --git a/pkg/controllers/job/plugins/env/env.go b/pkg/controllers/job/plugins/env/env.go index ec4746691e5..16d967a1469 100644 --- a/pkg/controllers/job/plugins/env/env.go +++ b/pkg/controllers/job/plugins/env/env.go @@ -31,7 +31,7 @@ type envPlugin struct { Clientset pluginsinterface.PluginClientset } -// New creates env plugin +// New creates env plugin. func New(client pluginsinterface.PluginClientset, arguments []string) pluginsinterface.PluginInterface { envPlugin := envPlugin{pluginArguments: arguments, Clientset: client} diff --git a/pkg/controllers/job/plugins/factory.go b/pkg/controllers/job/plugins/factory.go index 80307dab225..b8425c45fdf 100644 --- a/pkg/controllers/job/plugins/factory.go +++ b/pkg/controllers/job/plugins/factory.go @@ -33,13 +33,13 @@ func init() { var pluginMutex sync.Mutex -// Plugin management +// Plugin management. var pluginBuilders = map[string]PluginBuilder{} -// PluginBuilder func prototype +// PluginBuilder func prototype. type PluginBuilder func(pluginsinterface.PluginClientset, []string) pluginsinterface.PluginInterface -// RegisterPluginBuilder register plugin builders +// RegisterPluginBuilder register plugin builders. func RegisterPluginBuilder(name string, pc PluginBuilder) { pluginMutex.Lock() defer pluginMutex.Unlock() @@ -47,7 +47,7 @@ func RegisterPluginBuilder(name string, pc PluginBuilder) { pluginBuilders[name] = pc } -// GetPluginBuilder returns plugin builder for a given plugin name +// GetPluginBuilder returns plugin builder for a given plugin name. func GetPluginBuilder(name string) (PluginBuilder, bool) { pluginMutex.Lock() defer pluginMutex.Unlock() diff --git a/pkg/controllers/job/plugins/interface/interface.go b/pkg/controllers/job/plugins/interface/interface.go index 71a4fcf770e..822ad981009 100644 --- a/pkg/controllers/job/plugins/interface/interface.go +++ b/pkg/controllers/job/plugins/interface/interface.go @@ -23,12 +23,12 @@ import ( vcbatch "volcano.sh/volcano/pkg/apis/batch/v1alpha1" ) -// PluginClientset clientset +// PluginClientset clientset. type PluginClientset struct { KubeClients kubernetes.Interface } -// PluginInterface interface +// PluginInterface interface. type PluginInterface interface { // The unique name of Plugin. Name() string diff --git a/pkg/controllers/job/plugins/svc/svc.go b/pkg/controllers/job/plugins/svc/svc.go index 4d01a04c910..424304f4de4 100644 --- a/pkg/controllers/job/plugins/svc/svc.go +++ b/pkg/controllers/job/plugins/svc/svc.go @@ -47,7 +47,7 @@ type servicePlugin struct { disableNetworkPolicy bool } -// New creates service plugin +// New creates service plugin. func New(client pluginsinterface.PluginClientset, arguments []string) pluginsinterface.PluginInterface { servicePlugin := servicePlugin{pluginArguments: arguments, Clientset: client} @@ -303,7 +303,7 @@ func (sp *servicePlugin) cmName(job *batch.Job) string { return fmt.Sprintf("%s-%s", job.Name, sp.Name()) } -// GenerateHosts generates hostnames per task +// GenerateHosts generates hostnames per task. func GenerateHosts(job *batch.Job) map[string]string { hostFile := make(map[string]string, len(job.Spec.Tasks)) diff --git a/pkg/controllers/job/state/factory.go b/pkg/controllers/job/state/factory.go index c5b5e4ef596..420817ae4cc 100644 --- a/pkg/controllers/job/state/factory.go +++ b/pkg/controllers/job/state/factory.go @@ -36,10 +36,10 @@ type ActionFn func(job *apis.JobInfo, fn UpdateStatusFn) error //KillActionFn kill all Pods of Job with phase not in podRetainPhase. type KillActionFn func(job *apis.JobInfo, podRetainPhase PhaseMap, fn UpdateStatusFn) error -//PodRetainPhaseNone stores no phase +//PodRetainPhaseNone stores no phase. var PodRetainPhaseNone = PhaseMap{} -// PodRetainPhaseSoft stores PodSucceeded and PodFailed Phase +// PodRetainPhaseSoft stores PodSucceeded and PodFailed Phase. var PodRetainPhaseSoft = PhaseMap{ v1.PodSucceeded: {}, v1.PodFailed: {}, @@ -52,13 +52,13 @@ var ( KillJob KillActionFn ) -//State interface +//State interface. type State interface { // Execute executes the actions based on current state. Execute(act v1alpha1.Action) error } -// NewState gets the state from the volcano job Phase +// NewState gets the state from the volcano job Phase. func NewState(jobInfo *apis.JobInfo) State { job := jobInfo.Job switch job.Status.State.Phase { diff --git a/pkg/controllers/job/state/util.go b/pkg/controllers/job/state/util.go index c37d7500823..0845d0c98b3 100644 --- a/pkg/controllers/job/state/util.go +++ b/pkg/controllers/job/state/util.go @@ -23,7 +23,7 @@ import ( // DefaultMaxRetry is the default number of retries. const DefaultMaxRetry int32 = 3 -// TotalTasks returns number of tasks in a given volcano job +// TotalTasks returns number of tasks in a given volcano job. func TotalTasks(job *vcbatch.Job) int32 { var rep int32 diff --git a/pkg/controllers/podgroup/pg_controller.go b/pkg/controllers/podgroup/pg_controller.go index 501cf976d63..50dcb3d99c7 100644 --- a/pkg/controllers/podgroup/pg_controller.go +++ b/pkg/controllers/podgroup/pg_controller.go @@ -34,7 +34,7 @@ import ( schedulinglister "volcano.sh/volcano/pkg/client/listers/scheduling/v1beta1" ) -// Controller the Podgroup Controller type +// Controller the Podgroup Controller type. type Controller struct { kubeClient kubernetes.Interface vcClient vcclientset.Interface @@ -53,7 +53,7 @@ type Controller struct { queue workqueue.RateLimitingInterface } -// NewPodgroupController create new Podgroup Controller +// NewPodgroupController create new Podgroup Controller. func NewPodgroupController( kubeClient kubernetes.Interface, vcClient vcclientset.Interface, @@ -97,7 +97,7 @@ func NewPodgroupController( return cc } -// Run start NewPodgroupController +// Run start NewPodgroupController. func (cc *Controller) Run(stopCh <-chan struct{}) { go cc.podInformer.Informer().Run(stopCh) go cc.pgInformer.Informer().Run(stopCh) diff --git a/pkg/controllers/queue/queue_controller.go b/pkg/controllers/queue/queue_controller.go index 369d15c011e..0504ce55dc3 100644 --- a/pkg/controllers/queue/queue_controller.go +++ b/pkg/controllers/queue/queue_controller.go @@ -89,7 +89,7 @@ type Controller struct { recorder record.EventRecorder } -// NewQueueController creates a QueueController +// NewQueueController creates a QueueController. func NewQueueController( kubeClient kubernetes.Interface, vcClient vcclientset.Interface, @@ -165,7 +165,7 @@ func NewQueueController( return c } -// Run starts QueueController +// Run starts QueueController. func (c *Controller) Run(stopCh <-chan struct{}) { defer utilruntime.HandleCrash() defer c.queue.ShutDown() diff --git a/pkg/controllers/queue/queue_controller_util.go b/pkg/controllers/queue/queue_controller_util.go index 17140f6bfd2..ad093666b8d 100644 --- a/pkg/controllers/queue/queue_controller_util.go +++ b/pkg/controllers/queue/queue_controller_util.go @@ -22,7 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// IsQueueReference return if ownerReference is Queue Kind +// IsQueueReference return if ownerReference is Queue Kind. func IsQueueReference(ref *metav1.OwnerReference) bool { if ref == nil { return false diff --git a/pkg/controllers/queue/state/factory.go b/pkg/controllers/queue/state/factory.go index fdf03bedc34..0d397653b97 100644 --- a/pkg/controllers/queue/state/factory.go +++ b/pkg/controllers/queue/state/factory.go @@ -21,13 +21,13 @@ import ( "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" ) -// State interface +// State interface. type State interface { // Execute executes the actions based on current state. Execute(action v1alpha1.Action) error } -// UpdateQueueStatusFn updates the queue status +// UpdateQueueStatusFn updates the queue status. type UpdateQueueStatusFn func(status *v1beta1.QueueStatus, podGroupList []string) // QueueActionFn will open, close or sync queue. @@ -42,7 +42,7 @@ var ( CloseQueue QueueActionFn ) -// NewState gets the state from queue status +// NewState gets the state from queue status. func NewState(queue *v1beta1.Queue) State { switch queue.Status.State { case "", v1beta1.QueueStateOpen: diff --git a/pkg/kube/config.go b/pkg/kube/config.go index 568f29e535a..cde0ac72f90 100644 --- a/pkg/kube/config.go +++ b/pkg/kube/config.go @@ -21,7 +21,7 @@ import ( "k8s.io/client-go/tools/clientcmd" ) -// ClientOptions used to build kube rest config +// ClientOptions used to build kube rest config. type ClientOptions struct { Master string KubeConfig string @@ -29,7 +29,7 @@ type ClientOptions struct { Burst int } -// BuildConfig builds kube rest config with the given options +// BuildConfig builds kube rest config with the given options. func BuildConfig(opt ClientOptions) (*rest.Config, error) { var cfg *rest.Config var err error diff --git a/pkg/version/version.go b/pkg/version/version.go index fbdd2b39b9f..0a99fc4c5f2 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -32,7 +32,7 @@ var ( apiVersion = "v1alpha1" ) -// PrintVersionAndExit prints versions from the array returned by Info() and exit +// PrintVersionAndExit prints versions from the array returned by Info() and exit. func PrintVersionAndExit() { for _, i := range Info(apiVersion) { fmt.Printf("%v\n", i) @@ -40,7 +40,7 @@ func PrintVersionAndExit() { os.Exit(0) } -// Info returns an array of various service versions +// Info returns an array of various service versions. func Info(apiVersion string) []string { return []string{ fmt.Sprintf("API Version: %s", apiVersion), diff --git a/pkg/webhooks/admission/jobs/mutate/mutate_job.go b/pkg/webhooks/admission/jobs/mutate/mutate_job.go index dd3b4ea8a16..c346aead378 100644 --- a/pkg/webhooks/admission/jobs/mutate/mutate_job.go +++ b/pkg/webhooks/admission/jobs/mutate/mutate_job.go @@ -70,7 +70,7 @@ type patchOperation struct { Value interface{} `json:"value,omitempty"` } -// MutateJobs mutate jobs +// MutateJobs mutate jobs. func Jobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse { klog.V(3).Infof("mutating jobs") diff --git a/pkg/webhooks/admission/jobs/validate/admit_job.go b/pkg/webhooks/admission/jobs/validate/admit_job.go index 60f5968ec24..07a8abb046b 100644 --- a/pkg/webhooks/admission/jobs/validate/admit_job.go +++ b/pkg/webhooks/admission/jobs/validate/admit_job.go @@ -69,7 +69,7 @@ var service = &router.AdmissionService{ var config = &router.AdmissionServiceConfig{} -// AdmitJobs is to admit jobs and return response +// AdmitJobs is to admit jobs and return response. func AdmitJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse { klog.V(3).Infof("admitting jobs -- %s", ar.Request.Operation) diff --git a/pkg/webhooks/admission/jobs/validate/util.go b/pkg/webhooks/admission/jobs/validate/util.go index 7363c55c687..071810efb3e 100644 --- a/pkg/webhooks/admission/jobs/validate/util.go +++ b/pkg/webhooks/admission/jobs/validate/util.go @@ -28,7 +28,7 @@ import ( busv1alpha1 "volcano.sh/volcano/pkg/apis/bus/v1alpha1" ) -// policyEventMap defines all policy events and whether to allow external use +// policyEventMap defines all policy events and whether to allow external use. var policyEventMap = map[busv1alpha1.Event]bool{ busv1alpha1.AnyEvent: true, busv1alpha1.PodFailedEvent: true, @@ -39,7 +39,7 @@ var policyEventMap = map[busv1alpha1.Event]bool{ busv1alpha1.CommandIssuedEvent: false, } -// policyActionMap defines all policy actions and whether to allow external use +// policyActionMap defines all policy actions and whether to allow external use. var policyActionMap = map[busv1alpha1.Action]bool{ busv1alpha1.AbortJobAction: true, busv1alpha1.RestartJobAction: true, @@ -158,7 +158,7 @@ func getValidActions() []busv1alpha1.Action { return actions } -// validateIO validates IO configuration +// validateIO validates IO configuration. func validateIO(volumes []batchv1alpha1.VolumeSpec) error { volumeMap := map[string]bool{} for _, volume := range volumes { diff --git a/pkg/webhooks/admission/pods/admit_pod.go b/pkg/webhooks/admission/pods/admit_pod.go index 0572dea4068..dacdd9159c0 100644 --- a/pkg/webhooks/admission/pods/admit_pod.go +++ b/pkg/webhooks/admission/pods/admit_pod.go @@ -63,7 +63,7 @@ var service = &router.AdmissionService{ var config = &router.AdmissionServiceConfig{} -// AdmitPods is to admit pods and return response +// AdmitPods is to admit pods and return response. func AdmitPods(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse { klog.V(3).Infof("admitting pods -- %s", ar.Request.Operation) @@ -92,10 +92,12 @@ func AdmitPods(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse { return &reviewResponse } -// allow pods to create when -// 1. schedulerName of pod isn't volcano -// 2. pod has Podgroup whose phase isn't Pending -// 3. normal pods whose schedulerName is volcano don't have podgroup +/* +allow pods to create when +1. schedulerName of pod isn't volcano +2. pod has Podgroup whose phase isn't Pending +3. normal pods whose schedulerName is volcano don't have podgroup. +*/ func validatePod(pod *v1.Pod, reviewResponse *v1beta1.AdmissionResponse) string { if pod.Spec.SchedulerName != config.SchedulerName { return "" diff --git a/pkg/webhooks/admission/queues/mutate/mutate_queue.go b/pkg/webhooks/admission/queues/mutate/mutate_queue.go index ea49a3cc4ca..11bc1f5e7c5 100644 --- a/pkg/webhooks/admission/queues/mutate/mutate_queue.go +++ b/pkg/webhooks/admission/queues/mutate/mutate_queue.go @@ -62,7 +62,7 @@ type patchOperation struct { Value interface{} `json:"value,omitempty"` } -// Queues mutate queues +// Queues mutate queues. func Queues(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse { klog.V(3).Infof("Mutating %s queue %s.", ar.Request.Operation, ar.Request.Name) diff --git a/pkg/webhooks/admission/queues/validate/validate_queue.go b/pkg/webhooks/admission/queues/validate/validate_queue.go index 56d1aca1303..133d47ea4aa 100644 --- a/pkg/webhooks/admission/queues/validate/validate_queue.go +++ b/pkg/webhooks/admission/queues/validate/validate_queue.go @@ -60,7 +60,7 @@ var service = &router.AdmissionService{ var config = &router.AdmissionServiceConfig{} -// AdmitQueues is to admit queues and return response +// AdmitQueues is to admit queues and return response. func AdmitQueues(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse { klog.V(3).Infof("Admitting %s queue %s.", ar.Request.Operation, ar.Request.Name) diff --git a/pkg/webhooks/router/interface.go b/pkg/webhooks/router/interface.go index e3f3de8d4e2..7e3cd4a9c65 100644 --- a/pkg/webhooks/router/interface.go +++ b/pkg/webhooks/router/interface.go @@ -24,7 +24,7 @@ import ( "volcano.sh/volcano/pkg/client/clientset/versioned" ) -//The AdmitFunc returns response +//The AdmitFunc returns response. type AdmitFunc func(v1beta1.AdmissionReview) *v1beta1.AdmissionResponse type AdmissionServiceConfig struct { diff --git a/pkg/webhooks/router/server.go b/pkg/webhooks/router/server.go index 7a28e1844bd..8988d74daaa 100644 --- a/pkg/webhooks/router/server.go +++ b/pkg/webhooks/router/server.go @@ -30,13 +30,13 @@ import ( "volcano.sh/volcano/pkg/webhooks/util" ) -// CONTENTTYPE http content-type +// CONTENTTYPE http content-type. var CONTENTTYPE = "Content-Type" -// APPLICATIONJSON json content +// APPLICATIONJSON json content. var APPLICATIONJSON = "application/json" -// Serve the http request +// Serve the http request. func Serve(w io.Writer, r *http.Request, admit AdmitFunc) { var body []byte if r.Body != nil { diff --git a/pkg/webhooks/schema/schema.go b/pkg/webhooks/schema/schema.go index 2da938a760d..61d9a739937 100644 --- a/pkg/webhooks/schema/schema.go +++ b/pkg/webhooks/schema/schema.go @@ -46,7 +46,7 @@ func addToScheme(scheme *runtime.Scheme) { v1beta1.AddToScheme(scheme) } -//DecodeJob decodes the job using deserializer from the raw object +//DecodeJob decodes the job using deserializer from the raw object. func DecodeJob(object runtime.RawExtension, resource metav1.GroupVersionResource) (*batchv1alpha1.Job, error) { jobResource := metav1.GroupVersionResource{Group: batchv1alpha1.SchemeGroupVersion.Group, Version: batchv1alpha1.SchemeGroupVersion.Version, Resource: "jobs"} raw := object.Raw @@ -85,7 +85,7 @@ func DecodePod(object runtime.RawExtension, resource metav1.GroupVersionResource return &pod, nil } -// DecodeQueue decodes the queue using deserializer from the raw object +// DecodeQueue decodes the queue using deserializer from the raw object. func DecodeQueue(object runtime.RawExtension, resource metav1.GroupVersionResource) (*schedulingv1beta1.Queue, error) { queueResource := metav1.GroupVersionResource{ Group: schedulingv1beta1.SchemeGroupVersion.Group, diff --git a/pkg/webhooks/util/util.go b/pkg/webhooks/util/util.go index e3b4691b845..cbed20edb25 100644 --- a/pkg/webhooks/util/util.go +++ b/pkg/webhooks/util/util.go @@ -22,7 +22,7 @@ import ( "k8s.io/klog" ) -//ToAdmissionResponse updates the admission response with the input error +//ToAdmissionResponse updates the admission response with the input error. func ToAdmissionResponse(err error) *v1beta1.AdmissionResponse { klog.Error(err) return &v1beta1.AdmissionResponse{ diff --git a/test/e2e/cli_util.go b/test/e2e/cli_util.go index b4d8bd3b6e6..2285e7bc98b 100644 --- a/test/e2e/cli_util.go +++ b/test/e2e/cli_util.go @@ -24,7 +24,7 @@ import ( . "github.com/onsi/gomega" ) -//ResumeJob resumes the job in the given namespace +//ResumeJob resumes the job in the given namespace. func ResumeJob(name string, namespace string) string { command := []string{"job", "resume"} Expect(name).NotTo(Equal(""), "Job name should not be empty in Resume job command") @@ -35,7 +35,7 @@ func ResumeJob(name string, namespace string) string { return RunCliCommand(command) } -//SuspendJob suspends the job in the given namepsace +// SuspendJob suspends the job in the given namepsace. func SuspendJob(name string, namespace string) string { command := []string{"job", "suspend"} Expect(name).NotTo(Equal(""), "Job name should not be empty in Suspend job command") @@ -46,7 +46,7 @@ func SuspendJob(name string, namespace string) string { return RunCliCommand(command) } -//ListJobs list all the jobs in the given namespace +// ListJobs list all the jobs in the given namespace. func ListJobs(namespace string) string { command := []string{"job", "list"} if namespace != "" { @@ -55,7 +55,7 @@ func ListJobs(namespace string) string { return RunCliCommand(command) } -//DeleteJob delete the job in the given namespace +// DeleteJob delete the job in the given namespace. func DeleteJob(name string, namespace string) string { command := []string{"job", "delete"} Expect(name).NotTo(Equal(""), "Job name should not be empty in delete job command") @@ -66,7 +66,7 @@ func DeleteJob(name string, namespace string) string { return RunCliCommand(command) } -//RunCliCommand runs the volcano command +// RunCliCommand runs the volcano command. func RunCliCommand(command []string) string { if masterURL() != "" { command = append(command, "--master", masterURL()) @@ -81,7 +81,7 @@ func RunCliCommand(command []string) string { return string(output) } -// RunCliCommandWithoutKubeConfig runs the volcano command +// RunCliCommandWithoutKubeConfig runs the volcano command. func RunCliCommandWithoutKubeConfig(command []string) string { if masterURL() != "" { command = append(command, "--master", masterURL()) diff --git a/test/e2e/util.go b/test/e2e/util.go index e8b504d1875..f5c46f74365 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -94,7 +94,7 @@ func kubeconfigPath(home string) string { return filepath.Join(home, ".kube", "config") // default kubeconfig path is $HOME/.kube/config } -// VolcanoCliBinary function gets the volcano cli binary +// VolcanoCliBinary function gets the volcano cli binary. func VolcanoCliBinary() string { if bin := os.Getenv("VC_BIN"); bin != "" { return filepath.Join(bin, "vcctl") @@ -1072,7 +1072,7 @@ func preparePatchBytesforNode(nodeName string, oldNode *v1.Node, newNode *v1.Nod return patchBytes, nil } -// IsNodeReady function returns the node ready status +// IsNodeReady function returns the node ready status. func IsNodeReady(node *v1.Node) bool { for _, c := range node.Status.Conditions { if c.Type == v1.NodeReady {