Skip to content

Commit

Permalink
Merge pull request #23 from bketelsen/init
Browse files Browse the repository at this point in the history
Relationship storage
  • Loading branch information
bketelsen authored Mar 12, 2019
2 parents b5ee61f + e75cf73 commit afcb933
Show file tree
Hide file tree
Showing 45 changed files with 118 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ generated/
bin/*
gin-bin
.idea/
lxdev
devlx
.envrc
Empty file modified .gometalinter.json
100644 → 100755
Empty file.
Empty file modified .goreleaser.yml
100644 → 100755
Empty file.
Empty file modified .goreleaser.yml.plush
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ install:

clean:
@rm -rf dist/
@rm ./lxdev
@rm -rf ./devlx

reset: install
@rm -rf ~/.lxdev
@lxdev config -t
@lxdev profile gui -w
@lxdev profile cli -w
@rm -rf ~/.devlx
@devlx config -t
@devlx profile gui -w
@devlx profile cli -w

tidy:
ifeq ($(GO111MODULE),on)
Expand All @@ -39,7 +39,7 @@ test:
@make tidy

shoulders:
@shoulders -n github.com/bketelsen/lxdev -w
@shoulders -n github.com/bketelsen/devlx -w

ci-deps:
$(GO_BIN) get -t ./...
Expand Down
44 changes: 23 additions & 21 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
# lxdev
# devlx

`lxdev` is a development tool that provisions temporary development environments. It uses [lxd](https://linuxcontainers.org) and `zfs` to make efficient, copy-on-write, workspaces from a user-provided template.
`devlx` is a development tool that provisions temporary development environments. It uses [lxd](https://linuxcontainers.org) and `zfs` to make efficient, copy-on-write, workspaces from a user-provided template.

[Watch this slightly outdated DEMO VIDEO](https://youtu.be/W6A00CHiDQ8)

## Getting Started

* Install LXD
* Install lxdev
* Install devlx

### Create initial configuration
```
lxdev init
devlx config -c
devlx config -t
```

This command write `$HOME/.lxdev.yaml`, `$HOME/.lxdev/profiles/*.yaml` and `$HOME/.lxdev/templates/realations.yaml`, which are configuration files, templates and container relation store for your containers.
These commands write `$HOME/.devlx.yaml` and `$HOME/.devlx/profiles/*.yaml`, which are configuration files and templates and container relation store for your containers for your containers.

### Additional commands for base LXC Profiles
### Create base LXC Profiles
=======

```
lxdev profile -w gui
lxdev profile -w cli
devlx profile -w gui
devlx profile -w cli
```

These commands create the base LXC profiles that `lxdev` needs to provision containers with access to the host.
These commands create the base LXC profiles that `devlx` needs to provision containers with access to the host.

### Create Templates

```
lxdev template create guitemplate --profile gui --provisioners vscode
lxdev template create clitemplate --profile cli --provisioners go,yadm
devlx template create guitemplate --profile gui --provisioners vscode
devlx template create clitemplate --profile cli --provisioners go,yadm
```
Let's unwrap that:

The name of the template {guitemplate,clitemplate} is totally up to you. These are base images that will be used later to create your containers. You "provision" them by passing in a comma separated list of `provisioners`, which are bash scripts that install things or otherwise modify the base image. Provisioners live in the `~/.lxdev/provision` directory in your $HOME. They're created once and never again modified by `lxdev` unless you remove the directory and run `lxdev config -t` again.
The name of the template {guitemplate,clitemplate} is totally up to you. These are base images that will be used later to create your containers. You "provision" them by passing in a comma separated list of `provisioners`, which are bash scripts that install things or otherwise modify the base image. Provisioners live in the `~/.devlx/provision` directory in your $HOME. They're created once and never again modified by `devlx` unless you remove the directory and run `devlx config -t` again.

The `guibase` and `clibase` provisioning templates are automatically applied to `gui` and `cli` profiles, you do not need to specify them separately. Use caution in editing these provisioners, as it is possible features installed in these provisioners are expected by `lxdev`.
The `guibase` and `clibase` provisioning templates are automatically applied to `gui` and `cli` profiles, you do not need to specify them separately. Use caution in editing these provisioners, as it is possible features installed in these provisioners are expected by `devlx`.

You can, and should, modify the existing provisioners or create new ones based on your needs.

The `profile` {gui,cli} is an lxc profile that's stored in `~/.lxdev/profiles`. They're standard `lxc` profiles that are applied when you create a template, then inherited by every container that's instantiated from those templates.
The `profile` {gui,cli} is an lxc profile that's stored in `~/.devlx/profiles`. They're standard `lxc` profiles that are applied when you create a template, then inherited by every container that's instantiated from those templates.


### Create your first container

```
lxdev create myproject --template guitemplate
devlx create myproject --template guitemplate
```
This creates a container called `myproject` from the template `guitemplate`, which has X11 and audio support by default.

### Connect to your container

```
lxdev shell myproject
devlx shell myproject
```

When using the shell (or its alias connect) command, you get dropped into a login shell in the container. You can run commands just like it was an SSH session, and you can open X11 apps which will be displayed on your host's X session. (I KNOW RIGHT??)
Expand All @@ -72,11 +74,11 @@ When there is one, you can download a release from GitHub.

Requires Go, tested with 1.12beta2.
```
git clone https://github.com/bketelsen/lxdev
git clone https://github.com/bketelsen/devlx
make deps // install dependencies
make test // run tests
make install // build and install the lxdev tool into your path
make install // build and install the devlx tool into your path
```

## Running the tests
Expand All @@ -95,19 +97,19 @@ Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c6

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/bketelsen/lxdev/tags).
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/bketelsen/devlx/tags).

## Authors

* **Brian Ketelsen** - *Initial work* - [BrianKetelsen.com](https://brianketelsen.com)

See also the list of [contributors](https://github.com/bketelsen/lxdev/contributors) who participated in this project.
See also the list of [contributors](https://github.com/bketelsen/devlx/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

See [SHOULDERS](SHOULDERS.md) for acknowledgments and thanks to the other projects that `lxdev` was built with.
See [SHOULDERS](SHOULDERS.md) for acknowledgments and thanks to the other projects that `devlx` was built with.
Special thanks to [Simos Xenitellis](https://blog.simos.info/how-to-easily-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/) for the tireless blogging. I learned nearly everything about this process from those posts.
12 changes: 6 additions & 6 deletions SHOULDERS.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# github.com/bketelsen/lxdev Stands on the Shoulders of Giants
# github.com/bketelsen/devlx Stands on the Shoulders of Giants

github.com/bketelsen/lxdev does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work.
github.com/bketelsen/devlx does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work.

Thank you to the following **GIANTS**:

Expand All @@ -9,13 +9,13 @@ Thank you to the following **GIANTS**:

* [github.com/bketelsen/libgo/events](https://godoc.org/github.com/bketelsen/libgo/events)

* [github.com/bketelsen/lxdev](https://godoc.org/github.com/bketelsen/lxdev)
* [github.com/bketelsen/devlx](https://godoc.org/github.com/bketelsen/devlx)

* [github.com/bketelsen/lxdev/cmd](https://godoc.org/github.com/bketelsen/lxdev/cmd)
* [github.com/bketelsen/devlx/cmd](https://godoc.org/github.com/bketelsen/devlx/cmd)

* [github.com/bketelsen/lxdev/lxd](https://godoc.org/github.com/bketelsen/lxdev/lxd)
* [github.com/bketelsen/devlx/lxd](https://godoc.org/github.com/bketelsen/devlx/lxd)

* [github.com/bketelsen/lxdev/packrd](https://godoc.org/github.com/bketelsen/lxdev/packrd)
* [github.com/bketelsen/devlx/packrd](https://godoc.org/github.com/bketelsen/devlx/packrd)

* [github.com/buger/goterm](https://godoc.org/github.com/buger/goterm)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd-packr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions cmd/config.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func createConfig() error {
if err != nil {
return err
}
f, err := os.Create(filepath.Join(home, ".lxdev.yaml"))
f, err := os.Create(filepath.Join(home, ".devlx.yaml"))
if err != nil {
return err
}
Expand All @@ -81,7 +81,7 @@ func checkConfig() error {
if err != nil {
return err
}
_, err = os.Stat(filepath.Join(home, ".lxdev.yaml"))
_, err = os.Stat(filepath.Join(home, ".devlx.yaml"))
if err != nil {
return err
}
Expand All @@ -94,7 +94,7 @@ func createTemplates() error {
return err
}

err = os.MkdirAll(filepath.Join(home, ".lxdev", "provision"), 0755)
err = os.MkdirAll(filepath.Join(home, ".devlx", "provision"), 0755)
if err != nil {
return err
}
Expand All @@ -103,7 +103,7 @@ func createTemplates() error {
if err != nil {
return err
}
f, err := os.Create(filepath.Join(home, ".lxdev", "provision", tpl))
f, err := os.Create(filepath.Join(home, ".devlx", "provision", tpl))
if err != nil {
return err
}
Expand All @@ -114,7 +114,7 @@ func createTemplates() error {
}

pbox := packr.New("profiles", "../templates/profiles")
err = os.MkdirAll(filepath.Join(home, ".lxdev", "profiles"), 0755)
err = os.MkdirAll(filepath.Join(home, ".devlx", "profiles"), 0755)
if err != nil {
return err
}
Expand All @@ -123,7 +123,7 @@ func createTemplates() error {
if err != nil {
return err
}
f, err := os.Create(filepath.Join(home, ".lxdev", "profiles", tpl))
f, err := os.Create(filepath.Join(home, ".devlx", "profiles", tpl))
if err != nil {
return err
}
Expand All @@ -143,12 +143,12 @@ func createRelationsStore() error {
return err
}

err = os.MkdirAll(filepath.Join(home, ".lxdev", "templates"), 0755)
err = os.MkdirAll(filepath.Join(home, ".devlx", "templates"), 0755)
if err != nil {
return err
}

f, err := os.Create(filepath.Join(home, ".lxdev", "templates", "relations.yaml"))
f, err := os.Create(filepath.Join(home, ".devlx", "templates", "relations.yaml"))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/connect.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package cmd
import (
"os"

client "github.com/bketelsen/lxdev/lxd"
client "github.com/bketelsen/devlx/lxd"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/create.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

client "github.com/bketelsen/lxdev/lxd"
client "github.com/bketelsen/devlx/lxd"
)

var (
Expand Down Expand Up @@ -44,7 +44,7 @@ var createCmd = &cobra.Command{

// Store the LXC Image -> Container relationship
log.Running("Storing image container relation ")
err = setContainerTemplateRealation(lxclient, name, template, true)
err = setContainerTemplateRelation(lxclient, name, template, true)
if err != nil {
log.Error("Unable to create container-template relations" + err.Error())
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/createtemplate.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"time"

client "github.com/bketelsen/lxdev/lxd"
client "github.com/bketelsen/devlx/lxd"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/exec.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"strings"

client "github.com/bketelsen/lxdev/lxd"
client "github.com/bketelsen/devlx/lxd"
"github.com/spf13/cobra"
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
// initCmd represents the init command
var initCmd = &cobra.Command{
Use: "init",
Short: "initialize your computer for lxdev usage",
Short: "initialize your computer for devlx usage",
Long: `The init command creates a configuration file, builds templates for
your containers, and creates lxc profiles that are required for operation.`,
Run: func(cmd *cobra.Command, args []string) {

log.Running("Initializing lxdev")
// create .lxdev.yaml file
log.Running("Initializing devlx")
// create .devlx.yaml file

log.Running("Creating configuration file")
err := createConfig()
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"strings"

client "github.com/bketelsen/lxdev/lxd"
client "github.com/bketelsen/devlx/lxd"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/lstemplate.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package cmd
import (
"os"

client "github.com/bketelsen/lxdev/lxd"
client "github.com/bketelsen/devlx/lxd"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var profiles = []string{"gui", "cli"}
// profileCmd represents the profile command
var profileCmd = &cobra.Command{
Use: "profile [name]",
Short: "create or replace the provisioning profile for lxdev",
Short: "create or replace the provisioning profile for devlx",
Long: `Profile creates or replaces the 'gui' and 'cli' profiles in lxc that allow you
to connect to running containers and possibly display X11 applications on the host. Run with
no arguments to create or update all required profiles.`,
Expand Down Expand Up @@ -76,7 +76,7 @@ func createProfiles(name string) error {
log.Error("Create Profile : " + err.Error())
return err
}
fpath := filepath.Join(home, ".lxdev", "profiles", filename)
fpath := filepath.Join(home, ".devlx", "profiles", filename)
f, err := os.Open(fpath)
defer f.Close()
if err != nil {
Expand Down
Loading

0 comments on commit afcb933

Please sign in to comment.