MCPcopy Index your code
hub / github.com/docker/cli / getConfigDetails

Function getConfigDetails

cli/command/stack/loader.go:86–116  ·  view source on GitHub ↗

getConfigDetails parse the composefiles specified in the cli and returns their ConfigDetails

(composefiles []string, stdin io.Reader)

Source from the content-addressed store, hash-verified

84
85// getConfigDetails parse the composefiles specified in the cli and returns their ConfigDetails
86func getConfigDetails(composefiles []string, stdin io.Reader) (composetypes.ConfigDetails, error) {
87 var details composetypes.ConfigDetails
88
89 if len(composefiles) == 0 {
90 return details, errors.New("specify a Compose file (with --compose-file)")
91 }
92
93 if composefiles[0] == "-" && len(composefiles) == 1 {
94 workingDir, err := os.Getwd()
95 if err != nil {
96 return details, err
97 }
98 details.WorkingDir = workingDir
99 } else {
100 absPath, err := filepath.Abs(composefiles[0])
101 if err != nil {
102 return details, err
103 }
104 details.WorkingDir = filepath.Dir(absPath)
105 }
106
107 var err error
108 details.ConfigFiles, err = loadConfigFiles(composefiles, stdin)
109 if err != nil {
110 return details, err
111 }
112 // Take the first file version (2 files can't have different version)
113 details.Version = schema.Version(details.ConfigFiles[0].Config)
114 details.Environment, err = buildEnvironment(os.Environ())
115 return details, err
116}
117
118func buildEnvironment(env []string) (map[string]string, error) {
119 result := make(map[string]string, len(env))

Callers 4

TestGetConfigDetailsFunction · 0.85
loadComposeFileFunction · 0.85
newConfigCommandFunction · 0.85

Calls 2

loadConfigFilesFunction · 0.85
buildEnvironmentFunction · 0.85

Tested by 2

TestGetConfigDetailsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…