go.mod github.com/Microsoft/hcsshim v0.8.16
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
26
vendor/github.com/Microsoft/hcsshim/hcn/hcnendpoint.go
generated
vendored
26
vendor/github.com/Microsoft/hcsshim/hcn/hcnendpoint.go
generated
vendored
@ -2,8 +2,9 @@ package hcn
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/Microsoft/hcsshim/internal/guid"
|
||||
"github.com/Microsoft/go-winio/pkg/guid"
|
||||
"github.com/Microsoft/hcsshim/internal/interop"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -121,7 +122,10 @@ func enumerateEndpoints(query string) ([]HostComputeEndpoint, error) {
|
||||
}
|
||||
|
||||
func createEndpoint(networkId string, endpointSettings string) (*HostComputeEndpoint, error) {
|
||||
networkGuid := guid.FromString(networkId)
|
||||
networkGuid, err := guid.FromString(networkId)
|
||||
if err != nil {
|
||||
return nil, errInvalidNetworkID
|
||||
}
|
||||
// Open network.
|
||||
var networkHandle hcnNetwork
|
||||
var resultBuffer *uint16
|
||||
@ -167,7 +171,10 @@ func createEndpoint(networkId string, endpointSettings string) (*HostComputeEndp
|
||||
}
|
||||
|
||||
func modifyEndpoint(endpointId string, settings string) (*HostComputeEndpoint, error) {
|
||||
endpointGuid := guid.FromString(endpointId)
|
||||
endpointGuid, err := guid.FromString(endpointId)
|
||||
if err != nil {
|
||||
return nil, errInvalidEndpointID
|
||||
}
|
||||
// Open endpoint
|
||||
var (
|
||||
endpointHandle hcnEndpoint
|
||||
@ -208,7 +215,10 @@ func modifyEndpoint(endpointId string, settings string) (*HostComputeEndpoint, e
|
||||
}
|
||||
|
||||
func deleteEndpoint(endpointId string) error {
|
||||
endpointGuid := guid.FromString(endpointId)
|
||||
endpointGuid, err := guid.FromString(endpointId)
|
||||
if err != nil {
|
||||
return errInvalidEndpointID
|
||||
}
|
||||
var resultBuffer *uint16
|
||||
hr := hcnDeleteEndpoint(&endpointGuid, &resultBuffer)
|
||||
if err := checkForErrors("hcnDeleteEndpoint", hr, resultBuffer); err != nil {
|
||||
@ -299,6 +309,10 @@ func GetEndpointByName(endpointName string) (*HostComputeEndpoint, error) {
|
||||
func (endpoint *HostComputeEndpoint) Create() (*HostComputeEndpoint, error) {
|
||||
logrus.Debugf("hcn::HostComputeEndpoint::Create id=%s", endpoint.Id)
|
||||
|
||||
if endpoint.HostComputeNamespace != "" {
|
||||
return nil, errors.New("endpoint create error, endpoint json HostComputeNamespace is read only and should not be set")
|
||||
}
|
||||
|
||||
jsonString, err := json.Marshal(endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -339,7 +353,7 @@ func ModifyEndpointSettings(endpointId string, request *ModifyEndpointSettingReq
|
||||
}
|
||||
|
||||
// ApplyPolicy applies a Policy (ex: ACL) on the Endpoint.
|
||||
func (endpoint *HostComputeEndpoint) ApplyPolicy(endpointPolicy PolicyEndpointRequest) error {
|
||||
func (endpoint *HostComputeEndpoint) ApplyPolicy(requestType RequestType, endpointPolicy PolicyEndpointRequest) error {
|
||||
logrus.Debugf("hcn::HostComputeEndpoint::ApplyPolicy id=%s", endpoint.Id)
|
||||
|
||||
settingsJson, err := json.Marshal(endpointPolicy)
|
||||
@ -348,7 +362,7 @@ func (endpoint *HostComputeEndpoint) ApplyPolicy(endpointPolicy PolicyEndpointRe
|
||||
}
|
||||
requestMessage := &ModifyEndpointSettingRequest{
|
||||
ResourceType: EndpointResourceTypePolicy,
|
||||
RequestType: RequestTypeUpdate,
|
||||
RequestType: requestType,
|
||||
Settings: settingsJson,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user