Skip to content

Commit fdf37e5

Browse files
committed
convert to fs.FS
1 parent 8c33dd2 commit fdf37e5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cmd/lk/agent.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
535535
return err
536536
}
537537

538-
projectType, err := agentfs.DetectProjectType(workingDir)
538+
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
539539
fmt.Printf("Detected project type [%s]\n", util.Accented(string(projectType)))
540540
if err != nil {
541541
return fmt.Errorf("unable to determine project type: %w, please use a supported project type, or create your own Dockerfile in the current directory", err)
@@ -555,7 +555,7 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
555555

556556
regions := cmd.StringSlice("regions")
557557
excludeFiles := []string{fmt.Sprintf("**/%s", config.LiveKitTOMLFile)}
558-
resp, err := agentsClient.CreateAgent(ctx, workingDir, secrets, regions, excludeFiles)
558+
resp, err := agentsClient.CreateAgent(ctx, os.DirFS(workingDir), secrets, regions, excludeFiles)
559559
if err != nil {
560560
if twerr, ok := err.(twirp.Error); ok {
561561
return fmt.Errorf("unable to create agent: %s", twerr.Msg())
@@ -681,7 +681,7 @@ func deployAgent(ctx context.Context, cmd *cli.Command) error {
681681
req.Secrets = secrets
682682
}
683683

684-
projectType, err := agentfs.DetectProjectType(workingDir)
684+
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
685685
if err != nil {
686686
return fmt.Errorf("unable to determine project type: %w, please use a supported project type, or create your own Dockerfile in the current directory", err)
687687
}
@@ -700,7 +700,7 @@ func deployAgent(ctx context.Context, cmd *cli.Command) error {
700700
}
701701

702702
excludeFiles := []string{fmt.Sprintf("**/%s", config.LiveKitTOMLFile)}
703-
if err := agentsClient.DeployAgent(ctx, agentId, workingDir, secrets, excludeFiles); err != nil {
703+
if err := agentsClient.DeployAgent(ctx, agentId, os.DirFS(workingDir), secrets, excludeFiles); err != nil {
704704
if twerr, ok := err.(twirp.Error); ok {
705705
return fmt.Errorf("unable to deploy agent: %s", twerr.Msg())
706706
}
@@ -1373,7 +1373,7 @@ func generateAgentDockerfile(ctx context.Context, cmd *cli.Command) error {
13731373
return err
13741374
}
13751375

1376-
projectType, err := agentfs.DetectProjectType(workingDir)
1376+
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
13771377
fmt.Printf("Detected project type [%s]\n", util.Accented(string(projectType)))
13781378
if err != nil {
13791379
return fmt.Errorf("unable to determine project type: %w, please use a supported project type, or create your own Dockerfile in the current directory", err)

pkg/agentfs/docker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
)
3434

3535
//go:embed examples/*
36-
var fs embed.FS
36+
var embedfs embed.FS
3737

3838
func HasDockerfile(dir string) (bool, error) {
3939
entries, err := os.ReadDir(dir)
@@ -76,14 +76,14 @@ func GenerateDockerArtifacts(dir string, projectType ProjectType, settingsMap ma
7676

7777
// NOTE: embed.FS uses unix-style path separators on all platforms, so cannot use filepath.Join here.
7878
// path.Join always uses '/' as the separator.
79-
dockerfileContent, err := fs.ReadFile(path.Join("examples", string(projectType)+".Dockerfile"))
79+
dockerfileContent, err := embedfs.ReadFile(path.Join("examples", string(projectType)+".Dockerfile"))
8080
if err != nil {
8181
return nil, nil, err
8282
}
8383

8484
// NOTE: embed.FS uses unix-style path separators on all platforms, so cannot use filepath.Join here
8585
// path.Join always uses '/' as the separator.
86-
dockerIgnoreContent, err := fs.ReadFile(path.Join("examples", string(projectType)+".dockerignore"))
86+
dockerIgnoreContent, err := embedfs.ReadFile(path.Join("examples", string(projectType)+".dockerignore"))
8787
if err != nil {
8888
return nil, nil, err
8989
}

0 commit comments

Comments
 (0)