1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-29 10:55:05 +00:00

Format project with gofmt, govet, misspell

This commit is contained in:
shuting 2019-05-15 18:53:45 -07:00
parent 9956f3ee12
commit b58e4f5026
7 changed files with 26 additions and 28 deletions

View file

@ -78,7 +78,7 @@ spec :
data: # data is optional
status:
events:
# log of applied policies. We will need a way to distingush between failed
# log of applied policies. We will need a way to distinguish between failed
# and succeeded operations

16
init.go
View file

@ -17,13 +17,12 @@ func createClientConfig(kubeconfig string) (*rest.Config, error) {
if kubeconfig == "" {
log.Printf("Using in-cluster configuration")
return rest.InClusterConfig()
} else {
log.Printf("Using configuration from '%s'", kubeconfig)
return clientcmd.BuildConfigFromFlags("", kubeconfig)
}
log.Printf("Using configuration from '%s'", kubeconfig)
return clientcmd.BuildConfigFromFlags("", kubeconfig)
}
func initTlsPemPair(certFile, keyFile string, clientConfig *rest.Config, kubeclient *kubeclient.KubeClient) (*tls.TlsPemPair, error) {
func initTLSPemPair(certFile, keyFile string, clientConfig *rest.Config, kubeclient *kubeclient.KubeClient) (*tls.TlsPemPair, error) {
var tlsPair *tls.TlsPemPair
if certFile != "" || keyFile != "" {
tlsPair = tlsPairFromFiles(certFile, keyFile)
@ -32,10 +31,9 @@ func initTlsPemPair(certFile, keyFile string, clientConfig *rest.Config, kubecli
var err error
if tlsPair != nil {
return tlsPair, nil
} else {
tlsPair, err = tlsPairFromCluster(clientConfig, kubeclient)
return tlsPair, err
}
tlsPair, err = tlsPairFromCluster(clientConfig, kubeclient)
return tlsPair, err
}
// Loads PEM private key and TLS certificate from given files
@ -66,14 +64,14 @@ func tlsPairFromFiles(certFile, keyFile string) *tls.TlsPemPair {
// Created pair is stored in cluster's secret.
// Returns struct with key/certificate pair.
func tlsPairFromCluster(configuration *rest.Config, client *kubeclient.KubeClient) (*tls.TlsPemPair, error) {
apiServerUrl, err := url.Parse(configuration.Host)
apiServerURL, err := url.Parse(configuration.Host)
if err != nil {
return nil, err
}
certProps := tls.TlsCertificateProps{
Service: config.WebhookServiceName,
Namespace: config.KubePolicyNamespace,
ApiServerHost: apiServerUrl.Hostname(),
ApiServerHost: apiServerURL.Hostname(),
}
tlsPair := client.ReadTlsPair(certProps)

View file

@ -54,7 +54,7 @@ func main() {
log.Fatalf("Error creating mutation webhook: %v\n", err)
}
tlsPair, err := initTlsPemPair(cert, key, clientConfig, kubeclient)
tlsPair, err := initTLSPemPair(cert, key, clientConfig, kubeclient)
if err != nil {
log.Fatalf("Failed to initialize TLS key/certificate pair: %v\n", err)
}

View file

@ -1,11 +1,11 @@
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/nirmata/kube-policy/pkg/apis/policy"
"github.com/nirmata/kube-policy/pkg/apis/policy"
)
// SchemeGroupVersion is group version used to register these objects
@ -13,25 +13,25 @@ var SchemeGroupVersion = schema.GroupVersion{Group: policy.GroupName, Version: "
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Policy{},
&PolicyList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
scheme.AddKnownTypes(SchemeGroupVersion,
&Policy{},
&PolicyList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

View file

@ -47,7 +47,7 @@ func JoinPatches(patches []PatchBytes) PatchBytes {
result = append(result, []byte("[\n")...)
for index, patch := range patches {
result = append(result, patch...)
if index != (len(patches) - 1) {
if index != len(patches)-1 {
result = append(result, []byte(",\n")...)
}
}

View file

@ -115,7 +115,7 @@ func (c *controller) processNextWorkItem() bool {
}(obj)
if err != nil {
log.Println((err))
log.Println(err)
}
return true
}

View file

@ -10,7 +10,7 @@ func (k MsgKey) String() string {
"Failed to satisfy policy on resource %s.The following rules %s failed to apply. Created Policy Violation",
"Failed to process rule %s of policy %s. Created Policy Violation %s",
"Policy applied successfully on the resource %s",
"Rule %s of Policy %s applied successfull",
"Rule %s of Policy %s applied successful",
"Failed to apply policy, blocked creation of resource %s. The following rules %s failed to apply",
"Failed to apply rule %s of policy %s Blocked update of the resource",
"Failed to apply policy on resource %s.Blocked update of the resource. The following rules %s failed to apply",