@@ -176,6 +176,11 @@ func GetPolicyType(policy Policy) CNIPolicyType {
176176 }
177177 }
178178
179+ // Check if the type is ACLPolicy
180+ if policy .Type == ACLPolicy {
181+ return ACLPolicy
182+ }
183+
179184 // Return empty string if the policy type is invalid
180185 log .Printf ("Returning policyType INVALID" )
181186 return ""
@@ -343,6 +348,28 @@ func GetHcnPortMappingPolicy(policy Policy) (hcn.EndpointPolicy, error) {
343348 return portMappingPolicy , nil
344349}
345350
351+ // GetHcnACLPolicy returns ACL policy.
352+ func GetHcnACLPolicy (policy Policy ) (hcn.EndpointPolicy , error ) {
353+ aclEndpolicySetting := hcn.EndpointPolicy {
354+ Type : hcn .ACL ,
355+ }
356+
357+ // Check beforehand, the input meets the expected format
358+ // otherwise, endpoint creation will fail later on.
359+ var aclPolicySetting hcn.AclPolicySetting
360+ if err := json .Unmarshal (policy .Data , & aclPolicySetting ); err != nil {
361+ return aclEndpolicySetting , err
362+ }
363+
364+ aclPolicySettingBytes , err := json .Marshal (aclPolicySetting )
365+ if err != nil {
366+ return aclEndpolicySetting , err
367+ }
368+
369+ aclEndpolicySetting .Settings = aclPolicySettingBytes
370+ return aclEndpolicySetting , nil
371+ }
372+
346373// GetHcnEndpointPolicies returns array of all endpoint policies.
347374func GetHcnEndpointPolicies (policyType CNIPolicyType , policies []Policy , epInfoData map [string ]interface {}, enableSnatForDns , enableMultiTenancy bool ) ([]hcn.EndpointPolicy , error ) {
348375 var (
@@ -363,6 +390,8 @@ func GetHcnEndpointPolicies(policyType CNIPolicyType, policies []Policy, epInfoD
363390 endpointPolicy , err = GetHcnRoutePolicy (policy )
364391 case PortMappingPolicy :
365392 endpointPolicy , err = GetHcnPortMappingPolicy (policy )
393+ case ACLPolicy :
394+ endpointPolicy , err = GetHcnACLPolicy (policy )
366395 default :
367396 // return error as we should be able to parse all the policies specified
368397 return hcnEndPointPolicies , fmt .Errorf ("Failed to set Policy: Type: %s, Data: %s" , policy .Type , policy .Data )
0 commit comments