-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5812 from jwhonce/wip/options
Add support for the global flags and config files
- Loading branch information
Showing
22 changed files
with
687 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package registry | ||
|
||
import ( | ||
"os" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/containers/common/pkg/config" | ||
"github.com/containers/libpod/libpod" | ||
"github.com/containers/libpod/pkg/domain/entities" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
const ( | ||
RootRequired = "RootRequired" | ||
) | ||
|
||
var ( | ||
PodmanOptions entities.PodmanConfig | ||
) | ||
|
||
// NewPodmanConfig creates a PodmanConfig from the environment | ||
func NewPodmanConfig() entities.PodmanConfig { | ||
if err := libpod.SetXdgDirs(); err != nil { | ||
logrus.Errorf(err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
var mode entities.EngineMode | ||
switch runtime.GOOS { | ||
case "darwin": | ||
fallthrough | ||
case "windows": | ||
mode = entities.TunnelMode | ||
case "linux": | ||
mode = entities.ABIMode | ||
default: | ||
logrus.Errorf("%s is not a supported OS", runtime.GOOS) | ||
os.Exit(1) | ||
} | ||
|
||
// cobra.Execute() may not be called yet, so we peek at os.Args. | ||
for _, v := range os.Args { | ||
// Prefix checking works because of how default EngineMode's | ||
// have been defined. | ||
if strings.HasPrefix(v, "--remote=") { | ||
mode = entities.TunnelMode | ||
} | ||
} | ||
|
||
// FIXME: for rootless, where to get the path | ||
// TODO: | ||
cfg, err := config.NewConfig("") | ||
if err != nil { | ||
logrus.Error("Failed to obtain podman configuration") | ||
os.Exit(1) | ||
} | ||
return entities.PodmanConfig{Config: cfg, EngineMode: mode} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.