Skip to content

Commit

Permalink
feat: Added insecure registry support
Browse files Browse the repository at this point in the history
Added --insecure-registry=[true|false] as a command line flag
when adding a docker-registry account.

This is dependent on spinnaker/clouddriver#1887 and will
require a dependency version bump once merged and released.

This fixes spinnaker/halyard#680.
  • Loading branch information
Evan Zeimet committed Sep 11, 2017
1 parent 287f356 commit 6c2c356
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ protected String getProviderName() {
)
private Long cacheIntervalSeconds = 30L;

@Parameter(
names = "--insecure-registry",
description = DockerRegistryCommandProperties.CACHE_INTERVAL_SECONDS_DESCRIPTION
)
private Boolean insecureRegistry = false;

@Override
protected Account buildAccount(String accountName) {
DockerRegistryAccount account = (DockerRegistryAccount) new DockerRegistryAccount().setName(accountName);
Expand All @@ -87,7 +93,8 @@ protected Account buildAccount(String accountName) {
.setPasswordFile(passwordFile)
.setUsername(username)
.setEmail(email)
.setCacheIntervalSeconds(cacheIntervalSeconds);
.setCacheIntervalSeconds(cacheIntervalSeconds)
.setInsecureRegistry(insecureRegistry);

return account;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ class DockerRegistryCommandProperties {
static final String CACHE_INTERVAL_SECONDS_DESCRIPTION =
"How many seconds elapse between polling your docker registry. Certain registries are sensitive to over-polling, and "
+ "larger intervals (e.g. 10 minutes = 600 seconds) are desirable if you're seeing rate limiting.";

static final String INSECURE_REGISTRY_DESCRIPTION = "Treat the docker registry as insecure (don't validate the ssl cert).";
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ protected String getProviderName() {
)
private Long cacheIntervalSeconds;

@Parameter(
names = "--insecure-registry",
description = DockerRegistryCommandProperties.INSECURE_REGISTRY_DESCRIPTION
)
private Boolean insecureRegistry = false;

@Override
protected Account editAccount(DockerRegistryAccount account) {
account.setAddress(isSet(address) ? address : account.getAddress());
Expand Down Expand Up @@ -115,6 +121,7 @@ protected Account editAccount(DockerRegistryAccount account) {
account.setUsername(isSet(username) ? username : account.getUsername());
account.setEmail(isSet(email) ? email : account.getEmail());
account.setCacheIntervalSeconds(isSet(cacheIntervalSeconds) ? cacheIntervalSeconds : account.getCacheIntervalSeconds());
account.setInsecureRegistry(isSet(insecureRegistry) ? insecureRegistry : account.getInsecureRegistry());

return account;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class DockerRegistryAccount extends Account {
private String password;
private String email;
private Long cacheIntervalSeconds = 30L;
private Boolean insecureRegistry = false;
private List<String> repositories = new ArrayList<>();
@LocalFile private String passwordFile;
@LocalFile private String dockerconfigFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void validate(ConfigProblemSetBuilder p, DockerRegistryAccount n) {
.passwordFile(n.getPasswordFile())
.dockerconfigFile(n.getDockerconfigFile())
.username(n.getUsername())
.insecureRegistry(n.getInsecureRegistry())
.build();
} catch (Exception e) {
p.addProblem(Severity.ERROR, "Failed to instantiate docker credentials for account \"" + n.getName() + "\".");
Expand Down

0 comments on commit 6c2c356

Please sign in to comment.