Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daytona as a library: importable #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

afarbos
Copy link
Contributor

@afarbos afarbos commented Sep 4, 2020

Like cloudsql-proxy and many other go binaries, it usually possible to import them within your own go applications. This PR would allow a similar behavior with daytona too, see example below:

package main

import (
	"fmt"
	"log"
	"os"
	"strings"

	cfg "github.com/cruise-automation/daytona/pkg/config"
	"github.com/cruise-automation/daytona/pkg/daytona"
)

func main() {
	os.Setenv("VAULT_SECRETS_FOO_BAR", "secret/foo/bar/")
	config := cfg.DefaultConfig()
	config.AWSAuth = true
	config.SecretEnv = true
	config.VaultAuthRoleName = "awesome-app-vault-role-name"
	if err := daytona.Run(config); err != nil {
		log.Fatalln(err.Error())
	}

	fmt.Println("== env ==")
	for _, e := range os.Environ() {
		pair := strings.SplitN(e, "=", 2)
		fmt.Println(pair[0])
	}
}

A lot of changes are just moving code, there is not actually so much changes more than creating the daytona package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant