Skip to content

Commit

Permalink
Update kanister build v0.0.20 (#1676)
Browse files Browse the repository at this point in the history
* update makefile to use kanister build v0.0.19

* Fix linter issues

* after marks review

* use ReadDir output directly

* remove accidental error check

* gofmt fixes

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
bathina2 and mergify[bot] committed Oct 17, 2022
1 parent 00dde3b commit db036d5
Show file tree
Hide file tree
Showing 59 changed files with 135 additions and 283 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ IMAGE_NAME := $(BIN)

IMAGE := $(REGISTRY)/$(IMAGE_NAME)

BUILD_IMAGE ?= ghcr.io/kanisterio/build:v0.0.18
BUILD_IMAGE ?= ghcr.io/kanisterio/build:v0.0.20

# tag 0.1.0 is, 0.0.1 (latest) + gh + aws + helm binary
DOCS_BUILD_IMAGE ?= ghcr.io/kanisterio/docker-sphinx:0.2.0
Expand Down
2 changes: 1 addition & 1 deletion docker/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY --from=goreleaser/goreleaser:v1.2.4 /usr/local/bin/goreleaser /usr/local/bi

COPY --from=alpine/helm:3.2.0 /usr/bin/helm /usr/local/bin/

COPY --from=golangci/golangci-lint:v1.23.7 /usr/bin/golangci-lint /usr/local/bin/
COPY --from=golangci/golangci-lint:v1.50 /usr/bin/golangci-lint /usr/local/bin/

RUN wget -O /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64 \
&& chmod +x /usr/local/bin/kind
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kanisterio/kanister

go 1.17
go 1.19

replace (
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.1
Expand Down
111 changes: 0 additions & 111 deletions go.sum

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions pkg/app/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"time"
Expand Down Expand Up @@ -426,7 +425,7 @@ func (kc *KafkaCluster) Initialize(ctx context.Context) error {
return nil
}

//Message describes the response we get after consuming a topic
// Message describes the response we get after consuming a topic
type Message struct {
Topic string `json:"topic"`
Key string `json:"key"`
Expand Down Expand Up @@ -502,7 +501,7 @@ func (kc *KafkaCluster) InsertRecord(ctx context.Context, namespace string) erro
return errors.New("Error inserting records in topic")
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
bytes, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand Down Expand Up @@ -619,7 +618,7 @@ func createConsumerGroup(uri string) error {
return errors.New("Error creating consumer")
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
bytes, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand Down Expand Up @@ -652,7 +651,7 @@ func subscribe(uri string) error {
return errors.New("Error subscribing to the topic")
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
bytes, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand All @@ -676,7 +675,7 @@ func consumeMessage(uri string) (int, error) {
return 0, err
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
bytes, err := io.ReadAll(resp.Body)
if err != nil {
return 0, err
}
Expand Down
11 changes: 5 additions & 6 deletions pkg/app/mysql-deploymentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package app

import (
"context"
"fmt"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -123,7 +122,7 @@ func (mdep *MysqlDepConfig) GetClusterScopedResources(ctx context.Context) []crv
func (mdep *MysqlDepConfig) Ping(ctx context.Context) error {
log.Print("Pinging the application", field.M{"app": mdep.name})

pingCMD := []string{"bash", "-c", fmt.Sprintf("mysql -u root -e 'show databases;'")}
pingCMD := []string{"bash", "-c", "mysql -u root -e 'show databases;'"}
_, stderr, err := mdep.execCommand(ctx, pingCMD)
if err != nil {
return errors.Wrapf(err, "Error while Pinging the database %s, %s", stderr, err)
Expand All @@ -135,7 +134,7 @@ func (mdep *MysqlDepConfig) Ping(ctx context.Context) error {
func (mdep *MysqlDepConfig) Insert(ctx context.Context) error {
log.Print("Inserting some records in mysql instance.", field.M{"app": mdep.name})

insertRecordCMD := []string{"bash", "-c", fmt.Sprintf("mysql -u root -e 'use testdb; INSERT INTO pets VALUES (\"Puffball\",\"Diane\",\"hamster\",\"f\",\"1999-03-30\",NULL); '")}
insertRecordCMD := []string{"bash", "-c", "mysql -u root -e 'use testdb; INSERT INTO pets VALUES (\"Puffball\",\"Diane\",\"hamster\",\"f\",\"1999-03-30\",NULL); '"}
_, stderr, err := mdep.execCommand(ctx, insertRecordCMD)
if err != nil {
return errors.Wrapf(err, "Error while inserting the data into msyql deployment config database: %s", stderr)
Expand All @@ -148,7 +147,7 @@ func (mdep *MysqlDepConfig) Insert(ctx context.Context) error {
func (mdep *MysqlDepConfig) Count(ctx context.Context) (int, error) {
log.Print("Counting the records from the mysql instance.", field.M{"app": mdep.name})

selectRowsCMD := []string{"bash", "-c", fmt.Sprintf("mysql -u root -e 'use testdb; select count(*) from pets; '")}
selectRowsCMD := []string{"bash", "-c", "mysql -u root -e 'use testdb; select count(*) from pets; '"}
stdout, stderr, err := mdep.execCommand(ctx, selectRowsCMD)
if err != nil {
return 0, errors.Wrapf(err, "Error while counting the data of the database: %s", stderr)
Expand All @@ -168,14 +167,14 @@ func (mdep *MysqlDepConfig) Reset(ctx context.Context) error {
log.Print("Resetting the mysql instance.", field.M{"app": "mysql"})

// delete all the data from the table
deleteCMD := []string{"bash", "-c", fmt.Sprintf("mysql -u root -e 'DROP DATABASE IF EXISTS testdb'")}
deleteCMD := []string{"bash", "-c", "mysql -u root -e 'DROP DATABASE IF EXISTS testdb'"}
_, stderr, err := mdep.execCommand(ctx, deleteCMD)
if err != nil {
return errors.Wrapf(err, "Error while dropping the mysql table: %s", stderr)
}

// create the database and a pets table
createCMD := []string{"bash", "-c", fmt.Sprintf("mysql -u root -e 'create database testdb; use testdb; CREATE TABLE pets (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);'")}
createCMD := []string{"bash", "-c", "mysql -u root -e 'create database testdb; use testdb; CREATE TABLE pets (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);'"}
_, stderr, err = mdep.execCommand(ctx, createCMD)
if err != nil {
return errors.Wrapf(err, "Error while creating the mysql table: %s", stderr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/postgresql-deploymentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (pgres *PostgreSQLDepConfig) Ping(ctx context.Context) error {
}

func (pgres *PostgreSQLDepConfig) Insert(ctx context.Context) error {
cmd := fmt.Sprintf("psql -d test -c \"INSERT INTO COMPANY (NAME,AGE,CREATED_AT) VALUES ('foo', 32, now());\"")
cmd := "psql -d test -c \"INSERT INTO COMPANY (NAME,AGE,CREATED_AT) VALUES ('foo', 32, now());\""
_, stderr, err := pgres.execCommand(ctx, []string{"bash", "-c", cmd})
if err != nil {
return errors.Wrapf(err, "Failed to create db in postgresql deployment config. %s", stderr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (pdb *PostgresDB) Ping(ctx context.Context) error {
}

func (pdb PostgresDB) Insert(ctx context.Context) error {
cmd := fmt.Sprintf("PGPASSWORD=${POSTGRES_PASSWORD} psql -d test -c \"INSERT INTO COMPANY (NAME,AGE,CREATED_AT) VALUES ('foo', 32, now());\"")
cmd := "PGPASSWORD=${POSTGRES_PASSWORD} psql -d test -c \"INSERT INTO COMPANY (NAME,AGE,CREATED_AT) VALUES ('foo', 32, now());\""
_, stderr, err := pdb.execCommand(ctx, []string{"sh", "-c", cmd})
if err != nil {
return errors.Wrapf(err, "Failed to create db in postgresql. %s", stderr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
dbTemplateURI = "https://raw.githubusercontent.com/openshift/origin/%s/examples/db-templates/%s-%s-template.json"
// PersistentStorage can be used if we want to deploy database with Persistent Volumes
PersistentStorage storage = "persistent" // nolint:varcheck
PersistentStorage storage = "persistent" //nolint:varcheck

// EphemeralStorage can be used if we don't want to deploy database with Persistent
EphemeralStorage storage = "ephemeral"
Expand Down
19 changes: 0 additions & 19 deletions pkg/blockstorage/awsebs/awsebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,25 +689,6 @@ func (s *EbsStorage) GetRegions(ctx context.Context) ([]string, error) {
return regions, nil
}

func (s *EbsStorage) queryRegionToZones(ctx context.Context, region string) ([]string, error) {
ec2Cli, err := newEC2Client(region, s.Ec2Cli.Config.Copy())
if err != nil {
return nil, errors.Wrapf(err, "Could not get EC2 client")
}
dazi := &ec2.DescribeAvailabilityZonesInput{}
dazo, err := ec2Cli.DescribeAvailabilityZonesWithContext(ctx, dazi)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get AZs for region %s", region)
}
azs := make([]string, 0, len(dazo.AvailabilityZones))
for _, az := range dazo.AvailabilityZones {
if az.ZoneName != nil {
azs = append(azs, *az.ZoneName)
}
}
return azs, nil
}

// SnapshotRestoreTargets is part of blockstorage.RestoreTargeter
func (s *EbsStorage) SnapshotRestoreTargets(ctx context.Context, snapshot *blockstorage.Snapshot) (global bool, regionsAndZones map[string][]string, err error) {
// A few checks from VolumeCreateFromSnapshot
Expand Down
13 changes: 0 additions & 13 deletions pkg/blockstorage/awsebs/awsebs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/service/ec2"
. "gopkg.in/check.v1"

Expand All @@ -38,18 +37,6 @@ type AWSEBSSuite struct{}

var _ = Suite(&AWSEBSSuite{})

func (s AWSEBSSuite) TestQueryRegionToZones(c *C) {
c.Skip("Only works on AWS")
ctx := context.Background()
region := "us-east-1"
ec2Cli, err := newEC2Client(region, aws.NewConfig().WithCredentials(credentials.NewEnvCredentials()))
c.Assert(err, IsNil)
provider := &EbsStorage{Ec2Cli: ec2Cli}
zs, err := provider.queryRegionToZones(ctx, region)
c.Assert(err, IsNil)
c.Assert(zs, DeepEquals, []string{"us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-east-1f"})
}

func (s AWSEBSSuite) TestVolumeParse(c *C) {
expected := blockstorage.Volume{
Az: "the-availability-zone",
Expand Down
4 changes: 2 additions & 2 deletions pkg/blockstorage/azure/azure_instance_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package azure

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"

"github.com/pkg/errors"
Expand Down Expand Up @@ -112,5 +112,5 @@ func (i *InstanceMetadata) queryMetadataBytes(path, format string) ([]byte, erro
return nil, errors.Errorf("Failed to get instance metadata with statusCode: %d, Path: %s", resp.StatusCode, path)
}
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}
8 changes: 6 additions & 2 deletions pkg/blockstorage/azure/azuredisk.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// TODO: Switch to using the latest azure sdk and remove nolint.
// Related Ticket- https://github.com/kanisterio/kanister/issues/1684
//
//nolint:staticcheck
package azure

import (
Expand Down Expand Up @@ -335,7 +339,7 @@ const (
var diskIDRe = regexp.MustCompile(diskIDRegEx)
var snapIDRe = regexp.MustCompile(snapshotIDRegEx)

// nolint:unparam
//nolint:unparam
func parseDiskID(id string) (subscription string, resourceGroup string, name string, err error) {
comps := diskIDRe.FindStringSubmatch(id)
if len(comps) != 4 {
Expand All @@ -344,7 +348,7 @@ func parseDiskID(id string) (subscription string, resourceGroup string, name str
return comps[1], comps[2], comps[3], nil
}

// nolint:unparam
//nolint:unparam
func parseSnapshotID(id string) (subscription string, resourceGroup string, name string, err error) {
comps := snapIDRe.FindStringSubmatch(id)
if len(comps) != 4 {
Expand Down
6 changes: 5 additions & 1 deletion pkg/blockstorage/azure/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// TODO: Switch to using the latest azure sdk and remove nolint.
// Related Ticket- https://github.com/kanisterio/kanister/issues/168
//
//nolint:staticcheck
package azure

import (
Expand Down Expand Up @@ -96,7 +100,7 @@ func NewClient(ctx context.Context, config map[string]string) (*Client, error) {
}, nil
}

// nolint:unparam
//nolint:unparam
func getAuthorizer(env azure.Environment, config map[string]string) (*autorest.BearerAuthorizer, error) {
if isClientCredsAvailable(config) {
return getClientCredsAuthorizer(env, config)
Expand Down
3 changes: 1 addition & 2 deletions pkg/blockstorage/gcepd/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package gcepd
import (
"context"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
Expand All @@ -39,7 +38,7 @@ func (s *ClientSuite) SetUpSuite(c *C) {}
func (s *ClientSuite) TestClient(c *C) {
var zone string
filename := s.GetEnvOrSkip(c, blockstorage.GoogleCloudCreds)
b, err := ioutil.ReadFile(filename)
b, err := os.ReadFile(filename)
c.Assert(err, IsNil)
gCli, err := NewClient(context.Background(), string(b))
c.Assert(err, IsNil)
Expand Down
6 changes: 3 additions & 3 deletions pkg/blockstorage/ibm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ var (
}
)

//client is a wrapper for Library client
// client is a wrapper for Library client
type client struct {
Service ibmprov.Session
SLCfg ibmcfg.SoftlayerConfig
}

//newClient returns a Client struct
// newClient returns a Client struct
func newClient(ctx context.Context, args map[string]string) (*client, error) {
return handleClientPanic(func() (*client, error) {
return newClientUnsafe(ctx, args)
Expand All @@ -99,7 +99,7 @@ func handleClientPanic(f func() (*client, error)) (c *client, err error) {
// newClientUnsafe may panic. See https://github.com/IBM/ibmcloud-storage-volume-lib/issues/79
func newClientUnsafe(ctx context.Context, args map[string]string) (*client, error) {
zaplog, _ := zap.NewProduction()
defer zaplog.Sync() // nolint: errcheck
defer zaplog.Sync() //nolint: errcheck

cfg, err := findDefaultConfig(ctx, args, zaplog)
if err != nil || cfg.Softlayer == nil {
Expand Down
5 changes: 2 additions & 3 deletions pkg/blockstorage/ibm/client_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package ibm

import (
"context"
"io/ioutil"
"os"

. "gopkg.in/check.v1"
Expand Down Expand Up @@ -47,7 +46,7 @@ func (s *KubeTestIBMClient) SetUpSuite(c *C) {
var secData []byte
var err error
if tomlPath, ok := os.LookupEnv(workAroundEnv); ok {
secData, err = ioutil.ReadFile(tomlPath)
secData, err = os.ReadFile(tomlPath)
c.Assert(err, IsNil)
} else {
c.Skip(workAroundEnv + " TOML path is not present")
Expand Down Expand Up @@ -97,7 +96,7 @@ func (s KubeTestIBMClient) TestIBMOldSecret(c *C) {
err := os.Unsetenv(IBMApiKeyEnv)
c.Assert(err, IsNil)
defer os.Setenv(IBMApiKeyEnv, apiKey)
secData, err := ioutil.ReadFile(oldTestTomlPath)
secData, err := os.ReadFile(oldTestTomlPath)
c.Assert(err, IsNil)
secretData := make(map[string][]byte)
secretData[IBMK8sSecretData] = secData
Expand Down
2 changes: 1 addition & 1 deletion pkg/blockstorage/ibm/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
IBMSLApiUsernameEnv = "IBM_SL_API_USERNAME"
)

//These are not executed as part of Pipeline, but usefull for development
// These are not executed as part of Pipeline, but usefull for development
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }

Expand Down
4 changes: 3 additions & 1 deletion pkg/blockstorage/ibm/ibmcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func (s *ibmCloud) volumeParse(ctx context.Context, vol *ibmprov.Volume) (*block
}
attribs[LunIDAttName] = vol.LunID

if len(vol.IscsiTargetIPAddresses) < 0 {
// TODO: Fix issue where we don't catch the error uf vol.IscsiTargetIPAddresses is empty
// Related ticket - https://github.com/kanisterio/kanister/issues/1683
if len(vol.IscsiTargetIPAddresses) < 0 { //nolint:staticcheck
return nil, errors.New("IscsiTargetIPAddresses are missing from Volume info")
}
if len(vol.Attributes) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/blockstorage/ibm/ibmcloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type TestIBMCloud struct {
volAtts map[string]string
}

//These are not executed as part of Pipeline, but usefull for development
// These are not executed as part of Pipeline, but usefull for development
var softlayerVolAtts = map[string]string{
ProviderTypeAttName: string(ibmprov.VolumeProviderType("endurance")),
TierAttName: "2",
Expand Down Expand Up @@ -131,7 +131,7 @@ func (s TestIBMCloud) TestVolRestore(c *C) {
c.Assert(err, IsNil)
snapTTags := map[string]string{"ibmblock_unit_test_snap": fmt.Sprintf("test-snap-%d", time.Now().Unix())}
bsSnap, err := s.provider.SnapshotCreate(context.Background(), *bsVol, snapTTags)
defer s.provider.SnapshotDelete(context.Background(), bsSnap) // nolint: errcheck
defer s.provider.SnapshotDelete(context.Background(), bsSnap) //nolint: errcheck
c.Assert(err, IsNil)
tTags := map[string]string{"ibmblock_unit_test_restore_vol": fmt.Sprintf("test-vol-%d", time.Now().Unix())}
resVol, err := s.provider.VolumeCreateFromSnapshot(context.Background(), *bsSnap, tTags)
Expand Down
1 change: 1 addition & 0 deletions pkg/blockstorage/vmware/vmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ func (ge govmomiError) Format() string {
return fmt.Sprintf("[%s]", strings.Join(msgs, "; "))
}

//nolint:gocognit
func (ge govmomiError) ExtractMessages() []string {
err := ge.err

Expand Down
Loading

0 comments on commit db036d5

Please sign in to comment.