MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / InitStack

Method InitStack

tools/mage/dev.go:284–338  ·  view source on GitHub ↗

InitStack initializes the Stack.

()

Source from the content-addressed store, hash-verified

282
283// InitStack initializes the Stack.
284func (Dev) InitStack() error {
285 if mg.Verbose() {
286 fmt.Println("Initializing the Stack")
287 }
288 if err := runGo("./cmd/ttn-lw-stack", "is-db", "migrate"); err != nil {
289 return err
290 }
291 if err := runGo("./cmd/ttn-lw-stack", "is-db", "create-admin-user",
292 "--id", "admin",
293 "--email", "admin@example.com",
294 "--password", "admin",
295 ); err != nil {
296 return err
297 }
298 if err := runGo("./cmd/ttn-lw-stack", "is-db", "create-oauth-client",
299 "--id", "cli",
300 "--name", "Command Line Interface",
301 "--owner", "admin",
302 "--no-secret",
303 "--redirect-uri", "local-callback",
304 "--redirect-uri", "code",
305 ); err != nil {
306 return err
307 }
308 if err := runGo("./cmd/ttn-lw-stack", "is-db", "create-oauth-client",
309 "--id", "console",
310 "--name", "Console",
311 "--owner", "admin",
312 "--secret", "console",
313 "--redirect-uri", "https://localhost:8885/console/oauth/callback",
314 "--redirect-uri", "http://localhost:1885/console/oauth/callback",
315 "--redirect-uri", "/console/oauth/callback",
316 "--logout-redirect-uri", "https://localhost:8885/console",
317 "--logout-redirect-uri", "http://localhost:1885/console",
318 "--logout-redirect-uri", "/console",
319 ); err != nil {
320 return err
321 }
322 var key ttnpb.APIKey
323 var jsonVal []byte
324 var err error
325 if jsonVal, err = outputJSONGo("run", "./cmd/ttn-lw-stack", "is-db", "create-user-api-key",
326 "--user-id", "admin",
327 "--name", "Admin User API Key",
328 ); err != nil {
329 return err
330 }
331 if err := jsonpb.TTN().Unmarshal(jsonVal, &key); err != nil {
332 return err
333 }
334 if err := writeToFile(filepath.Join(devDir, "admin_api_key.txt"), []byte(key.Key)); err != nil {
335 return err
336 }
337 return nil
338}
339
340// StartDevStack starts TTS in end-to-end test configuration.
341func (Dev) StartDevStack() error {

Callers

nothing calls this directly

Calls 6

TTNFunction · 0.92
runGoFunction · 0.85
outputJSONGoFunction · 0.85
writeToFileFunction · 0.85
UnmarshalMethod · 0.65
JoinMethod · 0.65

Tested by

no test coverage detected