-
Notifications
You must be signed in to change notification settings - Fork 9
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 | ||
|
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
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) |
There was a problem hiding this comment.
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)