Skip to content

Commit

Permalink
fix: codeql warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dacleyra committed Oct 31, 2023
1 parent 43b9c17 commit ebb748a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
3 changes: 3 additions & 0 deletions pkg/bundle/bundle_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func (f *BundleFile) open(fileName string) error {
}

info, err := file.Stat()
if err != nil {
return err
}

// if the tar file has been written to previously, we need to remove the last
// 1024 bytes to append new files
Expand Down
11 changes: 0 additions & 11 deletions pkg/clients/ilmt/ilmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -89,33 +88,28 @@ func (ilmtC *ilmtClient) FetchUsageData(ctx context.Context, dateRange DateRange
urlForStandaloneProductUsage, err := ilmtC.req.FetchUsageData(ctx, ilmtC.IlmtConfig.Host, ilmtC.IlmtConfig.Token, CRITERIA_STANDALONE, strings.Split(selectedDate.String(), BLANK_VALUE)[0], strings.Split(selectedDate.String(), BLANK_VALUE)[0])
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

urlForProductPartOfBndlUsage, err := ilmtC.req.FetchUsageData(ctx, ilmtC.IlmtConfig.Host, ilmtC.IlmtConfig.Token, CRITEIRA_PRODUCTPARTOFBNDL, strings.Split(selectedDate.String(), BLANK_VALUE)[0], strings.Split(selectedDate.String(), BLANK_VALUE)[0])
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

urlForParentProductUsage, err := ilmtC.req.FetchUsageData(ctx, ilmtC.IlmtConfig.Host, ilmtC.IlmtConfig.Token, CRITERIA_PARENTPRODUCT, strings.Split(selectedDate.String(), BLANK_VALUE)[0], strings.Split(selectedDate.String(), BLANK_VALUE)[0])
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

// licence usage for product
standaloneProductResp, err := ilmtC.Do(urlForStandaloneProductUsage)

if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

standaloneProductRespData, err := ioutil.ReadAll(standaloneProductResp.Body)
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

var standaloneProductRespObj StandaloneProductResp
Expand All @@ -125,13 +119,11 @@ func (ilmtC *ilmtClient) FetchUsageData(ctx context.Context, dateRange DateRange
productPartOfBndlResp, err := ilmtC.Do(urlForProductPartOfBndlUsage)
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

productPartOfBndlRespData, err := ioutil.ReadAll(productPartOfBndlResp.Body)
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

var productPartOfBndlRespObj ProductPartOfBndlResp
Expand All @@ -141,13 +133,11 @@ func (ilmtC *ilmtClient) FetchUsageData(ctx context.Context, dateRange DateRange
parentProductResp, err := ilmtC.Do(urlForParentProductUsage)
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

parentProductRespData, err := ioutil.ReadAll(parentProductResp.Body)
if err != nil {
log.Fatal(err.Error())
return -1, EMPTY, err
}

var parentProductRespObj ParentProductResp
Expand Down Expand Up @@ -206,7 +196,6 @@ func (ilmtC *ilmtClient) FetchUsageData(ctx context.Context, dateRange DateRange
parentProductId, parentProductName, metricId, err := GetParentProduct(prodPartOfBundle, parentProductRespObj)
if err != nil {
log.Fatal(err.Error())
os.Exit(1)
}
host := ilmtC.IlmtConfig.Host[8:38]
BELL := '\a'
Expand Down
3 changes: 3 additions & 0 deletions pkg/clients/marketplace/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ func (r *marketplaceMetricClient) makeFormFile(fileName string, file []byte) (fo
func (r *marketplaceMetricClient) uploadFile(ctx context.Context, form []byte, formContent string) (id string, err error) {
var req *http.Request
req, err = http.NewRequestWithContext(ctx, "POST", fmt.Sprintf(marketplaceMetricsPath, r.client.URL), bytes.NewReader(form))
if err != nil {
return "", err
}
req.Header.Set("Content-Type", formContent)

// Perform the request
Expand Down
3 changes: 3 additions & 0 deletions pkg/datactl/config/client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func (config *DirectClientConfig) RawConfig() (*datactlapi.Config, error) {

func (config *DirectClientConfig) MarketplaceClientConfig() (*marketplace.MarketplaceConfig, error) {
mktplConfig, err := clients.ProvideMarketplaceUpload(&config.config)
if err != nil {
return nil, err
}

logger.Info("TLS", "MinVersion", config.overrides.MinVersion)
tlsVersion, err := k8sapiflag.TLSVersion(config.overrides.MinVersion)
Expand Down
4 changes: 3 additions & 1 deletion pkg/datactl/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ func writeConfig(
return err
}
writeFile, err := mutate(currConfig)

if err != nil {
return err
}
if !writeFile {
return nil
}
Expand Down

0 comments on commit ebb748a

Please sign in to comment.