Skip to content

Commit

Permalink
Lint fix for admission package
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita15p committed Jun 18, 2019
1 parent e176964 commit 10b9069
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
1 change: 0 additions & 1 deletion hack/.golint_failures
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
volcano.sh/volcano/pkg/admission
volcano.sh/volcano/pkg/controllers/apis
volcano.sh/volcano/pkg/controllers/cache
volcano.sh/volcano/pkg/controllers/job
Expand Down
16 changes: 13 additions & 3 deletions pkg/admission/admission_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@ import (
)

const (
AdmitJobPath = "/jobs"
//AdmitJobPath is the pattern for the jobs admission
AdmitJobPath = "/jobs"
//MutateJobPath is the pattern for the mutating jobs
MutateJobPath = "/mutating-jobs"
PVCInputName = "volcano.sh/job-input"
//PVCInputName stores the input name of PVC
PVCInputName = "volcano.sh/job-input"
//PVCOutputName stores the output name of PVC
PVCOutputName = "volcano.sh/job-output"
)

//The AdmitFunc returns response
type AdmitFunc func(v1beta1.AdmissionReview) *v1beta1.AdmissionResponse

var scheme = runtime.NewScheme()

//Codecs is for retrieving serializers for the supported wire formats
//and conversion wrappers to define preferred internal and external versions.
var Codecs = serializer.NewCodecFactory(scheme)

// policyEventMap defines all policy events and whether to allow external use
Expand Down Expand Up @@ -75,6 +83,7 @@ func addToScheme(scheme *runtime.Scheme) {
admissionregistrationv1beta1.AddToScheme(scheme)
}

//ToAdmissionResponse updates the admission response with the input error
func ToAdmissionResponse(err error) *v1beta1.AdmissionResponse {
glog.Error(err)
return &v1beta1.AdmissionResponse{
Expand All @@ -84,6 +93,7 @@ func ToAdmissionResponse(err error) *v1beta1.AdmissionResponse {
}
}

//DecodeJob decodes the job using deserializer from the raw object
func DecodeJob(object runtime.RawExtension, resource metav1.GroupVersionResource) (v1alpha1.Job, error) {
jobResource := metav1.GroupVersionResource{Group: v1alpha1.SchemeGroupVersion.Group, Version: v1alpha1.SchemeGroupVersion.Version, Resource: "jobs"}
raw := object.Raw
Expand Down Expand Up @@ -178,7 +188,7 @@ func getValidActions() []v1alpha1.Action {
return actions
}

// validate IO configuration
// ValidateIO validate IO configuration
func ValidateIO(volumes []v1alpha1.VolumeSpec) (string, bool) {
volumeMap := map[string]bool{}
for _, volume := range volumes {
Expand Down
2 changes: 1 addition & 1 deletion pkg/admission/admit_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
//KubeBatchClientSet is kube-batch clientset
var KubeBatchClientSet versioned.Interface

// job admit.
// AdmitJobs is to admit jobs and return response
func AdmitJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {

glog.V(3).Infof("admitting jobs -- %s", ar.Request.Operation)
Expand Down
4 changes: 2 additions & 2 deletions pkg/admission/admit_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func TestValidateExecution(t *testing.T) {

namespace := "test"
var invTtl int32 = -1
var invTTL int32 = -1

testCases := []struct {
Name string
Expand Down Expand Up @@ -281,7 +281,7 @@ func TestValidateExecution(t *testing.T) {
},
},
},
TTLSecondsAfterFinished: &invTtl,
TTLSecondsAfterFinished: &invTTL,
},
},
reviewResponse: v1beta1.AdmissionResponse{Allowed: true},
Expand Down
3 changes: 2 additions & 1 deletion pkg/admission/mutate_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
)

const (
//DefaultQueue constant stores the name of the queue as "default"
DefaultQueue = "default"
)

Expand All @@ -38,7 +39,7 @@ type patchOperation struct {
Value interface{} `json:"value,omitempty"`
}

// mutate job.
// MutateJobs mutate jobs
func MutateJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
glog.V(3).Infof("mutating jobs")

Expand Down

0 comments on commit 10b9069

Please sign in to comment.