MCPcopy Create free account
hub / github.com/perkeep/perkeep / clientConfigFromServer

Method clientConfigFromServer

cmd/pk-put/init.go:146–179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144}
145
146func (c *initCmd) clientConfigFromServer() (*clientconfig.Config, error) {
147 if c.noconfig {
148 log.Print("--userpass and --noconfig are mutually exclusive")
149 return nil, cmdmain.ErrUsage
150 }
151 server := client.ExplicitServer()
152 if server == "" {
153 log.Print("--userpass requires --server")
154 return nil, cmdmain.ErrUsage
155 }
156 fields := strings.Split(c.userPass, ":")
157 if len(fields) != 2 {
158 log.Printf("wrong userpass; wanted username:password, got %q", c.userPass)
159 return nil, cmdmain.ErrUsage
160 }
161
162 cl := client.NewOrFail(
163 client.OptionNoExternalConfig(),
164 client.OptionServer(server),
165 client.OptionAuthMode(auth.NewBasicAuth(fields[0], fields[1])),
166 client.OptionInsecure(c.insecureTLS),
167 )
168
169 helpRoot, err := cl.HelpRoot()
170 if err != nil {
171 return nil, err
172 }
173
174 var cc clientconfig.Config
175 if err := cl.GetJSON(ctxbg, helpRoot+"?clientConfig=true", &cc); err != nil {
176 return nil, err
177 }
178 return &cc, nil
179}
180
181func (c *initCmd) writeConfig(cc *clientconfig.Config) error {
182 configFilePath := osutil.UserClientConfigPath()

Callers 1

RunCommandMethod · 0.95

Calls 10

ExplicitServerFunction · 0.92
NewOrFailFunction · 0.92
OptionNoExternalConfigFunction · 0.92
OptionServerFunction · 0.92
OptionAuthModeFunction · 0.92
NewBasicAuthFunction · 0.92
OptionInsecureFunction · 0.92
PrintfMethod · 0.80
HelpRootMethod · 0.80
GetJSONMethod · 0.65

Tested by

no test coverage detected