-
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.
Merge pull request #1501 from simonferquel/use-context-commands
Fast context switch: commands
- Loading branch information
Showing
63 changed files
with
4,013 additions
and
146 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
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:",omitempty"` | ||
StackOrchestrator Orchestrator `json:",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.