From db99a289b6439f439f555cf122d9b858ca83d0f5 Mon Sep 17 00:00:00 2001 From: parauliya Date: Wed, 10 Mar 2021 18:11:40 +0530 Subject: [PATCH] Addressed couple of feedbacks from the list mentioned in #34 Signed-off-by: parauliya --- tink/client/hardware.go | 8 ++++---- tink/client/template.go | 8 ++++---- tink/client/workflow.go | 20 ++++++++++---------- tink/controllers/workflow/controller.go | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tink/client/hardware.go b/tink/client/hardware.go index 783ee472..4fa234e5 100644 --- a/tink/client/hardware.go +++ b/tink/client/hardware.go @@ -47,7 +47,7 @@ func (t *Hardware) Create(ctx context.Context, h *hardware.Hardware) error { } if _, err := t.client.Push(ctx, &hardware.PushRequest{Data: h}); err != nil { - return fmt.Errorf("failed to create hardware in Tinkerbell: %w", err) + return fmt.Errorf("creating hardware in Tinkerbell: %w", err) } return nil @@ -56,7 +56,7 @@ func (t *Hardware) Create(ctx context.Context, h *hardware.Hardware) error { // Update Tinkerbell Hardware. func (t *Hardware) Update(ctx context.Context, h *hardware.Hardware) error { if _, err := t.client.Push(ctx, &hardware.PushRequest{Data: h}); err != nil { - return fmt.Errorf("failed to update template in Tinkerbell: %w", err) + return fmt.Errorf("updating template in Tinkerbell: %w", err) } return nil @@ -88,7 +88,7 @@ func (t *Hardware) Get(ctx context.Context, id, ip, mac string) (*hardware.Hardw return nil, fmt.Errorf("hardware %w", ErrNotFound) } - return nil, fmt.Errorf("failed to get hardware from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting hardware from Tinkerbell: %w", err) } return tinkHardware, nil @@ -101,7 +101,7 @@ func (t *Hardware) Delete(ctx context.Context, id string) error { return fmt.Errorf("hardware %w", ErrNotFound) } - return fmt.Errorf("failed to delete hardware from Tinkerbell: %w", err) + return fmt.Errorf("deleting hardware from Tinkerbell: %w", err) } return nil diff --git a/tink/client/template.go b/tink/client/template.go index 81d406a3..02a27c30 100644 --- a/tink/client/template.go +++ b/tink/client/template.go @@ -48,7 +48,7 @@ func (t *Template) Get(ctx context.Context, id, name string) (*template.Workflow return nil, fmt.Errorf("template %w", ErrNotFound) } - return nil, fmt.Errorf("failed to get template from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting template from Tinkerbell: %w", err) } return tinkTemplate, nil @@ -57,7 +57,7 @@ func (t *Template) Get(ctx context.Context, id, name string) (*template.Workflow // Update a Tinkerbell Template. func (t *Template) Update(ctx context.Context, template *template.WorkflowTemplate) error { if _, err := t.client.UpdateTemplate(ctx, template); err != nil { - return fmt.Errorf("failed to update template in Tinkerbell: %w", err) + return fmt.Errorf("updating template in Tinkerbefll: %w", err) } return nil @@ -67,7 +67,7 @@ func (t *Template) Update(ctx context.Context, template *template.WorkflowTempla func (t *Template) Create(ctx context.Context, template *template.WorkflowTemplate) error { resp, err := t.client.CreateTemplate(ctx, template) if err != nil { - return fmt.Errorf("failed to create template in Tinkerbell: %w", err) + return fmt.Errorf("creating template in Tinkerbell: %w", err) } template.Id = resp.GetId() @@ -85,7 +85,7 @@ func (t *Template) Delete(ctx context.Context, id string) error { return fmt.Errorf("template %w", ErrNotFound) } - return fmt.Errorf("failed to delete template from Tinkerbell: %w", err) + return fmt.Errorf("deleting template from Tinkerbell: %w", err) } return nil diff --git a/tink/client/workflow.go b/tink/client/workflow.go index b96f1c46..48a78365 100644 --- a/tink/client/workflow.go +++ b/tink/client/workflow.go @@ -46,7 +46,7 @@ func (t *Workflow) Get(ctx context.Context, id string) (*workflow.Workflow, erro return nil, fmt.Errorf("workflow %w", ErrNotFound) } - return nil, fmt.Errorf("failed to get workflow from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting workflow from Tinkerbell: %w", err) } return tinkWorkflow, nil @@ -62,7 +62,7 @@ func (t *Workflow) GetMetadata(ctx context.Context, id string) ([]byte, error) { return nil, fmt.Errorf("workflow %w", ErrNotFound) } - return nil, fmt.Errorf("failed to get workflow version from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting workflow version from Tinkerbell: %w", err) } req := &workflow.GetWorkflowDataRequest{WorkflowId: id, Version: verResp.GetVersion()} @@ -73,7 +73,7 @@ func (t *Workflow) GetMetadata(ctx context.Context, id string) ([]byte, error) { return nil, fmt.Errorf("workflow %w", ErrNotFound) } - return nil, fmt.Errorf("failed to get workflow metadata from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting workflow metadata from Tinkerbell: %w", err) } return resp.GetData(), nil @@ -89,7 +89,7 @@ func (t *Workflow) GetActions(ctx context.Context, id string) ([]*workflow.Workf return nil, fmt.Errorf("workflow %w", ErrNotFound) } - return nil, fmt.Errorf("failed to get workflow actions from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting workflow actions from Tinkerbell: %w", err) } return resp.GetActionList(), nil @@ -105,7 +105,7 @@ func (t *Workflow) GetEvents(ctx context.Context, id string) ([]*workflow.Workfl return nil, fmt.Errorf("workflow %w", ErrNotFound) } - return nil, fmt.Errorf("failed to get workflow events from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting workflow events from Tinkerbell: %w", err) } result := []*workflow.WorkflowActionStatus{} @@ -117,7 +117,7 @@ func (t *Workflow) GetEvents(ctx context.Context, id string) ([]*workflow.Workfl } if err != nil { - return nil, fmt.Errorf("failed to get workflow event from Tinkerbell: %w", err) + return nil, fmt.Errorf("getting workflow event from Tinkerbell: %w", err) } result = append(result, e) @@ -136,7 +136,7 @@ func (t *Workflow) GetState(ctx context.Context, id string) (workflow.State, err return 0, fmt.Errorf("workflow %w", ErrNotFound) } - return 0, fmt.Errorf("failed to get workflow state from Tinkerbell: %w", err) + return 0, fmt.Errorf("getting workflow state from Tinkerbell: %w", err) } currIndex := resp.GetCurrentActionIndex() @@ -180,7 +180,7 @@ func (t *Workflow) Create(ctx context.Context, templateID, hardwareID string) (s resp, err := t.client.CreateWorkflow(ctx, req) if err != nil { - return "", fmt.Errorf("failed to create workflow in Tinkerbell: %w", err) + return "", fmt.Errorf("creating workflow in Tinkerbell: %w", err) } return resp.GetId(), nil @@ -193,7 +193,7 @@ func (t *Workflow) Delete(ctx context.Context, id string) error { return fmt.Errorf("workflow %w", ErrNotFound) } - return fmt.Errorf("failed to delete workflow from Tinkerbell: %w", err) + return fmt.Errorf("deleting workflow from Tinkerbell: %w", err) } return nil @@ -213,7 +213,7 @@ func HardwareToJSON(h *hardware.Hardware) (string, error) { hardwareJSON, err := json.Marshal(hardwareInfo) if err != nil { - return "", fmt.Errorf("failed to marshal hardware info into json: %w", err) + return "", fmt.Errorf("marshaling hardware info into json: %w", err) } return string(hardwareJSON), nil diff --git a/tink/controllers/workflow/controller.go b/tink/controllers/workflow/controller.go index 2e07087c..d7a8c324 100644 --- a/tink/controllers/workflow/controller.go +++ b/tink/controllers/workflow/controller.go @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package controllers contains controllers for Tinkerbell. -package controllers +// Package workflow contains controllers for Tinkerbell workflow. +package workflow import ( "context"