diff --git a/agent/structs/config_entry_routes.go b/agent/structs/config_entry_routes.go index 1235723f89..f99c6abd19 100644 --- a/agent/structs/config_entry_routes.go +++ b/agent/structs/config_entry_routes.go @@ -443,7 +443,7 @@ type HTTPService struct { // to routing it to the upstream service Filters HTTPFilters - acl.EnterpriseMeta + acl.EnterpriseMeta `hcl:",squash" mapstructure:",squash"` } func (s HTTPService) ServiceName() ServiceName { diff --git a/agent/structs/config_entry_status.go b/agent/structs/config_entry_status.go index 85140f3e5a..2a56ba08a0 100644 --- a/agent/structs/config_entry_status.go +++ b/agent/structs/config_entry_status.go @@ -22,7 +22,7 @@ type ResourceReference struct { // unused, this should be blank. SectionName string - acl.EnterpriseMeta + acl.EnterpriseMeta `hcl:",squash" mapstructure:",squash"` } func (r *ResourceReference) String() string { diff --git a/test/integration/consul-container/test/gateways/http_route_test.go b/test/integration/consul-container/test/gateways/http_route_test.go index f0f9586887..d7e30c6a7c 100644 --- a/test/integration/consul-container/test/gateways/http_route_test.go +++ b/test/integration/consul-container/test/gateways/http_route_test.go @@ -38,7 +38,7 @@ func TestHTTPRouteFlattening(t *testing.T) { } t.Parallel() - //infrastructure set up + // infrastructure set up listenerPort := 6000 clusterConfig := &libtopology.ClusterConfig{ @@ -65,7 +65,7 @@ func TestHTTPRouteFlattening(t *testing.T) { HTTPPort: 8080, GRPCPort: 8079, }, []string{ - //customizes response code so we can distinguish between which service is responding + // customizes response code so we can distinguish between which service is responding "-echo-server-default-params", fmt.Sprintf("status=%d", service1ResponseCode), }) serviceTwo := createService(t, cluster, &libservice.ServiceOpts{ @@ -85,11 +85,10 @@ func TestHTTPRouteFlattening(t *testing.T) { path1 := "/" path2 := "/v2" - //write config entries + // write config entries proxyDefaults := &api.ProxyConfigEntry{ - Kind: api.ProxyDefaults, - Name: api.ProxyConfigGlobal, - Namespace: namespace, + Kind: api.ProxyDefaults, + Name: api.ProxyConfigGlobal, Config: map[string]interface{}{ "protocol": "http", }, @@ -189,23 +188,23 @@ func TestHTTPRouteFlattening(t *testing.T) { require.NoError(t, cluster.ConfigEntryWrite(routeOne)) require.NoError(t, cluster.ConfigEntryWrite(routeTwo)) - //create gateway service + // create gateway service gatewayService, err := libservice.NewGatewayService(context.Background(), gatewayName, "api", cluster.Agents[0], listenerPort) require.NoError(t, err) libassert.CatalogServiceExists(t, client, gatewayName, nil) - //make sure config entries have been properly created + // make sure config entries have been properly created checkGatewayConfigEntry(t, client, gatewayName, namespace) checkHTTPRouteConfigEntry(t, client, routeOneName, namespace) checkHTTPRouteConfigEntry(t, client, routeTwoName, namespace) - //gateway resolves routes + // gateway resolves routes gatewayPort, err := gatewayService.GetPort(listenerPort) require.NoError(t, err) - //route 2 with headers + // route 2 with headers - //Same v2 path with and without header + // Same v2 path with and without header checkRoute(t, gatewayPort, "/v2", map[string]string{ "Host": "test.foo", "x-v2": "v2", @@ -214,7 +213,7 @@ func TestHTTPRouteFlattening(t *testing.T) { "Host": "test.foo", }, checkOptions{statusCode: service2ResponseCode, testName: "service2 just path match"}) - ////v1 path with the header + // //v1 path with the header checkRoute(t, gatewayPort, "/check", map[string]string{ "Host": "test.foo", "x-v2": "v2", @@ -225,12 +224,12 @@ func TestHTTPRouteFlattening(t *testing.T) { "x-v2": "v2", }, checkOptions{statusCode: service2ResponseCode, testName: "service2 v2 with path"}) - //hit service 1 by hitting root path + // hit service 1 by hitting root path checkRoute(t, gatewayPort, "", map[string]string{ "Host": "test.foo", }, checkOptions{debug: false, statusCode: service1ResponseCode, testName: "service1 root prefix"}) - //hit service 1 by hitting v2 path with v1 hostname + // hit service 1 by hitting v2 path with v1 hostname checkRoute(t, gatewayPort, "/v2", map[string]string{ "Host": "test.example", }, checkOptions{debug: false, statusCode: service1ResponseCode, testName: "service1, v2 path with v2 hostname"}) @@ -244,9 +243,9 @@ func TestHTTPRoutePathRewrite(t *testing.T) { t.Parallel() - //infrastructure set up + // infrastructure set up listenerPort := 6001 - //create cluster + // create cluster cluster := createCluster(t, listenerPort) client := cluster.Agents[0].GetClient() fooStatusCode := 400 @@ -260,14 +259,14 @@ func TestHTTPRoutePathRewrite(t *testing.T) { HTTPPort: 8080, GRPCPort: 8081, }, []string{ - //customizes response code so we can distinguish between which service is responding + // customizes response code so we can distinguish between which service is responding "-echo-debug-path", fooPath, "-echo-server-default-params", fmt.Sprintf("status=%d", fooStatusCode), }) barService := createService(t, cluster, &libservice.ServiceOpts{ Name: "bar", ID: "bar", - //TODO we can potentially get conflicts if these ports are the same + // TODO we can potentially get conflicts if these ports are the same HTTPPort: 8079, GRPCPort: 8078, }, []string{ @@ -283,11 +282,10 @@ func TestHTTPRoutePathRewrite(t *testing.T) { fooUnrewritten := "/foo" barUnrewritten := "/bar" - //write config entries + // write config entries proxyDefaults := &api.ProxyConfigEntry{ - Kind: api.ProxyDefaults, - Name: api.ProxyConfigGlobal, - Namespace: namespace, + Kind: api.ProxyDefaults, + Name: api.ProxyConfigGlobal, Config: map[string]interface{}{ "protocol": "http", }, @@ -379,12 +377,12 @@ func TestHTTPRoutePathRewrite(t *testing.T) { require.NoError(t, cluster.ConfigEntryWrite(fooRoute)) require.NoError(t, cluster.ConfigEntryWrite(barRoute)) - //create gateway service + // create gateway service gatewayService, err := libservice.NewGatewayService(context.Background(), gatewayName, "api", cluster.Agents[0], listenerPort) require.NoError(t, err) libassert.CatalogServiceExists(t, client, gatewayName, nil) - //make sure config entries have been properly created + // make sure config entries have been properly created checkGatewayConfigEntry(t, client, gatewayName, namespace) checkHTTPRouteConfigEntry(t, client, invalidRouteName, namespace) checkHTTPRouteConfigEntry(t, client, validRouteName, namespace) @@ -392,26 +390,26 @@ func TestHTTPRoutePathRewrite(t *testing.T) { gatewayPort, err := gatewayService.GetPort(listenerPort) require.NoError(t, err) - //TODO these were the assertions we had in the original test. potentially would want more test cases + // TODO these were the assertions we had in the original test. potentially would want more test cases - //NOTE: Hitting the debug path code overrides default expected value + // NOTE: Hitting the debug path code overrides default expected value debugExpectedStatusCode := 200 - //hit foo, making sure path is being rewritten by hitting the debug page + // hit foo, making sure path is being rewritten by hitting the debug page checkRoute(t, gatewayPort, fooUnrewritten, map[string]string{ "Host": "test.foo", }, checkOptions{debug: true, statusCode: debugExpectedStatusCode, testName: "foo service"}) - //make sure foo is being sent to proper service + // make sure foo is being sent to proper service checkRoute(t, gatewayPort, fooUnrewritten+"/foo", map[string]string{ "Host": "test.foo", }, checkOptions{debug: false, statusCode: fooStatusCode, testName: "foo service"}) - //hit bar, making sure its been rewritten + // hit bar, making sure its been rewritten checkRoute(t, gatewayPort, barUnrewritten, map[string]string{ "Host": "test.foo", }, checkOptions{debug: true, statusCode: debugExpectedStatusCode, testName: "bar service"}) - //hit bar, making sure its being sent to the proper service + // hit bar, making sure its being sent to the proper service checkRoute(t, gatewayPort, barUnrewritten+"/bar", map[string]string{ "Host": "test.foo", }, checkOptions{debug: false, statusCode: barStatusCode, testName: "bar service"}) @@ -448,9 +446,8 @@ func TestHTTPRouteParentRefChange(t *testing.T) { // write config entries proxyDefaults := &api.ProxyConfigEntry{ - Kind: api.ProxyDefaults, - Name: api.ProxyConfigGlobal, - Namespace: namespace, + Kind: api.ProxyDefaults, + Name: api.ProxyConfigGlobal, Config: map[string]interface{}{ "protocol": "http", },