MCPcopy Create free account
hub / github.com/rilldata/rill / writeEnv

Function writeEnv

runtime/runtime.go:346–366  ·  view source on GitHub ↗
(ctx context.Context, env string, vars map[string]string, repo drivers.RepoStore)

Source from the content-addressed store, hash-verified

344}
345
346func writeEnv(ctx context.Context, env string, vars map[string]string, repo drivers.RepoStore) error {
347 var path string
348 if env == "" {
349 path = ".env"
350 } else {
351 path = fmt.Sprintf(".%s.env", env)
352 }
353 contents, err := godotenv.Marshal(vars)
354 if err != nil {
355 return fmt.Errorf("failed to marshal env vars: %w", err)
356 }
357 err = repo.Put(ctx, path, strings.NewReader(contents))
358 if err != nil {
359 return fmt.Errorf("failed to write %q: %w", path, err)
360 }
361 _, err = gitutil.EnsureGitignoreHas(ctx, repo, path)
362 if err != nil {
363 return fmt.Errorf("failed to update .gitignore for %q: %w", path, err)
364 }
365 return nil
366}
367
368func instanceAnnotationsToAttribs(instance *drivers.Instance) []attribute.KeyValue {
369 attrs := make([]attribute.KeyValue, 0, len(instance.Annotations)+2)

Callers 2

reloadConfigMethod · 0.85
pullEnvMethod · 0.85

Calls 3

EnsureGitignoreHasFunction · 0.92
ErrorfMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected