Skip to content

Commit

Permalink
ci: add -v, --fix args for golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gillson <[email protected]>
  • Loading branch information
TylerGillson committed Jul 23, 2024
1 parent 3ef3ec2 commit 6183d09
Show file tree
Hide file tree
Showing 33 changed files with 377 additions and 385 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ linters-settings:
linters:
disable-all: true
enable:
- dupl
- errcheck
- exportloopref
- goconst
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
rev: v1.59.1
hooks:
- id: golangci-lint
entry: golangci-lint run --new-from-rev HEAD --whole-files
entry: golangci-lint run --new-from-rev HEAD --whole-files --fix
types: [go]
language: golang
require_serial: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ vet: ## Run go vet against code
go vet ./...

lint: golangci-lint ## Run golangci-lint against code
$(GOLANGCI_LINT) run
$(GOLANGCI_LINT) run -v ./...

pre-commit-install: pre-commit ## Install pre-commit hooks
@if [ "$(GITHUB_ACTIONS)" != "true" ]; then \
Expand Down
4 changes: 2 additions & 2 deletions client/addon_deployment_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (h *V1Client) UpdateAddonDeployment(cluster *models.V1SpectroCluster, body

resolveNotifications := true
params := clientV1.NewV1SpectroClustersPatchProfilesParams().
WithContext(ContextForScope(cluster.Metadata.Annotations[Scope], h.projectUid)).
WithContext(ContextForScope(cluster.Metadata.Annotations[Scope], h.projectUID)).
WithUID(uid).
WithBody(body).
WithResolveNotification(&resolveNotifications)
Expand All @@ -40,7 +40,7 @@ func IsProfileAttachedByName(cluster *models.V1SpectroCluster, newProfile *model
func (h *V1Client) CreateAddonDeployment(cluster *models.V1SpectroCluster, body *models.V1SpectroClusterProfiles) error {
resolveNotifications := false // during initial creation we never need to resolve packs
params := clientV1.NewV1SpectroClustersPatchProfilesParams().
WithContext(ContextForScope(cluster.Metadata.Annotations[Scope], h.projectUid)).
WithContext(ContextForScope(cluster.Metadata.Annotations[Scope], h.projectUID)).
WithUID(cluster.Metadata.UID).
WithBody(body).
WithResolveNotification(&resolveNotifications)
Expand Down
2 changes: 1 addition & 1 deletion client/appliance.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package client

import (
"fmt"

"github.com/spectrocloud/gomi/pkg/ptr"
"fmt"
clientV1 "github.com/spectrocloud/palette-api-go/client/v1"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/client/herr"
Expand Down
2 changes: 1 addition & 1 deletion client/application_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (h *V1Client) DeleteApplicationProfile(uid string) error {
return err
}
params := clientV1.NewV1AppProfilesUIDDeleteParams().
WithContext(ContextForScope(profile.Metadata.Annotations[Scope], h.projectUid)).
WithContext(ContextForScope(profile.Metadata.Annotations[Scope], h.projectUID)).
WithUID(uid)
_, err = h.Client.V1AppProfilesUIDDelete(params)
return err
Expand Down
27 changes: 13 additions & 14 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import (
)

type V1Client struct {

Client clientV1.ClientService

ctx context.Context
apikey string
jwt string
username string
password string
hubbleUri string
projectUid string
hubbleURI string
projectUID string
schemes []string
insecureSkipVerify bool
transportDebug bool
Expand Down Expand Up @@ -67,9 +66,9 @@ func WithPassword(password string) func(*V1Client) {
}
}

func WithHubbleURI(hubbleUri string) func(*V1Client) {
func WithHubbleURI(hubbleURI string) func(*V1Client) {
return func(v *V1Client) {
v.hubbleUri = hubbleUri
v.hubbleURI = hubbleURI
}
}

Expand All @@ -79,10 +78,10 @@ func WithInsecureSkipVerify(insecureSkipVerify bool) func(*V1Client) {
}
}

func WithScopeProject(projectUid string) func(*V1Client) {
func WithScopeProject(projectUID string) func(*V1Client) {
return func(v *V1Client) {
v.projectUid = projectUid
v.ctx = ContextForScope("project", projectUid)
v.projectUID = projectUID
v.ctx = ContextForScope("project", projectUID)
}
}

Expand Down Expand Up @@ -110,12 +109,12 @@ func WithTransportDebug() func(*V1Client) {
}
}

func ContextForScope(scope, projectUid string) context.Context {
func ContextForScope(scope, projectUID string) context.Context {
ctx := context.Background()
if scope == "project" {
ctx = context.WithValue(ctx, transport.CUSTOM_HEADERS, transport.Values{
HeaderMap: map[string]string{
"ProjectUid": projectUid,
"ProjectUid": projectUID,
}},
)
}
Expand All @@ -124,7 +123,7 @@ func ContextForScope(scope, projectUid string) context.Context {

func (h *V1Client) Clone() *V1Client {
opts := []func(*V1Client){
WithHubbleURI(h.hubbleUri),
WithHubbleURI(h.hubbleURI),
WithInsecureSkipVerify(h.insecureSkipVerify),
WithRetries(h.retryAttempts),
WithSchemes(h.schemes),
Expand All @@ -139,8 +138,8 @@ func (h *V1Client) Clone() *V1Client {
if h.username != "" && h.password != "" {
opts = append(opts, WithUsername(h.username), WithPassword(h.password))
}
if h.projectUid != "" {
opts = append(opts, WithScopeProject(h.projectUid))
if h.projectUID != "" {
opts = append(opts, WithScopeProject(h.projectUID))
}
if h.transportDebug {
opts = append(opts, WithTransportDebug())
Expand Down Expand Up @@ -196,7 +195,7 @@ func (h *V1Client) authenticate() error {
}

func (h *V1Client) baseTransport() *transport.Runtime {
httpTransport := transport.NewWithClient(h.hubbleUri, "", h.schemes, h.httpClient())
httpTransport := transport.NewWithClient(h.hubbleURI, "", h.schemes, h.httpClient())
httpTransport.RetryAttempts = h.retryAttempts
httpTransport.Debug = h.transportDebug
return httpTransport
Expand Down
31 changes: 17 additions & 14 deletions client/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func (h *V1Client) GetClusterByName(name string, virtual bool) (*models.V1Spectr
return cluster, nil
}

func (h *V1Client) GetClusterSummary(clusterId string) (*models.V1SpectroClusterUIDSummary, error) {
func (h *V1Client) GetClusterSummary(clusterID string) (*models.V1SpectroClusterUIDSummary, error) {
params := clientV1.NewV1SpectroClustersSummaryUIDParamsWithContext(h.ctx).
WithUID(clusterId)
WithUID(clusterID)
resp, err := h.Client.V1SpectroClustersSummaryUID(params)
if err != nil {
return nil, err
Expand Down Expand Up @@ -152,7 +152,7 @@ func (h *V1Client) GetClusterImportManifest(uid string) (string, error) {
return builder.String(), nil
}

func (h *V1Client) UpdateClusterProfileValues(uid, context string, profiles *models.V1SpectroClusterProfiles) error {
func (h *V1Client) UpdateClusterProfileValues(uid string, profiles *models.V1SpectroClusterProfiles) error {
params := clientV1.NewV1SpectroClustersUpdateProfilesParamsWithContext(h.ctx).
WithUID(uid).
WithBody(profiles).
Expand All @@ -173,21 +173,21 @@ func (h *V1Client) ImportClusterGeneric(meta *models.V1ObjectMetaInputEntity) (s
return *resp.Payload.UID, nil
}

func (h *V1Client) ApproveClusterRepave(clusterUid string) error {
func (h *V1Client) ApproveClusterRepave(clusterUID string) error {
params := clientV1.NewV1SpectroClustersUIDRepaveApproveUpdateParamsWithContext(h.ctx).
WithUID(clusterUid)
WithUID(clusterUID)
_, err := h.Client.V1SpectroClustersUIDRepaveApproveUpdate(params)
return err
}

func (h *V1Client) GetRepaveReasons(clusterUid string) ([]string, error) {
func (h *V1Client) GetRepaveReasons(clusterUID string) ([]string, error) {
params := clientV1.NewV1SpectroClustersUIDRepaveGetParamsWithContext(h.ctx).
WithUID(clusterUid)
WithUID(clusterUID)
resp, err := h.Client.V1SpectroClustersUIDRepaveGet(params)
if err != nil {
return nil, err
}
var reasons []string
reasons := make([]string, 0, len(resp.Payload.Spec.Reasons))
for _, r := range resp.Payload.Spec.Reasons {
reasons = append(reasons, fmt.Sprintf("Repave - Code: %s, Reason: %s", r.Code, r.Message))
}
Expand Down Expand Up @@ -252,8 +252,8 @@ func clusterNameEqFilter(name string) *models.V1SearchFilterItem {
}
}

func (h *V1Client) GetLogFetcherStatus(uid string, logFetcherUid *string) (*models.V1ClusterLogFetcher, error) {
params := clientV1.NewV1ClusterFeatureLogFetcherGetParamsWithContext(h.ctx).WithUID(uid).WithRequestID(logFetcherUid)
func (h *V1Client) GetLogFetcherStatus(uid string, logFetcherUID *string) (*models.V1ClusterLogFetcher, error) {
params := clientV1.NewV1ClusterFeatureLogFetcherGetParamsWithContext(h.ctx).WithUID(uid).WithRequestID(logFetcherUID)
resp, err := h.Client.V1ClusterFeatureLogFetcherGet(params)
if err != nil {
return nil, err
Expand All @@ -270,24 +270,27 @@ func (h *V1Client) InitiateDownloadOfClusterLogs(uid string, V1ClusterLogFetcher
return resp.GetPayload().UID, nil
}

func (h *V1Client) DownloadLogs(uid string, logFetcherUid string) (io.Writer, error) {
func (h *V1Client) DownloadLogs(uid string, logFetcherUID string) (io.Writer, error) {
filename := "logs-" + uid + ".zip"
params := clientV1.NewV1ClusterFeatureLogFetcherLogDownloadParamsWithContext(h.ctx).WithUID(logFetcherUid).WithFileName(&filename)
var buf bytes.Buffer
writer := io.Writer(&buf)

params := clientV1.NewV1ClusterFeatureLogFetcherLogDownloadParamsWithContext(h.ctx).WithUID(logFetcherUID).WithFileName(&filename)
resp, err := h.Client.V1ClusterFeatureLogFetcherLogDownload(params, writer)
if err != nil {
return nil, err
}
logfile := resp.GetPayload()
file_location := "/tmp/" + filename
fo, err := os.Create(filepath.Clean(file_location))

fileLocation := filepath.Join(os.TempDir(), filename)
fo, err := os.Create(filepath.Clean(fileLocation))
if err != nil {
return nil, fmt.Errorf("error while creating a file %v", err)
}
_, err = buf.WriteTo(fo)
if err != nil {
return nil, fmt.Errorf("error while writing log content to a file %v", err)
}

return logfile, nil
}
20 changes: 10 additions & 10 deletions client/cluster_aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ func (h *V1Client) CreateClusterAks(cluster *models.V1SpectroAzureClusterEntity)
return *resp.Payload.UID, nil
}

func (h *V1Client) CreateMachinePoolAks(cloudConfigUid string, machinePool *models.V1AzureMachinePoolConfigEntity) error {
func (h *V1Client) CreateMachinePoolAks(cloudConfigUID string, machinePool *models.V1AzureMachinePoolConfigEntity) error {
params := clientV1.NewV1CloudConfigsAksMachinePoolCreateParamsWithContext(h.ctx).
WithConfigUID(cloudConfigUid).
WithConfigUID(cloudConfigUID).
WithBody(machinePool)
_, err := h.Client.V1CloudConfigsAksMachinePoolCreate(params)
return err
}

func (h *V1Client) UpdateMachinePoolAks(cloudConfigUid string, machinePool *models.V1AzureMachinePoolConfigEntity) error {
func (h *V1Client) UpdateMachinePoolAks(cloudConfigUID string, machinePool *models.V1AzureMachinePoolConfigEntity) error {
params := clientV1.NewV1CloudConfigsAksMachinePoolUpdateParamsWithContext(h.ctx).
WithConfigUID(cloudConfigUid).
WithConfigUID(cloudConfigUID).
WithMachinePoolName(*machinePool.PoolConfig.Name).
WithBody(machinePool)
_, err := h.Client.V1CloudConfigsAksMachinePoolUpdate(params)
return err
}

func (h *V1Client) DeleteMachinePoolAks(cloudConfigUid, machinePoolName string) error {
func (h *V1Client) DeleteMachinePoolAks(cloudConfigUID, machinePoolName string) error {
params := clientV1.NewV1CloudConfigsAksMachinePoolDeleteParamsWithContext(h.ctx).
WithConfigUID(cloudConfigUid).
WithConfigUID(cloudConfigUID).
WithMachinePoolName(machinePoolName)
_, err := h.Client.V1CloudConfigsAksMachinePoolDelete(params)
return err
}

func (h *V1Client) GetCloudConfigAks(configUid string) (*models.V1AzureCloudConfig, error) {
func (h *V1Client) GetCloudConfigAks(configUID string) (*models.V1AzureCloudConfig, error) {
params := clientV1.NewV1CloudConfigsAksGetParamsWithContext(h.ctx).
WithConfigUID(configUid)
WithConfigUID(configUID)
resp, err := h.Client.V1CloudConfigsAksGet(params)
if apiutil.Is404(err) {
return nil, nil
Expand All @@ -56,9 +56,9 @@ func (h *V1Client) GetCloudConfigAks(configUid string) (*models.V1AzureCloudConf
return resp.Payload, nil
}

func (h *V1Client) GetNodeStatusMapAks(configUid, machinePoolName string) (map[string]models.V1CloudMachineStatus, error) {
func (h *V1Client) GetNodeStatusMapAks(configUID, machinePoolName string) (map[string]models.V1CloudMachineStatus, error) {
params := clientV1.NewV1CloudConfigsAksPoolMachinesListParamsWithContext(h.ctx).
WithConfigUID(configUid).
WithConfigUID(configUID).
WithMachinePoolName(machinePoolName)
mpList, err := h.Client.V1CloudConfigsAksPoolMachinesList(params)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions client/cluster_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@ func (h *V1Client) CreateClusterAws(cluster *models.V1SpectroAwsClusterEntity) (
return *resp.Payload.UID, nil
}

func (h *V1Client) CreateMachinePoolAws(cloudConfigUid string, machinePool *models.V1AwsMachinePoolConfigEntity) error {
func (h *V1Client) CreateMachinePoolAws(cloudConfigUID string, machinePool *models.V1AwsMachinePoolConfigEntity) error {
params := clientV1.NewV1CloudConfigsAwsMachinePoolCreateParamsWithContext(h.ctx).
WithConfigUID(cloudConfigUid).
WithConfigUID(cloudConfigUID).
WithBody(machinePool)
_, err := h.Client.V1CloudConfigsAwsMachinePoolCreate(params)
return err
}

func (h *V1Client) UpdateMachinePoolAws(cloudConfigUid string, machinePool *models.V1AwsMachinePoolConfigEntity) error {
func (h *V1Client) UpdateMachinePoolAws(cloudConfigUID string, machinePool *models.V1AwsMachinePoolConfigEntity) error {
params := clientV1.NewV1CloudConfigsAwsMachinePoolUpdateParamsWithContext(h.ctx).
WithConfigUID(cloudConfigUid).
WithConfigUID(cloudConfigUID).
WithMachinePoolName(*machinePool.PoolConfig.Name).
WithBody(machinePool)
_, err := h.Client.V1CloudConfigsAwsMachinePoolUpdate(params)
return err
}

func (h *V1Client) DeleteMachinePoolAws(cloudConfigUid, machinePoolName string) error {
func (h *V1Client) DeleteMachinePoolAws(cloudConfigUID, machinePoolName string) error {
params := clientV1.NewV1CloudConfigsAwsMachinePoolDeleteParamsWithContext(h.ctx).
WithConfigUID(cloudConfigUid).
WithConfigUID(cloudConfigUID).
WithMachinePoolName(machinePoolName)
_, err := h.Client.V1CloudConfigsAwsMachinePoolDelete(params)
return err
}

func (h *V1Client) GetCloudConfigAws(configUid string) (*models.V1AwsCloudConfig, error) {
func (h *V1Client) GetCloudConfigAws(configUID string) (*models.V1AwsCloudConfig, error) {
params := clientV1.NewV1CloudConfigsAwsGetParamsWithContext(h.ctx).
WithConfigUID(configUid)
WithConfigUID(configUID)
resp, err := h.Client.V1CloudConfigsAwsGet(params)
if apiutil.Is404(err) {
return nil, nil
Expand All @@ -66,9 +66,9 @@ func (h *V1Client) ImportClusterAws(meta *models.V1ObjectMetaInputEntity) (strin
return *resp.Payload.UID, nil
}

func (h *V1Client) GetNodeStatusMapAws(configUid, machinePoolName string) (map[string]models.V1CloudMachineStatus, error) {
func (h *V1Client) GetNodeStatusMapAws(configUID, machinePoolName string) (map[string]models.V1CloudMachineStatus, error) {
params := clientV1.NewV1CloudConfigsAwsPoolMachinesListParamsWithContext(h.ctx).
WithConfigUID(configUid).
WithConfigUID(configUID).
WithMachinePoolName(machinePoolName)
mpList, err := h.Client.V1CloudConfigsAwsPoolMachinesList(params)
if err != nil {
Expand Down
Loading

0 comments on commit 6183d09

Please sign in to comment.