(ctx context.Context)
| 976 | } |
| 977 | |
| 978 | func (src *ModuleSource) outerEnvFile(ctx context.Context) (*EnvFile, string, error) { |
| 979 | dag, err := CurrentDagqlServer(ctx) |
| 980 | if err != nil { |
| 981 | return nil, "", err |
| 982 | } |
| 983 | var envFilePath dagql.String |
| 984 | if err := dag.Select(ctx, dag.Root(), &envFilePath, |
| 985 | dagql.Selector{Field: "host"}, |
| 986 | dagql.Selector{ |
| 987 | Field: "findUp", |
| 988 | Args: []dagql.NamedInput{ |
| 989 | {Name: "name", Value: dagql.NewString(".env")}, |
| 990 | }, |
| 991 | }, |
| 992 | ); err != nil { |
| 993 | return nil, "", fmt.Errorf("failed to find-up outer .env: %s", err.Error()) |
| 994 | } |
| 995 | if envFilePath == "" { |
| 996 | return &EnvFile{}, "", nil |
| 997 | } |
| 998 | // Check if the found .env path is a regular file (not a directory) |
| 999 | envFileDir := path.Dir(envFilePath.String()) |
| 1000 | envFileName := path.Base(envFilePath.String()) |
| 1001 | var isRegularFile bool |
| 1002 | if err := dag.Select(ctx, dag.Root(), &isRegularFile, |
| 1003 | dagql.Selector{Field: "host"}, |
| 1004 | dagql.Selector{ |
| 1005 | Field: "directory", |
| 1006 | Args: []dagql.NamedInput{ |
| 1007 | {Name: "path", Value: dagql.String(envFileDir)}, |
| 1008 | {Name: "include", Value: dagql.ArrayInput[dagql.String]{dagql.String(envFileName)}}, |
| 1009 | }, |
| 1010 | }, |
| 1011 | dagql.Selector{ |
| 1012 | Field: "exists", |
| 1013 | Args: []dagql.NamedInput{ |
| 1014 | {Name: "path", Value: dagql.String(envFileName)}, |
| 1015 | {Name: "expectedType", Value: dagql.Opt(ExistsTypeRegular)}, |
| 1016 | }, |
| 1017 | }, |
| 1018 | ); err != nil { |
| 1019 | return nil, "", fmt.Errorf("failed to check outer env file type at %q: %w", envFilePath.String(), err) |
| 1020 | } |
| 1021 | if !isRegularFile { |
| 1022 | return &EnvFile{}, "", nil |
| 1023 | } |
| 1024 | var envFile *EnvFile |
| 1025 | if err := dag.Select(ctx, dag.Root(), &envFile, |
| 1026 | dagql.Selector{Field: "host"}, |
| 1027 | dagql.Selector{ |
| 1028 | Field: "file", |
| 1029 | Args: []dagql.NamedInput{ |
| 1030 | {Name: "path", Value: envFilePath}, |
| 1031 | }, |
| 1032 | }, |
| 1033 | dagql.Selector{ |
| 1034 | Field: "asEnvFile", |
| 1035 | Args: []dagql.NamedInput{ |
no test coverage detected