Skip to content

Commit

Permalink
Merge pull request #830 from daixiang0/dot
Browse files Browse the repository at this point in the history
Lint: fix godot issue
  • Loading branch information
volcano-sh-bot authored May 26, 2020
2 parents db8a51f + b5dc951 commit a907ca8
Show file tree
Hide file tree
Showing 65 changed files with 203 additions and 177 deletions.
22 changes: 22 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,30 @@ issues:
linters:
- golint
- dupl
- 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
- path: fake
linters:
- golint
- deadcode
- godot
2 changes: 1 addition & 1 deletion cmd/cli/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions cmd/controller-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller-manager/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions cmd/scheduler/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -112,7 +112,7 @@ func (s *ServerOption) CheckOptionOrDie() error {
return nil
}

// RegisterOptions registers options
// RegisterOptions registers options.
func (s *ServerOption) RegisterOptions() {
ServerOpts = s
}
2 changes: 1 addition & 1 deletion cmd/scheduler/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions cmd/webhook-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions cmd/webhook-manager/app/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions pkg/apis/batch/v1alpha1/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand All @@ -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
Expand Down Expand Up @@ -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 ':'.
Expand All @@ -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 (
Expand Down Expand Up @@ -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
Expand All @@ -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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/bus/v1alpha1/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down
24 changes: 13 additions & 11 deletions pkg/apis/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down Expand Up @@ -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{
Expand All @@ -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) {
Expand All @@ -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 && apierrors.IsNotFound(err) {
Expand All @@ -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

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/scheduling/scheme/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/scheduling/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -113,7 +113,7 @@ const (
NotEnoughPodsReason string = "NotEnoughTasks"
)

// QueueEvent represent the phase of queue
// QueueEvent represent the phase of queue.
type QueueEvent string

const (
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/scheduling/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -113,7 +113,7 @@ const (
NotEnoughPodsReason string = "NotEnoughTasks"
)

// QueueEvent represent the phase of queue
// QueueEvent represent the phase of queue.
type QueueEvent string

const (
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/job/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ 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)

cmd.Flags().StringVarP(&deleteJobFlags.Namespace, "namespace", "n", "default", "the namespace of job")
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 {
Expand Down
Loading

0 comments on commit a907ca8

Please sign in to comment.