20 Commits

Author SHA1 Message Date
Chris Crone
d154c41586 Update copyright
Signed-off-by: Chris Crone <christopher.crone@docker.com>
2020-09-22 12:13:00 +02:00
Guillaume Tardif
9c6aead797 Allow running commands with HOME=“”.
Do not try to create ~/.docker before using CONFIG_DIR. HOME=“” will result in trying to use a relative .docker folder as default config folder, and if we cannot create the context store for any reason, try delegate to Moby CLI.

Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
2020-09-17 09:08:17 +02:00
Chris Crone
4c6280b0e9 Rename docker/api -> docker/compose-cli
Signed-off-by: Chris Crone <christopher.crone@docker.com>
2020-08-21 17:28:39 +02:00
Christopher Crone
207b57ba81 context: Move to gotest.tools
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
2020-08-04 13:39:00 +02:00
Djordje Lukic
ad72c866cc Add license headers 2020-06-18 16:48:03 +02:00
Guillaume Tardif
e7682682fb Store context type in metadata to make retrocompatibility with previous contexts easier (potentially switching back and forth) 2020-06-10 18:17:48 +02:00
Guillaume Tardif
d2648da2d9 Fix shell out to docker-classic when invoking 2020-05-27 16:12:40 +02:00
Djordje Lukic
11339761ca Change the way a context is stored
Initially we stored the context data in the `Metadata` of the context
but in hindsight this data would be better of in the `Endpoints` because
that's what it is used for.

Before:
```json
{
  "Name": "aci",
  "Metadata": {
    "Type": "aci",
    "Data": {
      "key": "value"
    }
  },
  "Endpoints": {
      "docker": {}
  }
}
```

After:
```json
{
  "Name": "aci",
  "Type": "aci",
  "Metadata": {},
  "Endpoints": {
      "aci": {
          "key": "value"
      },
      "docker": {}
  }
}
```

With this change the contexts that we create are more in line with the contexts the docker cli creates.

It also makes the code less complicated since we don't need to marsal twice any more. The API is nicer too:

```go
// Get a context:
c, err := store.Get(contextName)

// Get the stored endpoint:
var aciContext store.AciContext
if err := contextStore.GetEndpoint(currentContext, &aciContext); err != nil {
	return nil, err
}
```
2020-05-22 16:32:43 +02:00
Djordje Lukic
95e07a2134 Add default context to the context ls output 2020-05-20 18:39:10 +02:00
Djordje Lukic
a506b7f4e9 Fix make protos
The base target for protos was missing goimports, which we run after
making protos so that the linter doesn't fail on generated code
2020-05-14 21:53:14 +02:00
Christopher Crone
3c43606a20 Add remove function to context store
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
2020-05-12 12:05:00 +02:00
Christopher Crone
4788dd5b93 Use common errors in context store
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
2020-05-12 12:05:00 +02:00
Djordje Lukic
24c035e822 Add comments on exported items, remove example command
Also add `make lint` to run the linter
2020-05-05 10:27:44 +02:00
Djordje Lukic
551eb2326f ACI context creation
And remove gRPC stuff from the client for now
2020-04-29 19:08:58 +02:00
Ulysses Souza
3380c9d459 Refactor store.New
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2020-04-27 18:56:37 +02:00
Djordje Lukic
e6597d6139 Don't cd into a directory before building
We pass the directory to build to the `go build` command
2020-04-27 15:42:59 +02:00
Djordje Lukic
756836ffab Use testify/suite and testify/require 2020-04-27 11:45:23 +02:00
Djordje Lukic
10bc4b93f6 Call moby if the command is unknown
Will also check if the context is an original docker context
2020-04-27 11:33:16 +02:00
Djordje Lukic
e2c7370a82 Implement context list 2020-04-26 22:07:50 +02:00
Djordje Lukic
3bb4fe163c Add docker context create command
This creates a context with a name and a type
2020-04-26 19:42:20 +02:00