Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Oct 7, 2024
1 parent 6511581 commit 8db92aa
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func main() {
fmt.Fprint(os.Stderr, title+"\n\n")
desc := swaggerSpec.Spec().Info.Description
if desc != "" {
fmt.Fprintf(os.Stderr, desc+"\n\n")
fmt.Fprint(os.Stderr, desc+"\n\n")
}
fmt.Fprintln(os.Stderr, pflag.CommandLine.FlagUsages())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/auth/keystone_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Keystone(logger log.Logger) func(token string) (*models.Principal, error) {
return func(token string) (*models.Principal, error) {
t, err := auth.Validate(token)
if err != nil {
return nil, errors.New(401, fmt.Sprintf("Authentication failed: %s", err))
return nil, errors.New(401, "Authentication failed: %s", err)
}
if t.Project == nil {
return nil, errors.New(401, "Auth token isn't project scoped")
Expand Down
10 changes: 5 additions & 5 deletions pkg/api/handlers/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (d *createCluster) Handle(params operations.CreateClusterParams, principal
spec := params.Body.Spec

if err := validate.UniqueItems("name", "body", params.Body.Spec.NodePools); err != nil {
return NewErrorResponse(&operations.CreateClusterDefault{}, int(err.Code()), err.Error())
return NewErrorResponse(&operations.CreateClusterDefault{}, int(err.Code()), "%s", err)
}

if params.Body.Spec.Version != "" {
Expand Down Expand Up @@ -80,7 +80,7 @@ func (d *createCluster) Handle(params operations.CreateClusterParams, principal
"kluster", name,
"project", principal.Account,
"err", err)
return NewErrorResponse(&operations.CreateClusterDefault{}, 400, err.Error())
return NewErrorResponse(&operations.CreateClusterDefault{}, 400, "%s", err)
}

if kluster.ClusterCIDR() == "" && !kluster.Spec.NoCloud {
Expand All @@ -104,9 +104,9 @@ func (d *createCluster) Handle(params operations.CreateClusterParams, principal
if !kluster.Spec.NoCloud {
if overlap, err := d.overlapWithSiblingCluster(kluster.ClusterCIDR(), kluster.Spec.Openstack.RouterID, principal); overlap || err != nil {
if overlap {
return NewErrorResponse(&operations.CreateClusterDefault{}, 409, err.Error())
return NewErrorResponse(&operations.CreateClusterDefault{}, 409, "%s", err)
}
return NewErrorResponse(&operations.CreateClusterDefault{}, 500, err.Error())
return NewErrorResponse(&operations.CreateClusterDefault{}, 500, "%s", err)
}
}
}
Expand All @@ -132,7 +132,7 @@ func (d *createCluster) Handle(params operations.CreateClusterParams, principal
if apierrors.IsAlreadyExists(err) {
return NewErrorResponse(&operations.CreateClusterDefault{}, 409, "Cluster with name %s already exists", name)
}
return NewErrorResponse(&operations.CreateClusterDefault{}, 500, err.Error())
return NewErrorResponse(&operations.CreateClusterDefault{}, 500, "%s", err)
}

//Wait for a second so that the newly created cluster shows up in the cache
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/get_cluster_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func (d *getBootstrapConfig) Handle(params operations.GetBootstrapConfigParams,
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetBootstrapConfigDefault{}, 404, "Kluster not found")
}
return NewErrorResponse(&operations.GetBootstrapConfigDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetBootstrapConfigDefault{}, 500, "%s", err)
}

secret, err := util.KlusterSecret(d.Kubernetes, kluster)
if err != nil {
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 404, "Secret not found")
}
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, "%s", err)
}

client, err := d.KlusterClientFactory.ClientFor(kluster)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/get_cluster_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ func (d *getClusterCredentials) Handle(params operations.GetClusterCredentialsPa
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 404, "Kluster not found")
}
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, "%s", err)
}
secret, err := util.KlusterSecret(d.Kubernetes, kluster)
if err != nil {
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 404, "Secret not found")
}
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, "%s", err)
}

factory := util.NewCertificateFactory(kluster, &secret.Certificates, "")
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/get_cluster_credentials_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ func (d *getClusterCredentialsOIDC) Handle(params operations.GetClusterCredentia
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 404, "Kluster not found")
}
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, "%s", err)
}

secret, err := util.KlusterSecret(d.Kubernetes, kluster)
if err != nil {
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 404, "Secret not found")
}
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, "%s", err)
}

secretID := secret.DexClientSecret
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/handlers/get_cluster_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (d *getClusterEvents) Handle(params operations.GetClusterEventsParams, prin
selector := eventsInterface.GetFieldSelector(&klusterName, &d.Namespace, &kind, nil)
kEvents, err := eventsInterface.List(context.TODO(), metav1.ListOptions{FieldSelector: selector.String()})
if err != nil {
return NewErrorResponse(&operations.GetClusterEventsDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterEventsDefault{}, 500, "%s", err)
}
events := make([]*models.Event, 0, len(kEvents.Items))
for _, ev := range kEvents.Items {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/handlers/get_cluster_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (d *getClusterInfo) Handle(params operations.GetClusterInfoParams, principa

links, err := d.getLinks()
if err != nil {
return NewErrorResponse(&operations.GetClusterInfoDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterInfoDefault{}, 500, "%s", err)
}

baseURL := fmt.Sprintf("%s://%s", requestutil.Scheme(params.HTTPRequest), requestutil.HostWithPort(params.HTTPRequest))
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/get_cluster_kubeadm_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ func (d *getClusterKubeadmSecret) Handle(params operations.GetClusterKubeadmSecr
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetClusterKubeadmSecretDefault{}, 404, "Kluster not found")
}
return NewErrorResponse(&operations.GetClusterKubeadmSecretDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterKubeadmSecretDefault{}, 500, "%s", err)
}

secret, err := util.KlusterSecret(d.Kubernetes, kluster)
if err != nil {
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 404, "Secret not found")
}
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetClusterCredentialsDefault{}, 500, "%s", err)
}

kadmSecret := corev1.Secret{
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/handlers/get_openstack_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type getOpenstackMetadata struct {
func (d *getOpenstackMetadata) Handle(params operations.GetOpenstackMetadataParams, principal *models.Principal) middleware.Responder {
openstackMetadata, err := fetchOpenstackMetadata(params.HTTPRequest, principal)
if err != nil {
return NewErrorResponse(&operations.GetOpenstackMetadataDefault{}, 500, err.Error())
return NewErrorResponse(&operations.GetOpenstackMetadataDefault{}, 500, "%s", err)
}

return operations.NewGetOpenstackMetadataOK().WithPayload(openstackMetadata)
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/handlers/list_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (d *listClusters) Handle(params operations.ListClustersParams, principal *m
klusterList, err := d.Klusters.List(accountSelector(principal))

if err != nil {
return NewErrorResponse(&operations.ListClustersDefault{}, 500, err.Error())
return NewErrorResponse(&operations.ListClustersDefault{}, 500, "%s", err)
}

clusters := make([]*models.Kluster, 0, len(klusterList))
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/handlers/show_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (d *showCluster) Handle(params operations.ShowClusterParams, principal *mod
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.ShowClusterDefault{}, 404, "Not found")
}
return NewErrorResponse(&operations.ShowClusterDefault{}, 500, err.Error())
return NewErrorResponse(&operations.ShowClusterDefault{}, 500, "%s", err)
}

return operations.NewShowClusterOK().WithPayload(klusterFromCRD(kluster))
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/handlers/terminate_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (d *terminateCluster) Handle(params operations.TerminateClusterParams, prin
if apierrors.IsNotFound(err) {
return NewErrorResponse(&operations.TerminateClusterDefault{}, 404, "Not found")
}
return NewErrorResponse(&operations.TerminateClusterDefault{}, 500, err.Error())
return NewErrorResponse(&operations.TerminateClusterDefault{}, 500, "%s", err)
}
if kluster.TerminationProtection() {
return NewErrorResponse(&operations.TerminateClusterDefault{}, 403, "Termination protection enabled")
Expand All @@ -40,7 +40,7 @@ func (d *terminateCluster) Handle(params operations.TerminateClusterParams, prin
return nil
})
if err != nil {
return NewErrorResponse(&operations.TerminateClusterDefault{}, 500, err.Error())
return NewErrorResponse(&operations.TerminateClusterDefault{}, 500, "%s", err)
}

// This issues a delete request for the Kluster CRD
Expand All @@ -54,7 +54,7 @@ func (d *terminateCluster) Handle(params operations.TerminateClusterParams, prin
// required once a Kluster is deleted.
propagationPolicy := metav1.DeletePropagationBackground
if err := klusterInterface.Delete(context.TODO(), qualifiedName(params.Name, principal.Account), metav1.DeleteOptions{PropagationPolicy: &propagationPolicy}); err != nil {
return NewErrorResponse(&operations.TerminateClusterDefault{}, 500, err.Error())
return NewErrorResponse(&operations.TerminateClusterDefault{}, 500, "%s", err)
}

return operations.NewTerminateClusterAccepted()
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/update_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ func (d *updateCluster) Handle(params operations.UpdateClusterParams, principal

switch e := err.(type) {
case apierrors.APIStatus:
return NewErrorResponse(&operations.UpdateClusterDefault{}, int(e.Status().Code), err.Error())
return NewErrorResponse(&operations.UpdateClusterDefault{}, int(e.Status().Code), "%s", err)
default:
return NewErrorResponse(&operations.UpdateClusterDefault{}, 500, err.Error())
return NewErrorResponse(&operations.UpdateClusterDefault{}, 500, "%s", err)
}

}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/kubernikusctl/auth/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (o *InitOptions) Run(c *cobra.Command) (err error) {
}

func (o *InitOptions) setup() error {
klog.V(2).Infof(o.openstack.PrintDebugAuthInfo())
klog.V(2).Info(o.openstack.PrintDebugAuthInfo())
fmt.Println(o.openstack.PrintAuthInfo())

if err := o.openstack.Authenticate(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/kubernikusctl/auth/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (o *RefreshOptions) setupClients() error {
return err
}

klog.V(2).Infof(o.openstack.PrintDebugAuthInfo())
klog.V(2).Info(o.openstack.PrintDebugAuthInfo())
fmt.Println(o.openstack.PrintAuthInfo())

if err := o.openstack.Authenticate(); err != nil {
Expand Down
16 changes: 8 additions & 8 deletions pkg/cmd/kubernikusctl/common/kubernikus.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (k *KubernikusClient) GetCredentials(name string) (string, error) {
if result.Code() == 404 {
return "", errors.Errorf("Cluster %v not found", name)
}
return "", errors.Errorf(result.Payload.Message)
return "", errors.Errorf("Error while getting cluster credentials: %s", result.Payload.Message)
case error:
return "", errors.Wrapf(err, "A generic error occurred")
}
Expand All @@ -67,7 +67,7 @@ func (k *KubernikusClient) GetCredentialsOIDC(name string) (string, error) {
if result.Code() == 404 {
return "", errors.Errorf("Cluster %v not found", name)
}
return "", errors.Errorf(result.Payload.Message)
return "", errors.Errorf("Error while getting oidc cluster credentials: %s", result.Payload.Message)
case error:
return "", errors.Wrapf(err, "A generic error occurred")
}
Expand All @@ -81,7 +81,7 @@ func (k *KubernikusClient) CreateCluster(cluster *models.Kluster) error {
switch err.(type) {
case *operations.CreateClusterDefault:
result := err.(*operations.CreateClusterDefault)
return errors.Errorf(result.Payload.Message)
return errors.Errorf("Error while creating cluster: %s", result.Payload.Message)
case error:
return errors.Wrap(err, "Error creating cluster")
}
Expand All @@ -94,7 +94,7 @@ func (k *KubernikusClient) DeleteCluster(name string) error {
switch err.(type) {
case *operations.TerminateClusterDefault:
result := err.(*operations.TerminateClusterDefault)
return errors.Errorf(result.Payload.Message)
return errors.Errorf("Error while terminating cluster: %s", result.Payload.Message)
case error:
return errors.Wrap(err, "Error deleting cluster")
}
Expand All @@ -108,7 +108,7 @@ func (k *KubernikusClient) ShowCluster(name string) (*models.Kluster, error) {
switch err.(type) {
case *operations.ShowClusterDefault:
result := err.(*operations.ShowClusterDefault)
return nil, errors.Errorf(result.Payload.Message)
return nil, errors.Errorf("Error while showing cluster: %s", result.Payload.Message)
case error:
return nil, errors.Wrap(err, "Getting cluster failed")
}
Expand All @@ -124,7 +124,7 @@ func (k *KubernikusClient) GetClusterValues(account, name string) (string, error
switch err.(type) {
case *operations.GetClusterValuesDefault:
result := err.(*operations.GetClusterValuesDefault)
return "", errors.Errorf(result.Payload.Message)
return "", errors.Errorf("Error while getting cluster values: %s", result.Payload.Message)
case error:
return "", errors.Wrap(err, "Getting cluster failed")
}
Expand All @@ -136,7 +136,7 @@ func (k *KubernikusClient) ListAllClusters() ([]*models.Kluster, error) {
switch err.(type) {
case *operations.ListClustersDefault:
result := err.(*operations.ListClustersDefault)
return nil, errors.Errorf(result.Payload.Message)
return nil, errors.Errorf("Error while listing cluster: %s", result.Payload.Message)
case error:
return nil, errors.Wrapf(err, "Listing clusters failed")
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func (k *KubernikusClient) GetDefaultCluster() (*models.Kluster, error) {
switch err.(type) {
case *operations.ListClustersDefault:
result := err.(*operations.ListClustersDefault)
return nil, errors.Errorf(result.Payload.Message)
return nil, errors.Errorf("Error while listing clusters: %s", result.Payload.Message)
case error:
return nil, errors.Wrapf(err, "Listing clusters failed")
}
Expand Down

0 comments on commit 8db92aa

Please sign in to comment.