-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a store to the CLI, that can be leveraged to persist and retrieve credentials for various API endpoints, as well as context-specific settings (initially, default stack orchestrator, but we could expand that). This comes with the logic to persist and retrieve endpoints configs for both Docker and Kubernetes APIs. Signed-off-by: Simon Ferquel <[email protected]>
- Loading branch information
1 parent
3a6f8b6
commit 7992dc3
Showing
29 changed files
with
2,153 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package command | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/docker/cli/cli/context/store" | ||
) | ||
|
||
// DockerContext is a typed representation of what we put in Context metadata | ||
type DockerContext struct { | ||
Description string `json:"description,omitempty"` | ||
StackOrchestrator Orchestrator `json:"stack_orchestrator,omitempty"` | ||
} | ||
|
||
// GetDockerContext extracts metadata from stored context metadata | ||
func GetDockerContext(storeMetadata store.ContextMetadata) (DockerContext, error) { | ||
if storeMetadata.Metadata == nil { | ||
// can happen if we save endpoints before assigning a context metadata | ||
// it is totally valid, and we should return a default initialized value | ||
return DockerContext{}, nil | ||
} | ||
res, ok := storeMetadata.Metadata.(DockerContext) | ||
if !ok { | ||
return DockerContext{}, errors.New("context metadata is not a valid DockerContext") | ||
} | ||
return res, nil | ||
} |
Oops, something went wrong.