summaryrefslogtreecommitdiff
path: root/cmd/podman/remoteclientconfig/configfile.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-16 14:04:58 -0700
committerGitHub <noreply@github.com>2020-04-16 14:04:58 -0700
commit0d2b5532c417c58bd24e71a56c5c55b43e423a59 (patch)
tree4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/remoteclientconfig/configfile.go
parent88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff)
parent241326a9a8c20ad7f2bcf651416b836e7778e090 (diff)
downloadpodman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.gz
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.bz2
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.zip
Merge pull request #5852 from baude/v1prune
Podman V2 birth
Diffstat (limited to 'cmd/podman/remoteclientconfig/configfile.go')
-rw-r--r--cmd/podman/remoteclientconfig/configfile.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/cmd/podman/remoteclientconfig/configfile.go b/cmd/podman/remoteclientconfig/configfile.go
deleted file mode 100644
index 56a868733..000000000
--- a/cmd/podman/remoteclientconfig/configfile.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package remoteclientconfig
-
-import (
- "io"
-
- "github.com/BurntSushi/toml"
- "github.com/pkg/errors"
-)
-
-// ReadRemoteConfig takes an io.Reader representing the remote configuration
-// file and returns a remoteconfig
-func ReadRemoteConfig(reader io.Reader) (*RemoteConfig, error) {
- var remoteConfig RemoteConfig
- // the configuration file does not exist
- if reader == nil {
- return &remoteConfig, ErrNoConfigationFile
- }
- _, err := toml.DecodeReader(reader, &remoteConfig)
- if err != nil {
- return nil, err
- }
- // We need to validate each remote connection has fields filled out
- for name, conn := range remoteConfig.Connections {
- if len(conn.Destination) < 1 {
- return nil, errors.Errorf("connection %q has no destination defined", name)
- }
- }
- return &remoteConfig, err
-}
-
-// GetDefault returns the default RemoteConnection. If there is only one
-// connection, we assume it is the default as well
-func (r *RemoteConfig) GetDefault() (*RemoteConnection, error) {
- if len(r.Connections) == 0 {
- return nil, ErrNoDefinedConnections
- }
- for _, v := range r.Connections {
- v := v
- if len(r.Connections) == 1 {
- // if there is only one defined connection, we assume it is
- // the default whether tagged as such or not
- return &v, nil
- }
- if v.IsDefault {
- return &v, nil
- }
- }
- return nil, ErrNoDefaultConnection
-}
-
-// GetRemoteConnection "looks up" a remote connection by name and returns it in the
-// form of a RemoteConnection
-func (r *RemoteConfig) GetRemoteConnection(name string) (*RemoteConnection, error) {
- if len(r.Connections) == 0 {
- return nil, ErrNoDefinedConnections
- }
- for k, v := range r.Connections {
- v := v
- if k == name {
- return &v, nil
- }
- }
- return nil, errors.Wrap(ErrConnectionNotFound, name)
-}