mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-27 15:41:35 +01:00
Coding style
This commit is contained in:
@@ -182,7 +182,6 @@ func (di *Diun) getRegOpts(id string) (model.RegOpts, error) {
|
||||
}
|
||||
if regopts, ok := di.cfg.RegOpts[id]; ok {
|
||||
return regopts, nil
|
||||
} else {
|
||||
return model.RegOpts{}, fmt.Errorf("%s not found", id)
|
||||
}
|
||||
return model.RegOpts{}, fmt.Errorf("%s not found", id)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ type Image struct {
|
||||
ExcludeTags []string `yaml:"exclude_tags,omitempty" json:",omitempty"`
|
||||
}
|
||||
|
||||
// Image status constants
|
||||
const (
|
||||
ImageStatusNew = ImageStatus("new")
|
||||
ImageStatusUpdate = ImageStatus("update")
|
||||
|
||||
@@ -10,7 +10,7 @@ type Providers struct {
|
||||
// PrdDocker holds docker provider configuration
|
||||
type PrdDocker struct {
|
||||
Endpoint string `yaml:"endpoint,omitempty" json:",omitempty"`
|
||||
ApiVersion string `yaml:"api_version,omitempty" json:",omitempty"`
|
||||
APIVersion string `yaml:"api_version,omitempty" json:",omitempty"`
|
||||
TLSCertsPath string `yaml:"tls_certs_path,omitempty" json:",omitempty"`
|
||||
TLSVerify bool `yaml:"tls_verify,omitempty" json:",omitempty"`
|
||||
WatchByDefault bool `yaml:"watch_by_default,omitempty" json:",omitempty"`
|
||||
@@ -20,7 +20,7 @@ type PrdDocker struct {
|
||||
// PrdSwarm holds swarm provider configuration
|
||||
type PrdSwarm struct {
|
||||
Endpoint string `yaml:"endpoint,omitempty" json:",omitempty"`
|
||||
ApiVersion string `yaml:"api_version,omitempty" json:",omitempty"`
|
||||
APIVersion string `yaml:"api_version,omitempty" json:",omitempty"`
|
||||
TLSCertsPath string `yaml:"tls_certs_path,omitempty" json:",omitempty"`
|
||||
TLSVerify bool `yaml:"tls_verify,omitempty" json:",omitempty"`
|
||||
WatchByDefault bool `yaml:"watch_by_default,omitempty" json:",omitempty"`
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/crazy-max/diun/internal/model"
|
||||
)
|
||||
|
||||
// ValidateContainerImage returns a standard image through Docker labels
|
||||
func ValidateContainerImage(image string, labels map[string]string, watchByDef bool) (img model.Image, err error) {
|
||||
if i := strings.Index(image, "@sha256:"); i > 0 {
|
||||
image = image[:i]
|
||||
|
||||
@@ -16,7 +16,7 @@ func (c *Client) listContainerImage(id string, elt model.PrdDocker) []model.Imag
|
||||
Str("provider", fmt.Sprintf("docker-%s", id)).
|
||||
Logger()
|
||||
|
||||
cli, err := docker.NewClient(elt.Endpoint, elt.ApiVersion, elt.TLSCertsPath, elt.TLSVerify)
|
||||
cli, err := docker.NewClient(elt.Endpoint, elt.APIVersion, elt.TLSCertsPath, elt.TLSVerify)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("Cannot create Docker client")
|
||||
return []model.Image{}
|
||||
|
||||
@@ -16,7 +16,7 @@ func (c *Client) listServiceImage(id string, elt model.PrdSwarm) []model.Image {
|
||||
Str("provider", fmt.Sprintf("swarm-%s", id)).
|
||||
Logger()
|
||||
|
||||
cli, err := docker.NewClient(elt.Endpoint, elt.ApiVersion, elt.TLSCertsPath, elt.TLSVerify)
|
||||
cli, err := docker.NewClient(elt.Endpoint, elt.APIVersion, elt.TLSCertsPath, elt.TLSVerify)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("Cannot create Docker client")
|
||||
return []model.Image{}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// Client represents an active docker object
|
||||
type Client struct {
|
||||
ctx context.Context
|
||||
Api *client.Client
|
||||
API *client.Client
|
||||
}
|
||||
|
||||
// NewClient initializes a new Docker API client with default values
|
||||
@@ -56,6 +56,6 @@ func NewClient(endpoint, apiVersion, tlsCertsPath string, tlsVerify bool) (*Clie
|
||||
|
||||
return &Client{
|
||||
ctx: ctx,
|
||||
Api: cli,
|
||||
API: cli,
|
||||
}, err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ContainerList returns Docker containers
|
||||
func (c *Client) ContainerList(filterArgs filters.Args) ([]types.Container, error) {
|
||||
containers, err := c.Api.ContainerList(c.ctx, types.ContainerListOptions{
|
||||
containers, err := c.API.ContainerList(c.ctx, types.ContainerListOptions{
|
||||
Filters: filterArgs,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
// ServiceList returns Swarm services
|
||||
func (c *Client) ServiceList(filterArgs filters.Args) ([]swarm.Service, error) {
|
||||
services, err := c.Api.ServiceList(c.ctx, types.ServiceListOptions{
|
||||
services, err := c.API.ServiceList(c.ctx, types.ServiceListOptions{
|
||||
Filters: filterArgs,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user