Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: format code about whitespace #180

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cmd/metrics-scraper/app/scrape/other.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func saveToDBWithConnection(db *sql.DB, appName, podName string, data *db.Parsed

// Insert metrics and values
for metricName, metricData := range data.Metrics {

result, err := tx.Exec(fmt.Sprintf(insertMainSQL, sanitizedPodName), metricName, metricData.Help, metricData.Type, data.CurrentTime)
if err != nil {
log.Printf("Error inserting data for metric %s: %v", metricName, err)
Expand Down Expand Up @@ -272,5 +271,4 @@ func parseMetricsToJSON(metricsOutput string) (*db.ParsedData, error) {
Metrics: metrics,
}
return parsedData, nil

}
2 changes: 1 addition & 1 deletion hack/verify-staticcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ else
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VER}
fi

if golangci-lint run --enable-only goimports,gci; then
if golangci-lint run --enable-only goimports,gci,whitespace; then
echo 'Congratulations! All Go source files have passed staticcheck.'
else
echo # print one empty line, separate from warning messages.
Expand Down
1 change: 0 additions & 1 deletion pkg/client/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func InitKubeConfig(options ...Option) {
}
kubernetesApiConfig = apiConfig
}

}

func InClusterClient() kubeclient.Interface {
Expand Down
2 changes: 0 additions & 2 deletions pkg/dataselect/dataselect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func TestSort(t *testing.T) {
testCase.Info, testCase.SortQuery, order, testCase.ExpectedOrder)
}
}

}

func TestPagination(t *testing.T) {
Expand Down Expand Up @@ -220,5 +219,4 @@ func TestPagination(t *testing.T) {
testCase.Info, testCase.PaginationQuery, order, testCase.ExpectedOrder)
}
}

}
5 changes: 0 additions & 5 deletions pkg/resource/common/resourcechannels.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ type DeploymentListChannel struct {
// that both must be read numReads times.
func GetDeploymentListChannel(client client.Interface,
nsQuery *NamespaceQuery, numReads int) DeploymentListChannel {

channel := DeploymentListChannel{
List: make(chan *apps.DeploymentList, numReads),
Error: make(chan error, numReads),
Expand Down Expand Up @@ -313,7 +312,6 @@ type ServiceListChannel struct {
// must be read numReads times.
func GetServiceListChannel(client client.Interface, nsQuery *NamespaceQuery,
numReads int) ServiceListChannel {

channel := ServiceListChannel{
List: make(chan *v1.ServiceList, numReads),
Error: make(chan error, numReads),
Expand Down Expand Up @@ -384,7 +382,6 @@ func GetPodListChannel(client client.Interface,
// GetPodListChannelWithOptions is GetPodListChannel plus listing options.
func GetPodListChannelWithOptions(client client.Interface, nsQuery *NamespaceQuery,
options metaV1.ListOptions, numReads int) PodListChannel {

channel := PodListChannel{
List: make(chan *v1.PodList, numReads),
Error: make(chan error, numReads),
Expand Down Expand Up @@ -462,7 +459,6 @@ type NodeListChannel struct {
// GetNodeListChannel returns a pair of channels to a Node list and errors that both must be read
// numReads times.
func GetNodeListChannel(client client.Interface, numReads int) NodeListChannel {

channel := NodeListChannel{
List: make(chan *v1.NodeList, numReads),
Error: make(chan error, numReads),
Expand Down Expand Up @@ -528,7 +524,6 @@ type ConfigMapListChannel struct {
// numReads times.
func GetConfigMapListChannel(client client.Interface, nsQuery *NamespaceQuery,
numReads int) ConfigMapListChannel {

channel := ConfigMapListChannel{
List: make(chan *v1.ConfigMapList, numReads),
Error: make(chan error, numReads),
Expand Down
1 change: 0 additions & 1 deletion pkg/resource/cronjob/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type CronJobDetail struct {

// GetCronJobDetail gets Cron Job details.
func GetCronJobDetail(client k8sClient.Interface, namespace, name string) (*CronJobDetail, error) {

rawObject, err := client.BatchV1().CronJobs(namespace).Get(context.TODO(), name, metaV1.GetOptions{})
if err != nil {
return nil, err
Expand Down
1 change: 0 additions & 1 deletion pkg/resource/cronjob/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
// GetCronJobEvents gets events associated to cron job.
func GetCronJobEvents(client client.Interface, dsQuery *dataselect.DataSelectQuery, namespace, name string) (
*common.EventList, error) {

raw, err := event.GetEvents(client, namespace, name)
if err != nil {
return event.EmptyEventList, err
Expand Down
2 changes: 0 additions & 2 deletions pkg/resource/cronjob/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ var emptyJobList = &job.JobList{
// GetCronJobJobs returns list of jobs owned by cron job.
func GetCronJobJobs(client client.Interface,
dsQuery *dataselect.DataSelectQuery, namespace, name string, active bool) (*job.JobList, error) {

cronJob, err := client.BatchV1().CronJobs(namespace).Get(context.TODO(), name, meta.GetOptions{})
if err != nil {
return emptyJobList, err
Expand Down Expand Up @@ -90,7 +89,6 @@ func GetCronJobJobs(client client.Interface,
// TriggerCronJob manually triggers a cron job and creates a new job.
func TriggerCronJob(client client.Interface,
namespace, name string) error {

cronJob, err := client.BatchV1().CronJobs(namespace).Get(context.TODO(), name, meta.GetOptions{})

if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/resource/cronjob/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func GetCronJobList(client client.Interface, nsQuery *common.NamespaceQuery,
// GetCronJobListFromChannels returns a list of all CronJobs in the cluster reading required resource
// list once from the channels.
func GetCronJobListFromChannels(channels *common.ResourceChannels, dsQuery *dataselect.DataSelectQuery) (*CronJobList, error) {

cronJobs := <-channels.CronJobList.List
err := <-channels.CronJobList.Error
nonCriticalErrors, criticalError := errors.ExtractErrors(err)
Expand All @@ -83,7 +82,6 @@ func GetCronJobListFromChannels(channels *common.ResourceChannels, dsQuery *data
}

func toCronJobList(cronJobs []batch.CronJob, nonCriticalErrors []error, dsQuery *dataselect.DataSelectQuery) *CronJobList {

list := &CronJobList{
Items: make([]CronJob, 0),
ListMeta: types.ListMeta{TotalItems: len(cronJobs)},
Expand Down
1 change: 0 additions & 1 deletion pkg/resource/daemonset/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
// label selector is targeting only 1 daemon set.
func GetServicesForDSDeletion(client client.Interface, labelSelector labels.Selector,
namespace string) ([]v1.Service, error) {

daemonSet, err := client.AppsV1().DaemonSets(namespace).List(context.TODO(), metaV1.ListOptions{
LabelSelector: labelSelector.String(),
FieldSelector: fields.Everything().String(),
Expand Down
1 change: 0 additions & 1 deletion pkg/resource/daemonset/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type DaemonSetDetail struct {

// GetDaemonSetDetail Returns detailed information about the given daemon set in the given namespace.
func GetDaemonSetDetail(client k8sClient.Interface, namespace, name string) (*DaemonSetDetail, error) {

log.Printf("Getting details of %s daemon set in %s namespace", name, namespace)
daemonSet, err := client.AppsV1().DaemonSets(namespace).Get(context.TODO(), name, metaV1.GetOptions{})
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/resource/daemonset/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func GetDaemonSetList(client kubernetes.Interface, nsQuery *common.NamespaceQuer
// GetDaemonSetListFromChannels returns a list of all Daemon Set in the cluster
// reading required resource list once from the channels.
func GetDaemonSetListFromChannels(channels *common.ResourceChannels, dsQuery *dataselect.DataSelectQuery) (*DaemonSetList, error) {

daemonSets := <-channels.DaemonSetList.List
err := <-channels.DaemonSetList.Error
nonCriticalErrors, criticalError := errors.ExtractErrors(err)
Expand Down Expand Up @@ -91,7 +90,6 @@ func GetDaemonSetListFromChannels(channels *common.ResourceChannels, dsQuery *da

func toDaemonSetList(daemonSets []apps.DaemonSet, pods []v1.Pod, events []v1.Event, nonCriticalErrors []error,
dsQuery *dataselect.DataSelectQuery) *DaemonSetList {

daemonSetList := &DaemonSetList{
DaemonSets: make([]DaemonSet, 0),
ListMeta: types.ListMeta{TotalItems: len(daemonSets)},
Expand Down
1 change: 0 additions & 1 deletion pkg/resource/deployment/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ type DeploymentDetail struct {

// GetDeploymentDetail returns model object of deployment and error, if any.
func GetDeploymentDetail(client client.Interface, namespace string, deploymentName string) (*DeploymentDetail, error) {

log.Printf("Getting details of %s deployment in %s namespace", deploymentName, namespace)

deployment, err := client.AppsV1().Deployments(namespace).Get(context.TODO(), deploymentName, metaV1.GetOptions{})
Expand Down
2 changes: 0 additions & 2 deletions pkg/resource/deployment/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func GetDeploymentList(client client.Interface, nsQuery *common.NamespaceQuery,
// GetDeploymentListFromChannels returns a list of all Deployments in the cluster
// reading required resource list once from the channels.
func GetDeploymentListFromChannels(channels *common.ResourceChannels, dsQuery *dataselect.DataSelectQuery) (*DeploymentList, error) {

deployments := <-channels.DeploymentList.List
err := <-channels.DeploymentList.Error
nonCriticalErrors, criticalError := errors.ExtractErrors(err)
Expand Down Expand Up @@ -115,7 +114,6 @@ func GetDeploymentListFromChannels(channels *common.ResourceChannels, dsQuery *d

func toDeploymentList(deployments []apps.Deployment, pods []v1.Pod, events []v1.Event, rs []apps.ReplicaSet,
nonCriticalErrors []error, dsQuery *dataselect.DataSelectQuery) *DeploymentList {

deploymentList := &DeploymentList{
Deployments: make([]Deployment, 0),
ListMeta: types.ListMeta{TotalItems: len(deployments)},
Expand Down
1 change: 0 additions & 1 deletion pkg/resource/job/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
// GetJobEvents gets events associated to job.
func GetJobEvents(client client.Interface, dsQuery *dataselect.DataSelectQuery, namespace, name string) (
*common.EventList, error) {

jobEvents, err := event.GetEvents(client, namespace, name)
if err != nil {
return event.EmptyEventList, err
Expand Down
2 changes: 0 additions & 2 deletions pkg/resource/job/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func GetJobList(client client.Interface, nsQuery *common.NamespaceQuery,

// GetJobListFromChannels returns a list of all Jobs in the cluster reading required resource list once from the channels.
func GetJobListFromChannels(channels *common.ResourceChannels, dsQuery *dataselect.DataSelectQuery) (*JobList, error) {

jobs := <-channels.JobList.List
err := <-channels.JobList.Error
nonCriticalErrors, criticalError := errors.ExtractErrors(err)
Expand Down Expand Up @@ -131,7 +130,6 @@ func GetJobListFromChannels(channels *common.ResourceChannels, dsQuery *datasele

func ToJobList(jobs []batch.Job, pods []v1.Pod, events []v1.Event, nonCriticalErrors []error,
dsQuery *dataselect.DataSelectQuery) *JobList {

jobList := &JobList{
Jobs: make([]Job, 0),
ListMeta: types.ListMeta{TotalItems: len(jobs)},
Expand Down
2 changes: 0 additions & 2 deletions pkg/resource/statefulset/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func GetStatefulSetList(client kubernetes.Interface, nsQuery *common.NamespaceQu
// GetStatefulSetListFromChannels returns a list of all Stateful Sets in the cluster reading
// required resource list once from the channels.
func GetStatefulSetListFromChannels(channels *common.ResourceChannels, dsQuery *dataselect.DataSelectQuery) (*StatefulSetList, error) {

statefulSets := <-channels.StatefulSetList.List
err := <-channels.StatefulSetList.Error
nonCriticalErrors, criticalError := errors.ExtractErrors(err)
Expand Down Expand Up @@ -96,7 +95,6 @@ func GetStatefulSetListFromChannels(channels *common.ResourceChannels, dsQuery *

func toStatefulSetList(statefulSets []apps.StatefulSet, pods []v1.Pod, events []v1.Event, nonCriticalErrors []error,
dsQuery *dataselect.DataSelectQuery) *StatefulSetList {

statefulSetList := &StatefulSetList{
StatefulSets: make([]StatefulSet, 0),
ListMeta: types.ListMeta{TotalItems: len(statefulSets)},
Expand Down