MCPcopy
hub / github.com/perkeep/perkeep / setCamdevVarsFor

Function setCamdevVarsFor

dev/devcam/env.go:108–155  ·  view source on GitHub ↗
(e *Env, altkey bool)

Source from the content-addressed store, hash-verified

106}
107
108func setCamdevVarsFor(e *Env, altkey bool) {
109 var setenv func(string, string) error
110 if e != nil {
111 setenv = func(k, v string) error { e.Set(k, v); return nil }
112 } else {
113 setenv = os.Setenv
114 }
115
116 setenv("CAMLI_AUTH", "userpass:camlistore:pass3179")
117 // env values for clients. server will overwrite them anyway in its setEnvVars.
118 root, err := rootInTmpDir()
119 if err != nil {
120 log.Fatal(err)
121 }
122 setenv("CAMLI_CACHE_DIR", filepath.Join(root, "client", "cache"))
123 setenv("CAMLI_CONFIG_DIR", filepath.Join("config", "dev-client-dir"))
124
125 secring := defaultSecring
126 identity := defaultIdentity
127
128 if altkey {
129 secring = filepath.FromSlash("pkg/jsonsign/testdata/password-foo-secring.gpg")
130 identity = "C7C3E176"
131 println("**\n** Note: password is \"foo\"\n**\n")
132 } else {
133 if *flagSecretRing != "" {
134 secring = *flagSecretRing
135 }
136 if *flagIdentity != "" {
137 identity = *flagIdentity
138 }
139 }
140
141 entity, err := jsonsign.EntityFromSecring(identity, secring)
142 if err != nil {
143 panic(err)
144 }
145 armoredPublicKey, err := jsonsign.ArmoredPublicKey(entity)
146 if err != nil {
147 panic(err)
148 }
149 pubKeyRef := blob.RefFromString(armoredPublicKey)
150
151 setenv("CAMLI_SECRET_RING", secring)
152 setenv("CAMLI_KEYID", identity)
153 setenv("CAMLI_PUBKEY_BLOBREF", pubKeyRef.String())
154 setenv("CAMLI_KV_VERIFY", "true")
155}
156
157func (e *Env) wipeCacheDir() {
158 cacheDir := e.m["CAMLI_CACHE_DIR"]

Callers 2

SetCamdevVarsMethod · 0.85
setCamdevVarsFunction · 0.85

Calls 7

EntityFromSecringFunction · 0.92
ArmoredPublicKeyFunction · 0.92
RefFromStringFunction · 0.92
rootInTmpDirFunction · 0.85
FatalMethod · 0.80
SetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected