Skip to content

Conversation

@simonferquel
Copy link
Contributor

- What I did

  • for plugins:
    • Expose the Context Store config
    • Make an existing config modifiable (to add endpoint types)
  • for Docker Desktop:
    • Expose all context operations (except listing, which will be done by directly using context store functions)

- How I did it

  • Just exposed a few existing symbols.
  • Added a SetEndpoint function on store.Config

- How to verify it

  • Modified code covered by unit tests
  • Added a test for SetEndpoint, making sure it applied to already created context stores

ping @ijc for the plugin related part
ping @gtardif @pgayvallet @guillaumerose @ebriney for the Docker Desktop part

@codecov-io
Copy link

codecov-io commented Jan 21, 2019

Codecov Report

Merging #1628 into master will decrease coverage by <.01%.
The diff coverage is 51.51%.

@@            Coverage Diff            @@
##           master   #1628      +/-   ##
=========================================
- Coverage    56.1%   56.1%   -0.01%     
=========================================
  Files         300     300              
  Lines       20578   20593      +15     
=========================================
+ Hits        11546   11554       +8     
- Misses       8202    8208       +6     
- Partials      830     831       +1

Copy link
Contributor

@ijc ijc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some pretty minor docs nits, but otherwise looks good from the plugins PoV, thanks for taking care of this?

@simonferquel
Copy link
Contributor Author

Thanks for spotting the missing exported symbols, fixed

@thaJeztah
Copy link
Member

thaJeztah commented Jan 22, 2019

(Copying this from #1519 (review));

The concern I have with exporting all of these is that;

  • These functions now become a public "API", with no interface defined for them
    • this can complicate making changes in the CLI (they were kept non-exported, as their signature/interface was not "stable")
  • Some of these functions actually have a "UX" component built-in (e.g. they print confirmation messages on stdout/stderr, have an option to print formatted output); is that really suitable for external consumption?
    • calling these functions would become almost equivalent to exec.Cmd("docker stack ls")

For the underlying code on the other hand, we have various interfaces defined; if those are lacking functionality that's needed, should we review those interfaces, and make that the API to use?

@simonferquel
Copy link
Contributor Author

Ok, I will try to move name validation and default context handling lower in the stack then

@ijc
Copy link
Contributor

ijc commented Jan 22, 2019

These functions now become a public "API", with no interface defined for them

  • this can complicate making changes in the CLI (they were kept non-exported, as their signature/interface was not "stable")

I don't think that dichotomy really exists as strongly as you have stated it, it is entirely valid for software to export an API which is explicitly unstable if the maintainers choose to do so and for them to then feel no qualms about changing it as necessary despite it being exported. I think that would be an entirely valid approach to consider for something like docker/cli (at least the bits under discussion here and in #1519). It just means that external consumers should be aware and be prepared to adjust as the unstable interfaces change (e.g. while they are revendoring).

@thaJeztah
Copy link
Member

Ah, sorry, I saw the comment on the other PR first, so let me copy my reply from there (#1519 (comment));

I was discussing with @chris-crone to add a note somewhere (perhaps the readme) to indicate that these functions, even though they're exported, should not be considered a stable API (as in; their signature can change, and shouldn't be relied on)

We could also add notes to the GoDoc of these, similar to https://golang.org/pkg/testing/#RunTests

An internal function but exported because it is cross-package; part of the implementation of the "go test" command.

But that would be a bit more work to do

I'm ok with this change, but we should add that note somewhere (separately from this PR), and start thinking of what changes would be needed to have a slightly higher-level interface than the API-client (to make it better consumable), but "lower" than the current functions (which, I think, are too tightly coupled to the CLI itself and the UX it has).

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one "nit" 😅

// ContextStoreConfig contains the config used by the context store
// A plugin's init function may modify it to define other typed endpoint metadata by calling
// ContextStoreConfig.SetEndpoint()
var ContextStoreConfig = store.NewConfig(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it better to have a function here ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to be used from outside)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like command.SetContextStoreEndpointType() ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or store.DefaultConfig() ? 🤔

@simonferquel
Copy link
Contributor Author

As discussed privately with @vdemeester, I'll wait for Silvin's pr to land and introduce a WithAdditionalEndpoint option

@thaJeztah
Copy link
Member

As discussed privately with @vdemeester, I'll wait for Silvin's pr to land and introduce a WithAdditionalEndpoint option

❤️ even better!

@simonferquel simonferquel force-pushed the context-switch-plugin-and-desktop branch from 67f15ee to 64d01ca Compare January 28, 2019 15:00
@simonferquel
Copy link
Contributor Author

@thaJeztah done! PTAL :)

@simonferquel
Copy link
Contributor Author

@vdemeester WDYT?

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐯

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes LGTM; can you squash commits?

This will allow plugins to have custom typed endpoints, as well as
create/remove/update contexts with the exact same results as the main
CLI (thinking of things like `docker ee login https://my-ucp-server
--context ucp-prod)`

Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
@simonferquel simonferquel force-pushed the context-switch-plugin-and-desktop branch from 64d01ca to 3126920 Compare January 29, 2019 10:22
@simonferquel
Copy link
Contributor Author

@thaJeztah rebased + squashed, thanks

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah thaJeztah merged commit a17f67e into docker:master Jan 29, 2019
@GordonTheTurtle GordonTheTurtle added this to the 19.03.0 milestone Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants