Skip to content

Commit

Permalink
Moved NetConfigClient struct into netconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mye956 committed Sep 26, 2024
1 parent 11b825c commit cfe5753
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 163 deletions.
3 changes: 2 additions & 1 deletion agent/handlers/task_server_setup_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
mock_stats "github.com/aws/amazon-ecs-agent/agent/stats/mock"
mock_ecs "github.com/aws/amazon-ecs-agent/ecs-agent/api/ecs/mocks"
v4 "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state"
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/utils/netconfig"
mock_netlinkwrapper "github.com/aws/amazon-ecs-agent/ecs-agent/utils/netlinkwrapper/mocks"

"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -127,7 +128,7 @@ func TestV4GetTaskMetadataWithTaskNetworkConfig(t *testing.T) {
}
tmdsAgentState := agentV4.NewTMDSAgentState(state, statsEngine, ecsClient, clusterName, availabilityzone, vpcID, containerInstanceArn)

netConfigClient := v4.NewNetworkConfigClient()
netConfigClient := netconfig.NewNetworkConfigClient()

if tc.setNetLinkExpectations != nil {
mock_netlinkwrapper := mock_netlinkwrapper.NewMockNetLink(ctrl)
Expand Down
2 changes: 1 addition & 1 deletion agent/handlers/v4/tmdsstate_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

// Returns task metadata including the task network configuration in v4 format for the
// task identified by the provided endpointContainerID.
func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *tmdsv4.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *netconfig.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
taskResponse, err := s.getTaskMetadata(v3EndpointID, false, true)
if err == nil {
// Obtain the name of the default network interface within the host network namespace
Expand Down
3 changes: 2 additions & 1 deletion agent/handlers/v4/tmdsstate_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package v4

import (
tmdsv4 "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state"
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/utils/netconfig"
)

// Returns task metadata including the task network configuration in v4 format for the
// task identified by the provided endpointContainerID.
func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *tmdsv4.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *netconfig.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
return s.getTaskMetadata(v3EndpointID, false, true)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions ecs-agent/tmds/handlers/fault/v1/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils"
v4 "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4"
state "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state"
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/utils/netconfig"
"github.com/aws/amazon-ecs-agent/ecs-agent/utils/execwrapper"
"github.com/aws/aws-sdk-go/aws"

"github.com/aws/aws-sdk-go/aws"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -933,7 +934,7 @@ func validateRequest(w http.ResponseWriter, request types.NetworkFaultRequest, r
func validateTaskMetadata(w http.ResponseWriter, agentState state.AgentState, requestType string, r *http.Request) (*state.TaskResponse, error) {
var taskMetadata state.TaskResponse
endpointContainerID := mux.Vars(r)[v4.EndpointContainerIDMuxName]
taskMetadata, err := agentState.GetTaskMetadataWithTaskNetworkConfig(endpointContainerID, state.NewNetworkConfigClient())
taskMetadata, err := agentState.GetTaskMetadataWithTaskNetworkConfig(endpointContainerID, netconfig.NewNetworkConfigClient())
if err != nil {
code, errResponse := getTaskMetadataErrorResponse(endpointContainerID, requestType, err)
responseBody := types.NewNetworkFaultInjectionErrorResponse(fmt.Sprintf("%v", errResponse))
Expand Down
Loading

0 comments on commit cfe5753

Please sign in to comment.