This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
Refactor Config-file-based auth #1051
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3553945
Add builder to RegistryConfigs
johnflavin 3b49937
Refactor config parsing. Add credsHelpers support.
johnflavin 37cb360
Remove unused/deprecated code. Un-deprecate code that is still used. …
johnflavin d4c25ad
Refactor credential helper code into its own class (with a delegate f…
johnflavin 5ed7e4a
Refactor code that gets a single RegistryAuth for a given registry
johnflavin 020a7d9
Use entrySet to satisfy findbugs
johnflavin 8ead412
Fix a bug in the order of reading different config sections. Add a te…
johnflavin a618b9d
Minor: fix logging in creds helper
johnflavin b8f1a32
Add javadoc to new classes
johnflavin 31e5f72
Remove RegistryAuthV2, which was used in the prior config reader / au…
johnflavin 5332f27
Add javadoc for RegistryAuth
johnflavin 0282016
Minor: reuse boolean value
johnflavin c72c1d1
changelog
johnflavin acfd42f
Add docker config file properties from https://github.com/docker/cli/…
johnflavin d2ede02
Fix javadoc style
johnflavin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
101 changes: 101 additions & 0 deletions
101
src/main/java/com/spotify/docker/client/DockerConfig.java
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,101 @@ | ||
/*- | ||
* -\-\- | ||
* docker-client | ||
* -- | ||
* Copyright (C) 2016 - 2018 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
|
||
package com.spotify.docker.client; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; | ||
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.google.auto.value.AutoValue; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.spotify.docker.client.messages.RegistryAuth; | ||
|
||
import java.util.Map; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Represents the contents of the docker config.json file. | ||
*/ | ||
@AutoValue | ||
@JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE) | ||
public abstract class DockerConfig { | ||
|
||
@Nullable | ||
@JsonProperty("credsHelpers") | ||
public abstract ImmutableMap<String, String> credsHelpers(); | ||
|
||
@Nullable | ||
@JsonProperty("auths") | ||
public abstract ImmutableMap<String, RegistryAuth> auths(); | ||
|
||
@Nullable | ||
@JsonProperty("HttpHeaders") | ||
public abstract ImmutableMap<String, String> httpHeaders(); | ||
|
||
@Nullable | ||
@JsonProperty("credsStore") | ||
public abstract String credsStore(); | ||
|
||
@Nullable | ||
@JsonProperty("detachKeys") | ||
public abstract String detachKeys(); | ||
|
||
@Nullable | ||
@JsonProperty("stackOrchestrator") | ||
public abstract String stackOrchestrator(); | ||
|
||
@Nullable | ||
@JsonProperty("psFormat") | ||
public abstract String psFormat(); | ||
|
||
@Nullable | ||
@JsonProperty("imagesFormat") | ||
public abstract String imagesFormat(); | ||
|
||
@JsonCreator | ||
public static DockerConfig create( | ||
@JsonProperty("credsHelpers") final Map<String, String> credsHelpers, | ||
@JsonProperty("auths") final Map<String, RegistryAuth> auths, | ||
@JsonProperty("HttpHeaders") final Map<String, String> httpHeaders, | ||
@JsonProperty("credsStore") final String credsStore, | ||
@JsonProperty("detachKeys") final String detachKeys, | ||
@JsonProperty("stackOrchestrator") final String stackOrchestrator, | ||
@JsonProperty("psFormat") final String psFormat, | ||
@JsonProperty("imagesFormat") final String imagesFormat) { | ||
return new AutoValue_DockerConfig( | ||
credsHelpers == null | ||
? ImmutableMap.<String, String>of() | ||
: ImmutableMap.copyOf(credsHelpers), | ||
auths == null | ||
? ImmutableMap.<String, RegistryAuth>of() | ||
: ImmutableMap.copyOf(auths), | ||
httpHeaders == null | ||
? ImmutableMap.<String, String>of() | ||
: ImmutableMap.copyOf(httpHeaders), | ||
credsStore, | ||
detachKeys, | ||
stackOrchestrator, | ||
psFormat, | ||
imagesFormat); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confusing that this field is capitialized differently than all the others 😕 I double-checked the format in https://github.com/docker/cli/blob/08cf36daa65e22771cc47365ff1507c156c4a459/man/docker-config-json.5.md to make sure this seems ok though 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't seen that page. All the searches I did for
docker config
got swamped by the new feature: https://docs.docker.com/engine/reference/commandline/config/.I should add several of these properties to the object. Not that I think there is any real chance someone will need them, but if we have the thing, it may as well be able to read what we know can be in there.