Adding network policy reference (#269)
This commit is contained in:
committed by
Robbie Zhang
parent
12700633b1
commit
36eb3db8a9
@@ -10,8 +10,8 @@ import (
|
|||||||
const (
|
const (
|
||||||
// BaseURI is the default URI used for compute services.
|
// BaseURI is the default URI used for compute services.
|
||||||
baseURI = "https://management.azure.com"
|
baseURI = "https://management.azure.com"
|
||||||
userAgent = "virtual-kubelet/azure-arm-aci/2018-06-01"
|
userAgent = "virtual-kubelet/azure-arm-aci/2018-07-01"
|
||||||
apiVersion = "2018-06-01"
|
apiVersion = "2018-07-01"
|
||||||
|
|
||||||
containerGroupURLPath = "subscriptions/{{.subscriptionId}}/resourceGroups/{{.resourceGroup}}/providers/Microsoft.ContainerInstance/containerGroups/{{.containerGroupName}}"
|
containerGroupURLPath = "subscriptions/{{.subscriptionId}}/resourceGroups/{{.resourceGroup}}/providers/Microsoft.ContainerInstance/containerGroups/{{.containerGroupName}}"
|
||||||
containerGroupListURLPath = "subscriptions/{{.subscriptionId}}/providers/Microsoft.ContainerInstance/containerGroups"
|
containerGroupListURLPath = "subscriptions/{{.subscriptionId}}/providers/Microsoft.ContainerInstance/containerGroups"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package aci
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -13,13 +14,14 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
client *Client
|
client *Client
|
||||||
location = "eastus"
|
location = "eastus2euap"
|
||||||
resourceGroup = "virtual-kubelet-tests"
|
resourceGroup = "virtual-kubelet-tests"
|
||||||
containerGroup = "virtual-kubelet-test-container-group"
|
containerGroup = "virtual-kubelet-test-container-group"
|
||||||
|
subscriptionID string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Create a resource group name with uuid.
|
//Create a resource group name with uuid.
|
||||||
uid := uuid.New()
|
uid := uuid.New()
|
||||||
resourceGroup += "-" + uid.String()[0:6]
|
resourceGroup += "-" + uid.String()[0:6]
|
||||||
}
|
}
|
||||||
@@ -32,6 +34,8 @@ func TestMain(m *testing.M) {
|
|||||||
log.Fatalf("Failed to load Azure authentication file: %v", err)
|
log.Fatalf("Failed to load Azure authentication file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subscriptionID = auth.SubscriptionID
|
||||||
|
|
||||||
// Check if the resource group exists and create it if not.
|
// Check if the resource group exists and create it if not.
|
||||||
rgCli, err := resourcegroups.NewClient(auth)
|
rgCli, err := resourcegroups.NewClient(auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -195,6 +199,55 @@ func TestCreateContainerGroup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateContainerGroupWithBadVNetFails(t *testing.T) {
|
||||||
|
_, err := client.CreateContainerGroup(resourceGroup, containerGroup, ContainerGroup{
|
||||||
|
Location: location,
|
||||||
|
ContainerGroupProperties: ContainerGroupProperties{
|
||||||
|
OsType: Linux,
|
||||||
|
Containers: []Container{
|
||||||
|
{
|
||||||
|
Name: "nginx",
|
||||||
|
ContainerProperties: ContainerProperties{
|
||||||
|
Image: "nginx",
|
||||||
|
Command: []string{"nginx", "-g", "daemon off;"},
|
||||||
|
Ports: []ContainerPort{
|
||||||
|
{
|
||||||
|
Protocol: ContainerNetworkProtocolTCP,
|
||||||
|
Port: 80,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Resources: ResourceRequirements{
|
||||||
|
Requests: &ResourceRequests{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
Limits: &ResourceLimits{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
NetworkProfile: &NetworkProfileDefinition{
|
||||||
|
ID: fmt.Sprintf(
|
||||||
|
"/subscriptions/%s/resourceGroups/%s/providers"+
|
||||||
|
"/Microsoft.Network/networkProfiles/%s",
|
||||||
|
subscriptionID,
|
||||||
|
resourceGroup,
|
||||||
|
"badNetworkProfile",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected create container group to fail with NetworkProfileNotFound, but returned nil")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "NetworkProfileNotFound") {
|
||||||
|
t.Fatalf("expected NetworkProfileNotFound to be in the error message but got: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetContainerGroup(t *testing.T) {
|
func TestGetContainerGroup(t *testing.T) {
|
||||||
cg, err, _ := client.GetContainerGroup(resourceGroup, containerGroup)
|
cg, err, _ := client.GetContainerGroup(resourceGroup, containerGroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -93,7 +93,11 @@ type ContainerGroupProperties struct {
|
|||||||
OsType OperatingSystemTypes `json:"osType,omitempty"`
|
OsType OperatingSystemTypes `json:"osType,omitempty"`
|
||||||
Volumes []Volume `json:"volumes,omitempty"`
|
Volumes []Volume `json:"volumes,omitempty"`
|
||||||
InstanceView ContainerGroupPropertiesInstanceView `json:"instanceView,omitempty"`
|
InstanceView ContainerGroupPropertiesInstanceView `json:"instanceView,omitempty"`
|
||||||
|
<<<<<<< HEAD
|
||||||
Diagnostics *ContainerGroupDiagnostics `json:"diagnostics,omitempty"`
|
Diagnostics *ContainerGroupDiagnostics `json:"diagnostics,omitempty"`
|
||||||
|
=======
|
||||||
|
NetworkProfile *NetworkProfileDefinition `json:"networkProfile,omitempty"`
|
||||||
|
>>>>>>> Adding network policy reference (#269)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerGroupPropertiesInstanceView is the instance view of the container group. Only valid in response.
|
// ContainerGroupPropertiesInstanceView is the instance view of the container group. Only valid in response.
|
||||||
@@ -102,6 +106,12 @@ type ContainerGroupPropertiesInstanceView struct {
|
|||||||
State string `json:"state,omitempty"`
|
State string `json:"state,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NetworkProfileDefinition is the network profile definition. ID should be of the form
|
||||||
|
// /subscriptions/{subscriptionId} or /providers/{resourceProviderNamespace}/
|
||||||
|
type NetworkProfileDefinition struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// ContainerGroupListResult is the container group list response that contains the container group properties.
|
// ContainerGroupListResult is the container group list response that contains the container group properties.
|
||||||
type ContainerGroupListResult struct {
|
type ContainerGroupListResult struct {
|
||||||
api.ResponseMetadata `json:"-"`
|
api.ResponseMetadata `json:"-"`
|
||||||
|
|||||||
Reference in New Issue
Block a user