Commit 025c57e6 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #37783 from brendandburns/acr

Automatic merge from submit-queue Add support for Azure Container Registry, update Azure dependencies @colemickens
parents 1286601c 91f19e3d
......@@ -30,51 +30,61 @@
},
{
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/compute",
"Comment": "v3.1.0-beta-24-g8316b90",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2"
"Comment": "v7.0.1-beta",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4"
},
{
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/containerregistry",
"Comment": "v7.0.1-beta",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4"
},
{
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/network",
"Comment": "v3.1.0-beta-24-g8316b90",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2"
"Comment": "v7.0.1-beta",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4"
},
{
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/storage",
"Comment": "v3.1.0-beta-24-g8316b90",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2"
"Comment": "v7.0.1-beta",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4"
},
{
"ImportPath": "github.com/Azure/azure-sdk-for-go/storage",
"Comment": "v3.1.0-beta-24-g8316b90",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2"
"Comment": "v7.0.1-beta",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4"
},
{
"ImportPath": "github.com/Azure/go-ansiterm",
"Rev": "70b2c90b260171e829f1ebd7c17f600c11858dbe"
"Rev": "fa152c58bc15761d0200cb75fe958b89a9d4888e"
},
{
"ImportPath": "github.com/Azure/go-ansiterm/winterm",
"Rev": "70b2c90b260171e829f1ebd7c17f600c11858dbe"
"Rev": "fa152c58bc15761d0200cb75fe958b89a9d4888e"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest",
"Comment": "v7.0.6-4-g2492d97",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a"
"Comment": "v7.2.2-8-ge0c77ec",
"Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest/azure",
"Comment": "v7.0.6-4-g2492d97",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a"
"Comment": "v7.2.2-8-ge0c77ec",
"Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest/date",
"Comment": "v7.0.6-4-g2492d97",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a"
"Comment": "v7.2.2-8-ge0c77ec",
"Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest/to",
"Comment": "v7.0.6-4-g2492d97",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a"
"Comment": "v7.2.2-8-ge0c77ec",
"Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest/validation",
"Comment": "v7.2.2-8-ge0c77ec",
"Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
},
{
"ImportPath": "github.com/MakeNowJust/heredoc",
......@@ -2304,12 +2314,12 @@
},
{
"ImportPath": "github.com/vmware/photon-controller-go-sdk/photon",
"Comment": "PROMOTED-336",
"Comment": "PROMOTED-339",
"Rev": "dd6be2029ef341cae37b2557ddd302f68176f832"
},
{
"ImportPath": "github.com/vmware/photon-controller-go-sdk/photon/lightwave",
"Comment": "PROMOTED-336",
"Comment": "PROMOTED-339",
"Rev": "dd6be2029ef341cae37b2557ddd302f68176f832"
},
{
......
......@@ -46,6 +46,7 @@ go_library(
"//pkg/cloudprovider/providers:go_default_library",
"//pkg/credentialprovider:go_default_library",
"//pkg/credentialprovider/aws:go_default_library",
"//pkg/credentialprovider/azure:go_default_library",
"//pkg/credentialprovider/gcp:go_default_library",
"//pkg/genericapiserver/authorizer:go_default_library",
"//pkg/healthz:go_default_library",
......
......@@ -20,6 +20,7 @@ package app
import (
// Credential providers
_ "k8s.io/kubernetes/pkg/credentialprovider/aws"
_ "k8s.io/kubernetes/pkg/credentialprovider/azure"
_ "k8s.io/kubernetes/pkg/credentialprovider/gcp"
// Network plugins
"k8s.io/kubernetes/pkg/kubelet/network"
......
......@@ -43,6 +43,7 @@ authorization-rbac-super-user
authorization-webhook-cache-authorized-ttl
authorization-webhook-cache-unauthorized-ttl
authorization-webhook-config-file
azure-container-registry-config
babysit-daemons
basic-auth-file
bench-pods
......
......@@ -68,7 +68,7 @@ func (az *Cloud) InstanceType(name types.NodeName) (string, error) {
} else if !exists {
return "", cloudprovider.InstanceNotFound
}
return string(machine.Properties.HardwareProfile.VMSize), nil
return string(machine.HardwareProfile.VMSize), nil
}
// List lists instances that match 'filter' which is a regular expression which must match the entire instance name (fqdn)
......
......@@ -57,7 +57,7 @@ func (az *Cloud) GetLoadBalancer(clusterName string, service *v1.Service) (statu
}
return &v1.LoadBalancerStatus{
Ingress: []v1.LoadBalancerIngress{{IP: *pip.Properties.IPAddress}},
Ingress: []v1.LoadBalancerIngress{{IP: *pip.IPAddress}},
}, true, nil
}
......@@ -95,9 +95,9 @@ func (az *Cloud) EnsureLoadBalancer(clusterName string, service *v1.Service, nod
}
if !existsLb {
lb = network.LoadBalancer{
Name: &lbName,
Location: &az.Location,
Properties: &network.LoadBalancerPropertiesFormat{},
Name: &lbName,
Location: &az.Location,
LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{},
}
}
......@@ -134,9 +134,9 @@ func (az *Cloud) EnsureLoadBalancer(clusterName string, service *v1.Service, nod
return nil, utilerrors.Flatten(errs)
}
glog.V(2).Infof("ensure(%s): FINISH - %s", serviceName, *pip.Properties.IPAddress)
glog.V(2).Infof("ensure(%s): FINISH - %s", serviceName, *pip.IPAddress)
return &v1.LoadBalancerStatus{
Ingress: []v1.LoadBalancerIngress{{IP: *pip.Properties.IPAddress}},
Ingress: []v1.LoadBalancerIngress{{IP: *pip.IPAddress}},
}, nil
}
......@@ -172,7 +172,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *v1.Servi
return reconcileErr
}
if lbNeedsUpdate {
if len(*lb.Properties.FrontendIPConfigurations) > 0 {
if len(*lb.FrontendIPConfigurations) > 0 {
glog.V(3).Infof("delete(%s): lb(%s) - updating", serviceName, lbName)
_, err = az.LoadBalancerClient.CreateOrUpdate(az.ResourceGroup, *lb.Name, lb, nil)
if err != nil {
......@@ -227,7 +227,7 @@ func (az *Cloud) ensurePublicIPExists(serviceName, pipName string) (*network.Pub
pip.Name = to.StringPtr(pipName)
pip.Location = to.StringPtr(az.Location)
pip.Properties = &network.PublicIPAddressPropertiesFormat{
pip.PublicIPAddressPropertiesFormat = &network.PublicIPAddressPropertiesFormat{
PublicIPAllocationMethod: network.Static,
}
pip.Tags = &map[string]*string{"service": &serviceName}
......@@ -273,8 +273,8 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
// Ensure LoadBalancer's Backend Pool Configuration
if wantLb {
newBackendPools := []network.BackendAddressPool{}
if lb.Properties.BackendAddressPools != nil {
newBackendPools = *lb.Properties.BackendAddressPools
if lb.BackendAddressPools != nil {
newBackendPools = *lb.BackendAddressPools
}
foundBackendPool := false
......@@ -294,15 +294,15 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
glog.V(10).Infof("reconcile(%s)(%t): lb backendpool - adding backendpool", serviceName, wantLb)
dirtyLb = true
lb.Properties.BackendAddressPools = &newBackendPools
lb.BackendAddressPools = &newBackendPools
}
}
// Ensure LoadBalancer's Frontend IP Configurations
dirtyConfigs := false
newConfigs := []network.FrontendIPConfiguration{}
if lb.Properties.FrontendIPConfigurations != nil {
newConfigs = *lb.Properties.FrontendIPConfigurations
if lb.FrontendIPConfigurations != nil {
newConfigs = *lb.FrontendIPConfigurations
}
if !wantLb {
for i := len(newConfigs) - 1; i >= 0; i-- {
......@@ -325,7 +325,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
newConfigs = append(newConfigs,
network.FrontendIPConfiguration{
Name: to.StringPtr(lbFrontendIPConfigName),
Properties: &network.FrontendIPConfigurationPropertiesFormat{
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{
ID: pip.ID,
},
......@@ -337,7 +337,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
}
if dirtyConfigs {
dirtyLb = true
lb.Properties.FrontendIPConfigurations = &newConfigs
lb.FrontendIPConfigurations = &newConfigs
}
// update probes/rules
......@@ -356,7 +356,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
expectedProbes[i] = network.Probe{
Name: &lbRuleName,
Properties: &network.ProbePropertiesFormat{
ProbePropertiesFormat: &network.ProbePropertiesFormat{
RequestPath: to.StringPtr(podPresencePath),
Protocol: network.ProbeProtocolHTTP,
Port: to.Int32Ptr(podPresencePort),
......@@ -367,7 +367,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
} else {
expectedProbes[i] = network.Probe{
Name: &lbRuleName,
Properties: &network.ProbePropertiesFormat{
ProbePropertiesFormat: &network.ProbePropertiesFormat{
Protocol: probeProto,
Port: to.Int32Ptr(port.NodePort),
IntervalInSeconds: to.Int32Ptr(5),
......@@ -378,7 +378,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
expectedRules[i] = network.LoadBalancingRule{
Name: &lbRuleName,
Properties: &network.LoadBalancingRulePropertiesFormat{
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
Protocol: transportProto,
FrontendIPConfiguration: &network.SubResource{
ID: to.StringPtr(lbFrontendIPConfigID),
......@@ -399,8 +399,8 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
// remove unwanted probes
dirtyProbes := false
var updatedProbes []network.Probe
if lb.Properties.Probes != nil {
updatedProbes = *lb.Properties.Probes
if lb.Probes != nil {
updatedProbes = *lb.Probes
}
for i := len(updatedProbes) - 1; i >= 0; i-- {
existingProbe := updatedProbes[i]
......@@ -433,14 +433,14 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
}
if dirtyProbes {
dirtyLb = true
lb.Properties.Probes = &updatedProbes
lb.Probes = &updatedProbes
}
// update rules
dirtyRules := false
var updatedRules []network.LoadBalancingRule
if lb.Properties.LoadBalancingRules != nil {
updatedRules = *lb.Properties.LoadBalancingRules
if lb.LoadBalancingRules != nil {
updatedRules = *lb.LoadBalancingRules
}
// update rules: remove unwanted
for i := len(updatedRules) - 1; i >= 0; i-- {
......@@ -474,7 +474,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
}
if dirtyRules {
dirtyLb = true
lb.Properties.LoadBalancingRules = &updatedRules
lb.LoadBalancingRules = &updatedRules
}
return lb, dirtyLb, nil
......@@ -510,7 +510,7 @@ func (az *Cloud) reconcileSecurityGroup(sg network.SecurityGroup, clusterName st
ix := i*len(sourceAddressPrefixes) + j
expectedSecurityRules[ix] = network.SecurityRule{
Name: to.StringPtr(securityRuleName),
Properties: &network.SecurityRulePropertiesFormat{
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
Protocol: securityProto,
SourcePortRange: to.StringPtr("*"),
DestinationPortRange: to.StringPtr(strconv.Itoa(int(port.Port))),
......@@ -526,8 +526,8 @@ func (az *Cloud) reconcileSecurityGroup(sg network.SecurityGroup, clusterName st
// update security rules
dirtySg := false
var updatedRules []network.SecurityRule
if sg.Properties.SecurityRules != nil {
updatedRules = *sg.Properties.SecurityRules
if sg.SecurityRules != nil {
updatedRules = *sg.SecurityRules
}
// update security rules: remove unwanted
for i := len(updatedRules) - 1; i >= 0; i-- {
......@@ -561,13 +561,13 @@ func (az *Cloud) reconcileSecurityGroup(sg network.SecurityGroup, clusterName st
return sg, false, err
}
expectedRule.Properties.Priority = to.Int32Ptr(nextAvailablePriority)
expectedRule.Priority = to.Int32Ptr(nextAvailablePriority)
updatedRules = append(updatedRules, expectedRule)
dirtySg = true
}
}
if dirtySg {
sg.Properties.SecurityRules = &updatedRules
sg.SecurityRules = &updatedRules
}
return sg, dirtySg, nil
}
......@@ -620,7 +620,7 @@ func (az *Cloud) ensureHostInPool(serviceName string, nodeName types.NodeName, b
// Check availability set
if az.PrimaryAvailabilitySetName != "" {
expectedAvailabilitySetName := az.getAvailabilitySetID(az.PrimaryAvailabilitySetName)
if !strings.EqualFold(*machine.Properties.AvailabilitySet.ID, expectedAvailabilitySetName) {
if !strings.EqualFold(*machine.AvailabilitySet.ID, expectedAvailabilitySetName) {
glog.V(3).Infof(
"nicupdate(%s): skipping nic (%s) since it is not in the primaryAvailabilitSet(%s)",
serviceName, nicName, az.PrimaryAvailabilitySetName)
......@@ -641,8 +641,8 @@ func (az *Cloud) ensureHostInPool(serviceName string, nodeName types.NodeName, b
foundPool := false
newBackendPools := []network.BackendAddressPool{}
if primaryIPConfig.Properties.LoadBalancerBackendAddressPools != nil {
newBackendPools = *primaryIPConfig.Properties.LoadBalancerBackendAddressPools
if primaryIPConfig.LoadBalancerBackendAddressPools != nil {
newBackendPools = *primaryIPConfig.LoadBalancerBackendAddressPools
}
for _, existingPool := range newBackendPools {
if strings.EqualFold(backendPoolID, *existingPool.ID) {
......@@ -656,7 +656,7 @@ func (az *Cloud) ensureHostInPool(serviceName string, nodeName types.NodeName, b
ID: to.StringPtr(backendPoolID),
})
primaryIPConfig.Properties.LoadBalancerBackendAddressPools = &newBackendPools
primaryIPConfig.LoadBalancerBackendAddressPools = &newBackendPools
glog.V(3).Infof("nicupdate(%s): nic(%s) - updating", serviceName, nicName)
_, err := az.InterfacesClient.CreateOrUpdate(az.ResourceGroup, *nic.Name, nic, nil)
......
......@@ -39,11 +39,11 @@ func (az *Cloud) ListRoutes(clusterName string) (routes []*cloudprovider.Route,
}
var kubeRoutes []*cloudprovider.Route
if routeTable.Properties.Routes != nil {
kubeRoutes = make([]*cloudprovider.Route, len(*routeTable.Properties.Routes))
for i, route := range *routeTable.Properties.Routes {
if routeTable.Routes != nil {
kubeRoutes = make([]*cloudprovider.Route, len(*routeTable.Routes))
for i, route := range *routeTable.Routes {
instance := mapRouteNameToNodeName(*route.Name)
cidr := *route.Properties.AddressPrefix
cidr := *route.AddressPrefix
glog.V(10).Infof("list: * instance=%q, cidr=%q", instance, cidr)
kubeRoutes[i] = &cloudprovider.Route{
......@@ -70,9 +70,9 @@ func (az *Cloud) CreateRoute(clusterName string, nameHint string, kubeRoute *clo
}
if !existsRouteTable {
routeTable = network.RouteTable{
Name: to.StringPtr(az.RouteTableName),
Location: to.StringPtr(az.Location),
Properties: &network.RouteTablePropertiesFormat{},
Name: to.StringPtr(az.RouteTableName),
Location: to.StringPtr(az.Location),
RouteTablePropertiesFormat: &network.RouteTablePropertiesFormat{},
}
glog.V(3).Infof("create: creating routetable. routeTableName=%q", az.RouteTableName)
......@@ -93,12 +93,12 @@ func (az *Cloud) CreateRoute(clusterName string, nameHint string, kubeRoute *clo
// 404 is fatal here
return err
}
if subnet.Properties.RouteTable != nil {
if *subnet.Properties.RouteTable.ID != *routeTable.ID {
return fmt.Errorf("The subnet has a route table, but it was unrecognized. Refusing to modify it. active_routetable=%q expected_routetable=%q", *subnet.Properties.RouteTable.ID, *routeTable.ID)
if subnet.RouteTable != nil {
if *subnet.RouteTable.ID != *routeTable.ID {
return fmt.Errorf("The subnet has a route table, but it was unrecognized. Refusing to modify it. active_routetable=%q expected_routetable=%q", *subnet.RouteTable.ID, *routeTable.ID)
}
} else {
subnet.Properties.RouteTable = &network.RouteTable{
subnet.RouteTable = &network.RouteTable{
ID: routeTable.ID,
}
glog.V(3).Info("create: updating subnet")
......@@ -116,7 +116,7 @@ func (az *Cloud) CreateRoute(clusterName string, nameHint string, kubeRoute *clo
routeName := mapNodeNameToRouteName(kubeRoute.TargetNode)
route := network.Route{
Name: to.StringPtr(routeName),
Properties: &network.RoutePropertiesFormat{
RoutePropertiesFormat: &network.RoutePropertiesFormat{
AddressPrefix: to.StringPtr(kubeRoute.DestinationCIDR),
NextHopType: network.RouteNextHopTypeVirtualAppliance,
NextHopIPAddress: to.StringPtr(targetIP),
......
......@@ -39,7 +39,7 @@ func (az *Cloud) AttachDisk(diskName, diskURI string, nodeName types.NodeName, l
} else if !exists {
return cloudprovider.InstanceNotFound
}
disks := *vm.Properties.StorageProfile.DataDisks
disks := *vm.StorageProfile.DataDisks
disks = append(disks,
compute.DataDisk{
Name: &diskName,
......@@ -53,7 +53,7 @@ func (az *Cloud) AttachDisk(diskName, diskURI string, nodeName types.NodeName, l
newVM := compute.VirtualMachine{
Location: vm.Location,
Properties: &compute.VirtualMachineProperties{
VirtualMachineProperties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{
DataDisks: &disks,
},
......@@ -91,7 +91,7 @@ func (az *Cloud) DisksAreAttached(diskNames []string, nodeName types.NodeName) (
return attached, err
}
disks := *vm.Properties.StorageProfile.DataDisks
disks := *vm.StorageProfile.DataDisks
for _, disk := range disks {
for _, diskName := range diskNames {
if disk.Name != nil && diskName != "" && *disk.Name == diskName {
......@@ -113,7 +113,7 @@ func (az *Cloud) DetachDiskByName(diskName, diskURI string, nodeName types.NodeN
return nil
}
disks := *vm.Properties.StorageProfile.DataDisks
disks := *vm.StorageProfile.DataDisks
for i, disk := range disks {
if (disk.Name != nil && diskName != "" && *disk.Name == diskName) || (disk.Vhd.URI != nil && diskURI != "" && *disk.Vhd.URI == diskURI) {
// found the disk
......@@ -124,7 +124,7 @@ func (az *Cloud) DetachDiskByName(diskName, diskURI string, nodeName types.NodeN
}
newVM := compute.VirtualMachine{
Location: vm.Location,
Properties: &compute.VirtualMachineProperties{
VirtualMachineProperties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{
DataDisks: &disks,
},
......@@ -148,7 +148,7 @@ func (az *Cloud) GetDiskLun(diskName, diskURI string, nodeName types.NodeName) (
} else if !exists {
return -1, cloudprovider.InstanceNotFound
}
disks := *vm.Properties.StorageProfile.DataDisks
disks := *vm.StorageProfile.DataDisks
for _, disk := range disks {
if disk.Lun != nil && (disk.Name != nil && diskName != "" && *disk.Name == diskName) || (disk.Vhd.URI != nil && diskURI != "" && *disk.Vhd.URI == diskURI) {
// found the disk
......@@ -169,7 +169,7 @@ func (az *Cloud) GetNextDiskLun(nodeName types.NodeName) (int32, error) {
return -1, cloudprovider.InstanceNotFound
}
used := make([]bool, maxLUN)
disks := *vm.Properties.StorageProfile.DataDisks
disks := *vm.StorageProfile.DataDisks
for _, disk := range disks {
if disk.Lun != nil {
used[*disk.Lun] = true
......
......@@ -50,7 +50,7 @@ func TestReconcileLoadBalancerAddPort(t *testing.T) {
}
// ensure we got a frontend ip configuration
if len(*lb.Properties.FrontendIPConfigurations) != 1 {
if len(*lb.FrontendIPConfigurations) != 1 {
t.Error("Expected the loadbalancer to have a frontend ip configuration")
}
......@@ -79,7 +79,7 @@ func TestReconcileLoadBalancerNodeHealth(t *testing.T) {
}
// ensure we got a frontend ip configuration
if len(*lb.Properties.FrontendIPConfigurations) != 1 {
if len(*lb.FrontendIPConfigurations) != 1 {
t.Error("Expected the loadbalancer to have a frontend ip configuration")
}
......@@ -110,7 +110,7 @@ func TestReconcileLoadBalancerRemoveAllPortsRemovesFrontendConfig(t *testing.T)
}
// ensure we abandoned the frontend ip configuration
if len(*lb.Properties.FrontendIPConfigurations) != 0 {
if len(*lb.FrontendIPConfigurations) != 0 {
t.Error("Expected the loadbalancer to have no frontend ip configuration")
}
......@@ -262,14 +262,14 @@ func getTestLoadBalancer(services ...v1.Service) network.LoadBalancer {
ruleName := getRuleName(&service, port)
rules = append(rules, network.LoadBalancingRule{
Name: to.StringPtr(ruleName),
Properties: &network.LoadBalancingRulePropertiesFormat{
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
FrontendPort: to.Int32Ptr(port.Port),
BackendPort: to.Int32Ptr(port.Port),
},
})
probes = append(probes, network.Probe{
Name: to.StringPtr(ruleName),
Properties: &network.ProbePropertiesFormat{
ProbePropertiesFormat: &network.ProbePropertiesFormat{
Port: to.Int32Ptr(port.NodePort),
},
})
......@@ -277,7 +277,7 @@ func getTestLoadBalancer(services ...v1.Service) network.LoadBalancer {
}
lb := network.LoadBalancer{
Properties: &network.LoadBalancerPropertiesFormat{
LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{
LoadBalancingRules: &rules,
Probes: &probes,
},
......@@ -304,7 +304,7 @@ func getTestSecurityGroup(services ...v1.Service) network.SecurityGroup {
for _, src := range sources {
rules = append(rules, network.SecurityRule{
Name: to.StringPtr(ruleName),
Properties: &network.SecurityRulePropertiesFormat{
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
SourceAddressPrefix: to.StringPtr(src),
DestinationPortRange: to.StringPtr(fmt.Sprintf("%d", port.Port)),
},
......@@ -314,7 +314,7 @@ func getTestSecurityGroup(services ...v1.Service) network.SecurityGroup {
}
sg := network.SecurityGroup{
Properties: &network.SecurityGroupPropertiesFormat{
SecurityGroupPropertiesFormat: &network.SecurityGroupPropertiesFormat{
SecurityRules: &rules,
},
}
......@@ -329,10 +329,10 @@ func validateLoadBalancer(t *testing.T, loadBalancer network.LoadBalancer, servi
expectedRuleCount++
wantedRuleName := getRuleName(&svc, wantedRule)
foundRule := false
for _, actualRule := range *loadBalancer.Properties.LoadBalancingRules {
for _, actualRule := range *loadBalancer.LoadBalancingRules {
if strings.EqualFold(*actualRule.Name, wantedRuleName) &&
*actualRule.Properties.FrontendPort == wantedRule.Port &&
*actualRule.Properties.BackendPort == wantedRule.Port {
*actualRule.FrontendPort == wantedRule.Port &&
*actualRule.BackendPort == wantedRule.Port {
foundRule = true
break
}
......@@ -344,38 +344,38 @@ func validateLoadBalancer(t *testing.T, loadBalancer network.LoadBalancer, servi
foundProbe := false
if serviceapi.NeedsHealthCheck(&svc) {
path, port := serviceapi.GetServiceHealthCheckPathPort(&svc)
for _, actualProbe := range *loadBalancer.Properties.Probes {
for _, actualProbe := range *loadBalancer.Probes {
if strings.EqualFold(*actualProbe.Name, wantedRuleName) &&
*actualProbe.Properties.Port == port &&
*actualProbe.Properties.RequestPath == path &&
actualProbe.Properties.Protocol == network.ProbeProtocolHTTP {
*actualProbe.Port == port &&
*actualProbe.RequestPath == path &&
actualProbe.Protocol == network.ProbeProtocolHTTP {
foundProbe = true
break
}
}
} else {
for _, actualProbe := range *loadBalancer.Properties.Probes {
for _, actualProbe := range *loadBalancer.Probes {
if strings.EqualFold(*actualProbe.Name, wantedRuleName) &&
*actualProbe.Properties.Port == wantedRule.NodePort {
*actualProbe.Port == wantedRule.NodePort {
foundProbe = true
break
}
}
}
if !foundProbe {
for _, actualProbe := range *loadBalancer.Properties.Probes {
t.Logf("Probe: %s %d", *actualProbe.Name, *actualProbe.Properties.Port)
for _, actualProbe := range *loadBalancer.Probes {
t.Logf("Probe: %s %d", *actualProbe.Name, *actualProbe.Port)
}
t.Errorf("Expected loadbalancer probe but didn't find it: %q", wantedRuleName)
}
}
}
lenRules := len(*loadBalancer.Properties.LoadBalancingRules)
lenRules := len(*loadBalancer.LoadBalancingRules)
if lenRules != expectedRuleCount {
t.Errorf("Expected the loadbalancer to have %d rules. Found %d.\n%v", expectedRuleCount, lenRules, loadBalancer.Properties.LoadBalancingRules)
t.Errorf("Expected the loadbalancer to have %d rules. Found %d.\n%v", expectedRuleCount, lenRules, loadBalancer.LoadBalancingRules)
}
lenProbes := len(*loadBalancer.Properties.Probes)
lenProbes := len(*loadBalancer.Probes)
if lenProbes != expectedRuleCount {
t.Errorf("Expected the loadbalancer to have %d probes. Found %d.", expectedRuleCount, lenProbes)
}
......@@ -391,10 +391,10 @@ func validateSecurityGroup(t *testing.T, securityGroup network.SecurityGroup, se
expectedRuleCount++
wantedRuleName := getRuleName(&svc, wantedRule)
foundRule := false
for _, actualRule := range *securityGroup.Properties.SecurityRules {
for _, actualRule := range *securityGroup.SecurityRules {
if strings.EqualFold(*actualRule.Name, wantedRuleName) &&
*actualRule.Properties.SourceAddressPrefix == source &&
*actualRule.Properties.DestinationPortRange == fmt.Sprintf("%d", wantedRule.Port) {
*actualRule.SourceAddressPrefix == source &&
*actualRule.DestinationPortRange == fmt.Sprintf("%d", wantedRule.Port) {
foundRule = true
break
}
......@@ -406,7 +406,7 @@ func validateSecurityGroup(t *testing.T, securityGroup network.SecurityGroup, se
}
}
lenRules := len(*securityGroup.Properties.SecurityRules)
lenRules := len(*securityGroup.SecurityRules)
if lenRules != expectedRuleCount {
t.Errorf("Expected the loadbalancer to have %d rules. Found %d.\n", expectedRuleCount, lenRules)
}
......@@ -420,7 +420,7 @@ func TestSecurityRulePriorityPicksNextAvailablePriority(t *testing.T) {
var i int32
for i = loadBalancerMinimumPriority; i < expectedPriority; i++ {
rules = append(rules, network.SecurityRule{
Properties: &network.SecurityRulePropertiesFormat{
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
Priority: to.Int32Ptr(i),
},
})
......@@ -442,7 +442,7 @@ func TestSecurityRulePriorityFailsIfExhausted(t *testing.T) {
var i int32
for i = loadBalancerMinimumPriority; i < loadBalancerMaximumPriority; i++ {
rules = append(rules, network.SecurityRule{
Properties: &network.SecurityRulePropertiesFormat{
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
Priority: to.Int32Ptr(i),
},
})
......
......@@ -133,12 +133,12 @@ func getProtocolsFromKubernetesProtocol(protocol v1.Protocol) (network.Transport
// This returns the full identifier of the primary NIC for the given VM.
func getPrimaryInterfaceID(machine compute.VirtualMachine) (string, error) {
if len(*machine.Properties.NetworkProfile.NetworkInterfaces) == 1 {
return *(*machine.Properties.NetworkProfile.NetworkInterfaces)[0].ID, nil
if len(*machine.NetworkProfile.NetworkInterfaces) == 1 {
return *(*machine.NetworkProfile.NetworkInterfaces)[0].ID, nil
}
for _, ref := range *machine.Properties.NetworkProfile.NetworkInterfaces {
if *ref.Properties.Primary {
for _, ref := range *machine.NetworkProfile.NetworkInterfaces {
if *ref.Primary {
return *ref.ID, nil
}
}
......@@ -147,12 +147,12 @@ func getPrimaryInterfaceID(machine compute.VirtualMachine) (string, error) {
}
func getPrimaryIPConfig(nic network.Interface) (*network.InterfaceIPConfiguration, error) {
if len(*nic.Properties.IPConfigurations) == 1 {
return &((*nic.Properties.IPConfigurations)[0]), nil
if len(*nic.IPConfigurations) == 1 {
return &((*nic.IPConfigurations)[0]), nil
}
for _, ref := range *nic.Properties.IPConfigurations {
if *ref.Properties.Primary {
for _, ref := range *nic.IPConfigurations {
if *ref.Primary {
return &ref, nil
}
}
......@@ -204,7 +204,7 @@ func getNextAvailablePriority(rules []network.SecurityRule) (int32, error) {
outer:
for smallest < loadBalancerMaximumPriority {
for _, rule := range rules {
if *rule.Properties.Priority == smallest {
if *rule.Priority == smallest {
smallest += spread
continue outer
}
......@@ -245,6 +245,6 @@ func (az *Cloud) getIPForMachine(nodeName types.NodeName) (string, error) {
return "", err
}
targetIP := *ipConfig.Properties.PrivateIPAddress
targetIP := *ipConfig.PrivateIPAddress
return targetIP, nil
}
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
"go_test",
"cgo_library",
)
go_library(
name = "go_default_library",
srcs = ["azure_credentials.go"],
tags = ["automanaged"],
deps = [
"//pkg/cloudprovider/providers/azure:go_default_library",
"//pkg/credentialprovider:go_default_library",
"//vendor:github.com/Azure/azure-sdk-for-go/arm/containerregistry",
"//vendor:github.com/Azure/go-autorest/autorest/azure",
"//vendor:github.com/golang/glog",
"//vendor:github.com/spf13/pflag",
"//vendor:gopkg.in/yaml.v2",
],
)
go_test(
name = "go_default_test",
srcs = ["azure_credentials_test.go"],
library = "go_default_library",
tags = ["automanaged"],
deps = [
"//vendor:github.com/Azure/azure-sdk-for-go/arm/containerregistry",
"//vendor:github.com/Azure/go-autorest/autorest/to",
],
)
/*
Copyright 2016 The Kubernetes Authors.
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 azure
import (
"fmt"
"io/ioutil"
"time"
yaml "gopkg.in/yaml.v2"
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
azureapi "github.com/Azure/go-autorest/autorest/azure"
"github.com/golang/glog"
"github.com/spf13/pflag"
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure"
"k8s.io/kubernetes/pkg/credentialprovider"
)
var flagConfigFile = pflag.String("azure-container-registry-config", "",
"Path to the file container Azure container registry configuration information.")
const dummyRegistryEmail = "name@contoso.com"
// init registers the various means by which credentials may
// be resolved on Azure.
func init() {
credentialprovider.RegisterCredentialProvider("azure",
&credentialprovider.CachingDockerConfigProvider{
Provider: NewACRProvider(flagConfigFile),
Lifetime: 1 * time.Minute,
})
}
type RegistriesClient interface {
List() (containerregistry.RegistryListResult, error)
}
func NewACRProvider(configFile *string) credentialprovider.DockerConfigProvider {
return &acrProvider{
file: configFile,
}
}
type acrProvider struct {
file *string
config azure.Config
environment azureapi.Environment
registryClient RegistriesClient
}
func (a *acrProvider) loadConfig(contents []byte) error {
err := yaml.Unmarshal(contents, &a.config)
if err != nil {
return err
}
if a.config.Cloud == "" {
a.environment = azureapi.PublicCloud
} else {
a.environment, err = azureapi.EnvironmentFromName(a.config.Cloud)
if err != nil {
return err
}
}
return nil
}
func (a *acrProvider) Enabled() bool {
if a.file == nil || len(*a.file) == 0 {
glog.V(5).Infof("Azure config unspecified, disabling")
return false
}
contents, err := ioutil.ReadFile(*a.file)
if err != nil {
glog.Errorf("Failed to load azure credential file: %v", err)
return false
}
if err := a.loadConfig(contents); err != nil {
glog.Errorf("Failed to parse azure credential file: %v", err)
return false
}
oauthConfig, err := a.environment.OAuthConfigForTenant(a.config.TenantID)
if err != nil {
glog.Errorf("Failed to get oauth config: %v", err)
return false
}
servicePrincipalToken, err := azureapi.NewServicePrincipalToken(
*oauthConfig,
a.config.AADClientID,
a.config.AADClientSecret,
a.environment.ServiceManagementEndpoint)
if err != nil {
glog.Errorf("Failed to create service principal token: %v", err)
return false
}
registryClient := containerregistry.NewRegistriesClient(a.config.SubscriptionID)
registryClient.BaseURI = a.environment.ResourceManagerEndpoint
registryClient.Authorizer = servicePrincipalToken
a.registryClient = registryClient
return true
}
func (a *acrProvider) Provide() credentialprovider.DockerConfig {
cfg := credentialprovider.DockerConfig{}
entry := credentialprovider.DockerConfigEntry{
Username: a.config.AADClientID,
Password: a.config.AADClientSecret,
Email: dummyRegistryEmail,
}
res, err := a.registryClient.List()
if err != nil {
glog.Errorf("Failed to list registries: %v", err)
return cfg
}
for ix := range *res.Value {
// TODO: I don't think this will work for national clouds
cfg[fmt.Sprintf("%s.azurecr.io", *(*res.Value)[ix].Name)] = entry
}
return cfg
}
func (a *acrProvider) LazyProvide() *credentialprovider.DockerConfigEntry {
return nil
}
/*
Copyright 2016 The Kubernetes Authors.
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 azure
import (
"testing"
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
"github.com/Azure/go-autorest/autorest/to"
)
type fakeClient struct {
results containerregistry.RegistryListResult
}
func (f *fakeClient) List() (containerregistry.RegistryListResult, error) {
return f.results, nil
}
func Test(t *testing.T) {
configStr := `
{
"aadClientId": "foo",
"aadClientSecret": "bar"
}`
result := containerregistry.RegistryListResult{
Value: &[]containerregistry.Registry{
{
Name: to.StringPtr("foo"),
},
{
Name: to.StringPtr("bar"),
},
{
Name: to.StringPtr("baz"),
},
},
}
fakeClient := &fakeClient{
results: result,
}
provider := &acrProvider{
registryClient: fakeClient,
}
provider.loadConfig([]byte(configStr))
creds := provider.Provide()
if len(creds) != len(*result.Value) {
t.Errorf("Unexpected list: %v, expected length %d", creds, len(*result.Value))
}
for _, cred := range creds {
if cred.Username != "foo" {
t.Errorf("expected 'foo' for username, saw: %v", cred.Username)
}
if cred.Password != "bar" {
t.Errorf("expected 'bar' for password, saw: %v", cred.Username)
}
}
for _, val := range *result.Value {
registryName := *val.Name + ".azurecr.io"
if _, found := creds[registryName]; !found {
t.Errorf("Missing expected registry: %s", registryName)
}
}
}
......@@ -21,6 +21,7 @@ package compute
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
......@@ -41,12 +42,19 @@ func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string)
return AvailabilitySetsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the operation to create or update the availability set.
// CreateOrUpdate create or update an availability set.
//
// resourceGroupName is the name of the resource group. name is parameters
// supplied to the Create Availability Set operation. parameters is
// parameters supplied to the Create Availability Set operation.
// resourceGroupName is the name of the resource group. name is the name of
// the availability set. parameters is parameters supplied to the Create
// Availability Set operation.
func (client AvailabilitySetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters AvailabilitySet) (result AvailabilitySet, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.AvailabilitySetProperties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.AvailabilitySetProperties.Statuses", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request")
......@@ -107,7 +115,7 @@ func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response
return
}
// Delete the operation to delete the availability set.
// Delete delete an availability set.
//
// resourceGroupName is the name of the resource group. availabilitySetName is
// the name of the availability set.
......@@ -169,7 +177,7 @@ func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (resul
return
}
// Get the operation to get the availability set.
// Get retrieves information about an availability set.
//
// resourceGroupName is the name of the resource group. availabilitySetName is
// the name of the availability set.
......@@ -232,7 +240,7 @@ func (client AvailabilitySetsClient) GetResponder(resp *http.Response) (result A
return
}
// List the operation to list the availability sets.
// List lists all availability sets in a resource group.
//
// resourceGroupName is the name of the resource group.
func (client AvailabilitySetsClient) List(resourceGroupName string) (result AvailabilitySetListResult, err error) {
......
......@@ -21,6 +21,7 @@ package compute
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
......@@ -41,10 +42,18 @@ func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string)
return UsageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// List lists compute usages for a subscription.
// List gets, for the specified location, the current compute resource usage
// information as well as the limits for compute resources under the
// subscription.
//
// location is the location upon which resource usage is queried.
// location is the location for which resource usage is queried.
func (client UsageOperationsClient) List(location string) (result ListUsagesResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: location,
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "compute.UsageOperationsClient", "List")
}
req, err := client.ListPreparer(location)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing request")
......@@ -106,7 +115,7 @@ func (client UsageOperationsClient) ListResponder(resp *http.Response) (result L
func (client UsageOperationsClient) ListNextResults(lastResults ListUsagesResult) (result ListUsagesResult, err error) {
req, err := lastResults.ListUsagesResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -115,12 +124,12 @@ func (client UsageOperationsClient) ListNextResults(lastResults ListUsagesResult
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -23,9 +23,9 @@ import (
)
const (
major = "3"
minor = "2"
patch = "0"
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
......
......@@ -21,6 +21,7 @@ package compute
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
......@@ -52,6 +53,13 @@ func NewVirtualMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID
// extensionParameters is parameters supplied to the Create Virtual Machine
// Extension operation.
func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: extensionParameters,
Constraints: []validation.Constraint{{Target: "extensionParameters.VirtualMachineExtensionProperties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "extensionParameters.VirtualMachineExtensionProperties.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, vmExtensionName, extensionParameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request")
......
......@@ -43,6 +43,9 @@ func NewVirtualMachineImagesClientWithBaseURI(baseURI string, subscriptionID str
// Get gets a virtual machine image.
//
// location is the name of a supported Azure region. publisherName is a valid
// image publisher. offer is a valid image publisher offer. skus is a valid
// image SKU. version is a valid image SKU version.
func (client VirtualMachineImagesClient) Get(location string, publisherName string, offer string, skus string, version string) (result VirtualMachineImage, err error) {
req, err := client.GetPreparer(location, publisherName, offer, skus, version)
if err != nil {
......@@ -105,9 +108,12 @@ func (client VirtualMachineImagesClient) GetResponder(resp *http.Response) (resu
return
}
// List gets a list of virtual machine images.
// List gets a list of all virtual machine image versions for the specified
// location, publisher, offer, and SKU.
//
// filter is the filter to apply on the operation.
// location is the name of a supported Azure region. publisherName is a valid
// image publisher. offer is a valid image publisher offer. skus is a valid
// image SKU. filter is the filter to apply on the operation.
func (client VirtualMachineImagesClient) List(location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListPreparer(location, publisherName, offer, skus, filter, top, orderby)
if err != nil {
......@@ -178,8 +184,11 @@ func (client VirtualMachineImagesClient) ListResponder(resp *http.Response) (res
return
}
// ListOffers gets a list of virtual machine image offers.
// ListOffers gets a list of virtual machine image offers for the specified
// location and publisher.
//
// location is the name of a supported Azure region. publisherName is a valid
// image publisher.
func (client VirtualMachineImagesClient) ListOffers(location string, publisherName string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListOffersPreparer(location, publisherName)
if err != nil {
......@@ -239,8 +248,10 @@ func (client VirtualMachineImagesClient) ListOffersResponder(resp *http.Response
return
}
// ListPublishers gets a list of virtual machine image publishers.
// ListPublishers gets a list of virtual machine image publishers for the
// specified Azure location.
//
// location is the name of a supported Azure region.
func (client VirtualMachineImagesClient) ListPublishers(location string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListPublishersPreparer(location)
if err != nil {
......@@ -299,8 +310,11 @@ func (client VirtualMachineImagesClient) ListPublishersResponder(resp *http.Resp
return
}
// ListSkus gets a list of virtual machine image skus.
// ListSkus gets a list of virtual machine image SKUs for the specified
// location, publisher, and offer.
//
// location is the name of a supported Azure region. publisherName is a valid
// image publisher. offer is a valid image publisher offer.
func (client VirtualMachineImagesClient) ListSkus(location string, publisherName string, offer string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListSkusPreparer(location, publisherName, offer)
if err != nil {
......
......@@ -21,6 +21,7 @@ package compute
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
......@@ -46,6 +47,12 @@ func NewVirtualMachineSizesClientWithBaseURI(baseURI string, subscriptionID stri
//
// location is the location upon which virtual-machine-sizes is queried.
func (client VirtualMachineSizesClient) List(location string) (result VirtualMachineSizeListResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: location,
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineSizesClient", "List")
}
req, err := client.ListPreparer(location)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request")
......
// Package containerregistry implements the Azure ARM Containerregistry
// service API version 2016-06-27-preview.
//
package containerregistry
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
)
const (
// APIVersion is the version of the Containerregistry
APIVersion = "2016-06-27-preview"
// DefaultBaseURI is the default URI used for the service Containerregistry
DefaultBaseURI = "https://management.azure.com"
)
// ManagementClient is the base client for Containerregistry.
type ManagementClient struct {
autorest.Client
BaseURI string
APIVersion string
SubscriptionID string
}
// New creates an instance of the ManagementClient client.
func New(subscriptionID string) ManagementClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the ManagementClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID,
}
}
package containerregistry
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/to"
"net/http"
)
// Registry is an object that represents a container registry.
type Registry struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
*RegistryProperties `json:"properties,omitempty"`
}
// RegistryCredentials is the result of a request to get the administrator
// login credentials for a container registry.
type RegistryCredentials struct {
autorest.Response `json:"-"`
Username *string `json:"username,omitempty"`
Password *string `json:"password,omitempty"`
}
// RegistryListResult is the result of a request to list container registries.
type RegistryListResult struct {
autorest.Response `json:"-"`
Value *[]Registry `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// RegistryListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client RegistryListResult) RegistryListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// RegistryNameCheckRequest is a request to check whether the container
// registry name is available.
type RegistryNameCheckRequest struct {
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
}
// RegistryNameStatus is the result of a request to check the availability of
// a container registry name.
type RegistryNameStatus struct {
autorest.Response `json:"-"`
NameAvailable *bool `json:"nameAvailable,omitempty"`
Reason *string `json:"reason,omitempty"`
Message *string `json:"message,omitempty"`
}
// RegistryProperties is the properties of a container registry.
type RegistryProperties struct {
LoginServer *string `json:"loginServer,omitempty"`
CreationDate *date.Time `json:"creationDate,omitempty"`
AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"`
StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"`
}
// RegistryPropertiesUpdateParameters is the parameters for updating the
// properties of a container registry.
type RegistryPropertiesUpdateParameters struct {
AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"`
StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"`
}
// RegistryUpdateParameters is the parameters for updating a container
// registry.
type RegistryUpdateParameters struct {
Tags *map[string]*string `json:"tags,omitempty"`
*RegistryPropertiesUpdateParameters `json:"properties,omitempty"`
}
// Resource is an Azure resource.
type Resource struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}
// StorageAccountProperties is the properties of a storage account for a
// container registry.
type StorageAccountProperties struct {
Name *string `json:"name,omitempty"`
AccessKey *string `json:"accessKey,omitempty"`
}
package containerregistry
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"fmt"
)
const (
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "containerregistry", "2016-06-27-preview")
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag)
}
// Package network implements the Azure ARM Network service API version
// 2016-06-01.
// 2016-09-01.
//
// The Microsoft Azure Network management API provides a RESTful set of web
// services that interact with Microsoft Azure Networks service to manage
// your network resrources. The API has entities that capture the
// relationship between an end user and the Microsoft Azure Networks service.
// your network resources. The API has entities that capture the relationship
// between an end user and the Microsoft Azure Networks service.
package network
// Copyright (c) Microsoft and contributors. All rights reserved.
......@@ -33,7 +33,7 @@ import (
const (
// APIVersion is the version of the Network
APIVersion = "2016-06-01"
APIVersion = "2016-09-01"
// DefaultBaseURI is the default URI used for the service Network
DefaultBaseURI = "https://management.azure.com"
......@@ -65,7 +65,7 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
// CheckDNSNameAvailability checks whether a domain name in the cloudapp.net
// zone is available for use.
//
// location is the location of the domain name domainNameLabel is the domain
// location is the location of the domain name. domainNameLabel is the domain
// name to be verified. It must conform to the following regular expression:
// ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
func (client ManagementClient) CheckDNSNameAvailability(location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) {
......
......@@ -26,8 +26,8 @@ import (
// ExpressRouteCircuitAuthorizationsClient is the the Microsoft Azure Network
// management API provides a RESTful set of web services that interact with
// Microsoft Azure Networks service to manage your network resrources. The
// API has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service to manage your network resources. The API
// has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type ExpressRouteCircuitAuthorizationsClient struct {
ManagementClient
......@@ -45,16 +45,15 @@ func NewExpressRouteCircuitAuthorizationsClientWithBaseURI(baseURI string, subsc
return ExpressRouteCircuitAuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put Authorization operation creates/updates an
// authorization in thespecified ExpressRouteCircuits This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
// CreateOrUpdate creates or updates an authorization in the specified express
// route circuit. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. authorizationName is the name of the
// authorization. authorizationParameters is parameters supplied to the
// create/update ExpressRouteCircuitAuthorization operation
// create or update express route circuit authorization operation.
func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdate(resourceGroupName string, circuitName string, authorizationName string, authorizationParameters ExpressRouteCircuitAuthorization, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, authorizationName, authorizationParameters, cancel)
if err != nil {
......@@ -118,11 +117,10 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(re
return
}
// Delete the delete authorization operation deletes the specified
// authorization from the specified ExpressRouteCircuit. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
// Delete deletes the specified authorization from the specified express route
// circuit. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. authorizationName is the name of the
......@@ -188,8 +186,8 @@ func (client ExpressRouteCircuitAuthorizationsClient) DeleteResponder(resp *http
return
}
// Get the GET authorization operation retrieves the specified authorization
// from the specified ExpressRouteCircuit.
// Get gets the specified authorization from the specified express route
// circuit.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. authorizationName is the name of the
......@@ -254,11 +252,10 @@ func (client ExpressRouteCircuitAuthorizationsClient) GetResponder(resp *http.Re
return
}
// List the List authorization operation retrieves all the authorizations in
// an ExpressRouteCircuit.
// List gets all authorizations in an express route circuit.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the curcuit.
// name of the circuit.
func (client ExpressRouteCircuitAuthorizationsClient) List(resourceGroupName string, circuitName string) (result AuthorizationListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, circuitName)
if err != nil {
......@@ -322,7 +319,7 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListResponder(resp *http.R
func (client ExpressRouteCircuitAuthorizationsClient) ListNextResults(lastResults AuthorizationListResult) (result AuthorizationListResult, err error) {
req, err := lastResults.AuthorizationListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -331,12 +328,12 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListNextResults(lastResult
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -26,8 +26,8 @@ import (
// ExpressRouteCircuitPeeringsClient is the the Microsoft Azure Network
// management API provides a RESTful set of web services that interact with
// Microsoft Azure Networks service to manage your network resrources. The
// API has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service to manage your network resources. The API
// has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type ExpressRouteCircuitPeeringsClient struct {
ManagementClient
......@@ -45,15 +45,15 @@ func NewExpressRouteCircuitPeeringsClientWithBaseURI(baseURI string, subscriptio
return ExpressRouteCircuitPeeringsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put Pering operation creates/updates an peering in the
// specified ExpressRouteCircuits This method may poll for completion.
// Polling can be canceled by passing the cancel channel argument. The
// channel will be used to cancel polling and any outstanding HTTP requests.
// CreateOrUpdate creates or updates a peering in the specified express route
// circuits. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. peeringName is the name of the peering.
// peeringParameters is parameters supplied to the create/update
// ExpressRouteCircuit Peering operation
// peeringParameters is parameters supplied to the create or update express
// route circuit peering operation.
func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdate(resourceGroupName string, circuitName string, peeringName string, peeringParameters ExpressRouteCircuitPeering, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, peeringName, peeringParameters, cancel)
if err != nil {
......@@ -117,10 +117,10 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *ht
return
}
// Delete the delete peering operation deletes the specified peering from the
// ExpressRouteCircuit. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
// Delete deletes the specified peering from the specified express route
// circuit. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. peeringName is the name of the peering.
......@@ -185,8 +185,8 @@ func (client ExpressRouteCircuitPeeringsClient) DeleteResponder(resp *http.Respo
return
}
// Get the GET peering operation retrieves the specified authorization from
// the ExpressRouteCircuit.
// Get gets the specified authorization from the specified express route
// circuit.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. peeringName is the name of the peering.
......@@ -250,11 +250,10 @@ func (client ExpressRouteCircuitPeeringsClient) GetResponder(resp *http.Response
return
}
// List the List peering operation retrieves all the peerings in an
// ExpressRouteCircuit.
// List gets all peerings in a specified express route circuit.
//
// resourceGroupName is the name of the resource group. circuitName is the
// name of the curcuit.
// name of the express route circuit.
func (client ExpressRouteCircuitPeeringsClient) List(resourceGroupName string, circuitName string) (result ExpressRouteCircuitPeeringListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, circuitName)
if err != nil {
......@@ -318,7 +317,7 @@ func (client ExpressRouteCircuitPeeringsClient) ListResponder(resp *http.Respons
func (client ExpressRouteCircuitPeeringsClient) ListNextResults(lastResults ExpressRouteCircuitPeeringListResult) (result ExpressRouteCircuitPeeringListResult, err error) {
req, err := lastResults.ExpressRouteCircuitPeeringListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -327,12 +326,12 @@ func (client ExpressRouteCircuitPeeringsClient) ListNextResults(lastResults Expr
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -26,8 +26,8 @@ import (
// ExpressRouteServiceProvidersClient is the the Microsoft Azure Network
// management API provides a RESTful set of web services that interact with
// Microsoft Azure Networks service to manage your network resrources. The
// API has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service to manage your network resources. The API
// has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type ExpressRouteServiceProvidersClient struct {
ManagementClient
......@@ -45,8 +45,7 @@ func NewExpressRouteServiceProvidersClientWithBaseURI(baseURI string, subscripti
return ExpressRouteServiceProvidersClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// List the List ExpressRouteServiceProvider operation retrieves all the
// available ExpressRouteServiceProviders.
// List gets all the available express route service providers.
func (client ExpressRouteServiceProvidersClient) List() (result ExpressRouteServiceProviderListResult, err error) {
req, err := client.ListPreparer()
if err != nil {
......@@ -108,7 +107,7 @@ func (client ExpressRouteServiceProvidersClient) ListResponder(resp *http.Respon
func (client ExpressRouteServiceProvidersClient) ListNextResults(lastResults ExpressRouteServiceProviderListResult) (result ExpressRouteServiceProviderListResult, err error) {
req, err := lastResults.ExpressRouteServiceProviderListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -117,12 +116,12 @@ func (client ExpressRouteServiceProvidersClient) ListNextResults(lastResults Exp
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -26,7 +26,7 @@ import (
// LoadBalancersClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type LoadBalancersClient struct {
......@@ -45,14 +45,14 @@ func NewLoadBalancersClientWithBaseURI(baseURI string, subscriptionID string) Lo
return LoadBalancersClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put LoadBalancer operation creates/updates a
// LoadBalancer This method may poll for completion. Polling can be canceled
// by passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
// CreateOrUpdate creates or updates a load balancer. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. loadBalancerName is
// the name of the loadBalancer. parameters is parameters supplied to the
// create/delete LoadBalancer operation
// the name of the load balancer. parameters is parameters supplied to the
// create or update load balancer operation.
func (client LoadBalancersClient) CreateOrUpdate(resourceGroupName string, loadBalancerName string, parameters LoadBalancer, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, loadBalancerName, parameters, cancel)
if err != nil {
......@@ -115,13 +115,13 @@ func (client LoadBalancersClient) CreateOrUpdateResponder(resp *http.Response) (
return
}
// Delete the delete loadbalancer operation deletes the specified
// loadbalancer. This method may poll for completion. Polling can be canceled
// by passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
// Delete deletes the specified load balancer. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. loadBalancerName is
// the name of the loadBalancer.
// the name of the load balancer.
func (client LoadBalancersClient) Delete(resourceGroupName string, loadBalancerName string, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, loadBalancerName, cancel)
if err != nil {
......@@ -182,11 +182,10 @@ func (client LoadBalancersClient) DeleteResponder(resp *http.Response) (result a
return
}
// Get the Get ntework interface operation retreives information about the
// specified network interface.
// Get gets the specified load balancer.
//
// resourceGroupName is the name of the resource group. loadBalancerName is
// the name of the loadBalancer. expand is expand references resources.
// the name of the load balancer. expand is expands referenced resources.
func (client LoadBalancersClient) Get(resourceGroupName string, loadBalancerName string, expand string) (result LoadBalancer, err error) {
req, err := client.GetPreparer(resourceGroupName, loadBalancerName, expand)
if err != nil {
......@@ -249,8 +248,7 @@ func (client LoadBalancersClient) GetResponder(resp *http.Response) (result Load
return
}
// List the List loadBalancer operation retrieves all the loadbalancers in a
// resource group.
// List gets all the load balancers in a resource group.
//
// resourceGroupName is the name of the resource group.
func (client LoadBalancersClient) List(resourceGroupName string) (result LoadBalancerListResult, err error) {
......@@ -315,7 +313,7 @@ func (client LoadBalancersClient) ListResponder(resp *http.Response) (result Loa
func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListResult) (result LoadBalancerListResult, err error) {
req, err := lastResults.LoadBalancerListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -324,19 +322,18 @@ func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListRe
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure responding to next results request")
}
return
}
// ListAll the List loadBalancer operation retrieves all the loadbalancers in
// a subscription.
// ListAll gets all the load balancers in a subscription.
func (client LoadBalancersClient) ListAll() (result LoadBalancerListResult, err error) {
req, err := client.ListAllPreparer()
if err != nil {
......@@ -398,7 +395,7 @@ func (client LoadBalancersClient) ListAllResponder(resp *http.Response) (result
func (client LoadBalancersClient) ListAllNextResults(lastResults LoadBalancerListResult) (result LoadBalancerListResult, err error) {
req, err := lastResults.LoadBalancerListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -407,12 +404,12 @@ func (client LoadBalancersClient) ListAllNextResults(lastResults LoadBalancerLis
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure sending next results request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure responding to next results request")
}
return
......
......@@ -21,12 +21,13 @@ package network
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// LocalNetworkGatewaysClient is the the Microsoft Azure Network management
// API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resrources. The API has
// Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type LocalNetworkGatewaysClient struct {
......@@ -45,17 +46,25 @@ func NewLocalNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID str
return LocalNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put LocalNetworkGateway operation creates/updates a
// local network gateway in the specified resource group through Network
// resource provider. This method may poll for completion. Polling can be
// CreateOrUpdate creates or updates a local network gateway in the specified
// resource group. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group.
// localNetworkGatewayName is the name of the local network gateway.
// parameters is parameters supplied to the Begin Create or update Local
// Network Gateway operation through Network resource provider.
// parameters is parameters supplied to the create or update local network
// gateway operation.
func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat.LocalNetworkAddressSpace", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.LocalNetworkGatewayPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, localNetworkGatewayName, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
......@@ -117,8 +126,7 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Resp
return
}
// Delete the Delete LocalNetworkGateway operation deletes the specifed local
// network Gateway through Network resource provider. This method may poll
// Delete deletes the specified local network gateway. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
......@@ -185,8 +193,7 @@ func (client LocalNetworkGatewaysClient) DeleteResponder(resp *http.Response) (r
return
}
// Get the Get LocalNetworkGateway operation retrieves information about the
// specified local network gateway through Network resource provider.
// Get gets the specified local network gateway in a resource group.
//
// resourceGroupName is the name of the resource group.
// localNetworkGatewayName is the name of the local network gateway.
......@@ -249,8 +256,7 @@ func (client LocalNetworkGatewaysClient) GetResponder(resp *http.Response) (resu
return
}
// List the List LocalNetworkGateways operation retrieves all the local
// network gateways stored.
// List gets all the local network gateways in a resource group.
//
// resourceGroupName is the name of the resource group.
func (client LocalNetworkGatewaysClient) List(resourceGroupName string) (result LocalNetworkGatewayListResult, err error) {
......@@ -315,7 +321,7 @@ func (client LocalNetworkGatewaysClient) ListResponder(resp *http.Response) (res
func (client LocalNetworkGatewaysClient) ListNextResults(lastResults LocalNetworkGatewayListResult) (result LocalNetworkGatewayListResult, err error) {
req, err := lastResults.LocalNetworkGatewayListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -324,12 +330,12 @@ func (client LocalNetworkGatewaysClient) ListNextResults(lastResults LocalNetwor
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -26,7 +26,7 @@ import (
// RoutesClient is the the Microsoft Azure Network management API provides a
// RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resrources. The API has entities that
// service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure
// Networks service.
type RoutesClient struct {
......@@ -43,14 +43,15 @@ func NewRoutesClientWithBaseURI(baseURI string, subscriptionID string) RoutesCli
return RoutesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put route operation creates/updates a route in the
// specified route table This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
// CreateOrUpdate creates or updates a route in the specified route table.
// This method may poll for completion. Polling can be canceled by passing
// the cancel channel argument. The channel will be used to cancel polling
// and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. routeName is the name of the route.
// routeParameters is parameters supplied to the create/update routeoperation
// routeParameters is parameters supplied to the create or update route
// operation.
func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters, cancel)
if err != nil {
......@@ -114,10 +115,10 @@ func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result
return
}
// Delete the delete route operation deletes the specified route from a route
// table. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
// Delete deletes the specified route from a route table. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. routeName is the name of the route.
......@@ -182,8 +183,7 @@ func (client RoutesClient) DeleteResponder(resp *http.Response) (result autorest
return
}
// Get the Get route operation retreives information about the specified route
// from the route table.
// Get gets the specified route from a route table.
//
// resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. routeName is the name of the route.
......@@ -247,8 +247,7 @@ func (client RoutesClient) GetResponder(resp *http.Response) (result Route, err
return
}
// List the List network security rule operation retrieves all the routes in a
// route table.
// List gets all routes in a route table.
//
// resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table.
......@@ -315,7 +314,7 @@ func (client RoutesClient) ListResponder(resp *http.Response) (result RouteListR
func (client RoutesClient) ListNextResults(lastResults RouteListResult) (result RouteListResult, err error) {
req, err := lastResults.RouteListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -324,12 +323,12 @@ func (client RoutesClient) ListNextResults(lastResults RouteListResult) (result
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -21,12 +21,13 @@ package network
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// RouteTablesClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type RouteTablesClient struct {
......@@ -44,15 +45,22 @@ func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) Rout
return RouteTablesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put RouteTable operation creates/updates a route tablein
// the specified resource group. This method may poll for completion. Polling
// can be canceled by passing the cancel channel argument. The channel will
// be used to cancel polling and any outstanding HTTP requests.
// CreateOrUpdate create or updates a route table in a specified resource
// group. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. parameters is parameters supplied to the
// create/update Route Table operation
// name of the route table. parameters is parameters supplied to the create
// or update route table operation.
func (client RouteTablesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, parameters RouteTable, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.RouteTablePropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.RouteTablePropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.RouteTablesClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", nil, "Failure preparing request")
......@@ -114,10 +122,10 @@ func (client RouteTablesClient) CreateOrUpdateResponder(resp *http.Response) (re
return
}
// Delete the Delete RouteTable operation deletes the specifed Route Table
// This method may poll for completion. Polling can be canceled by passing
// the cancel channel argument. The channel will be used to cancel polling
// and any outstanding HTTP requests.
// Delete deletes the specified route table. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table.
......@@ -181,11 +189,10 @@ func (client RouteTablesClient) DeleteResponder(resp *http.Response) (result aut
return
}
// Get the Get RouteTables operation retrieves information about the specified
// route table.
// Get gets the specified route table.
//
// resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. expand is expand references resources.
// name of the route table. expand is expands referenced resources.
func (client RouteTablesClient) Get(resourceGroupName string, routeTableName string, expand string) (result RouteTable, err error) {
req, err := client.GetPreparer(resourceGroupName, routeTableName, expand)
if err != nil {
......@@ -248,7 +255,7 @@ func (client RouteTablesClient) GetResponder(resp *http.Response) (result RouteT
return
}
// List the list RouteTables returns all route tables in a resource group
// List gets all route tables in a resource group.
//
// resourceGroupName is the name of the resource group.
func (client RouteTablesClient) List(resourceGroupName string) (result RouteTableListResult, err error) {
......@@ -313,7 +320,7 @@ func (client RouteTablesClient) ListResponder(resp *http.Response) (result Route
func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult) (result RouteTableListResult, err error) {
req, err := lastResults.RouteTableListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -322,18 +329,18 @@ func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure responding to next results request")
}
return
}
// ListAll the list RouteTables returns all route tables in a subscription
// ListAll gets all route tables in a subscription.
func (client RouteTablesClient) ListAll() (result RouteTableListResult, err error) {
req, err := client.ListAllPreparer()
if err != nil {
......@@ -395,7 +402,7 @@ func (client RouteTablesClient) ListAllResponder(resp *http.Response) (result Ro
func (client RouteTablesClient) ListAllNextResults(lastResults RouteTableListResult) (result RouteTableListResult, err error) {
req, err := lastResults.RouteTableListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -404,12 +411,12 @@ func (client RouteTablesClient) ListAllNextResults(lastResults RouteTableListRes
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure sending next results request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure responding to next results request")
}
return
......
......@@ -21,12 +21,13 @@ package network
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// SecurityGroupsClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type SecurityGroupsClient struct {
......@@ -45,17 +46,25 @@ func NewSecurityGroupsClientWithBaseURI(baseURI string, subscriptionID string) S
return SecurityGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put NetworkSecurityGroup operation creates/updates a
// network security groupin the specified resource group. This method may
// poll for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
// CreateOrUpdate creates or updates a network security group in the specified
// resource group. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group.
// parameters is parameters supplied to the create/update Network Security
// Group operation
// parameters is parameters supplied to the create or update network security
// group operation.
func (client SecurityGroupsClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.SecurityGroupsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
......@@ -117,10 +126,10 @@ func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response)
return
}
// Delete the Delete NetworkSecurityGroup operation deletes the specifed
// network security group This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
// Delete deletes the specified network security group. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group.
......@@ -184,12 +193,11 @@ func (client SecurityGroupsClient) DeleteResponder(resp *http.Response) (result
return
}
// Get the Get NetworkSecurityGroups operation retrieves information about the
// specified network security group.
// Get gets the specified network security group.
//
// resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group. expand
// is expand references resources.
// is expands referenced resources.
func (client SecurityGroupsClient) Get(resourceGroupName string, networkSecurityGroupName string, expand string) (result SecurityGroup, err error) {
req, err := client.GetPreparer(resourceGroupName, networkSecurityGroupName, expand)
if err != nil {
......@@ -252,8 +260,7 @@ func (client SecurityGroupsClient) GetResponder(resp *http.Response) (result Sec
return
}
// List the list NetworkSecurityGroups returns all network security groups in
// a resource group
// List gets all network security groups in a resource group.
//
// resourceGroupName is the name of the resource group.
func (client SecurityGroupsClient) List(resourceGroupName string) (result SecurityGroupListResult, err error) {
......@@ -318,7 +325,7 @@ func (client SecurityGroupsClient) ListResponder(resp *http.Response) (result Se
func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) {
req, err := lastResults.SecurityGroupListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -327,19 +334,18 @@ func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupList
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure responding to next results request")
}
return
}
// ListAll the list NetworkSecurityGroups returns all network security groups
// in a subscription
// ListAll gets all network security groups in a subscription.
func (client SecurityGroupsClient) ListAll() (result SecurityGroupListResult, err error) {
req, err := client.ListAllPreparer()
if err != nil {
......@@ -401,7 +407,7 @@ func (client SecurityGroupsClient) ListAllResponder(resp *http.Response) (result
func (client SecurityGroupsClient) ListAllNextResults(lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) {
req, err := lastResults.SecurityGroupListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -410,12 +416,12 @@ func (client SecurityGroupsClient) ListAllNextResults(lastResults SecurityGroupL
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending next results request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure responding to next results request")
}
return
......
......@@ -21,12 +21,13 @@ package network
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// SecurityRulesClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type SecurityRulesClient struct {
......@@ -45,18 +46,26 @@ func NewSecurityRulesClientWithBaseURI(baseURI string, subscriptionID string) Se
return SecurityRulesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put network security rule operation creates/updates a
// security rule in the specified network security group This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
// CreateOrUpdate creates or updates a security rule in the specified network
// security group. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group.
// securityRuleName is the name of the security rule. securityRuleParameters
// is parameters supplied to the create/update network security rule
// operation
// is parameters supplied to the create or update network security rule
// operation.
func (client SecurityRulesClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters SecurityRule, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: securityRuleParameters,
Constraints: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat.SourceAddressPrefix", Name: validation.Null, Rule: true, Chain: nil},
{Target: "securityRuleParameters.SecurityRulePropertiesFormat.DestinationAddressPrefix", Name: validation.Null, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.SecurityRulesClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", nil, "Failure preparing request")
......@@ -119,10 +128,10 @@ func (client SecurityRulesClient) CreateOrUpdateResponder(resp *http.Response) (
return
}
// Delete the delete network security rule operation deletes the specified
// network security rule. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
// Delete deletes the specified network security rule. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group.
......@@ -188,8 +197,7 @@ func (client SecurityRulesClient) DeleteResponder(resp *http.Response) (result a
return
}
// Get the Get NetworkSecurityRule operation retreives information about the
// specified network security rule.
// Get get the specified network security rule.
//
// resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group.
......@@ -254,8 +262,7 @@ func (client SecurityRulesClient) GetResponder(resp *http.Response) (result Secu
return
}
// List the List network security rule operation retrieves all the security
// rules in a network security group.
// List gets all security rules in a network security group.
//
// resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group.
......@@ -322,7 +329,7 @@ func (client SecurityRulesClient) ListResponder(resp *http.Response) (result Sec
func (client SecurityRulesClient) ListNextResults(lastResults SecurityRuleListResult) (result SecurityRuleListResult, err error) {
req, err := lastResults.SecurityRuleListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -331,12 +338,12 @@ func (client SecurityRulesClient) ListNextResults(lastResults SecurityRuleListRe
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -21,12 +21,13 @@ package network
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// SubnetsClient is the the Microsoft Azure Network management API provides a
// RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resrources. The API has entities that
// service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure
// Networks service.
type SubnetsClient struct {
......@@ -43,16 +44,34 @@ func NewSubnetsClientWithBaseURI(baseURI string, subscriptionID string) SubnetsC
return SubnetsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put Subnet operation creates/updates a subnet in
// thespecified virtual network This method may poll for completion. Polling
// can be canceled by passing the cancel channel argument. The channel will
// be used to cancel polling and any outstanding HTTP requests.
// CreateOrUpdate creates or updates a subnet in the specified virtual
// network. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. subnetName is the name of the subnet.
// subnetParameters is parameters supplied to the create/update Subnet
// operation
// subnetParameters is parameters supplied to the create or update subnet
// operation.
func (client SubnetsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters Subnet, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: subnetParameters,
Constraints: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
}},
{Target: "subnetParameters.SubnetPropertiesFormat.RouteTable", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.RouteTable.RouteTablePropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.RouteTable.RouteTablePropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}}},
}},
{Target: "subnetParameters.SubnetPropertiesFormat.IPConfigurations", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.SubnetsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", nil, "Failure preparing request")
......@@ -115,10 +134,9 @@ func (client SubnetsClient) CreateOrUpdateResponder(resp *http.Response) (result
return
}
// Delete the delete subnet operation deletes the specified subnet. This
// method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and
// any outstanding HTTP requests.
// Delete deletes the specified subnet. This method may poll for completion.
// Polling can be canceled by passing the cancel channel argument. The
// channel will be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. subnetName is the name of the subnet.
......@@ -183,12 +201,11 @@ func (client SubnetsClient) DeleteResponder(resp *http.Response) (result autores
return
}
// Get the Get subnet operation retreives information about the specified
// subnet.
// Get gets the specified subnet by virtual network and resource group.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. subnetName is the name of the subnet.
// expand is expand references resources.
// expand is expands referenced resources.
func (client SubnetsClient) Get(resourceGroupName string, virtualNetworkName string, subnetName string, expand string) (result Subnet, err error) {
req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, subnetName, expand)
if err != nil {
......@@ -252,8 +269,7 @@ func (client SubnetsClient) GetResponder(resp *http.Response) (result Subnet, er
return
}
// List the List subnets operation retrieves all the subnets in a virtual
// network.
// List gets all subnets in a virtual network.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network.
......@@ -320,7 +336,7 @@ func (client SubnetsClient) ListResponder(resp *http.Response) (result SubnetLis
func (client SubnetsClient) ListNextResults(lastResults SubnetListResult) (result SubnetListResult, err error) {
req, err := lastResults.SubnetListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -329,12 +345,12 @@ func (client SubnetsClient) ListNextResults(lastResults SubnetListResult) (resul
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -21,12 +21,13 @@ package network
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// UsagesClient is the the Microsoft Azure Network management API provides a
// RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resrources. The API has entities that
// service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure
// Networks service.
type UsagesClient struct {
......@@ -45,8 +46,14 @@ func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesCli
// List lists compute usages for a subscription.
//
// location is the location upon which resource usage is queried.
// location is the location where resource usage is queried.
func (client UsagesClient) List(location string) (result UsagesListResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: location,
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.UsagesClient", "List")
}
req, err := client.ListPreparer(location)
if err != nil {
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing request")
......@@ -108,7 +115,7 @@ func (client UsagesClient) ListResponder(resp *http.Response) (result UsagesList
func (client UsagesClient) ListNextResults(lastResults UsagesListResult) (result UsagesListResult, err error) {
req, err := lastResults.UsagesListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -117,12 +124,12 @@ func (client UsagesClient) ListNextResults(lastResults UsagesListResult) (result
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -23,9 +23,9 @@ import (
)
const (
major = "3"
minor = "2"
patch = "0"
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
......@@ -34,7 +34,7 @@ const (
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "network", "2016-06-01")
return fmt.Sprintf(userAgentFormat, Version(), "network", "2016-09-01")
}
// Version returns the semantic version (see http://semver.org) of the client.
......
......@@ -26,7 +26,7 @@ import (
// VirtualNetworkPeeringsClient is the the Microsoft Azure Network management
// API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resrources. The API has
// Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type VirtualNetworkPeeringsClient struct {
......@@ -45,16 +45,15 @@ func NewVirtualNetworkPeeringsClientWithBaseURI(baseURI string, subscriptionID s
return VirtualNetworkPeeringsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate the Put virtual network peering operation creates/updates a
// peering in the specified virtual network This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
// CreateOrUpdate creates or updates a peering in the specified virtual
// network. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. virtualNetworkPeeringName is the name of
// the peering. virtualNetworkPeeringParameters is parameters supplied to the
// create/update virtual network peering operation
// create or update virtual network peering operation.
func (client VirtualNetworkPeeringsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, cancel)
if err != nil {
......@@ -118,10 +117,10 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Re
return
}
// Delete the delete virtual network peering operation deletes the specified
// peering. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
// Delete deletes the specified virtual network peering. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. virtualNetworkPeeringName is the name of
......@@ -187,8 +186,7 @@ func (client VirtualNetworkPeeringsClient) DeleteResponder(resp *http.Response)
return
}
// Get the Get virtual network peering operation retreives information about
// the specified virtual network peering.
// Get gets the specified virtual network peering.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. virtualNetworkPeeringName is the name of
......@@ -253,8 +251,7 @@ func (client VirtualNetworkPeeringsClient) GetResponder(resp *http.Response) (re
return
}
// List the List virtual network peerings operation retrieves all the peerings
// in a virtual network.
// List gets all virtual network peerings in a virtual network.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network.
......@@ -321,7 +318,7 @@ func (client VirtualNetworkPeeringsClient) ListResponder(resp *http.Response) (r
func (client VirtualNetworkPeeringsClient) ListNextResults(lastResults VirtualNetworkPeeringListResult) (result VirtualNetworkPeeringListResult, err error) {
req, err := lastResults.VirtualNetworkPeeringListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -330,12 +327,12 @@ func (client VirtualNetworkPeeringsClient) ListNextResults(lastResults VirtualNe
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure responding to next results request")
}
return
......
......@@ -26,7 +26,7 @@ import (
// VirtualNetworksClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type VirtualNetworksClient struct {
......@@ -45,7 +45,7 @@ func NewVirtualNetworksClientWithBaseURI(baseURI string, subscriptionID string)
return VirtualNetworksClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CheckIPAddressAvailability checks whether a private Ip address is available
// CheckIPAddressAvailability checks whether a private IP address is available
// for use.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
......@@ -113,15 +113,14 @@ func (client VirtualNetworksClient) CheckIPAddressAvailabilityResponder(resp *ht
return
}
// CreateOrUpdate the Put VirtualNetwork operation creates/updates a virtual
// network in the specified resource group. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
// CreateOrUpdate creates or updates a virtual network in the specified
// resource group. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used
// to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. parameters is parameters supplied to the
// create/update Virtual Network operation
// create or update virtual network operation
func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, parameters VirtualNetwork, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters, cancel)
if err != nil {
......@@ -184,10 +183,10 @@ func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response)
return
}
// Delete the Delete VirtualNetwork operation deletes the specifed virtual
// network This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
// Delete deletes the specified virtual network. This method may poll for
// completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network.
......@@ -251,11 +250,10 @@ func (client VirtualNetworksClient) DeleteResponder(resp *http.Response) (result
return
}
// Get the Get VirtualNetwork operation retrieves information about the
// specified virtual network.
// Get gets the specified virtual network by resource group.
//
// resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. expand is expand references resources.
// the name of the virtual network. expand is expands referenced resources.
func (client VirtualNetworksClient) Get(resourceGroupName string, virtualNetworkName string, expand string) (result VirtualNetwork, err error) {
req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, expand)
if err != nil {
......@@ -318,8 +316,7 @@ func (client VirtualNetworksClient) GetResponder(resp *http.Response) (result Vi
return
}
// List the list VirtualNetwork returns all Virtual Networks in a resource
// group
// List gets all virtual networks in a resource group.
//
// resourceGroupName is the name of the resource group.
func (client VirtualNetworksClient) List(resourceGroupName string) (result VirtualNetworkListResult, err error) {
......@@ -384,7 +381,7 @@ func (client VirtualNetworksClient) ListResponder(resp *http.Response) (result V
func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkListResult) (result VirtualNetworkListResult, err error) {
req, err := lastResults.VirtualNetworkListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -393,19 +390,18 @@ func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkLi
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure responding to next results request")
}
return
}
// ListAll the list VirtualNetwork returns all Virtual Networks in a
// subscription
// ListAll gets all virtual networks in a subscription.
func (client VirtualNetworksClient) ListAll() (result VirtualNetworkListResult, err error) {
req, err := client.ListAllPreparer()
if err != nil {
......@@ -467,7 +463,7 @@ func (client VirtualNetworksClient) ListAllResponder(resp *http.Response) (resul
func (client VirtualNetworksClient) ListAllNextResults(lastResults VirtualNetworkListResult) (result VirtualNetworkListResult, err error) {
req, err := lastResults.VirtualNetworkListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing next results request request")
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing next results request")
}
if req == nil {
return
......@@ -476,12 +472,12 @@ func (client VirtualNetworksClient) ListAllNextResults(lastResults VirtualNetwor
resp, err := client.ListAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure sending next results request request")
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure sending next results request")
}
result, err = client.ListAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure responding to next results request request")
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure responding to next results request")
}
return
......
......@@ -131,15 +131,15 @@ const (
// Account is the storage account.
type Account struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Sku *Sku `json:"sku,omitempty"`
Kind Kind `json:"kind,omitempty"`
Properties *AccountProperties `json:"properties,omitempty"`
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Sku *Sku `json:"sku,omitempty"`
Kind Kind `json:"kind,omitempty"`
*AccountProperties `json:"properties,omitempty"`
}
// AccountCheckNameAvailabilityParameters is
......@@ -148,13 +148,14 @@ type AccountCheckNameAvailabilityParameters struct {
Type *string `json:"type,omitempty"`
}
// AccountCreateParameters is the parameters to provide for the account.
// AccountCreateParameters is the parameters used when creating a storage
// account.
type AccountCreateParameters struct {
Sku *Sku `json:"sku,omitempty"`
Kind Kind `json:"kind,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Properties *AccountPropertiesCreateParameters `json:"properties,omitempty"`
Sku *Sku `json:"sku,omitempty"`
Kind Kind `json:"kind,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
*AccountPropertiesCreateParameters `json:"properties,omitempty"`
}
// AccountKey is an access key for the storage account.
......@@ -164,13 +165,13 @@ type AccountKey struct {
Permissions KeyPermission `json:"permissions,omitempty"`
}
// AccountListKeysResult is the ListKeys operation response.
// AccountListKeysResult is the response from the ListKeys operation.
type AccountListKeysResult struct {
autorest.Response `json:"-"`
Keys *[]AccountKey `json:"keys,omitempty"`
}
// AccountListResult is the list storage accounts operation response.
// AccountListResult is the response from the List Storage Accounts operation.
type AccountListResult struct {
autorest.Response `json:"-"`
Value *[]Account `json:"value,omitempty"`
......@@ -211,11 +212,12 @@ type AccountRegenerateKeyParameters struct {
KeyName *string `json:"keyName,omitempty"`
}
// AccountUpdateParameters is the parameters to provide for the account.
// AccountUpdateParameters is the parameters that can be provided when
// updating the storage account properties.
type AccountUpdateParameters struct {
Sku *Sku `json:"sku,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Properties *AccountPropertiesUpdateParameters `json:"properties,omitempty"`
Sku *Sku `json:"sku,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
*AccountPropertiesUpdateParameters `json:"properties,omitempty"`
}
// CheckNameAvailabilityResult is the CheckNameAvailability operation response.
......@@ -233,25 +235,26 @@ type CustomDomain struct {
UseSubDomain *bool `json:"useSubDomain,omitempty"`
}
// Encryption is the encryption settings on the account.
// Encryption is the encryption settings on the storage account.
type Encryption struct {
Services *EncryptionServices `json:"services,omitempty"`
KeySource *string `json:"keySource,omitempty"`
}
// EncryptionService is an encrypted service.
// EncryptionService is a service that allows server-side encryption to be
// used.
type EncryptionService struct {
Enabled *bool `json:"enabled,omitempty"`
LastEnabledTime *date.Time `json:"lastEnabledTime,omitempty"`
}
// EncryptionServices is the encrypted services.
// EncryptionServices is a list of services that support encryption.
type EncryptionServices struct {
Blob *EncryptionService `json:"blob,omitempty"`
}
// Endpoints is the URIs that are used to perform a retrieval of a public
// blob, queue or table object.
// blob, queue, or table object.
type Endpoints struct {
Blob *string `json:"blob,omitempty"`
Queue *string `json:"queue,omitempty"`
......@@ -282,13 +285,14 @@ type Usage struct {
Name *UsageName `json:"name,omitempty"`
}
// UsageListResult is the List Usages operation response.
// UsageListResult is the response from the List Usages operation.
type UsageListResult struct {
autorest.Response `json:"-"`
Value *[]Usage `json:"value,omitempty"`
}
// UsageName is the Usage Names.
// UsageName is the usage names that can be used; currently limited to
// StorageAccount.
type UsageName struct {
Value *string `json:"value,omitempty"`
LocalizedValue *string `json:"localizedValue,omitempty"`
......
......@@ -23,9 +23,9 @@ import (
)
const (
major = "3"
minor = "2"
patch = "0"
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
......
# Azure Storage SDK for Go
The `github.com/Azure/azure-sdk-for-go/storage` package is used to perform operations in Azure Storage Service. To manage your storage accounts (Azure Resource Manager / ARM), use the [github.com/Azure/azure-sdk-for-go/arm/storage](../arm/storage) package. For your classic storage accounts (Azure Service Management / ASM), use [github.com/Azure/azure-sdk-for-go/management/storageservice](../management/storageservice) package.
This package includes support for [Azure Storage Emulator](https://azure.microsoft.com/documentation/articles/storage-use-emulator/)
\ No newline at end of file
......@@ -128,6 +128,7 @@ func NewBasicClient(accountName, accountKey string) (Client, error) {
return NewEmulatorClient()
}
return NewClient(accountName, accountKey, DefaultBaseURL, DefaultAPIVersion, defaultUseHTTPS)
}
//NewEmulatorClient contructs a Client intended to only work with Azure
......@@ -305,7 +306,7 @@ func (c Client) buildCanonicalizedResourceTable(uri string) (string, error) {
cr := "/" + c.getCanonicalizedAccountName()
if len(u.Path) > 0 {
cr += u.Path
cr += u.EscapedPath()
}
return cr, nil
......
......@@ -82,6 +82,24 @@ func (p PeekMessagesParameters) getParameters() url.Values {
return out
}
// UpdateMessageParameters is the set of options can be specified for Update Messsage
// operation. A zero struct does not use any preferences for the request.
type UpdateMessageParameters struct {
PopReceipt string
VisibilityTimeout int
}
func (p UpdateMessageParameters) getParameters() url.Values {
out := url.Values{}
if p.PopReceipt != "" {
out.Set("popreceipt", p.PopReceipt)
}
if p.VisibilityTimeout != 0 {
out.Set("visibilitytimeout", strconv.Itoa(p.VisibilityTimeout))
}
return out
}
// GetMessagesResponse represents a response returned from Get Messages
// operation.
type GetMessagesResponse struct {
......@@ -304,3 +322,23 @@ func (c QueueServiceClient) DeleteMessage(queue, messageID, popReceipt string) e
defer resp.body.Close()
return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
}
// UpdateMessage operation deletes the specified message.
//
// See https://msdn.microsoft.com/en-us/library/azure/hh452234.aspx
func (c QueueServiceClient) UpdateMessage(queue string, messageID string, message string, params UpdateMessageParameters) error {
uri := c.client.getEndpoint(queueServiceName, pathForMessage(queue, messageID), params.getParameters())
req := putMessageRequest{MessageText: message}
body, nn, err := xmlMarshal(req)
if err != nil {
return err
}
headers := c.client.getStandardHeaders()
headers["Content-Length"] = fmt.Sprintf("%d", nn)
resp, err := c.client.exec("PUT", uri, headers, body)
if err != nil {
return err
}
defer resp.body.Close()
return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
}
......@@ -10,6 +10,8 @@ import (
"reflect"
)
// Annotating as secure for gas scanning
/* #nosec */
const (
partitionKeyNode = "PartitionKey"
rowKeyNode = "RowKey"
......@@ -98,6 +100,10 @@ func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousCo
resp, err := c.client.execTable("GET", uri, headers, nil)
if err != nil {
return nil, nil, err
}
contToken := extractContinuationTokenFromHeaders(resp.headers)
if err != nil {
......
......@@ -77,7 +77,7 @@ func headersFromStruct(v interface{}) map[string]string {
for i := 0; i < value.NumField(); i++ {
key := value.Type().Field(i).Tag.Get("header")
val := value.Field(i).String()
if val != "" {
if key != "" && val != "" {
headers[key] = val
}
}
......
......@@ -7,3 +7,6 @@ For example the parser might receive "ESC, [, A" as a stream of three characters
The parser (parser.go) is a partial implementation of this state machine (http://vt100.net/emu/vt500_parser.png). There are also two event handler implementations, one for tests (test_event_handler.go) to validate that the expected events are being produced and called, the other is a Windows implementation (winterm/win_event_handler.go).
See parser_test.go for examples exercising the state machine and generating appropriate function calls.
-----
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
......@@ -124,32 +124,32 @@ func getByteRange(start byte, end byte) []byte {
return bytes
}
var ToGroundBytes = getToGroundBytes()
var Executors = getExecuteBytes()
var toGroundBytes = getToGroundBytes()
var executors = getExecuteBytes()
// SPACE 20+A0 hex Always and everywhere a blank space
// Intermediate 20-2F hex !"#$%&'()*+,-./
var Intermeds = getByteRange(0x20, 0x2F)
var intermeds = getByteRange(0x20, 0x2F)
// Parameters 30-3F hex 0123456789:;<=>?
// CSI Parameters 30-39, 3B hex 0123456789;
var CsiParams = getByteRange(0x30, 0x3F)
var csiParams = getByteRange(0x30, 0x3F)
var CsiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)
var csiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)
// Uppercase 40-5F hex @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
var UpperCase = getByteRange(0x40, 0x5F)
var upperCase = getByteRange(0x40, 0x5F)
// Lowercase 60-7E hex `abcdefghijlkmnopqrstuvwxyz{|}~
var LowerCase = getByteRange(0x60, 0x7E)
var lowerCase = getByteRange(0x60, 0x7E)
// Alphabetics 40-7E hex (all of upper and lower case)
var Alphabetics = append(UpperCase, LowerCase...)
var alphabetics = append(upperCase, lowerCase...)
var Printables = getByteRange(0x20, 0x7F)
var printables = getByteRange(0x20, 0x7F)
var EscapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
var EscapeToGroundBytes = getEscapeToGroundBytes()
var escapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
var escapeToGroundBytes = getEscapeToGroundBytes()
// See http://www.vt100.net/emu/vt500_parser.png for description of the complex
// byte ranges below
......
package ansiterm
type AnsiContext struct {
type ansiContext struct {
currentChar byte
paramBuffer []byte
interBuffer []byte
......
package ansiterm
type CsiEntryState struct {
BaseState
type csiEntryState struct {
baseState
}
func (csiState CsiEntryState) Handle(b byte) (s State, e error) {
func (csiState csiEntryState) Handle(b byte) (s state, e error) {
logger.Infof("CsiEntry::Handle %#x", b)
nextState, err := csiState.BaseState.Handle(b)
nextState, err := csiState.baseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}
switch {
case sliceContains(Alphabetics, b):
return csiState.parser.Ground, nil
case sliceContains(CsiCollectables, b):
return csiState.parser.CsiParam, nil
case sliceContains(Executors, b):
case sliceContains(alphabetics, b):
return csiState.parser.ground, nil
case sliceContains(csiCollectables, b):
return csiState.parser.csiParam, nil
case sliceContains(executors, b):
return csiState, csiState.parser.execute()
}
return csiState, nil
}
func (csiState CsiEntryState) Transition(s State) error {
func (csiState csiEntryState) Transition(s state) error {
logger.Infof("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name())
csiState.BaseState.Transition(s)
csiState.baseState.Transition(s)
switch s {
case csiState.parser.Ground:
case csiState.parser.ground:
return csiState.parser.csiDispatch()
case csiState.parser.CsiParam:
case csiState.parser.csiParam:
switch {
case sliceContains(CsiParams, csiState.parser.context.currentChar):
case sliceContains(csiParams, csiState.parser.context.currentChar):
csiState.parser.collectParam()
case sliceContains(Intermeds, csiState.parser.context.currentChar):
case sliceContains(intermeds, csiState.parser.context.currentChar):
csiState.parser.collectInter()
}
}
......@@ -43,7 +43,7 @@ func (csiState CsiEntryState) Transition(s State) error {
return nil
}
func (csiState CsiEntryState) Enter() error {
func (csiState csiEntryState) Enter() error {
csiState.parser.clear()
return nil
}
package ansiterm
type CsiParamState struct {
BaseState
type csiParamState struct {
baseState
}
func (csiState CsiParamState) Handle(b byte) (s State, e error) {
func (csiState csiParamState) Handle(b byte) (s state, e error) {
logger.Infof("CsiParam::Handle %#x", b)
nextState, err := csiState.BaseState.Handle(b)
nextState, err := csiState.baseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}
switch {
case sliceContains(Alphabetics, b):
return csiState.parser.Ground, nil
case sliceContains(CsiCollectables, b):
case sliceContains(alphabetics, b):
return csiState.parser.ground, nil
case sliceContains(csiCollectables, b):
csiState.parser.collectParam()
return csiState, nil
case sliceContains(Executors, b):
case sliceContains(executors, b):
return csiState, csiState.parser.execute()
}
return csiState, nil
}
func (csiState CsiParamState) Transition(s State) error {
func (csiState csiParamState) Transition(s state) error {
logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
csiState.BaseState.Transition(s)
csiState.baseState.Transition(s)
switch s {
case csiState.parser.Ground:
case csiState.parser.ground:
return csiState.parser.csiDispatch()
}
......
package ansiterm
type EscapeIntermediateState struct {
BaseState
type escapeIntermediateState struct {
baseState
}
func (escState EscapeIntermediateState) Handle(b byte) (s State, e error) {
logger.Infof("EscapeIntermediateState::Handle %#x", b)
nextState, err := escState.BaseState.Handle(b)
func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
logger.Infof("escapeIntermediateState::Handle %#x", b)
nextState, err := escState.baseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}
switch {
case sliceContains(Intermeds, b):
case sliceContains(intermeds, b):
return escState, escState.parser.collectInter()
case sliceContains(Executors, b):
case sliceContains(executors, b):
return escState, escState.parser.execute()
case sliceContains(EscapeIntermediateToGroundBytes, b):
return escState.parser.Ground, nil
case sliceContains(escapeIntermediateToGroundBytes, b):
return escState.parser.ground, nil
}
return escState, nil
}
func (escState EscapeIntermediateState) Transition(s State) error {
logger.Infof("EscapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
escState.BaseState.Transition(s)
func (escState escapeIntermediateState) Transition(s state) error {
logger.Infof("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
escState.baseState.Transition(s)
switch s {
case escState.parser.Ground:
case escState.parser.ground:
return escState.parser.escDispatch()
}
......
package ansiterm
type EscapeState struct {
BaseState
type escapeState struct {
baseState
}
func (escState EscapeState) Handle(b byte) (s State, e error) {
logger.Infof("EscapeState::Handle %#x", b)
nextState, err := escState.BaseState.Handle(b)
func (escState escapeState) Handle(b byte) (s state, e error) {
logger.Infof("escapeState::Handle %#x", b)
nextState, err := escState.baseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}
switch {
case b == ANSI_ESCAPE_SECONDARY:
return escState.parser.CsiEntry, nil
return escState.parser.csiEntry, nil
case b == ANSI_OSC_STRING_ENTRY:
return escState.parser.OscString, nil
case sliceContains(Executors, b):
return escState.parser.oscString, nil
case sliceContains(executors, b):
return escState, escState.parser.execute()
case sliceContains(EscapeToGroundBytes, b):
return escState.parser.Ground, nil
case sliceContains(Intermeds, b):
return escState.parser.EscapeIntermediate, nil
case sliceContains(escapeToGroundBytes, b):
return escState.parser.ground, nil
case sliceContains(intermeds, b):
return escState.parser.escapeIntermediate, nil
}
return escState, nil
}
func (escState EscapeState) Transition(s State) error {
func (escState escapeState) Transition(s state) error {
logger.Infof("Escape::Transition %s --> %s", escState.Name(), s.Name())
escState.BaseState.Transition(s)
escState.baseState.Transition(s)
switch s {
case escState.parser.Ground:
case escState.parser.ground:
return escState.parser.escDispatch()
case escState.parser.EscapeIntermediate:
case escState.parser.escapeIntermediate:
return escState.parser.collectInter()
}
return nil
}
func (escState EscapeState) Enter() error {
func (escState escapeState) Enter() error {
escState.parser.clear()
return nil
}
package ansiterm
type GroundState struct {
BaseState
type groundState struct {
baseState
}
func (gs GroundState) Handle(b byte) (s State, e error) {
func (gs groundState) Handle(b byte) (s state, e error) {
gs.parser.context.currentChar = b
nextState, err := gs.BaseState.Handle(b)
nextState, err := gs.baseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}
switch {
case sliceContains(Printables, b):
case sliceContains(printables, b):
return gs, gs.parser.print()
case sliceContains(Executors, b):
case sliceContains(executors, b):
return gs, gs.parser.execute()
}
......
package ansiterm
type OscStringState struct {
BaseState
type oscStringState struct {
baseState
}
func (oscState OscStringState) Handle(b byte) (s State, e error) {
func (oscState oscStringState) Handle(b byte) (s state, e error) {
logger.Infof("OscString::Handle %#x", b)
nextState, err := oscState.BaseState.Handle(b)
nextState, err := oscState.baseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}
switch {
case isOscStringTerminator(b):
return oscState.parser.Ground, nil
return oscState.parser.ground, nil
}
return oscState, nil
......
......@@ -2,7 +2,6 @@ package ansiterm
import (
"errors"
"fmt"
"io/ioutil"
"os"
......@@ -12,18 +11,18 @@ import (
var logger *logrus.Logger
type AnsiParser struct {
currState State
currState state
eventHandler AnsiEventHandler
context *AnsiContext
CsiEntry State
CsiParam State
DcsEntry State
Escape State
EscapeIntermediate State
Error State
Ground State
OscString State
stateMap []State
context *ansiContext
csiEntry state
csiParam state
dcsEntry state
escape state
escapeIntermediate state
error state
ground state
oscString state
stateMap []state
}
func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser {
......@@ -41,27 +40,27 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser
parser := &AnsiParser{
eventHandler: evtHandler,
context: &AnsiContext{},
context: &ansiContext{},
}
parser.CsiEntry = CsiEntryState{BaseState{name: "CsiEntry", parser: parser}}
parser.CsiParam = CsiParamState{BaseState{name: "CsiParam", parser: parser}}
parser.DcsEntry = DcsEntryState{BaseState{name: "DcsEntry", parser: parser}}
parser.Escape = EscapeState{BaseState{name: "Escape", parser: parser}}
parser.EscapeIntermediate = EscapeIntermediateState{BaseState{name: "EscapeIntermediate", parser: parser}}
parser.Error = ErrorState{BaseState{name: "Error", parser: parser}}
parser.Ground = GroundState{BaseState{name: "Ground", parser: parser}}
parser.OscString = OscStringState{BaseState{name: "OscString", parser: parser}}
parser.stateMap = []State{
parser.CsiEntry,
parser.CsiParam,
parser.DcsEntry,
parser.Escape,
parser.EscapeIntermediate,
parser.Error,
parser.Ground,
parser.OscString,
parser.csiEntry = csiEntryState{baseState{name: "CsiEntry", parser: parser}}
parser.csiParam = csiParamState{baseState{name: "CsiParam", parser: parser}}
parser.dcsEntry = dcsEntryState{baseState{name: "DcsEntry", parser: parser}}
parser.escape = escapeState{baseState{name: "Escape", parser: parser}}
parser.escapeIntermediate = escapeIntermediateState{baseState{name: "EscapeIntermediate", parser: parser}}
parser.error = errorState{baseState{name: "Error", parser: parser}}
parser.ground = groundState{baseState{name: "Ground", parser: parser}}
parser.oscString = oscStringState{baseState{name: "OscString", parser: parser}}
parser.stateMap = []state{
parser.csiEntry,
parser.csiParam,
parser.dcsEntry,
parser.escape,
parser.escapeIntermediate,
parser.error,
parser.ground,
parser.oscString,
}
parser.currState = getState(initialState, parser.stateMap)
......@@ -70,7 +69,7 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser
return parser
}
func getState(name string, states []State) State {
func getState(name string, states []state) state {
for _, el := range states {
if el.Name() == name {
return el
......@@ -99,7 +98,7 @@ func (ap *AnsiParser) handle(b byte) error {
if newState == nil {
logger.Warning("newState is nil")
return errors.New(fmt.Sprintf("New state of 'nil' is invalid."))
return errors.New("New state of 'nil' is invalid.")
}
if newState != ap.currState {
......@@ -111,7 +110,7 @@ func (ap *AnsiParser) handle(b byte) error {
return nil
}
func (ap *AnsiParser) changeState(newState State) error {
func (ap *AnsiParser) changeState(newState state) error {
logger.Infof("ChangeState %s --> %s", ap.currState.Name(), newState.Name())
// Exit old state
......
......@@ -31,7 +31,7 @@ func parseParams(bytes []byte) ([]string, error) {
return params, nil
}
func parseCmd(context AnsiContext) (string, error) {
func parseCmd(context ansiContext) (string, error) {
return string(context.currentChar), nil
}
......
......@@ -113,7 +113,7 @@ func (ap *AnsiParser) print() error {
}
func (ap *AnsiParser) clear() error {
ap.context = &AnsiContext{}
ap.context = &ansiContext{}
return nil
}
......
package ansiterm
import (
"fmt"
"testing"
)
func getStateNames() []string {
parser, _ := createTestParser("Ground")
stateNames := []string{}
for _, state := range parser.stateMap {
stateNames = append(stateNames, state.Name())
}
return stateNames
}
func stateTransitionHelper(t *testing.T, start string, end string, bytes []byte) {
for _, b := range bytes {
bytes := []byte{byte(b)}
parser, _ := createTestParser(start)
parser.Parse(bytes)
validateState(t, parser.currState, end)
}
}
func anyToXHelper(t *testing.T, bytes []byte, expectedState string) {
for _, s := range getStateNames() {
stateTransitionHelper(t, s, expectedState, bytes)
}
}
func funcCallParamHelper(t *testing.T, bytes []byte, start string, expected string, expectedCalls []string) {
parser, evtHandler := createTestParser(start)
parser.Parse(bytes)
validateState(t, parser.currState, expected)
validateFuncCalls(t, evtHandler.FunctionCalls, expectedCalls)
}
func parseParamsHelper(t *testing.T, bytes []byte, expectedParams []string) {
params, err := parseParams(bytes)
if err != nil {
t.Errorf("Parameter parse error: %v", err)
return
}
if len(params) != len(expectedParams) {
t.Errorf("Parsed parameters: %v", params)
t.Errorf("Expected parameters: %v", expectedParams)
t.Errorf("Parameter length failure: %d != %d", len(params), len(expectedParams))
return
}
for i, v := range expectedParams {
if v != params[i] {
t.Errorf("Parsed parameters: %v", params)
t.Errorf("Expected parameters: %v", expectedParams)
t.Errorf("Parameter parse failure: %s != %s at position %d", v, params[i], i)
}
}
}
func cursorSingleParamHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
funcCallParamHelper(t, []byte{'2', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([23])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', ';', '4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
}
func cursorTwoParamHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1 1])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1 1])", funcName)})
funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 1])", funcName)})
funcCallParamHelper(t, []byte{'2', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([23 1])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 3])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', ';', '4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 3])", funcName)})
}
func eraseHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)})
funcCallParamHelper(t, []byte{'1', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
funcCallParamHelper(t, []byte{'3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([3])", funcName)})
funcCallParamHelper(t, []byte{'4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)})
funcCallParamHelper(t, []byte{'1', ';', '2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
}
func scrollHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'1', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'5', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([5])", funcName)})
funcCallParamHelper(t, []byte{'4', ';', '6', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([4])", funcName)})
}
func clearOnStateChangeHelper(t *testing.T, start string, end string, bytes []byte) {
p, _ := createTestParser(start)
fillContext(p.context)
p.Parse(bytes)
validateState(t, p.currState, end)
validateEmptyContext(t, p.context)
}
func c0Helper(t *testing.T, bytes []byte, expectedState string, expectedCalls []string) {
parser, evtHandler := createTestParser("Ground")
parser.Parse(bytes)
validateState(t, parser.currState, expectedState)
validateFuncCalls(t, evtHandler.FunctionCalls, expectedCalls)
}
package ansiterm
import (
"testing"
)
func createTestParser(s string) (*AnsiParser, *TestAnsiEventHandler) {
evtHandler := CreateTestAnsiEventHandler()
parser := CreateParser(s, evtHandler)
return parser, evtHandler
}
func validateState(t *testing.T, actualState State, expectedStateName string) {
actualName := "Nil"
if actualState != nil {
actualName = actualState.Name()
}
if actualName != expectedStateName {
t.Errorf("Invalid State: '%s' != '%s'", actualName, expectedStateName)
}
}
func validateFuncCalls(t *testing.T, actualCalls []string, expectedCalls []string) {
actualCount := len(actualCalls)
expectedCount := len(expectedCalls)
if actualCount != expectedCount {
t.Errorf("Actual calls: %v", actualCalls)
t.Errorf("Expected calls: %v", expectedCalls)
t.Errorf("Call count error: %d != %d", actualCount, expectedCount)
return
}
for i, v := range actualCalls {
if v != expectedCalls[i] {
t.Errorf("Actual calls: %v", actualCalls)
t.Errorf("Expected calls: %v", expectedCalls)
t.Errorf("Mismatched calls: %s != %s with lengths %d and %d", v, expectedCalls[i], len(v), len(expectedCalls[i]))
}
}
}
func fillContext(context *AnsiContext) {
context.currentChar = 'A'
context.paramBuffer = []byte{'C', 'D', 'E'}
context.interBuffer = []byte{'F', 'G', 'H'}
}
func validateEmptyContext(t *testing.T, context *AnsiContext) {
var expectedCurrChar byte = 0x0
if context.currentChar != expectedCurrChar {
t.Errorf("Currentchar mismatch '%#x' != '%#x'", context.currentChar, expectedCurrChar)
}
if len(context.paramBuffer) != 0 {
t.Errorf("Non-empty parameter buffer: %v", context.paramBuffer)
}
if len(context.paramBuffer) != 0 {
t.Errorf("Non-empty intermediate buffer: %v", context.interBuffer)
}
}
package ansiterm
type StateId int
type stateID int
type State interface {
type state interface {
Enter() error
Exit() error
Handle(byte) (State, error)
Handle(byte) (state, error)
Name() string
Transition(State) error
Transition(state) error
}
type BaseState struct {
type baseState struct {
name string
parser *AnsiParser
}
func (base BaseState) Enter() error {
func (base baseState) Enter() error {
return nil
}
func (base BaseState) Exit() error {
func (base baseState) Exit() error {
return nil
}
func (base BaseState) Handle(b byte) (s State, e error) {
func (base baseState) Handle(b byte) (s state, e error) {
switch {
case b == CSI_ENTRY:
return base.parser.CsiEntry, nil
return base.parser.csiEntry, nil
case b == DCS_ENTRY:
return base.parser.DcsEntry, nil
return base.parser.dcsEntry, nil
case b == ANSI_ESCAPE_PRIMARY:
return base.parser.Escape, nil
return base.parser.escape, nil
case b == OSC_STRING:
return base.parser.OscString, nil
case sliceContains(ToGroundBytes, b):
return base.parser.Ground, nil
return base.parser.oscString, nil
case sliceContains(toGroundBytes, b):
return base.parser.ground, nil
}
return nil, nil
}
func (base BaseState) Name() string {
func (base baseState) Name() string {
return base.name
}
func (base BaseState) Transition(s State) error {
if s == base.parser.Ground {
func (base baseState) Transition(s state) error {
if s == base.parser.ground {
execBytes := []byte{0x18}
execBytes = append(execBytes, 0x1A)
execBytes = append(execBytes, getByteRange(0x80, 0x8F)...)
......@@ -62,10 +62,10 @@ func (base BaseState) Transition(s State) error {
return nil
}
type DcsEntryState struct {
BaseState
type dcsEntryState struct {
baseState
}
type ErrorState struct {
BaseState
type errorState struct {
baseState
}
package ansiterm
import (
"fmt"
"strconv"
)
type TestAnsiEventHandler struct {
FunctionCalls []string
}
func CreateTestAnsiEventHandler() *TestAnsiEventHandler {
evtHandler := TestAnsiEventHandler{}
evtHandler.FunctionCalls = make([]string, 0)
return &evtHandler
}
func (h *TestAnsiEventHandler) recordCall(call string, params []string) {
s := fmt.Sprintf("%s(%v)", call, params)
h.FunctionCalls = append(h.FunctionCalls, s)
}
func (h *TestAnsiEventHandler) Print(b byte) error {
h.recordCall("Print", []string{string(b)})
return nil
}
func (h *TestAnsiEventHandler) Execute(b byte) error {
h.recordCall("Execute", []string{string(b)})
return nil
}
func (h *TestAnsiEventHandler) CUU(param int) error {
h.recordCall("CUU", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUD(param int) error {
h.recordCall("CUD", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUF(param int) error {
h.recordCall("CUF", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUB(param int) error {
h.recordCall("CUB", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CNL(param int) error {
h.recordCall("CNL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CPL(param int) error {
h.recordCall("CPL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CHA(param int) error {
h.recordCall("CHA", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) VPA(param int) error {
h.recordCall("VPA", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUP(x int, y int) error {
xS, yS := strconv.Itoa(x), strconv.Itoa(y)
h.recordCall("CUP", []string{xS, yS})
return nil
}
func (h *TestAnsiEventHandler) HVP(x int, y int) error {
xS, yS := strconv.Itoa(x), strconv.Itoa(y)
h.recordCall("HVP", []string{xS, yS})
return nil
}
func (h *TestAnsiEventHandler) DECTCEM(visible bool) error {
h.recordCall("DECTCEM", []string{strconv.FormatBool(visible)})
return nil
}
func (h *TestAnsiEventHandler) DECOM(visible bool) error {
h.recordCall("DECOM", []string{strconv.FormatBool(visible)})
return nil
}
func (h *TestAnsiEventHandler) DECCOLM(use132 bool) error {
h.recordCall("DECOLM", []string{strconv.FormatBool(use132)})
return nil
}
func (h *TestAnsiEventHandler) ED(param int) error {
h.recordCall("ED", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) EL(param int) error {
h.recordCall("EL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) IL(param int) error {
h.recordCall("IL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) DL(param int) error {
h.recordCall("DL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) ICH(param int) error {
h.recordCall("ICH", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) DCH(param int) error {
h.recordCall("DCH", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) SGR(params []int) error {
strings := []string{}
for _, v := range params {
strings = append(strings, strconv.Itoa(v))
}
h.recordCall("SGR", strings)
return nil
}
func (h *TestAnsiEventHandler) SU(param int) error {
h.recordCall("SU", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) SD(param int) error {
h.recordCall("SD", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) DA(params []string) error {
h.recordCall("DA", params)
return nil
}
func (h *TestAnsiEventHandler) DECSTBM(top int, bottom int) error {
topS, bottomS := strconv.Itoa(top), strconv.Itoa(bottom)
h.recordCall("DECSTBM", []string{topS, bottomS})
return nil
}
func (h *TestAnsiEventHandler) RI() error {
h.recordCall("RI", nil)
return nil
}
func (h *TestAnsiEventHandler) IND() error {
h.recordCall("IND", nil)
return nil
}
func (h *TestAnsiEventHandler) Flush() error {
return nil
}
......@@ -9,7 +9,7 @@ import (
"strings"
"syscall"
. "github.com/Azure/go-ansiterm"
"github.com/Azure/go-ansiterm"
)
// Windows keyboard constants
......@@ -85,17 +85,17 @@ func newAnsiCommand(command []byte) *ansiCommand {
if lastCharIndex != 0 {
start := 1
// skip if double char escape sequence
if command[0] == ANSI_ESCAPE_PRIMARY && command[1] == ANSI_ESCAPE_SECONDARY {
if command[0] == ansiterm.ANSI_ESCAPE_PRIMARY && command[1] == ansiterm.ANSI_ESCAPE_SECONDARY {
start++
}
// convert this to GetNextParam method
ac.Parameters = strings.Split(string(command[start:lastCharIndex]), ANSI_PARAMETER_SEP)
ac.Parameters = strings.Split(string(command[start:lastCharIndex]), ansiterm.ANSI_PARAMETER_SEP)
}
return ac
}
func (ac *ansiCommand) paramAsSHORT(index int, defaultValue SHORT) SHORT {
func (ac *ansiCommand) paramAsSHORT(index int, defaultValue int16) int16 {
if index < 0 || index >= len(ac.Parameters) {
return defaultValue
}
......@@ -105,7 +105,7 @@ func (ac *ansiCommand) paramAsSHORT(index int, defaultValue SHORT) SHORT {
return defaultValue
}
return SHORT(param)
return int16(param)
}
func (ac *ansiCommand) String() string {
......@@ -119,12 +119,12 @@ func (ac *ansiCommand) String() string {
// See http://manpages.ubuntu.com/manpages/intrepid/man4/console_codes.4.html.
func isAnsiCommandChar(b byte) bool {
switch {
case ANSI_COMMAND_FIRST <= b && b <= ANSI_COMMAND_LAST && b != ANSI_ESCAPE_SECONDARY:
case ansiterm.ANSI_COMMAND_FIRST <= b && b <= ansiterm.ANSI_COMMAND_LAST && b != ansiterm.ANSI_ESCAPE_SECONDARY:
return true
case b == ANSI_CMD_G1 || b == ANSI_CMD_OSC || b == ANSI_CMD_DECPAM || b == ANSI_CMD_DECPNM:
case b == ansiterm.ANSI_CMD_G1 || b == ansiterm.ANSI_CMD_OSC || b == ansiterm.ANSI_CMD_DECPAM || b == ansiterm.ANSI_CMD_DECPNM:
// non-CSI escape sequence terminator
return true
case b == ANSI_CMD_STR_TERM || b == ANSI_BEL:
case b == ansiterm.ANSI_CMD_STR_TERM || b == ansiterm.ANSI_BEL:
// String escape sequence terminator
return true
}
......@@ -132,11 +132,11 @@ func isAnsiCommandChar(b byte) bool {
}
func isXtermOscSequence(command []byte, current byte) bool {
return (len(command) >= 2 && command[0] == ANSI_ESCAPE_PRIMARY && command[1] == ANSI_CMD_OSC && current != ANSI_BEL)
return (len(command) >= 2 && command[0] == ansiterm.ANSI_ESCAPE_PRIMARY && command[1] == ansiterm.ANSI_CMD_OSC && current != ansiterm.ANSI_BEL)
}
func isCharacterSelectionCmdChar(b byte) bool {
return (b == ANSI_CMD_G0 || b == ANSI_CMD_G1 || b == ANSI_CMD_G2 || b == ANSI_CMD_G3)
return (b == ansiterm.ANSI_CMD_G0 || b == ansiterm.ANSI_CMD_G1 || b == ansiterm.ANSI_CMD_G2 || b == ansiterm.ANSI_CMD_G3)
}
// bytesToHex converts a slice of bytes to a human-readable string.
......@@ -150,7 +150,7 @@ func bytesToHex(b []byte) string {
// ensureInRange adjusts the passed value, if necessary, to ensure it is within
// the passed min / max range.
func ensureInRange(n SHORT, min SHORT, max SHORT) SHORT {
func ensureInRange(n int16, min int16, max int16) int16 {
if n < min {
return min
} else if n > max {
......
......@@ -66,21 +66,21 @@ const (
// -- The attributes are combined to produce various colors (e.g., Blue + Green will create Cyan).
// Clearing all foreground or background colors results in black; setting all creates white.
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes.
FOREGROUND_BLUE WORD = 0x0001
FOREGROUND_GREEN WORD = 0x0002
FOREGROUND_RED WORD = 0x0004
FOREGROUND_INTENSITY WORD = 0x0008
FOREGROUND_MASK WORD = 0x000F
BACKGROUND_BLUE WORD = 0x0010
BACKGROUND_GREEN WORD = 0x0020
BACKGROUND_RED WORD = 0x0040
BACKGROUND_INTENSITY WORD = 0x0080
BACKGROUND_MASK WORD = 0x00F0
COMMON_LVB_MASK WORD = 0xFF00
COMMON_LVB_REVERSE_VIDEO WORD = 0x4000
COMMON_LVB_UNDERSCORE WORD = 0x8000
FOREGROUND_BLUE uint16 = 0x0001
FOREGROUND_GREEN uint16 = 0x0002
FOREGROUND_RED uint16 = 0x0004
FOREGROUND_INTENSITY uint16 = 0x0008
FOREGROUND_MASK uint16 = 0x000F
BACKGROUND_BLUE uint16 = 0x0010
BACKGROUND_GREEN uint16 = 0x0020
BACKGROUND_RED uint16 = 0x0040
BACKGROUND_INTENSITY uint16 = 0x0080
BACKGROUND_MASK uint16 = 0x00F0
COMMON_LVB_MASK uint16 = 0xFF00
COMMON_LVB_REVERSE_VIDEO uint16 = 0x4000
COMMON_LVB_UNDERSCORE uint16 = 0x8000
// Input event types
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx.
......@@ -104,60 +104,53 @@ const (
)
// Windows API Console types
// -- See https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx for core types (e.g., SHORT)
// -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD)
// -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment
type (
SHORT int16
BOOL int32
WORD uint16
WCHAR uint16
DWORD uint32
CHAR_INFO struct {
UnicodeChar WCHAR
Attributes WORD
UnicodeChar uint16
Attributes uint16
}
CONSOLE_CURSOR_INFO struct {
Size DWORD
Visible BOOL
Size uint32
Visible int32
}
CONSOLE_SCREEN_BUFFER_INFO struct {
Size COORD
CursorPosition COORD
Attributes WORD
Attributes uint16
Window SMALL_RECT
MaximumWindowSize COORD
}
COORD struct {
X SHORT
Y SHORT
X int16
Y int16
}
SMALL_RECT struct {
Left SHORT
Top SHORT
Right SHORT
Bottom SHORT
Left int16
Top int16
Right int16
Bottom int16
}
// INPUT_RECORD is a C/C++ union of which KEY_EVENT_RECORD is one case, it is also the largest
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx.
INPUT_RECORD struct {
EventType WORD
EventType uint16
KeyEvent KEY_EVENT_RECORD
}
KEY_EVENT_RECORD struct {
KeyDown BOOL
RepeatCount WORD
VirtualKeyCode WORD
VirtualScanCode WORD
UnicodeChar WCHAR
ControlKeyState DWORD
KeyDown int32
RepeatCount uint16
VirtualKeyCode uint16
VirtualScanCode uint16
UnicodeChar uint16
ControlKeyState uint32
}
WINDOW_BUFFER_SIZE struct {
......@@ -165,12 +158,12 @@ type (
}
)
// boolToBOOL converts a Go bool into a Windows BOOL.
func boolToBOOL(f bool) BOOL {
// boolToBOOL converts a Go bool into a Windows int32.
func boolToBOOL(f bool) int32 {
if f {
return BOOL(1)
return int32(1)
} else {
return BOOL(0)
return int32(0)
}
}
......@@ -242,7 +235,7 @@ func SetConsoleScreenBufferSize(handle uintptr, coord COORD) error {
// SetConsoleTextAttribute sets the attributes of characters written to the
// console screen buffer by the WriteFile or WriteConsole function.
// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686047(v=vs.85).aspx.
func SetConsoleTextAttribute(handle uintptr, attribute WORD) error {
func SetConsoleTextAttribute(handle uintptr, attribute uint16) error {
r1, r2, err := setConsoleTextAttributeProc.Call(handle, uintptr(attribute), 0)
use(attribute)
return checkError(r1, r2, err)
......@@ -280,7 +273,7 @@ func ReadConsoleInput(handle uintptr, buffer []INPUT_RECORD, count *uint32) erro
// It returns true if the handle was signaled; false otherwise.
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx.
func WaitForSingleObject(handle uintptr, msWait uint32) (bool, error) {
r1, _, err := waitForSingleObjectProc.Call(handle, uintptr(DWORD(msWait)))
r1, _, err := waitForSingleObjectProc.Call(handle, uintptr(uint32(msWait)))
switch r1 {
case WAIT_ABANDONED, WAIT_TIMEOUT:
return false, nil
......@@ -320,8 +313,8 @@ func checkError(r1, r2 uintptr, err error) error {
// coordToPointer converts a COORD into a uintptr (by fooling the type system).
func coordToPointer(c COORD) uintptr {
// Note: This code assumes the two SHORTs are correctly laid out; the "cast" to DWORD is just to get a pointer to pass.
return uintptr(*((*DWORD)(unsafe.Pointer(&c))))
// Note: This code assumes the two SHORTs are correctly laid out; the "cast" to uint32 is just to get a pointer to pass.
return uintptr(*((*uint32)(unsafe.Pointer(&c))))
}
// use is a no-op, but the compiler cannot see that it is.
......
......@@ -2,9 +2,7 @@
package winterm
import (
. "github.com/Azure/go-ansiterm"
)
import "github.com/Azure/go-ansiterm"
const (
FOREGROUND_COLOR_MASK = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
......@@ -13,83 +11,83 @@ const (
// collectAnsiIntoWindowsAttributes modifies the passed Windows text mode flags to reflect the
// request represented by the passed ANSI mode.
func collectAnsiIntoWindowsAttributes(windowsMode WORD, inverted bool, baseMode WORD, ansiMode SHORT) (WORD, bool) {
func collectAnsiIntoWindowsAttributes(windowsMode uint16, inverted bool, baseMode uint16, ansiMode int16) (uint16, bool) {
switch ansiMode {
// Mode styles
case ANSI_SGR_BOLD:
case ansiterm.ANSI_SGR_BOLD:
windowsMode = windowsMode | FOREGROUND_INTENSITY
case ANSI_SGR_DIM, ANSI_SGR_BOLD_DIM_OFF:
case ansiterm.ANSI_SGR_DIM, ansiterm.ANSI_SGR_BOLD_DIM_OFF:
windowsMode &^= FOREGROUND_INTENSITY
case ANSI_SGR_UNDERLINE:
case ansiterm.ANSI_SGR_UNDERLINE:
windowsMode = windowsMode | COMMON_LVB_UNDERSCORE
case ANSI_SGR_REVERSE:
case ansiterm.ANSI_SGR_REVERSE:
inverted = true
case ANSI_SGR_REVERSE_OFF:
case ansiterm.ANSI_SGR_REVERSE_OFF:
inverted = false
case ANSI_SGR_UNDERLINE_OFF:
case ansiterm.ANSI_SGR_UNDERLINE_OFF:
windowsMode &^= COMMON_LVB_UNDERSCORE
// Foreground colors
case ANSI_SGR_FOREGROUND_DEFAULT:
case ansiterm.ANSI_SGR_FOREGROUND_DEFAULT:
windowsMode = (windowsMode &^ FOREGROUND_MASK) | (baseMode & FOREGROUND_MASK)
case ANSI_SGR_FOREGROUND_BLACK:
case ansiterm.ANSI_SGR_FOREGROUND_BLACK:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK)
case ANSI_SGR_FOREGROUND_RED:
case ansiterm.ANSI_SGR_FOREGROUND_RED:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED
case ANSI_SGR_FOREGROUND_GREEN:
case ansiterm.ANSI_SGR_FOREGROUND_GREEN:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN
case ANSI_SGR_FOREGROUND_YELLOW:
case ansiterm.ANSI_SGR_FOREGROUND_YELLOW:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN
case ANSI_SGR_FOREGROUND_BLUE:
case ansiterm.ANSI_SGR_FOREGROUND_BLUE:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_BLUE
case ANSI_SGR_FOREGROUND_MAGENTA:
case ansiterm.ANSI_SGR_FOREGROUND_MAGENTA:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_BLUE
case ANSI_SGR_FOREGROUND_CYAN:
case ansiterm.ANSI_SGR_FOREGROUND_CYAN:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN | FOREGROUND_BLUE
case ANSI_SGR_FOREGROUND_WHITE:
case ansiterm.ANSI_SGR_FOREGROUND_WHITE:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
// Background colors
case ANSI_SGR_BACKGROUND_DEFAULT:
case ansiterm.ANSI_SGR_BACKGROUND_DEFAULT:
// Black with no intensity
windowsMode = (windowsMode &^ BACKGROUND_MASK) | (baseMode & BACKGROUND_MASK)
case ANSI_SGR_BACKGROUND_BLACK:
case ansiterm.ANSI_SGR_BACKGROUND_BLACK:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK)
case ANSI_SGR_BACKGROUND_RED:
case ansiterm.ANSI_SGR_BACKGROUND_RED:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED
case ANSI_SGR_BACKGROUND_GREEN:
case ansiterm.ANSI_SGR_BACKGROUND_GREEN:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN
case ANSI_SGR_BACKGROUND_YELLOW:
case ansiterm.ANSI_SGR_BACKGROUND_YELLOW:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN
case ANSI_SGR_BACKGROUND_BLUE:
case ansiterm.ANSI_SGR_BACKGROUND_BLUE:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_BLUE
case ANSI_SGR_BACKGROUND_MAGENTA:
case ansiterm.ANSI_SGR_BACKGROUND_MAGENTA:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_BLUE
case ANSI_SGR_BACKGROUND_CYAN:
case ansiterm.ANSI_SGR_BACKGROUND_CYAN:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN | BACKGROUND_BLUE
case ANSI_SGR_BACKGROUND_WHITE:
case ansiterm.ANSI_SGR_BACKGROUND_WHITE:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
}
......@@ -97,6 +95,6 @@ func collectAnsiIntoWindowsAttributes(windowsMode WORD, inverted bool, baseMode
}
// invertAttributes inverts the foreground and background colors of a Windows attributes value
func invertAttributes(windowsMode WORD) WORD {
func invertAttributes(windowsMode uint16) uint16 {
return (COMMON_LVB_MASK & windowsMode) | ((FOREGROUND_MASK & windowsMode) << 4) | ((BACKGROUND_MASK & windowsMode) >> 4)
}
......@@ -3,11 +3,11 @@
package winterm
const (
Horizontal = iota
Vertical
horizontal = iota
vertical
)
func (h *WindowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_INFO) SMALL_RECT {
func (h *windowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_INFO) SMALL_RECT {
if h.originMode {
sr := h.effectiveSr(info.Window)
return SMALL_RECT{
......@@ -27,7 +27,7 @@ func (h *WindowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_IN
}
// setCursorPosition sets the cursor to the specified position, bounded to the screen size
func (h *WindowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error {
func (h *windowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error {
position.X = ensureInRange(position.X, window.Left, window.Right)
position.Y = ensureInRange(position.Y, window.Top, window.Bottom)
err := SetConsoleCursorPosition(h.fd, position)
......@@ -38,15 +38,15 @@ func (h *WindowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL
return err
}
func (h *WindowsAnsiEventHandler) moveCursorVertical(param int) error {
return h.moveCursor(Vertical, param)
func (h *windowsAnsiEventHandler) moveCursorVertical(param int) error {
return h.moveCursor(vertical, param)
}
func (h *WindowsAnsiEventHandler) moveCursorHorizontal(param int) error {
return h.moveCursor(Horizontal, param)
func (h *windowsAnsiEventHandler) moveCursorHorizontal(param int) error {
return h.moveCursor(horizontal, param)
}
func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error {
func (h *windowsAnsiEventHandler) moveCursor(moveMode int, param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil {
return err
......@@ -54,10 +54,10 @@ func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error {
position := info.CursorPosition
switch moveMode {
case Horizontal:
position.X += SHORT(param)
case Vertical:
position.Y += SHORT(param)
case horizontal:
position.X += int16(param)
case vertical:
position.Y += int16(param)
}
if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil {
......@@ -67,7 +67,7 @@ func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error {
return nil
}
func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error {
func (h *windowsAnsiEventHandler) moveCursorLine(param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil {
return err
......@@ -75,7 +75,7 @@ func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error {
position := info.CursorPosition
position.X = 0
position.Y += SHORT(param)
position.Y += int16(param)
if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil {
return err
......@@ -84,14 +84,14 @@ func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error {
return nil
}
func (h *WindowsAnsiEventHandler) moveCursorColumn(param int) error {
func (h *windowsAnsiEventHandler) moveCursorColumn(param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil {
return err
}
position := info.CursorPosition
position.X = SHORT(param) - 1
position.X = int16(param) - 1
if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil {
return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment