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

feat(mock): add logic from go-vela/mock #229

Merged
merged 2 commits into from
Oct 29, 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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/go-vela/types v0.10.0
github.com/google/go-cmp v0.5.6
github.com/joho/godotenv v1.4.0
github.com/opencontainers/image-spec v1.0.1
github.com/prometheus/client_golang v1.11.0
github.com/sirupsen/logrus v1.8.1
github.com/urfave/cli/v2 v2.3.0
Expand Down
11 changes: 11 additions & 0 deletions mock/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2021 Target Brands, Inc. All rights reserved.
//
// Use of this source code is governed by the LICENSE file in this repository.

// Package mock provides a collection of mock
// packages used for a Vela worker.
//
// Usage:
//
// import "github.com/go-vela/worker/mock"
package mock
59 changes: 59 additions & 0 deletions mock/docker/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2021 Target Brands, Inc. All rights reserved.
//
// Use of this source code is governed by the LICENSE file in this repository.

package docker

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
5-59 lines are duplicate of mock/docker/secret.go:5-71 (dupl)


import (
"context"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
)

// ConfigService implements all the config
// related functions for the Docker mock.
type ConfigService struct{}

// ConfigCreate is a helper function to simulate
// a mocked call to create a config for a
// Docker swarm cluster.
func (c *ConfigService) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
line is 120 characters (lll)

return types.ConfigCreateResponse{}, nil
}

// ConfigInspectWithRaw is a helper function to simulate
// a mocked call to inspect a config for a Docker swarm
// cluster and return the raw body received from the API.
func (c *ConfigService) ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
line is 110 characters (lll)

return swarm.Config{}, nil, nil
}

// ConfigList is a helper function to simulate
// a mocked call to list the configs for a
// Docker swarm cluster.
func (c *ConfigService) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
line is 114 characters (lll)

return nil, nil
}

// ConfigRemove is a helper function to simulate
// a mocked call to remove a config for a
// Docker swarm cluster.
func (c *ConfigService) ConfigRemove(ctx context.Context, id string) error { return nil }

// ConfigUpdate is a helper function to simulate
// a mocked call to update a config for a
// Docker swarm cluster.
func (c *ConfigService) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
line is 124 characters (lll)

return nil
}

// WARNING: DO NOT REMOVE THIS UNDER ANY CIRCUMSTANCES
//
// This line serves as a quick and efficient way to ensure that our
// ImageService satisfies the ImageAPIClient interface that
// the Docker client expects.
//
// https://pkg.go.dev/github.com/docker/docker/client?tab=doc#ConfigAPIClient
var _ client.ConfigAPIClient = (*ConfigService)(nil)
Loading