Skip to content

Commit 62e9733

Browse files
committed
Add a flag for using dev credentials.
1 parent 5cc6361 commit 62e9733

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

.nanpa/dev-flag.kdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
minor type="added" "flag for using dev credentials"

cmd/lk/utils.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import (
2323
"github.com/twitchtv/twirp"
2424
"github.com/urfave/cli/v3"
2525

26+
"github.com/livekit/protocol/utils/interceptors"
27+
2628
"github.com/livekit/livekit-cli/v2/pkg/config"
2729
"github.com/livekit/livekit-cli/v2/pkg/util"
28-
"github.com/livekit/protocol/utils/interceptors"
2930
)
3031

3132
var (
@@ -62,6 +63,10 @@ var (
6263
Usage: "Your `SECRET`",
6364
Sources: cli.EnvVars("LIVEKIT_API_SECRET"),
6465
},
66+
&cli.BoolFlag{
67+
Name: "dev",
68+
Usage: "Use developer credentials for local LiveKit server",
69+
},
6570
&cli.StringFlag{
6671
Name: "project",
6772
Usage: "`NAME` of a configured project",
@@ -166,6 +171,9 @@ func loadProjectDetails(c *cli.Command, opts ...loadOption) (*config.ProjectConf
166171

167172
// if explicit project is defined, then use it
168173
if c.String("project") != "" {
174+
if c.Bool("dev") {
175+
return nil, errors.New("both project and dev flags are set")
176+
}
169177
pc, err := config.LoadProject(c.String("project"))
170178
if err != nil {
171179
return nil, err
@@ -177,6 +185,9 @@ func loadProjectDetails(c *cli.Command, opts ...loadOption) (*config.ProjectConf
177185

178186
// if explicit subdomain is provided, use it
179187
if c.String("subdomain") != "" {
188+
if c.Bool("dev") {
189+
return nil, errors.New("both subdomain and dev flags are set")
190+
}
180191
pc, err := config.LoadProjectBySubdomain(c.String("subdomain"))
181192
if err != nil {
182193
return nil, err
@@ -191,9 +202,15 @@ func loadProjectDetails(c *cli.Command, opts ...loadOption) (*config.ProjectConf
191202
pc.URL = val
192203
}
193204
if val := c.String("api-key"); val != "" {
205+
if c.Bool("dev") {
206+
return nil, errors.New("both api-key and dev flags are set")
207+
}
194208
pc.APIKey = val
195209
}
196210
if val := c.String("api-secret"); val != "" {
211+
if c.Bool("dev") {
212+
return nil, errors.New("both api-secret and dev flags are set")
213+
}
197214
pc.APISecret = val
198215
}
199216
if pc.APIKey != "" && pc.APISecret != "" && (pc.URL != "" || !p.requireURL) {
@@ -214,6 +231,12 @@ func loadProjectDetails(c *cli.Command, opts ...loadOption) (*config.ProjectConf
214231
}
215232
return pc, nil
216233
}
234+
if c.Bool("dev") {
235+
pc.APIKey = "devkey"
236+
pc.APISecret = "secret"
237+
fmt.Println("Using dev credentials")
238+
return pc, nil
239+
}
217240

218241
// load default project
219242
dp, err := config.LoadDefaultProject()

0 commit comments

Comments
 (0)