Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressed couple of feedbacks from the list mentioned in #34 #48

Merged
merged 1 commit into from
Mar 10, 2021
Merged
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
8 changes: 4 additions & 4 deletions tink/client/hardware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tink/client/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tink/client/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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{}
Expand All @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tink/controllers/workflow/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down