Skip to content
Open
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
10 changes: 4 additions & 6 deletions cmd/image/qcow2ova/password-generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import (
)

// GeneratePassword generates the password of length n
func GeneratePassword(n int) (b64Password string, err error) {
func GeneratePassword(n int) (string, error) {
b := make([]byte, n)
_, err = rand.Read(b)
if err != nil {
return
if _, err := rand.Read(b); err != nil {
return "", err
}
b64Password = base64.URLEncoding.EncodeToString(b)
return
return base64.URLEncoding.EncodeToString(b), nil
}
27 changes: 18 additions & 9 deletions cmd/image/qcow2ova/validate/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,48 @@
package tools

import (
"fmt"
"os/exec"
"strings"

"k8s.io/klog/v2"
)

var commands = map[string]string{
var imageBinaries = map[string]string{
"qemu-img": "yum install qemu-img -y",
"growpart": "yum install cloud-utils-growpart -y",
}

type Rule struct {
failedCommand string
missingBins []string
}

func (p *Rule) String() string {
return "tools"
}

func (p *Rule) Verify() error {
for command := range commands {
path, err := exec.LookPath(command)
for binary := range imageBinaries {
path, err := exec.LookPath(binary)
if err != nil {
p.failedCommand = command
return err
p.missingBins = append(p.missingBins, binary)
} else {
klog.Infof("%s found at %s", binary, path)
}
klog.Infof("%s found at %s", command, path)
}
if len(p.missingBins) > 0 {
return fmt.Errorf("executable file(s) not found in $PATH: %s", strings.Join(p.missingBins, ", "))
}
return nil
}

func (p *Rule) Hint() string {
if p.failedCommand != "" {
return commands[p.failedCommand]
if len(p.missingBins) > 0 {
var hints []string
for _, binary := range p.missingBins {
hints = append(hints, imageBinaries[binary])
}
return strings.Join(hints, "\n")
}
return ""
}
3 changes: 1 addition & 2 deletions pkg/client/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/IBM-Cloud/power-go-client/ibmpisession"
"github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events"
"github.com/IBM/go-sdk-core/v5/core"
"github.com/ppc64le-cloud/pvsadm/pkg"
)

type Client struct {
Expand All @@ -38,6 +37,6 @@ func NewClient(sess *ibmpisession.IBMPISession, powerinstanceid string) *Client
}

func (c *Client) GetPcloudEventsGetsince(since time.Duration) (*p_cloud_events.PcloudEventsGetqueryOK, error) {
params := p_cloud_events.NewPcloudEventsGetqueryParamsWithTimeout(pkg.TIMEOUT).WithCloudInstanceID(c.instanceID).WithFromTime(core.StringPtr(time.Now().UTC().Add(-since).Format(time.RFC3339)))
params := p_cloud_events.NewPcloudEventsGetqueryParams().WithCloudInstanceID(c.instanceID).WithFromTime(core.StringPtr(time.Now().UTC().Add(-since).Format(time.RFC3339)))
return c.client.PcloudEventsGetquery(params, c.session.AuthInfo(c.instanceID))
}
21 changes: 0 additions & 21 deletions pkg/types.go

This file was deleted.