Skip to content

Commit

Permalink
Fix lint error in cmd package
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajadeepan D Ramesh committed Jun 11, 2019
1 parent ab4e709 commit b5ab5cb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cmd/admission/app/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package configure

import (
Expand All @@ -28,7 +29,7 @@ import (
admissionregistrationv1beta1client "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1"
)

// admission-controller server config.
// Config admission-controller server config.
type Config struct {
Master string
Kubeconfig string
Expand All @@ -43,11 +44,13 @@ type Config struct {
PrintVersion bool
}

// NewConfig create new config
func NewConfig() *Config {
c := Config{}
return &c
}

// AddFlags add flags
func (c *Config) AddFlags() {
flag.StringVar(&c.Master, "master", c.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
flag.StringVar(&c.Kubeconfig, "kubeconfig", c.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
Expand All @@ -68,6 +71,7 @@ func (c *Config) AddFlags() {
flag.BoolVar(&c.PrintVersion, "version", false, "Show version and quit")
}

// 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
10 changes: 8 additions & 2 deletions cmd/admission/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package app

import (
Expand All @@ -34,11 +35,14 @@ import (
)

const (
CONTENTTYPE = "Content-Type"
//CONTENTTYPE http content-type
CONTENTTYPE = "Content-Type"

//APPLICATIONJSON json content
APPLICATIONJSON = "application/json"
)

// Get a clientset with restConfig.
// GetClient Get a clientset with restConfig.
func GetClient(restConfig *restclient.Config) *kubernetes.Clientset {
clientset, err := kubernetes.NewForConfig(restConfig)
if err != nil {
Expand All @@ -47,6 +51,7 @@ func GetClient(restConfig *restclient.Config) *kubernetes.Clientset {
return clientset
}

//GetKubeBatchClient get a clientset for kubebatch
func GetKubeBatchClient(restConfig *restclient.Config) *versioned.Clientset {
clientset, err := versioned.NewForConfig(restConfig)
if err != nil {
Expand Down Expand Up @@ -85,6 +90,7 @@ func ConfigTLS(config *appConf.Config, restConfig *restclient.Config) *tls.Confi
return &tls.Config{}
}

//Serve the http request
func Serve(w http.ResponseWriter, r *http.Request, admit admissioncontroller.AdmitFunc) {
var body []byte
if r.Body != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/controllers/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (s *ServerOption) AddFlags(fs *pflag.FlagSet) {
fs.BoolVar(&s.PrintVersion, "version", false, "Show version and quit")
}

// 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
3 changes: 3 additions & 0 deletions cmd/controllers/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"

// Initialize client auth plugin.
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -71,6 +73,7 @@ func buildConfig(opt *options.ServerOption) (*rest.Config, error) {
return cfg, nil
}

//Run the controller
func Run(opt *options.ServerOption) error {
config, err := buildConfig(opt)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions hack/.golint_failures
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
volcano.sh/volcano/cmd/admission/app
volcano.sh/volcano/cmd/admission/app/configure
volcano.sh/volcano/cmd/controllers/app
volcano.sh/volcano/cmd/controllers/app/options
volcano.sh/volcano/pkg/admission
volcano.sh/volcano/pkg/apis/batch/v1alpha1
volcano.sh/volcano/pkg/apis/bus/v1alpha1
Expand Down

0 comments on commit b5ab5cb

Please sign in to comment.