-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACI should use the configurable DNS server (#127)
- Loading branch information
Showing
13 changed files
with
229 additions
and
2 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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/microsoft/jenkins/containeragents/aci/dns/AciDnsConfig.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,43 @@ | ||
package com.microsoft.jenkins.containeragents.aci.dns; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractDescribableImpl; | ||
import hudson.model.Descriptor; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class AciDnsConfig extends AbstractDescribableImpl<AciDnsConfig> { | ||
|
||
private List<AciDnsServer> dnsServers = new ArrayList<>(); | ||
|
||
@DataBoundConstructor | ||
public AciDnsConfig() { | ||
} | ||
|
||
public List<AciDnsServer> getDnsServers() { | ||
return dnsServers; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setDnsServers(List<AciDnsServer> dnsServers) { | ||
this.dnsServers = dnsServers.stream() | ||
.filter(aciDnsServer -> !aciDnsServer.getAddress().isEmpty()) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<AciDnsConfig> { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Aci DNS Config"; | ||
} | ||
|
||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/microsoft/jenkins/containeragents/aci/dns/AciDnsServer.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,30 @@ | ||
package com.microsoft.jenkins.containeragents.aci.dns; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractDescribableImpl; | ||
import hudson.model.Descriptor; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
public class AciDnsServer extends AbstractDescribableImpl<AciDnsServer> { | ||
|
||
private String address; | ||
|
||
@DataBoundConstructor | ||
public AciDnsServer(String address) { | ||
this.address = address; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<AciDnsServer> { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Aci DNS Server"; | ||
} | ||
|
||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
...sources/com/microsoft/jenkins/containeragents/aci/AciPrivateIpAddress/help-dnsConfig.html
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,10 @@ | ||
<div> | ||
Select if the container instance should use a specific DNS configuration. (See also | ||
<a href="https://docs.microsoft.com/en-us/azure/templates/microsoft.containerinstance/containergroups?tabs=json#dnsconfiguration"> | ||
Azure documentation about Container Group | ||
</a>). | ||
<p> | ||
Important: Currently, only a list of dns server name is supported. | ||
</p> | ||
|
||
</div> |
13 changes: 13 additions & 0 deletions
13
src/main/resources/com/microsoft/jenkins/containeragents/aci/dns/AciDnsConfig/config.jelly
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,13 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form"> | ||
|
||
<f:entry> | ||
<f:repeatable field="dnsServerNames" minimum="0"> | ||
<f:entry title="DNS server name" field="dnsServer"> | ||
<f:textbox/> | ||
</f:entry> | ||
</f:repeatable> | ||
</f:entry> | ||
|
||
|
||
</j:jelly> |
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
19 changes: 19 additions & 0 deletions
19
src/test/java/com/microsoft/jenkins/containeragents/aci/AciContainerTemplateTest.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,19 @@ | ||
package com.microsoft.jenkins.containeragents.aci; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
|
||
public class AciContainerTemplateTest { | ||
|
||
@Test | ||
public void ignoreWhitespaceInImageName() { | ||
AciContainerTemplate templateUnderTest = new AciContainerTemplate("name", "label", 100, | ||
"osType", " image ", "command" , "rootFs", null, null, | ||
null, null, null, "cpu", "memory"); | ||
|
||
assertThat(templateUnderTest.getImage(), equalTo("image")); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/java/com/microsoft/jenkins/containeragents/aci/dns/AciDnsConfigTest.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,21 @@ | ||
package com.microsoft.jenkins.containeragents.aci.dns; | ||
|
||
|
||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasSize; | ||
|
||
public class AciDnsConfigTest { | ||
|
||
@Test | ||
public void emptyDnServerNamesAreIgnored(){ | ||
AciDnsConfig configUnderTest = new AciDnsConfig(); | ||
configUnderTest.setDnsServers(Arrays.asList(new AciDnsServer("dnsServerName"), new AciDnsServer(""))); | ||
|
||
assertThat(configUnderTest.getDnsServers(), hasSize(1)); | ||
} | ||
|
||
} |
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