func (m *MockSecretsManagerAPI) DescribeSecretWithContext(arg0 aws.Context, arg1 *secretsmanager.DescribeSecretInput, arg2 ...request.Option) (*secretsmanager.DescribeSecretOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "DescribeSecretWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.DescribeSecretOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) DescribeSecretWithContext ( arg0 aws . Context , arg1 * secretsmanager . DescribeSecretInput , arg2 ... request . Option ) ( * secretsmanager . DescribeSecretOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . DescribeSecretOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// DescribeSecretWithContext mocks base method


func (m *MockSecretsManagerAPI) GetRandomPassword(arg0 *secretsmanager.GetRandomPasswordInput) (*secretsmanager.GetRandomPasswordOutput, error) {
	ret := m.ctrl.Call(m, "GetRandomPassword", arg0)
	ret0, _ := ret[0].(*secretsmanager.GetRandomPasswordOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetRandomPassword ( arg0 * secretsmanager . GetRandomPasswordInput ) ( * secretsmanager . GetRandomPasswordOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . GetRandomPasswordOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) GetRandomPasswordRequest(arg0 *secretsmanager.GetRandomPasswordInput) (*request.Request, *secretsmanager.GetRandomPasswordOutput) {
	ret := m.ctrl.Call(m, "GetRandomPasswordRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.GetRandomPasswordOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetRandomPasswordRequest ( arg0 * secretsmanager . GetRandomPasswordInput ) ( * request . Request , * secretsmanager . GetRandomPasswordOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . GetRandomPasswordOutput ) return ret0 , ret1 }

// GetRandomPasswordRequest mocks base method


func (m *MockSecretsManagerAPI) GetRandomPasswordWithContext(arg0 aws.Context, arg1 *secretsmanager.GetRandomPasswordInput, arg2 ...request.Option) (*secretsmanager.GetRandomPasswordOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "GetRandomPasswordWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.GetRandomPasswordOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetRandomPasswordWithContext ( arg0 aws . Context , arg1 * secretsmanager . GetRandomPasswordInput , arg2 ... request . Option ) ( * secretsmanager . GetRandomPasswordOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . GetRandomPasswordOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// GetRandomPasswordWithContext mocks base method


func (m *MockSecretsManagerAPI) GetResourcePolicy(arg0 *secretsmanager.GetResourcePolicyInput) (*secretsmanager.GetResourcePolicyOutput, error) {
	ret := m.ctrl.Call(m, "GetResourcePolicy", arg0)
	ret0, _ := ret[0].(*secretsmanager.GetResourcePolicyOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetResourcePolicy ( arg0 * secretsmanager . GetResourcePolicyInput ) ( * secretsmanager . GetResourcePolicyOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . GetResourcePolicyOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) GetResourcePolicyRequest(arg0 *secretsmanager.GetResourcePolicyInput) (*request.Request, *secretsmanager.GetResourcePolicyOutput) {
	ret := m.ctrl.Call(m, "GetResourcePolicyRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.GetResourcePolicyOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetResourcePolicyRequest ( arg0 * secretsmanager . GetResourcePolicyInput ) ( * request . Request , * secretsmanager . GetResourcePolicyOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . GetResourcePolicyOutput ) return ret0 , ret1 }

// GetResourcePolicyRequest mocks base method


func (m *MockSecretsManagerAPI) GetResourcePolicyWithContext(arg0 aws.Context, arg1 *secretsmanager.GetResourcePolicyInput, arg2 ...request.Option) (*secretsmanager.GetResourcePolicyOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "GetResourcePolicyWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.GetResourcePolicyOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetResourcePolicyWithContext ( arg0 aws . Context , arg1 * secretsmanager . GetResourcePolicyInput , arg2 ... request . Option ) ( * secretsmanager . GetResourcePolicyOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . GetResourcePolicyOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// GetResourcePolicyWithContext mocks base method


func (m *MockSecretsManagerAPI) GetSecretValue(arg0 *secretsmanager.GetSecretValueInput) (*secretsmanager.GetSecretValueOutput, error) {
	ret := m.ctrl.Call(m, "GetSecretValue", arg0)
	ret0, _ := ret[0].(*secretsmanager.GetSecretValueOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetSecretValue ( arg0 * secretsmanager . GetSecretValueInput ) ( * secretsmanager . GetSecretValueOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . GetSecretValueOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) GetSecretValueRequest(arg0 *secretsmanager.GetSecretValueInput) (*request.Request, *secretsmanager.GetSecretValueOutput) {
	ret := m.ctrl.Call(m, "GetSecretValueRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.GetSecretValueOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetSecretValueRequest ( arg0 * secretsmanager . GetSecretValueInput ) ( * request . Request , * secretsmanager . GetSecretValueOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . GetSecretValueOutput ) return ret0 , ret1 }

// GetSecretValueRequest mocks base method


func (m *MockSecretsManagerAPI) GetSecretValueWithContext(arg0 aws.Context, arg1 *secretsmanager.GetSecretValueInput, arg2 ...request.Option) (*secretsmanager.GetSecretValueOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "GetSecretValueWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.GetSecretValueOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) GetSecretValueWithContext ( arg0 aws . Context , arg1 * secretsmanager . GetSecretValueInput , arg2 ... request . Option ) ( * secretsmanager . GetSecretValueOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . GetSecretValueOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// GetSecretValueWithContext mocks base method


func (m *MockSecretsManagerAPI) ListSecretVersionIds(arg0 *secretsmanager.ListSecretVersionIdsInput) (*secretsmanager.ListSecretVersionIdsOutput, error) {
	ret := m.ctrl.Call(m, "ListSecretVersionIds", arg0)
	ret0, _ := ret[0].(*secretsmanager.ListSecretVersionIdsOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) ListSecretVersionIds ( arg0 * secretsmanager . ListSecretVersionIdsInput ) ( * secretsmanager . ListSecretVersionIdsOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . ListSecretVersionIdsOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// ListSecretVersionIds mocks base method


func (m *MockSecretsManagerAPI) ListSecretVersionIdsPages(arg0 *secretsmanager.ListSecretVersionIdsInput, arg1 func(*secretsmanager.ListSecretVersionIdsOutput, bool) bool) error {
	ret := m.ctrl.Call(m, "ListSecretVersionIdsPages", arg0, arg1)
	ret0, _ := ret[0].(error)
	return ret0
}

func ( m * MockSecretsManagerAPI ) ListSecretVersionIdsPages ( arg0 * secretsmanager . ListSecretVersionIdsInput , arg1 func ( * secretsmanager . ListSecretVersionIdsOutput , bool ) bool ) error { ret := m . ctrl . Call ( m , " " , arg0 , arg1 ) ret0 , _ := ret [ 0 ] . ( error ) return ret0 }

// ListSecretVersionIdsPages mocks base method


func (m *MockSecretsManagerAPI) ListSecretVersionIdsPagesWithContext(arg0 aws.Context, arg1 *secretsmanager.ListSecretVersionIdsInput, arg2 func(*secretsmanager.ListSecretVersionIdsOutput, bool) bool, arg3 ...request.Option) error {
	varargs := []interface{}{arg0, arg1, arg2}
	for _, a := range arg3 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "ListSecretVersionIdsPagesWithContext", varargs...)
	ret0, _ := ret[0].(error)
	return ret0
}

func ( m * MockSecretsManagerAPI ) ListSecretVersionIdsPagesWithContext ( arg0 aws . Context , arg1 * secretsmanager . ListSecretVersionIdsInput , arg2 func ( * secretsmanager . ListSecretVersionIdsOutput , bool ) bool , arg3 ... request . Option ) error { varargs := [ ] interface { } { arg0 , arg1 , arg2 } for _ , a := range arg3 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( error ) return ret0 }

// ListSecretVersionIdsPagesWithContext mocks base method


func (m *MockSecretsManagerAPI) ListSecretVersionIdsRequest(arg0 *secretsmanager.ListSecretVersionIdsInput) (*request.Request, *secretsmanager.ListSecretVersionIdsOutput) {
	ret := m.ctrl.Call(m, "ListSecretVersionIdsRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.ListSecretVersionIdsOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) ListSecretVersionIdsRequest ( arg0 * secretsmanager . ListSecretVersionIdsInput ) ( * request . Request , * secretsmanager . ListSecretVersionIdsOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . ListSecretVersionIdsOutput ) return ret0 , ret1 }

// ListSecretVersionIdsRequest mocks base method


func (m *MockSecretsManagerAPI) ListSecrets(arg0 *secretsmanager.ListSecretsInput) (*secretsmanager.ListSecretsOutput, error) {
	ret := m.ctrl.Call(m, "ListSecrets", arg0)
	ret0, _ := ret[0].(*secretsmanager.ListSecretsOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) ListSecrets ( arg0 * secretsmanager . ListSecretsInput ) ( * secretsmanager . ListSecretsOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . ListSecretsOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) ListSecretsPages(arg0 *secretsmanager.ListSecretsInput, arg1 func(*secretsmanager.ListSecretsOutput, bool) bool) error {
	ret := m.ctrl.Call(m, "ListSecretsPages", arg0, arg1)
	ret0, _ := ret[0].(error)
	return ret0
}

func ( m * MockSecretsManagerAPI ) ListSecretsPages ( arg0 * secretsmanager . ListSecretsInput , arg1 func ( * secretsmanager . ListSecretsOutput , bool ) bool ) error { ret := m . ctrl . Call ( m , " " , arg0 , arg1 ) ret0 , _ := ret [ 0 ] . ( error ) return ret0 }


func (m *MockSecretsManagerAPI) ListSecretsRequest(arg0 *secretsmanager.ListSecretsInput) (*request.Request, *secretsmanager.ListSecretsOutput) {
	ret := m.ctrl.Call(m, "ListSecretsRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.ListSecretsOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) ListSecretsRequest ( arg0 * secretsmanager . ListSecretsInput ) ( * request . Request , * secretsmanager . ListSecretsOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . ListSecretsOutput ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) ListSecretsWithContext(arg0 aws.Context, arg1 *secretsmanager.ListSecretsInput, arg2 ...request.Option) (*secretsmanager.ListSecretsOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "ListSecretsWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.ListSecretsOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) ListSecretsWithContext ( arg0 aws . Context , arg1 * secretsmanager . ListSecretsInput , arg2 ... request . Option ) ( * secretsmanager . ListSecretsOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . ListSecretsOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// ListSecretsWithContext mocks base method


func (m *MockSecretsManagerAPI) PutResourcePolicy(arg0 *secretsmanager.PutResourcePolicyInput) (*secretsmanager.PutResourcePolicyOutput, error) {
	ret := m.ctrl.Call(m, "PutResourcePolicy", arg0)
	ret0, _ := ret[0].(*secretsmanager.PutResourcePolicyOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) PutResourcePolicy ( arg0 * secretsmanager . PutResourcePolicyInput ) ( * secretsmanager . PutResourcePolicyOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . PutResourcePolicyOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) PutResourcePolicyRequest(arg0 *secretsmanager.PutResourcePolicyInput) (*request.Request, *secretsmanager.PutResourcePolicyOutput) {
	ret := m.ctrl.Call(m, "PutResourcePolicyRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.PutResourcePolicyOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) PutResourcePolicyRequest ( arg0 * secretsmanager . PutResourcePolicyInput ) ( * request . Request , * secretsmanager . PutResourcePolicyOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . PutResourcePolicyOutput ) return ret0 , ret1 }

// PutResourcePolicyRequest mocks base method


func (m *MockSecretsManagerAPI) PutResourcePolicyWithContext(arg0 aws.Context, arg1 *secretsmanager.PutResourcePolicyInput, arg2 ...request.Option) (*secretsmanager.PutResourcePolicyOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "PutResourcePolicyWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.PutResourcePolicyOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) PutResourcePolicyWithContext ( arg0 aws . Context , arg1 * secretsmanager . PutResourcePolicyInput , arg2 ... request . Option ) ( * secretsmanager . PutResourcePolicyOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . PutResourcePolicyOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// PutResourcePolicyWithContext mocks base method


func (m *MockSecretsManagerAPI) PutSecretValue(arg0 *secretsmanager.PutSecretValueInput) (*secretsmanager.PutSecretValueOutput, error) {
	ret := m.ctrl.Call(m, "PutSecretValue", arg0)
	ret0, _ := ret[0].(*secretsmanager.PutSecretValueOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) PutSecretValue ( arg0 * secretsmanager . PutSecretValueInput ) ( * secretsmanager . PutSecretValueOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . PutSecretValueOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) PutSecretValueRequest(arg0 *secretsmanager.PutSecretValueInput) (*request.Request, *secretsmanager.PutSecretValueOutput) {
	ret := m.ctrl.Call(m, "PutSecretValueRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.PutSecretValueOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) PutSecretValueRequest ( arg0 * secretsmanager . PutSecretValueInput ) ( * request . Request , * secretsmanager . PutSecretValueOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . PutSecretValueOutput ) return ret0 , ret1 }

// PutSecretValueRequest mocks base method


func (m *MockSecretsManagerAPI) PutSecretValueWithContext(arg0 aws.Context, arg1 *secretsmanager.PutSecretValueInput, arg2 ...request.Option) (*secretsmanager.PutSecretValueOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "PutSecretValueWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.PutSecretValueOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) PutSecretValueWithContext ( arg0 aws . Context , arg1 * secretsmanager . PutSecretValueInput , arg2 ... request . Option ) ( * secretsmanager . PutSecretValueOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . PutSecretValueOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// PutSecretValueWithContext mocks base method


func (m *MockSecretsManagerAPI) RestoreSecret(arg0 *secretsmanager.RestoreSecretInput) (*secretsmanager.RestoreSecretOutput, error) {
	ret := m.ctrl.Call(m, "RestoreSecret", arg0)
	ret0, _ := ret[0].(*secretsmanager.RestoreSecretOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) RestoreSecret ( arg0 * secretsmanager . RestoreSecretInput ) ( * secretsmanager . RestoreSecretOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . RestoreSecretOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) RestoreSecretRequest(arg0 *secretsmanager.RestoreSecretInput) (*request.Request, *secretsmanager.RestoreSecretOutput) {
	ret := m.ctrl.Call(m, "RestoreSecretRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.RestoreSecretOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) RestoreSecretRequest ( arg0 * secretsmanager . RestoreSecretInput ) ( * request . Request , * secretsmanager . RestoreSecretOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . RestoreSecretOutput ) return ret0 , ret1 }

// RestoreSecretRequest mocks base method


func (m *MockSecretsManagerAPI) RestoreSecretWithContext(arg0 aws.Context, arg1 *secretsmanager.RestoreSecretInput, arg2 ...request.Option) (*secretsmanager.RestoreSecretOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "RestoreSecretWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.RestoreSecretOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) RestoreSecretWithContext ( arg0 aws . Context , arg1 * secretsmanager . RestoreSecretInput , arg2 ... request . Option ) ( * secretsmanager . RestoreSecretOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . RestoreSecretOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// RestoreSecretWithContext mocks base method


func (m *MockSecretsManagerAPI) RotateSecret(arg0 *secretsmanager.RotateSecretInput) (*secretsmanager.RotateSecretOutput, error) {
	ret := m.ctrl.Call(m, "RotateSecret", arg0)
	ret0, _ := ret[0].(*secretsmanager.RotateSecretOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) RotateSecret ( arg0 * secretsmanager . RotateSecretInput ) ( * secretsmanager . RotateSecretOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . RotateSecretOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) RotateSecretRequest(arg0 *secretsmanager.RotateSecretInput) (*request.Request, *secretsmanager.RotateSecretOutput) {
	ret := m.ctrl.Call(m, "RotateSecretRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.RotateSecretOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) RotateSecretRequest ( arg0 * secretsmanager . RotateSecretInput ) ( * request . Request , * secretsmanager . RotateSecretOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . RotateSecretOutput ) return ret0 , ret1 }

// RotateSecretRequest mocks base method


func (m *MockSecretsManagerAPI) RotateSecretWithContext(arg0 aws.Context, arg1 *secretsmanager.RotateSecretInput, arg2 ...request.Option) (*secretsmanager.RotateSecretOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "RotateSecretWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.RotateSecretOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) RotateSecretWithContext ( arg0 aws . Context , arg1 * secretsmanager . RotateSecretInput , arg2 ... request . Option ) ( * secretsmanager . RotateSecretOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . RotateSecretOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// RotateSecretWithContext mocks base method


func (m *MockSecretsManagerAPI) TagResource(arg0 *secretsmanager.TagResourceInput) (*secretsmanager.TagResourceOutput, error) {
	ret := m.ctrl.Call(m, "TagResource", arg0)
	ret0, _ := ret[0].(*secretsmanager.TagResourceOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) TagResource ( arg0 * secretsmanager . TagResourceInput ) ( * secretsmanager . TagResourceOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . TagResourceOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) TagResourceRequest(arg0 *secretsmanager.TagResourceInput) (*request.Request, *secretsmanager.TagResourceOutput) {
	ret := m.ctrl.Call(m, "TagResourceRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.TagResourceOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) TagResourceRequest ( arg0 * secretsmanager . TagResourceInput ) ( * request . Request , * secretsmanager . TagResourceOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . TagResourceOutput ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) UntagResource(arg0 *secretsmanager.UntagResourceInput) (*secretsmanager.UntagResourceOutput, error) {
	ret := m.ctrl.Call(m, "UntagResource", arg0)
	ret0, _ := ret[0].(*secretsmanager.UntagResourceOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UntagResource ( arg0 * secretsmanager . UntagResourceInput ) ( * secretsmanager . UntagResourceOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . UntagResourceOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) UntagResourceRequest(arg0 *secretsmanager.UntagResourceInput) (*request.Request, *secretsmanager.UntagResourceOutput) {
	ret := m.ctrl.Call(m, "UntagResourceRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.UntagResourceOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UntagResourceRequest ( arg0 * secretsmanager . UntagResourceInput ) ( * request . Request , * secretsmanager . UntagResourceOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . UntagResourceOutput ) return ret0 , ret1 }

// UntagResourceRequest mocks base method


func (m *MockSecretsManagerAPI) UntagResourceWithContext(arg0 aws.Context, arg1 *secretsmanager.UntagResourceInput, arg2 ...request.Option) (*secretsmanager.UntagResourceOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "UntagResourceWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.UntagResourceOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UntagResourceWithContext ( arg0 aws . Context , arg1 * secretsmanager . UntagResourceInput , arg2 ... request . Option ) ( * secretsmanager . UntagResourceOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . UntagResourceOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// UntagResourceWithContext mocks base method


func (m *MockSecretsManagerAPI) UpdateSecret(arg0 *secretsmanager.UpdateSecretInput) (*secretsmanager.UpdateSecretOutput, error) {
	ret := m.ctrl.Call(m, "UpdateSecret", arg0)
	ret0, _ := ret[0].(*secretsmanager.UpdateSecretOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UpdateSecret ( arg0 * secretsmanager . UpdateSecretInput ) ( * secretsmanager . UpdateSecretOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . UpdateSecretOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (m *MockSecretsManagerAPI) UpdateSecretRequest(arg0 *secretsmanager.UpdateSecretInput) (*request.Request, *secretsmanager.UpdateSecretOutput) {
	ret := m.ctrl.Call(m, "UpdateSecretRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.UpdateSecretOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UpdateSecretRequest ( arg0 * secretsmanager . UpdateSecretInput ) ( * request . Request , * secretsmanager . UpdateSecretOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . UpdateSecretOutput ) return ret0 , ret1 }

// UpdateSecretRequest mocks base method


func (m *MockSecretsManagerAPI) UpdateSecretVersionStage(arg0 *secretsmanager.UpdateSecretVersionStageInput) (*secretsmanager.UpdateSecretVersionStageOutput, error) {
	ret := m.ctrl.Call(m, "UpdateSecretVersionStage", arg0)
	ret0, _ := ret[0].(*secretsmanager.UpdateSecretVersionStageOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UpdateSecretVersionStage ( arg0 * secretsmanager . UpdateSecretVersionStageInput ) ( * secretsmanager . UpdateSecretVersionStageOutput , error ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . UpdateSecretVersionStageOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// UpdateSecretVersionStage mocks base method


func (m *MockSecretsManagerAPI) UpdateSecretVersionStageRequest(arg0 *secretsmanager.UpdateSecretVersionStageInput) (*request.Request, *secretsmanager.UpdateSecretVersionStageOutput) {
	ret := m.ctrl.Call(m, "UpdateSecretVersionStageRequest", arg0)
	ret0, _ := ret[0].(*request.Request)
	ret1, _ := ret[1].(*secretsmanager.UpdateSecretVersionStageOutput)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UpdateSecretVersionStageRequest ( arg0 * secretsmanager . UpdateSecretVersionStageInput ) ( * request . Request , * secretsmanager . UpdateSecretVersionStageOutput ) { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( * request . Request ) ret1 , _ := ret [ 1 ] . ( * secretsmanager . UpdateSecretVersionStageOutput ) return ret0 , ret1 }

// UpdateSecretVersionStageRequest mocks base method


func (m *MockSecretsManagerAPI) UpdateSecretVersionStageWithContext(arg0 aws.Context, arg1 *secretsmanager.UpdateSecretVersionStageInput, arg2 ...request.Option) (*secretsmanager.UpdateSecretVersionStageOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "UpdateSecretVersionStageWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.UpdateSecretVersionStageOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UpdateSecretVersionStageWithContext ( arg0 aws . Context , arg1 * secretsmanager . UpdateSecretVersionStageInput , arg2 ... request . Option ) ( * secretsmanager . UpdateSecretVersionStageOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . UpdateSecretVersionStageOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// UpdateSecretVersionStageWithContext mocks base method


func (mr *MockSecretsManagerAPIMockRecorder) UpdateSecretVersionStageWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
	varargs := append([]interface{}{arg0, arg1}, arg2...)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSecretVersionStageWithContext", reflect.TypeOf((*MockSecretsManagerAPI)(nil).UpdateSecretVersionStageWithContext), varargs...)
}

func ( mr * MockSecretsManagerAPIMockRecorder ) UpdateSecretVersionStageWithContext ( arg0 , arg1 interface { } , arg2 ... interface { } ) * gomock . Call { varargs := append ( [ ] interface { } { arg0 , arg1 } , arg2 ... ) return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockSecretsManagerAPI ) ( nil ) . UpdateSecretVersionStageWithContext ) , varargs ... ) }

// UpdateSecretVersionStageWithContext indicates an expected call of UpdateSecretVersionStageWithContext


func (m *MockSecretsManagerAPI) UpdateSecretWithContext(arg0 aws.Context, arg1 *secretsmanager.UpdateSecretInput, arg2 ...request.Option) (*secretsmanager.UpdateSecretOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "UpdateSecretWithContext", varargs...)
	ret0, _ := ret[0].(*secretsmanager.UpdateSecretOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockSecretsManagerAPI ) UpdateSecretWithContext ( arg0 aws . Context , arg1 * secretsmanager . UpdateSecretInput , arg2 ... request . Option ) ( * secretsmanager . UpdateSecretOutput , error ) { varargs := [ ] interface { } { arg0 , arg1 } for _ , a := range arg2 { varargs = append ( varargs , a ) } ret := m . ctrl . Call ( m , " " , varargs ... ) ret0 , _ := ret [ 0 ] . ( * secretsmanager . UpdateSecretOutput ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }

// UpdateSecretWithContext mocks base method


func createBindsEnv(binds []string, env []string, dataDirOnHost string, metadataDirectoryPath string) ([]string, []string) {
	randID := uuid.New()
	instanceBind := fmt.Sprintf(`%s/%s:%s/%s`, dataDirOnHost, metadataDirectoryPath, mountPoint, randID)
	metadataEnvVariable := fmt.Sprintf("%s=%s/%s/%s", metadataEnvironmentVariable, mountPoint, randID, metadataFile)
	binds = append(binds, instanceBind)
	env = append(env, metadataEnvVariable)
	return binds, env
}

func createBindsEnv ( binds [ ] string , env [ ] string , dataDirOnHost string , metadataDirectoryPath string ) ( [ ] string , [ ] string ) { randID := uuid . New ( ) instanceBind := fmt . Sprintf ( `%s/%s:%s/%s` , dataDirOnHost , metadataDirectoryPath , mountPoint , randID ) metadataEnvVariable := fmt . Sprintf ( " " , metadataEnvironmentVariable , mountPoint , randID , metadataFile ) binds = append ( binds , instanceBind ) env = append ( env , metadataEnvVariable ) return binds , env }

// createBindsEnv will do the appropriate formatting to add a new mount in a container's HostConfig
// and add the metadata file path as an environment variable ECS_CONTAINER_METADATA_FILE
// We add an additional uuid to the path to ensure it does not conflict with user mounts

createBindsEnv will do the appropriate formatting to add a new mount in a container s HostConfig and add the metadata file path as an environment variable ECS_CONTAINER_METADATA_FILE We add an additional uuid to the path to ensure it does not conflict with user mounts


func (manager *metadataManager) parseMetadataAtContainerCreate(task *apitask.Task, containerName string) Metadata {
	return Metadata{
		cluster: manager.cluster,
		taskMetadata: TaskMetadata{
			containerName:          containerName,
			taskARN:                task.Arn,
			taskDefinitionFamily:   task.Family,
			taskDefinitionRevision: task.Version,
		},
		containerInstanceARN:  manager.containerInstanceARN,
		metadataStatus:        MetadataInitial,
		availabilityZone:      manager.availabilityZone,
		hostPublicIPv4Address: manager.hostPublicIPv4Address,
	}
}

func ( manager * metadataManager ) parseMetadataAtContainerCreate ( task * apitask . Task , containerName string ) Metadata { return Metadata { cluster : manager . cluster , taskMetadata : TaskMetadata { containerName : containerName , taskARN : task . Arn , taskDefinitionFamily : task . Family , taskDefinitionRevision : task . Version , } , containerInstanceARN : manager . containerInstanceARN , metadataStatus : MetadataInitial , availabilityZone : manager . availabilityZone , hostPublicIPv4Address : manager . hostPublicIPv4Address , } }

// parseMetadataAtContainerCreate gathers metadata from task and cluster configurations
// then packages it for JSON Marshaling. We use this version to get data
// available prior to container creation
// Since we accept incomplete metadata fields, we should not return
// errors here and handle them at this or the above stage.

parseMetadataAtContainerCreate gathers metadata from task and cluster configurations then packages it for JSON Marshaling . We use this version to get data available prior to container creation Since we accept incomplete metadata fields we should not return errors here and handle them at this or the above stage .


func (manager *metadataManager) parseMetadata(dockerContainer *types.ContainerJSON, task *apitask.Task, containerName string) Metadata {
	dockerMD := parseDockerContainerMetadata(task.Arn, containerName, dockerContainer)
	return Metadata{
		cluster: manager.cluster,
		taskMetadata: TaskMetadata{
			containerName:          containerName,
			taskARN:                task.Arn,
			taskDefinitionFamily:   task.Family,
			taskDefinitionRevision: task.Version,
		},
		dockerContainerMetadata: dockerMD,
		containerInstanceARN:    manager.containerInstanceARN,
		metadataStatus:          MetadataReady,
		availabilityZone:        manager.availabilityZone,
		hostPublicIPv4Address:   manager.hostPublicIPv4Address,
	}
}

func ( manager * metadataManager ) parseMetadata ( dockerContainer * types . ContainerJSON , task * apitask . Task , containerName string ) Metadata { dockerMD := parseDockerContainerMetadata ( task . Arn , containerName , dockerContainer ) return Metadata { cluster : manager . cluster , taskMetadata : TaskMetadata { containerName : containerName , taskARN : task . Arn , taskDefinitionFamily : task . Family , taskDefinitionRevision : task . Version , } , dockerContainerMetadata : dockerMD , containerInstanceARN : manager . containerInstanceARN , metadataStatus : MetadataReady , availabilityZone : manager . availabilityZone , hostPublicIPv4Address : manager . hostPublicIPv4Address , } }

// parseMetadata gathers metadata from a docker container, and task
// configuration and data then packages it for JSON Marshaling
// Since we accept incomplete metadata fields, we should not return
// errors here and handle them at this or the above stage.

parseMetadata gathers metadata from a docker container and task configuration and data then packages it for JSON Marshaling Since we accept incomplete metadata fields we should not return errors here and handle them at this or the above stage .


func parseDockerContainerMetadata(taskARN string, containerName string, dockerContainer *types.ContainerJSON) DockerContainerMetadata {
	if dockerContainer == nil {
		seelog.Warnf("Failed to parse container metadata for task %s container %s: container metadata not available or does not exist", taskARN, containerName)
		return DockerContainerMetadata{}
	}

	// In most cases a container should never lack a config but we check regardless to avoid
	// nil pointer exceptions (Could occur if there is some error in the docker api call, if the
	// container we receive has incomplete information)
	imageNameFromConfig := ""
	if dockerContainer.Config != nil {
		imageNameFromConfig = dockerContainer.Config.Image
	} else {
		seelog.Warnf("Failed to parse container metadata for task %s container %s: container has no configuration", taskARN, containerName)
	}

	if dockerContainer.ContainerJSONBase == nil {
		seelog.Warnf("Failed to parse container metadata for task %s container %s: container has no host configuration", taskARN, containerName)
		return DockerContainerMetadata{
			imageName: imageNameFromConfig,
		}
	}
	networkMetadata, err := parseNetworkMetadata(dockerContainer.NetworkSettings, dockerContainer.HostConfig)

	if err != nil {
		seelog.Warnf("Failed to parse container metadata for task %s container %s: %v", taskARN, containerName, err)
	}

	// Get Port bindings from NetworkSettings
	var ports []apicontainer.PortBinding
	ports, err = apicontainer.PortBindingFromDockerPortBinding(dockerContainer.NetworkSettings.Ports)
	if err != nil {
		seelog.Warnf("Failed to parse container metadata for task %s container %s: %v", taskARN, containerName, err)
	}

	return DockerContainerMetadata{
		containerID:         dockerContainer.ID,
		dockerContainerName: dockerContainer.Name,
		imageID:             dockerContainer.Image,
		imageName:           imageNameFromConfig,
		ports:               ports,
		networkInfo:         networkMetadata,
	}
}

// parseDockerContainerMetadata parses the metadata in a docker container
// and packages this data for JSON marshaling
// Since we accept incomplete metadata fields, we should not return
// errors here and handle them at this stage.

parseDockerContainerMetadata parses the metadata in a docker container and packages this data for JSON marshaling Since we accept incomplete metadata fields we should not return errors here and handle them at this stage .


func parseNetworkMetadata(settings *types.NetworkSettings, hostConfig *dockercontainer.HostConfig) (NetworkMetadata, error) {
	// Network settings and Host configuration should not be missing except due to errors
	if settings == nil {
		err := fmt.Errorf("parse network metadata: could not find network settings")
		return NetworkMetadata{}, err
	}

	if hostConfig == nil {
		err := fmt.Errorf("parse network metadata: could not find host configuration")
		return NetworkMetadata{}, err
	}

	// This metadata is the information provided in older versions of the API
	// We get the NetworkMode (Network interface name) from the HostConfig because this
	// this is the network with which the container is created
	ipv4AddressFromSettings := settings.IPAddress
	networkModeFromHostConfig := string(hostConfig.NetworkMode)

	// Extensive Network information is not available for Docker API versions 1.17-1.20
	// Instead we only get the details of the first network
	networkList := make([]Network, 0)
	if len(settings.Networks) > 0 {
		for modeFromSettings, containerNetwork := range settings.Networks {
			networkMode := modeFromSettings
			ipv4Addresses := []string{containerNetwork.IPAddress}
			network := Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses}
			networkList = append(networkList, network)
		}
	} else {
		ipv4Addresses := []string{ipv4AddressFromSettings}
		network := Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses}
		networkList = append(networkList, network)
	}

	return NetworkMetadata{
		networks: networkList,
	}, nil
}

// parseNetworkMetadata parses the docker.NetworkSettings struct and
// packages the desired metadata for JSON marshaling
// Since we accept incomplete metadata fields, we should not return
// errors here and handle them at this stage.

parseNetworkMetadata parses the docker . NetworkSettings struct and packages the desired metadata for JSON marshaling Since we accept incomplete metadata fields we should not return errors here and handle them at this stage .


func (n *NvidiaGPUManager) Initialize() error {
	if GPUInfoFileExists() {
		// GPU info file found
		gpuJSON, err := GetGPUInfoJSON()
		if err != nil {
			return errors.Wrapf(err, "could not read GPU file content")
		}
		var nvidiaGPUInfo NvidiaGPUManager
		err = json.Unmarshal(gpuJSON, &nvidiaGPUInfo)
		if err != nil {
			return errors.Wrapf(err, "could not unmarshal GPU file content")
		}
		n.SetDriverVersion(nvidiaGPUInfo.GetDriverVersion())
		nvidiaGPUInfo.lock.RLock()
		gpuIDs := nvidiaGPUInfo.GetGPUIDsUnsafe()
		nvidiaGPUInfo.lock.RUnlock()
		n.SetGPUIDs(gpuIDs)
		n.SetDevices()
	} else {
		seelog.Error("Config for GPU support is enabled, but GPU information is not found; continuing without it")
	}
	return nil
}

func
(
n
*
NvidiaGPUManager
)
Initialize
(
)
error
{
if
GPUInfoFileExists
(
)
{
// GPU info file found
gpuJSON
,
err
:=
GetGPUInfoJSON
(
)
if
err
!=
{
return
errors
.
Wrapf
(
err
,
"
"
)
}
var
nvidiaGPUInfo
NvidiaGPUManager
err
=
json
.
Unmarshal
(
gpuJSON
,
&
nvidiaGPUInfo
)
if
err
!=
{
return
errors
.
Wrapf
(
err
,
"
"
)
}
n
.
SetDriverVersion
(
nvidiaGPUInfo
.
GetDriverVersion
(
)
)
nvidiaGPUInfo
.
lock
.
RLock
(
)
gpuIDs
:=
nvidiaGPUInfo
.
GetGPUIDsUnsafe
(
)
nvidiaGPUInfo
.
lock
.
RUnlock
(
)
n
.
SetGPUIDs
(
gpuIDs
)
n
.
SetDevices
(
)
}
else
{
seelog
.
Error
(
"
"
)
}
return
}

// Initialize sets the fields of Nvidia GPU Manager struct


func (n *NvidiaGPUManager) SetGPUIDs(gpuIDs []string) {
	n.lock.Lock()
	defer n.lock.Unlock()
	n.GPUIDs = gpuIDs
}

func ( n * NvidiaGPUManager ) SetGPUIDs ( gpuIDs [ ] string ) { n . lock . Lock ( ) defer n . lock . Unlock ( ) n . GPUIDs = gpuIDs }


func (n *NvidiaGPUManager) SetDriverVersion(version string) {
	n.lock.Lock()
	defer n.lock.Unlock()
	n.DriverVersion = version
}

func ( n * NvidiaGPUManager ) SetDriverVersion ( version string ) { n . lock . Lock ( ) defer n . lock . Unlock ( ) n . DriverVersion = version }

// SetDriverVersion is a setter for nvidia driver version


func (n *NvidiaGPUManager) GetDriverVersion() string {
	n.lock.RLock()
	defer n.lock.RUnlock()
	return n.DriverVersion
}

func ( n * NvidiaGPUManager ) GetDriverVersion ( ) string { n . lock . RLock ( ) defer n . lock . RUnlock ( ) return n . DriverVersion }

// GetDriverVersion is a getter for nvidia driver version


func (n *NvidiaGPUManager) GetDevices() []*ecs.PlatformDevice {
	n.lock.RLock()
	defer n.lock.RUnlock()
	return n.GPUDevices
}

func ( n * NvidiaGPUManager ) GetDevices ( ) [ ] * ecs . PlatformDevice { n . lock . RLock ( ) defer n . lock . RUnlock ( ) return n . GPUDevices }

// GetDevices returns the GPU devices as PlatformDevices


func NewMockLicenseProvider(ctrl *gomock.Controller) *MockLicenseProvider {
	mock := &MockLicenseProvider{ctrl: ctrl}
	mock.recorder = &MockLicenseProviderMockRecorder{mock}
	return mock
}

func NewMockLicenseProvider ( ctrl * gomock . Controller ) * MockLicenseProvider { mock := & MockLicenseProvider { ctrl : ctrl } mock . recorder = & MockLicenseProviderMockRecorder { mock } return mock }

// NewMockLicenseProvider creates a new mock instance


func (m *MockLicenseProvider) GetText() (string, error) {
	ret := m.ctrl.Call(m, "GetText")
	ret0, _ := ret[0].(string)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockLicenseProvider ) GetText ( ) ( string , error ) { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( string ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (mr *MockLicenseProviderMockRecorder) GetText() *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetText", reflect.TypeOf((*MockLicenseProvider)(nil).GetText))
}

func ( mr * MockLicenseProviderMockRecorder ) GetText ( ) * gomock . Call { return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockLicenseProvider ) ( nil ) . GetText ) ) }

// GetText indicates an expected call of GetText


func NewMockBackoff(ctrl *gomock.Controller) *MockBackoff {
	mock := &MockBackoff{ctrl: ctrl}
	mock.recorder = &MockBackoffMockRecorder{mock}
	return mock
}

func NewMockBackoff ( ctrl * gomock . Controller ) * MockBackoff { mock := & MockBackoff { ctrl : ctrl } mock . recorder = & MockBackoffMockRecorder { mock } return mock }

// NewMockBackoff creates a new mock instance


func (m *MockBackoff) Duration() time.Duration {
	ret := m.ctrl.Call(m, "Duration")
	ret0, _ := ret[0].(time.Duration)
	return ret0
}

func ( m * MockBackoff ) Duration ( ) time . Duration { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( time . Duration ) return ret0 }


func (mr *MockBackoffMockRecorder) Duration() *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Duration", reflect.TypeOf((*MockBackoff)(nil).Duration))
}

func ( mr * MockBackoffMockRecorder ) Duration ( ) * gomock . Call { return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockBackoff ) ( nil ) . Duration ) ) }

// Duration indicates an expected call of Duration


func (status *MetadataStatus) UnmarshalText(text []byte) error {
	t := string(text)
	switch t {
	case MetadataInitialText:
		*status = MetadataInitial
	case MetadataReadyText:
		*status = MetadataReady
	default:
		return fmt.Errorf("failed unmarshalling MetadataStatus %s", text)
	}
	return nil
}

func ( status * MetadataStatus ) UnmarshalText ( text [ ] byte ) error { t := string ( text ) switch t { case MetadataInitialText : * status = MetadataInitial case MetadataReadyText : * status = MetadataReady default : return fmt . Errorf ( " " , text ) } return nil }

// Allows unmarshaling from byte to MetadataStatus text form


func (*DefaultTime) After(d time.Duration) <-chan time.Time {
	return time.After(d)
}

func ( * DefaultTime ) After ( d time . Duration ) <- chan time . Time { return time . After ( d ) }

// After sleeps for the given duration and then writes to to the returned channel


func (*DefaultTime) AfterFunc(d time.Duration, f func()) Timer {
	return time.AfterFunc(d, f)
}

func ( * DefaultTime ) AfterFunc ( d time . Duration , f func ( ) ) Timer { return time . AfterFunc ( d , f ) }

// AfterFunc waits for the duration to elapse and then calls f in its own
// goroutine. It returns a Timer that can be used to cancel the call using its
// Stop method.

AfterFunc waits for the duration to elapse and then calls f in its own goroutine . It returns a Timer that can be used to cancel the call using its Stop method .


func Since(t time.Time) time.Duration {
	return _time.Now().Sub(t)
}

func Since ( t time . Time ) time . Duration { return _time . Now ( ) . Sub ( t ) }

// Since returns the time different from Now and the given time t


func NewMockTaskResource(ctrl *gomock.Controller) *MockTaskResource {
	mock := &MockTaskResource{ctrl: ctrl}
	mock.recorder = &MockTaskResourceMockRecorder{mock}
	return mock
}

func NewMockTaskResource ( ctrl * gomock . Controller ) * MockTaskResource { mock := & MockTaskResource { ctrl : ctrl } mock . recorder = & MockTaskResourceMockRecorder { mock } return mock }

// NewMockTaskResource creates a new mock instance


func (m *MockTaskResource) ApplyTransition(arg0 status0.ResourceStatus) error {
	ret := m.ctrl.Call(m, "ApplyTransition", arg0)
	ret0, _ := ret[0].(error)
	return ret0
}

func ( m * MockTaskResource ) ApplyTransition ( arg0 status0 . ResourceStatus ) error { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( error ) return ret0 }


func (m *MockTaskResource) Cleanup() error {
	ret := m.ctrl.Call(m, "Cleanup")
	ret0, _ := ret[0].(error)
	return ret0
}

func ( m * MockTaskResource ) Cleanup ( ) error { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( error ) return ret0 }


func (m *MockTaskResource) GetCreatedAt() time.Time {
	ret := m.ctrl.Call(m, "GetCreatedAt")
	ret0, _ := ret[0].(time.Time)
	return ret0
}

func ( m * MockTaskResource ) GetCreatedAt ( ) time . Time { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( time . Time ) return ret0 }


func (m *MockTaskResource) GetTerminalReason() string {
	ret := m.ctrl.Call(m, "GetTerminalReason")
	ret0, _ := ret[0].(string)
	return ret0
}

func ( m * MockTaskResource ) GetTerminalReason ( ) string { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( string ) return ret0 }


func (mr *MockTaskResourceMockRecorder) Initialize(arg0, arg1, arg2 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Initialize", reflect.TypeOf((*MockTaskResource)(nil).Initialize), arg0, arg1, arg2)
}

func ( mr * MockTaskResourceMockRecorder ) Initialize ( arg0 , arg1 , arg2 interface { } ) * gomock . Call { return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockTaskResource ) ( nil ) . Initialize ) , arg0 , arg1 , arg2 ) }

// Initialize indicates an expected call of Initialize


func (m *MockTaskResource) KnownCreated() bool {
	ret := m.ctrl.Call(m, "KnownCreated")
	ret0, _ := ret[0].(bool)
	return ret0
}

func ( m * MockTaskResource ) KnownCreated ( ) bool { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( bool ) return ret0 }


func (mr *MockTaskResourceMockRecorder) MarshalJSON() *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarshalJSON", reflect.TypeOf((*MockTaskResource)(nil).MarshalJSON))
}

func ( mr * MockTaskResourceMockRecorder ) MarshalJSON ( ) * gomock . Call { return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockTaskResource ) ( nil ) . MarshalJSON ) ) }

// MarshalJSON indicates an expected call of MarshalJSON


func (m *MockTaskResource) NextKnownState() status0.ResourceStatus {
	ret := m.ctrl.Call(m, "NextKnownState")
	ret0, _ := ret[0].(status0.ResourceStatus)
	return ret0
}

func ( m * MockTaskResource ) NextKnownState ( ) status0 . ResourceStatus { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( status0 . ResourceStatus ) return ret0 }


func (m *MockTaskResource) SetAppliedStatus(arg0 status0.ResourceStatus) bool {
	ret := m.ctrl.Call(m, "SetAppliedStatus", arg0)
	ret0, _ := ret[0].(bool)
	return ret0
}

func ( m * MockTaskResource ) SetAppliedStatus ( arg0 status0 . ResourceStatus ) bool { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( bool ) return ret0 }


func (mr *MockTaskResourceMockRecorder) SetAppliedStatus(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAppliedStatus", reflect.TypeOf((*MockTaskResource)(nil).SetAppliedStatus), arg0)
}

func ( mr * MockTaskResourceMockRecorder ) SetAppliedStatus ( arg0 interface { } ) * gomock . Call { return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockTaskResource ) ( nil ) . SetAppliedStatus ) , arg0 ) }

// SetAppliedStatus indicates an expected call of SetAppliedStatus


func (m *MockTaskResource) SetCreatedAt(arg0 time.Time) {
	m.ctrl.Call(m, "SetCreatedAt", arg0)
}

func ( m * MockTaskResource ) SetCreatedAt ( arg0 time . Time ) { m . ctrl . Call ( m , " " , arg0 ) }


func (m *MockTaskResource) SetDesiredStatus(arg0 status0.ResourceStatus) {
	m.ctrl.Call(m, "SetDesiredStatus", arg0)
}

func ( m * MockTaskResource ) SetDesiredStatus ( arg0 status0 . ResourceStatus ) { m . ctrl . Call ( m , " " , arg0 ) }


func (m *MockTaskResource) SetKnownStatus(arg0 status0.ResourceStatus) {
	m.ctrl.Call(m, "SetKnownStatus", arg0)
}

func ( m * MockTaskResource ) SetKnownStatus ( arg0 status0 . ResourceStatus ) { m . ctrl . Call ( m , " " , arg0 ) }


func (m *MockTaskResource) StatusString(arg0 status0.ResourceStatus) string {
	ret := m.ctrl.Call(m, "StatusString", arg0)
	ret0, _ := ret[0].(string)
	return ret0
}

func ( m * MockTaskResource ) StatusString ( arg0 status0 . ResourceStatus ) string { ret := m . ctrl . Call ( m , " " , arg0 ) ret0 , _ := ret [ 0 ] . ( string ) return ret0 }


func NewMockLoader(ctrl *gomock.Controller) *MockLoader {
	mock := &MockLoader{ctrl: ctrl}
	mock.recorder = &MockLoaderMockRecorder{mock}
	return mock
}

func NewMockLoader ( ctrl * gomock . Controller ) * MockLoader { mock := & MockLoader { ctrl : ctrl } mock . recorder = & MockLoaderMockRecorder { mock } return mock }

// NewMockLoader creates a new mock instance


func (mr *MockLoaderMockRecorder) LoadImage(arg0, arg1, arg2 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadImage", reflect.TypeOf((*MockLoader)(nil).LoadImage), arg0, arg1, arg2)
}

func ( mr * MockLoaderMockRecorder ) LoadImage ( arg0 , arg1 , arg2 interface { } ) * gomock . Call { return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockLoader ) ( nil ) . LoadImage ) , arg0 , arg1 , arg2 ) }

// LoadImage indicates an expected call of LoadImage


func (cnferror ContainerNotFound) Error() string {
	return fmt.Sprintf("Could not find container '%s' in task '%s'",
		cnferror.ContainerName, cnferror.TaskArn)
}

func ( cnferror ContainerNotFound ) Error ( ) string { return fmt . Sprintf ( " " , cnferror . ContainerName , cnferror . TaskArn ) }

// Error returns an error string for the ContainerNotFound error


func (event *DockerContainerChangeEvent) String() string {
	res := fmt.Sprintf("Status: %s, DockerID: %s", event.Status.String(), event.DockerID)
	res += ", health: " + event.Health.Status.String()

	if event.ExitCode != nil {
		res += fmt.Sprintf(", ExitCode: %d", aws.IntValue(event.ExitCode))
	}

	if len(event.PortBindings) != 0 {
		res += fmt.Sprintf(", PortBindings: %v", event.PortBindings)
	}

	if event.Error != nil {
		res += ", Error: " + event.Error.Error()
	}

	if len(event.Volumes) != 0 {
		res += fmt.Sprintf(", Volumes: %v", event.Volumes)
	}

	if len(event.Labels) != 0 {
		res += fmt.Sprintf(", Labels: %v", event.Labels)
	}

	if !event.CreatedAt.IsZero() {
		res += ", CreatedAt: " + event.CreatedAt.String()
	}
	if !event.StartedAt.IsZero() {
		res += ", StartedAt: " + event.StartedAt.String()
	}
	if !event.FinishedAt.IsZero() {
		res += ", FinishedAt: " + event.FinishedAt.String()
	}

	return res
}

func ( event * DockerContainerChangeEvent ) String ( ) string { res := fmt . Sprintf ( " " , event . Status . String ( ) , event . DockerID ) res += " " + event . Health . Status . String ( ) if event . ExitCode != nil { res += fmt . Sprintf ( " " , aws . IntValue ( event . ExitCode ) ) } if len ( event . PortBindings ) != 0 { res += fmt . Sprintf ( " " , event . PortBindings ) } if event . Error != nil { res += " " + event . Error . Error ( ) } if len ( event . Volumes ) != 0 { res += fmt . Sprintf ( " " , event . Volumes ) } if len ( event . Labels ) != 0 { res += fmt . Sprintf ( " " , event . Labels ) } if ! event . CreatedAt . IsZero ( ) { res += " " + event . CreatedAt . String ( ) } if ! event . StartedAt . IsZero ( ) { res += " " + event . StartedAt . String ( ) } if ! event . FinishedAt . IsZero ( ) { res += " " + event . FinishedAt . String ( ) } return res }

// String returns a human readable string of the container change event


func (tv *TaskVolume) UnmarshalJSON(b []byte) error {
	// Format: {name: volumeName, host: HostVolume, dockerVolumeConfiguration {}}
	intermediate := make(map[string]json.RawMessage)
	if err := json.Unmarshal(b, &intermediate); err != nil {
		return err
	}
	name, ok := intermediate["name"]
	if !ok {
		return errors.New("invalid Volume; must include a name")
	}
	if err := json.Unmarshal(name, &tv.Name); err != nil {
		return err
	}

	volumeType, ok := intermediate["type"]
	if !ok {
		volumeType = []byte(`"host"`)
		seelog.Infof("Unmarshal task volume: volume type not specified, default to host")
	}
	if err := json.Unmarshal(volumeType, &tv.Type); err != nil {
		return err
	}

	switch tv.Type {
	case HostVolumeType:
		return tv.unmarshalHostVolume(intermediate["host"])
	case DockerVolumeType:
		return tv.unmarshalDockerVolume(intermediate["dockerVolumeConfiguration"])
	default:
		return errors.Errorf("invalid Volume: type must be docker or host, got %q", tv.Type)
	}
}

// UnmarshalJSON for TaskVolume determines the name and volume type, and
// unmarshals it into the appropriate HostVolume fulfilling interfaces

UnmarshalJSON for TaskVolume determines the name and volume type and unmarshals it into the appropriate HostVolume fulfilling interfaces


func (tv *TaskVolume) MarshalJSON() ([]byte, error) {
	result := make(map[string]interface{})

	if len(tv.Type) == 0 {
		tv.Type = HostVolumeType
	}

	result["name"] = tv.Name
	result["type"] = tv.Type

	switch tv.Type {
	case DockerVolumeType:
		result["dockerVolumeConfiguration"] = tv.Volume
	case HostVolumeType:
		result["host"] = tv.Volume
	default:
		return nil, errors.Errorf("unrecognized volume type: %q", tv.Type)
	}

	return json.Marshal(result)
}

func ( tv * TaskVolume ) MarshalJSON ( ) ( [ ] byte , error ) { result := make ( map [ string ] interface { } ) if len ( tv . Type ) == 0 { tv . Type = HostVolumeType } result [ " " ] = tv . Name result [ " " ] = tv . Type switch tv . Type { case DockerVolumeType : result [ " " ] = tv . Volume case HostVolumeType : result [ " " ] = tv . Volume default : return nil , errors . Errorf ( " " , tv . Type ) } return json . Marshal ( result ) }

// MarshalJSON overrides the logic for JSON-encoding a  TaskVolume object

MarshalJSON overrides the logic for JSON - encoding a TaskVolume object


func (*ssmClientCreator) NewSSMClient(region string,
	creds credentials.IAMRoleCredentials) ssmclient.SSMClient {
	cfg := aws.NewConfig().
		WithHTTPClient(httpclient.New(roundtripTimeout, false)).
		WithRegion(region).
		WithCredentials(
			awscreds.NewStaticCredentials(creds.AccessKeyID, creds.SecretAccessKey,
				creds.SessionToken))
	sess := session.Must(session.NewSession(cfg))
	return ssm.New(sess)
}

func ( * ssmClientCreator ) NewSSMClient ( region string , creds credentials . IAMRoleCredentials ) ssmclient . SSMClient { cfg := aws . NewConfig ( ) . WithHTTPClient ( httpclient . New ( roundtripTimeout , false ) ) . WithRegion ( region ) . WithCredentials ( awscreds . NewStaticCredentials ( creds . AccessKeyID , creds . SecretAccessKey , creds . SessionToken ) ) sess := session . Must ( session . NewSession ( cfg ) ) return ssm . New ( sess ) }

//SSM Client will automatically retry 3 times when has throttling error


func (f *factory) GetClient(version dockerclient.DockerVersion) (sdkclient.Client, error) {
	for _, v := range getWindowsReplaceableVersions() {
		if v == version {
			version = minDockerAPIVersion
			break
		}
	}
	return f.getClient(version)
}

func ( f * factory ) GetClient ( version dockerclient . DockerVersion ) ( sdkclient . Client , error ) { for _ , v := range getWindowsReplaceableVersions ( ) { if v == version { version = minDockerAPIVersion break } } return f . getClient ( version ) }

// GetClient will replace some versions of Docker on Windows. We need this because
// agent assumes that it can always call older versions of the docker API.

GetClient will replace some versions of Docker on Windows . We need this because agent assumes that it can always call older versions of the docker API .


func getWindowsReplaceableVersions() []dockerclient.DockerVersion {
	return []dockerclient.DockerVersion{
		dockerclient.Version_1_17,
		dockerclient.Version_1_18,
		dockerclient.Version_1_19,
		dockerclient.Version_1_20,
		dockerclient.Version_1_21,
		dockerclient.Version_1_22,
		dockerclient.Version_1_23,
	}
}

func getWindowsReplaceableVersions ( ) [ ] dockerclient . DockerVersion { return [ ] dockerclient . DockerVersion { dockerclient . Version_1_17 , dockerclient . Version_1_18 , dockerclient . Version_1_19 , dockerclient . Version_1_20 , dockerclient . Version_1_21 , dockerclient . Version_1_22 , dockerclient . Version_1_23 , } }

// getWindowsReplaceableVersions returns the set of versions that agent will report
// as Docker 1.24

getWindowsReplaceableVersions returns the set of versions that agent will report as Docker 1 . 24


func getWindowsSupportedVersions() []dockerclient.DockerVersion {
	return []dockerclient.DockerVersion{
		dockerclient.Version_1_24,
		dockerclient.Version_1_25,
		dockerclient.Version_1_26,
		dockerclient.Version_1_27,
		dockerclient.Version_1_28,
		dockerclient.Version_1_29,
		dockerclient.Version_1_30,
	}
}

func getWindowsSupportedVersions ( ) [ ] dockerclient . DockerVersion { return [ ] dockerclient . DockerVersion { dockerclient . Version_1_24 , dockerclient . Version_1_25 , dockerclient . Version_1_26 , dockerclient . Version_1_27 , dockerclient . Version_1_28 , dockerclient . Version_1_29 , dockerclient . Version_1_30 , } }

// getWindowsSupportedVersions returns the set of remote api versions that are
// supported by agent in windows

getWindowsSupportedVersions returns the set of remote api versions that are supported by agent in windows


func PortBindingFromDockerPortBinding(dockerPortBindings nat.PortMap) ([]PortBinding, apierrors.NamedError) {
	portBindings := make([]PortBinding, 0, len(dockerPortBindings))

	for port, bindings := range dockerPortBindings {
		containerPort, err := nat.ParsePort(port.Port())
		if err != nil {
			return nil, &apierrors.DefaultNamedError{Name: UnparseablePortErrorName, Err: "Error parsing docker port as int " + err.Error()}
		}
		protocol, err := NewTransportProtocol(port.Proto())
		if err != nil {
			return nil, &apierrors.DefaultNamedError{Name: UnrecognizedTransportProtocolErrorName, Err: err.Error()}
		}

		for _, binding := range bindings {
			hostPort, err := strconv.Atoi(binding.HostPort)
			if err != nil {
				return nil, &apierrors.DefaultNamedError{Name: UnparseablePortErrorName, Err: "Error parsing port binding as int " + err.Error()}
			}
			portBindings = append(portBindings, PortBinding{
				ContainerPort: uint16(containerPort),
				HostPort:      uint16(hostPort),
				BindIP:        binding.HostIP,
				Protocol:      protocol,
			})
		}
	}
	return portBindings, nil
}

func PortBindingFromDockerPortBinding ( dockerPortBindings nat . PortMap ) ( [ ] PortBinding , apierrors . NamedError ) { portBindings := make ( [ ] PortBinding , 0 , len ( dockerPortBindings ) ) for port , bindings := range dockerPortBindings { containerPort , err := nat . ParsePort ( port . Port ( ) ) if err != nil { return nil , & apierrors . DefaultNamedError { Name : UnparseablePortErrorName , Err : " " + err . Error ( ) } } protocol , err := NewTransportProtocol ( port . Proto ( ) ) if err != nil { return nil , & apierrors . DefaultNamedError { Name : UnrecognizedTransportProtocolErrorName , Err : err . Error ( ) } } for _ , binding := range bindings { hostPort , err := strconv . Atoi ( binding . HostPort ) if err != nil { return nil , & apierrors . DefaultNamedError { Name : UnparseablePortErrorName , Err : " " + err . Error ( ) } } portBindings = append ( portBindings , PortBinding { ContainerPort : uint16 ( containerPort ) , HostPort : uint16 ( hostPort ) , BindIP : binding . HostIP , Protocol : protocol , } ) } } return portBindings , nil }

// PortBindingFromDockerPortBinding constructs a PortBinding slice from a docker
// NetworkSettings.Ports map.

PortBindingFromDockerPortBinding constructs a PortBinding slice from a docker NetworkSettings . Ports map .


func NewASMAuthResource(taskARN string,
	asmRequirements []*apicontainer.ASMAuthData,
	executionCredentialsID string,
	credentialsManager credentials.Manager,
	asmClientCreator factory.ClientCreator) *ASMAuthResource {

	c := &ASMAuthResource{
		taskARN:                taskARN,
		requiredASMResources:   asmRequirements,
		credentialsManager:     credentialsManager,
		executionCredentialsID: executionCredentialsID,
		asmClientCreator:       asmClientCreator,
	}

	c.initStatusToTransition()
	return c
}

func NewASMAuthResource ( taskARN string , asmRequirements [ ] * apicontainer . ASMAuthData , executionCredentialsID string , credentialsManager credentials . Manager , asmClientCreator factory . ClientCreator ) * ASMAuthResource { c := & ASMAuthResource { taskARN : taskARN , requiredASMResources : asmRequirements , credentialsManager : credentialsManager , executionCredentialsID : executionCredentialsID , asmClientCreator : asmClientCreator , } c . initStatusToTransition ( ) return c }

// NewASMAuthResource creates a new ASMAuthResource object


func (auth *ASMAuthResource) Create() error {
	seelog.Infof("ASM Auth: Retrieving credentials for containers in task: [%s]", auth.taskARN)
	if auth.dockerAuthData == nil {
		auth.dockerAuthData = make(map[string]types.AuthConfig)
	}
	for _, a := range auth.GetRequiredASMResources() {
		err := auth.retrieveASMDockerAuthData(a)
		if err != nil {
			auth.setTerminalReason(err.Error())
			return err
		}
	}

	return nil
}

func ( auth * ASMAuthResource ) Create ( ) error { seelog . Infof ( " " , auth . taskARN ) if auth . dockerAuthData == nil { auth . dockerAuthData = make ( map [ string ] types . AuthConfig ) } for _ , a := range auth . GetRequiredASMResources ( ) { err := auth . retrieveASMDockerAuthData ( a ) if err != nil { auth . setTerminalReason ( err . Error ( ) ) return err } } return nil }


func (auth *ASMAuthResource) GetRequiredASMResources() []*apicontainer.ASMAuthData {
	auth.lock.RLock()
	defer auth.lock.RUnlock()

	return auth.requiredASMResources
}

func ( auth * ASMAuthResource ) GetRequiredASMResources ( ) [ ] * apicontainer . ASMAuthData { auth . lock . RLock ( ) defer auth . lock . RUnlock ( ) return auth . requiredASMResources }

// GetRequiredASMResources returns the list of ASMAuthData that has to be
// retrieved from AWS Secrets Manager

GetRequiredASMResources returns the list of ASMAuthData that has to be retrieved from AWS Secrets Manager


func (auth *ASMAuthResource) GetExecutionCredentialsID() string {
	auth.lock.RLock()
	defer auth.lock.RUnlock()

	return auth.executionCredentialsID
}

func ( auth * ASMAuthResource ) GetExecutionCredentialsID ( ) string { auth . lock . RLock ( ) defer auth . lock . RUnlock ( ) return auth . executionCredentialsID }

// GetExecutionCredentialsID returns the execution role's credential ID

GetExecutionCredentialsID returns the execution role s credential ID


func (auth *ASMAuthResource) clearASMDockerAuthConfig() {
	auth.lock.Lock()
	defer auth.lock.Unlock()

	for k := range auth.dockerAuthData {
		delete(auth.dockerAuthData, k)
	}
}

func ( auth * ASMAuthResource ) clearASMDockerAuthConfig ( ) { auth . lock . Lock ( ) defer auth . lock . Unlock ( ) for k := range auth . dockerAuthData { delete ( auth . dockerAuthData , k ) } }

// clearASMDockerAuthConfig cycles through the collection of docker private
// registry auth data and removes them from the task

clearASMDockerAuthConfig cycles through the collection of docker private registry auth data and removes them from the task


func (auth *ASMAuthResource) GetASMDockerAuthConfig(secretID string) (types.AuthConfig, bool) {
	auth.lock.RLock()
	defer auth.lock.RUnlock()

	d, ok := auth.dockerAuthData[secretID]
	return d, ok
}

func ( auth * ASMAuthResource ) GetASMDockerAuthConfig ( secretID string ) ( types . AuthConfig , bool ) { auth . lock . RLock ( ) defer auth . lock . RUnlock ( ) d , ok := auth . dockerAuthData [ secretID ] return d , ok }

// GetASMDockerAuthConfig retrieves the docker private registry auth data from
// the task

GetASMDockerAuthConfig retrieves the docker private registry auth data from the task


func (auth *ASMAuthResource) MarshalJSON() ([]byte, error) {
	if auth == nil {
		return nil, errors.New("asm-auth resource is nil")
	}
	createdAt := auth.GetCreatedAt()
	return json.Marshal(asmAuthResourceJSON{
		TaskARN:   auth.taskARN,
		CreatedAt: &createdAt,
		DesiredStatus: func() *ASMAuthStatus {
			desiredState := auth.GetDesiredStatus()
			status := ASMAuthStatus(desiredState)
			return &status
		}(),
		KnownStatus: func() *ASMAuthStatus {
			knownState := auth.GetKnownStatus()
			status := ASMAuthStatus(knownState)
			return &status
		}(),
		RequiredASMResources:   auth.GetRequiredASMResources(),
		ExecutionCredentialsID: auth.GetExecutionCredentialsID(),
	})
}

func ( auth * ASMAuthResource ) MarshalJSON ( ) ( [ ] byte , error ) { if auth == nil { return nil , errors . New ( " " ) } createdAt := auth . GetCreatedAt ( ) return json . Marshal ( asmAuthResourceJSON { TaskARN : auth . taskARN , CreatedAt : & createdAt , DesiredStatus : func ( ) * ASMAuthStatus { desiredState := auth . GetDesiredStatus ( ) status := ASMAuthStatus ( desiredState ) return & status } ( ) , KnownStatus : func ( ) * ASMAuthStatus { knownState := auth . GetKnownStatus ( ) status := ASMAuthStatus ( knownState ) return & status } ( ) , RequiredASMResources : auth . GetRequiredASMResources ( ) , ExecutionCredentialsID : auth . GetExecutionCredentialsID ( ) , } ) }

// MarshalJSON serialises the ASMAuthResource struct to JSON


func (auth *ASMAuthResource) UnmarshalJSON(b []byte) error {
	temp := asmAuthResourceJSON{}

	if err := json.Unmarshal(b, &temp); err != nil {
		return err
	}

	if temp.DesiredStatus != nil {
		auth.SetDesiredStatus(resourcestatus.ResourceStatus(*temp.DesiredStatus))
	}
	if temp.KnownStatus != nil {
		auth.SetKnownStatus(resourcestatus.ResourceStatus(*temp.KnownStatus))
	}
	if temp.CreatedAt != nil && !temp.CreatedAt.IsZero() {
		auth.SetCreatedAt(*temp.CreatedAt)
	}
	if temp.RequiredASMResources != nil {
		auth.requiredASMResources = temp.RequiredASMResources
	}
	auth.taskARN = temp.TaskARN
	auth.executionCredentialsID = temp.ExecutionCredentialsID

	return nil
}

func ( auth * ASMAuthResource ) UnmarshalJSON ( b [ ] byte ) error { temp := asmAuthResourceJSON { } if err := json . Unmarshal ( b , & temp ) ; err != nil { return err } if temp . DesiredStatus != nil { auth . SetDesiredStatus ( resourcestatus . ResourceStatus ( * temp . DesiredStatus ) ) } if temp . KnownStatus != nil { auth . SetKnownStatus ( resourcestatus . ResourceStatus ( * temp . KnownStatus ) ) } if temp . CreatedAt != nil && ! temp . CreatedAt . IsZero ( ) { auth . SetCreatedAt ( * temp . CreatedAt ) } if temp . RequiredASMResources != nil { auth . requiredASMResources = temp . RequiredASMResources } auth . taskARN = temp . TaskARN auth . executionCredentialsID = temp . ExecutionCredentialsID return nil }

// UnmarshalJSON deserialises the raw JSON to a ASMAuthResource struct


func ContainerMetadataHandler(state dockerstate.TaskEngineState) func(http.ResponseWriter, *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		containerID, err := getContainerIDByRequest(r, state)
		if err != nil {
			responseJSON, _ := json.Marshal(
				fmt.Sprintf("V3 container metadata handler: unable to get container ID from request: %s", err.Error()))
			utils.WriteJSONToResponse(w, http.StatusBadRequest, responseJSON, utils.RequestTypeContainerMetadata)
			return
		}
		containerResponse, err := GetContainerResponse(containerID, state)
		if err != nil {
			errResponseJSON, _ := json.Marshal(err.Error())
			utils.WriteJSONToResponse(w, http.StatusBadRequest, errResponseJSON, utils.RequestTypeContainerMetadata)
			return
		}
		seelog.Infof("V3 container metadata handler: writing response for container '%s'", containerID)

		responseJSON, _ := json.Marshal(containerResponse)
		utils.WriteJSONToResponse(w, http.StatusOK, responseJSON, utils.RequestTypeContainerMetadata)
	}
}

func ContainerMetadataHandler ( state dockerstate . TaskEngineState ) func ( http . ResponseWriter , * http . Request ) { return func ( w http . ResponseWriter , r * http . Request ) { containerID , err := getContainerIDByRequest ( r , state ) if err != nil { responseJSON , _ := json . Marshal ( fmt . Sprintf ( " " , err . Error ( ) ) ) utils . WriteJSONToResponse ( w , http . StatusBadRequest , responseJSON , utils . RequestTypeContainerMetadata ) return } containerResponse , err := GetContainerResponse ( containerID , state ) if err != nil { errResponseJSON , _ := json . Marshal ( err . Error ( ) ) utils . WriteJSONToResponse ( w , http . StatusBadRequest , errResponseJSON , utils . RequestTypeContainerMetadata ) return } seelog . Infof ( " " , containerID ) responseJSON , _ := json . Marshal ( containerResponse ) utils . WriteJSONToResponse ( w , http . StatusOK , responseJSON , utils . RequestTypeContainerMetadata ) } }

// ContainerMetadataHandler returns the handler method for handling container metadata requests.

ContainerMetadataHandler returns the handler method for handling container metadata requests .


func GetContainerResponse(containerID string, state dockerstate.TaskEngineState) (*v2.ContainerResponse, error) {
	containerResponse, err := v2.NewContainerResponse(containerID, state)
	if err != nil {
		return nil, errors.Errorf("Unable to generate metadata for container '%s'", containerID)
	}
	// fill in network details if not set
	if containerResponse.Networks == nil {
		if containerResponse.Networks, err = GetContainerNetworkMetadata(containerID, state); err != nil {
			return nil, err
		}
	}
	return containerResponse, nil
}

func
GetContainerResponse
(
containerID
string
,
state
dockerstate
.
TaskEngineState
)
(
*
v2
.
ContainerResponse
,
error
)
{
containerResponse
,
err
:=
v2
.
NewContainerResponse
(
containerID
,
state
)
if
err
!=
{
return
,
errors
.
Errorf
(
"
"
,
containerID
)
}
// fill in network details if not set
if
containerResponse
.
Networks
==
{
if
containerResponse
.
Networks
,
err
=
GetContainerNetworkMetadata
(
containerID
,
state
)
;
err
!=
{
return
,
err
}
}
return
containerResponse
,
}

// GetContainerResponse gets container response for v3 metadata


func GetContainerNetworkMetadata(containerID string, state dockerstate.TaskEngineState) ([]containermetadata.Network, error) {
	dockerContainer, ok := state.ContainerByID(containerID)
	if !ok {
		return nil, errors.Errorf("Unable to find container '%s'", containerID)
	}
	// the logic here has been reused from
	// https://github.com/aws/amazon-ecs-agent/blob/0c8913ba33965cf6ffdd6253fad422458d9346bd/agent/containermetadata/parse_metadata.go#L123
	settings := dockerContainer.Container.GetNetworkSettings()
	if settings == nil {
		return nil, errors.Errorf("Unable to generate network response for container '%s'", containerID)
	}
	// This metadata is the information provided in older versions of the API
	// We get the NetworkMode (Network interface name) from the HostConfig because this
	// this is the network with which the container is created
	ipv4AddressFromSettings := settings.IPAddress
	networkModeFromHostConfig := dockerContainer.Container.GetNetworkMode()

	// Extensive Network information is not available for Docker API versions 1.17-1.20
	// Instead we only get the details of the first network
	networks := make([]containermetadata.Network, 0)
	if len(settings.Networks) > 0 {
		for modeFromSettings, containerNetwork := range settings.Networks {
			networkMode := modeFromSettings
			ipv4Addresses := []string{containerNetwork.IPAddress}
			network := containermetadata.Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses}
			networks = append(networks, network)
		}
	} else {
		ipv4Addresses := []string{ipv4AddressFromSettings}
		network := containermetadata.Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses}
		networks = append(networks, network)
	}
	return networks, nil
}

// GetContainerNetworkMetadata returns the network metadata for the container


func (cgroup *CgroupResource) Initialize(resourceFields *taskresource.ResourceFields,
	taskKnownStatus status.TaskStatus,
	taskDesiredStatus status.TaskStatus) {
}

func ( cgroup * CgroupResource ) Initialize ( resourceFields * taskresource . ResourceFields , taskKnownStatus status . TaskStatus , taskDesiredStatus status . TaskStatus ) { }


func StartDefaultTerminationHandler(saver statemanager.Saver, taskEngine engine.TaskEngine) {
	signalChannel := make(chan os.Signal, 2)
	signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)

	sig := <-signalChannel
	seelog.Debugf("Termination handler received termination signal: %s", sig.String())

	err := FinalSave(saver, taskEngine)
	if err != nil {
		seelog.Criticalf("Error saving state before final shutdown: %v", err)
		// Terminal because it's a sigterm; the user doesn't want it to restart
		os.Exit(exitcodes.ExitTerminal)
	}
	os.Exit(exitcodes.ExitSuccess)
}

// StartDefaultTerminationHandler defines a default termination handler suitable for running in a process


func FinalSave(saver statemanager.Saver, taskEngine engine.TaskEngine) error {
	engineDisabled := make(chan error)

	disableTimer := time.AfterFunc(engineDisableTimeout, func() {
		engineDisabled <- errors.New("final save: timed out waiting for TaskEngine to settle")
	})

	go func() {
		seelog.Debug("Shutting down task engine for final save")
		taskEngine.Disable()
		disableTimer.Stop()
		engineDisabled <- nil
	}()

	disableErr := <-engineDisabled

	stateSaved := make(chan error)
	saveTimer := time.AfterFunc(finalSaveTimeout, func() {
		stateSaved <- errors.New("final save: timed out trying to save to disk")
	})
	go func() {
		seelog.Debug("Saving state before shutting down")
		stateSaved <- saver.ForceSave()
		saveTimer.Stop()
	}()

	saveErr := <-stateSaved

	if disableErr != nil || saveErr != nil {
		return apierrors.NewMultiError(disableErr, saveErr)
	}
	return nil
}

func FinalSave ( saver statemanager . Saver , taskEngine engine . TaskEngine ) error { engineDisabled := make ( chan error ) disableTimer := time . AfterFunc ( engineDisableTimeout , func ( ) { engineDisabled <- errors . New ( " " ) } ) go func ( ) { seelog . Debug ( " " ) taskEngine . Disable ( ) disableTimer . Stop ( ) engineDisabled <- nil } ( ) disableErr := <- engineDisabled stateSaved := make ( chan error ) saveTimer := time . AfterFunc ( finalSaveTimeout , func ( ) { stateSaved <- errors . New ( " " ) } ) go func ( ) { seelog . Debug ( " " ) stateSaved <- saver . ForceSave ( ) saveTimer . Stop ( ) } ( ) saveErr := <- stateSaved if disableErr != nil || saveErr != nil { return apierrors . NewMultiError ( disableErr , saveErr ) } return nil }

// FinalSave should be called immediately before exiting, and only before
// exiting, in order to flush tasks to disk. It waits a short timeout for state
// to settle if necessary. If unable to reach a steady-state and save within
// this short timeout, it returns an error

FinalSave should be called immediately before exiting and only before exiting in order to flush tasks to disk . It waits a short timeout for state to settle if necessary . If unable to reach a steady - state and save within this short timeout it returns an error


func (key *cacheKey) String() string {
	return fmt.Sprintf("%s-%s-%s-%s", key.roleARN, key.region, key.registryID, key.endpointOverride)
}

func ( key * cacheKey ) String ( ) string { return fmt . Sprintf ( " " , key . roleARN , key . region , key . registryID , key . endpointOverride ) }

// String formats the cachKey as a string


func NewECRAuthProvider(ecrFactory ecr.ECRFactory, cache async.Cache) DockerAuthProvider {
	return &ecrAuthProvider{
		tokenCache: cache,
		factory:    ecrFactory,
	}
}

func NewECRAuthProvider ( ecrFactory ecr . ECRFactory , cache async . Cache ) DockerAuthProvider { return & ecrAuthProvider { tokenCache : cache , factory : ecrFactory , } }

// NewECRAuthProvider returns a DockerAuthProvider that can handle retrieve
// credentials for pulling from Amazon EC2 Container Registry

NewECRAuthProvider returns a DockerAuthProvider that can handle retrieve credentials for pulling from Amazon EC2 Container Registry


func (authProvider *ecrAuthProvider) getAuthConfigFromCache(key cacheKey) *types.AuthConfig {
	token, ok := authProvider.tokenCache.Get(key.String())
	if !ok {
		return nil
	}

	cachedToken, ok := token.(*ecrapi.AuthorizationData)
	if !ok {
		log.Warnf("Reading ECR credentials from cache failed")
		return nil
	}

	if authProvider.IsTokenValid(cachedToken) {
		auth, err := extractToken(cachedToken)
		if err != nil {
			log.Errorf("Extract docker auth from cache failed, err: %v", err)
			// Remove invalid token from cache
			authProvider.tokenCache.Delete(key.String())
			return nil
		}
		return &auth
	} else {
		// Remove invalid token from cache
		authProvider.tokenCache.Delete(key.String())
	}
	return nil
}

func
(
authProvider
*
ecrAuthProvider
)
getAuthConfigFromCache
(
key
cacheKey
)
*
types
.
AuthConfig
{
token
,
ok
:=
authProvider
.
tokenCache
.
Get
(
key
.
String
(
)
)
if
!
ok
{
return
}
cachedToken
,
ok
:=
token
.
(
*
ecrapi
.
AuthorizationData
)
if
!
ok
{
log
.
Warnf
(
"
"
)
return
}
if
authProvider
.
IsTokenValid
(
cachedToken
)
{
auth
,
err
:=
extractToken
(
cachedToken
)
if
err
!=
{
log
.
Errorf
(
"
"
,
err
)
// Remove invalid token from cache
authProvider
.
tokenCache
.
Delete
(
key
.
String
(
)
)
return
}
return
&
auth
}
else
{
// Remove invalid token from cache
authProvider
.
tokenCache
.
Delete
(
key
.
String
(
)
)
}
return
}

// getAuthconfigFromCache retrieves the token from cache


func (authProvider *ecrAuthProvider) getAuthConfigFromECR(image string, key cacheKey, authData *apicontainer.ECRAuthData) (types.AuthConfig, error) {
	// Create ECR client to get the token
	client, err := authProvider.factory.GetClient(authData)
	if err != nil {
		return types.AuthConfig{}, err
	}

	log.Debugf("Calling ECR.GetAuthorizationToken for %s", image)
	ecrAuthData, err := client.GetAuthorizationToken(authData.RegistryID)
	if err != nil {
		return types.AuthConfig{}, err
	}
	if ecrAuthData == nil {
		return types.AuthConfig{}, fmt.Errorf("ecr auth: missing AuthorizationData in ECR response for %s", image)
	}

	// Verify the auth data has the correct format for ECR
	if ecrAuthData.ProxyEndpoint != nil &&
		strings.HasPrefix(proxyEndpointScheme+image, aws.StringValue(ecrAuthData.ProxyEndpoint)) &&
		ecrAuthData.AuthorizationToken != nil {

		// Cache the new token
		authProvider.tokenCache.Set(key.String(), ecrAuthData)
		return extractToken(ecrAuthData)
	}
	return types.AuthConfig{}, fmt.Errorf("ecr auth: AuthorizationData is malformed for %s", image)
}

// getAuthConfigFromECR calls the ECR API to get docker auth config


func (authProvider *ecrAuthProvider) IsTokenValid(authData *ecrapi.AuthorizationData) bool {
	if authData == nil || authData.ExpiresAt == nil {
		return false
	}

	refreshTime := aws.TimeValue(authData.ExpiresAt).
		Add(-1 * retry.AddJitter(MinimumJitterDuration, MinimumJitterDuration))

	return time.Now().Before(refreshTime)
}

func ( authProvider * ecrAuthProvider ) IsTokenValid ( authData * ecrapi . AuthorizationData ) bool { if authData == nil || authData . ExpiresAt == nil { return false } refreshTime := aws . TimeValue ( authData . ExpiresAt ) . Add ( - 1 * retry . AddJitter ( MinimumJitterDuration , MinimumJitterDuration ) ) return time . Now ( ) . Before ( refreshTime ) }

// IsTokenValid checks the token is still within it's expiration window. We early expire to allow
// for timing in calls and add jitter to avoid refreshing all of the tokens at once.

IsTokenValid checks the token is still within it s expiration window . We early expire to allow for timing in calls and add jitter to avoid refreshing all of the tokens at once .


func createTaskResponse(task *apitask.Task, found bool, resourceID string, state dockerstate.TaskEngineState) ([]byte, int) {
	var responseJSON []byte
	status := http.StatusOK
	if found {
		containerMap, _ := state.ContainerMapByArn(task.Arn)
		responseJSON, _ = json.Marshal(NewTaskResponse(task, containerMap))
	} else {
		seelog.Warn("Could not find requested resource: " + resourceID)
		responseJSON, _ = json.Marshal(&TaskResponse{})
		status = http.StatusNotFound
	}
	return responseJSON, status
}

func createTaskResponse ( task * apitask . Task , found bool , resourceID string , state dockerstate . TaskEngineState ) ( [ ] byte , int ) { var responseJSON [ ] byte status := http . StatusOK if found { containerMap , _ := state . ContainerMapByArn ( task . Arn ) responseJSON , _ = json . Marshal ( NewTaskResponse ( task , containerMap ) ) } else { seelog . Warn ( " " + resourceID ) responseJSON , _ = json . Marshal ( & TaskResponse { } ) status = http . StatusNotFound } return responseJSON , status }

// createTaskResponse creates JSON response and sets the http status code for the task queried.

createTaskResponse creates JSON response and sets the http status code for the task queried .


func NewTaskStateChangeEvent(task *apitask.Task, reason string) (TaskStateChange, error) {
	var event TaskStateChange
	taskKnownStatus := task.GetKnownStatus()
	if !taskKnownStatus.BackendRecognized() {
		return event, errors.Errorf(
			"create task state change event api: status not recognized by ECS: %v",
			taskKnownStatus)
	}
	if task.GetSentStatus() >= taskKnownStatus {
		return event, errors.Errorf(
			"create task state change event api: status [%s] already sent",
			taskKnownStatus.String())
	}

	event = TaskStateChange{
		TaskARN: task.Arn,
		Status:  taskKnownStatus,
		Reason:  reason,
		Task:    task,
	}

	event.SetTaskTimestamps()

	return event, nil
}

func NewTaskStateChangeEvent ( task * apitask . Task , reason string ) ( TaskStateChange , error ) { var event TaskStateChange taskKnownStatus := task . GetKnownStatus ( ) if ! taskKnownStatus . BackendRecognized ( ) { return event , errors . Errorf ( " " , taskKnownStatus ) } if task . GetSentStatus ( ) >= taskKnownStatus { return event , errors . Errorf ( " " , taskKnownStatus . String ( ) ) } event = TaskStateChange { TaskARN : task . Arn , Status : taskKnownStatus , Reason : reason , Task : task , } event . SetTaskTimestamps ( ) return event , nil }

// NewTaskStateChangeEvent creates a new task state change event


func NewContainerStateChangeEvent(task *apitask.Task, cont *apicontainer.Container, reason string) (ContainerStateChange, error) {
	var event ContainerStateChange
	contKnownStatus := cont.GetKnownStatus()
	if !contKnownStatus.ShouldReportToBackend(cont.GetSteadyStateStatus()) {
		return event, errors.Errorf(
			"create container state change event api: status not recognized by ECS: %v",
			contKnownStatus)
	}
	if cont.IsInternal() {
		return event, errors.Errorf(
			"create container state change event api: internal container: %s",
			cont.Name)
	}
	if cont.GetSentStatus() >= contKnownStatus {
		return event, errors.Errorf(
			"create container state change event api: status [%s] already sent for container %s, task %s",
			contKnownStatus.String(), cont.Name, task.Arn)
	}

	if reason == "" && cont.ApplyingError != nil {
		reason = cont.ApplyingError.Error()
	}
	event = ContainerStateChange{
		TaskArn:       task.Arn,
		ContainerName: cont.Name,
		Status:        contKnownStatus.BackendStatus(cont.GetSteadyStateStatus()),
		ExitCode:      cont.GetKnownExitCode(),
		PortBindings:  cont.GetKnownPortBindings(),
		Reason:        reason,
		Container:     cont,
	}

	return event, nil
}

func NewContainerStateChangeEvent ( task * apitask . Task , cont * apicontainer . Container , reason string ) ( ContainerStateChange , error ) { var event ContainerStateChange contKnownStatus := cont . GetKnownStatus ( ) if ! contKnownStatus . ShouldReportToBackend ( cont . GetSteadyStateStatus ( ) ) { return event , errors . Errorf ( " " , contKnownStatus ) } if cont . IsInternal ( ) { return event , errors . Errorf ( " " , cont . Name ) } if cont . GetSentStatus ( ) >= contKnownStatus { return event , errors . Errorf ( " " , contKnownStatus . String ( ) , cont . Name , task . Arn ) } if reason == " " && cont . ApplyingError != nil { reason = cont . ApplyingError . Error ( ) } event = ContainerStateChange { TaskArn : task . Arn , ContainerName : cont . Name , Status : contKnownStatus . BackendStatus ( cont . GetSteadyStateStatus ( ) ) , ExitCode : cont . GetKnownExitCode ( ) , PortBindings : cont . GetKnownPortBindings ( ) , Reason : reason , Container : cont , } return event , nil }

// NewContainerStateChangeEvent creates a new container state change event


func (change *TaskStateChange) SetTaskTimestamps() {
	if change.Task == nil {
		return
	}

	// Send the task timestamp if set
	if timestamp := change.Task.GetPullStartedAt(); !timestamp.IsZero() {
		change.PullStartedAt = aws.Time(timestamp.UTC())
	}
	if timestamp := change.Task.GetPullStoppedAt(); !timestamp.IsZero() {
		change.PullStoppedAt = aws.Time(timestamp.UTC())
	}
	if timestamp := change.Task.GetExecutionStoppedAt(); !timestamp.IsZero() {
		change.ExecutionStoppedAt = aws.Time(timestamp.UTC())
	}
}

func
(
change
*
TaskStateChange
)
SetTaskTimestamps
(
)
{
if
change
.
Task
==
{
return
}
// Send the task timestamp if set
if
timestamp
:=
change
.
Task
.
GetPullStartedAt
(
)
;
!
timestamp
.
IsZero
(
)
{
change
.
PullStartedAt
=
aws
.
Time
(
timestamp
.
UTC
(
)
)
}
if
timestamp
:=
change
.
Task
.
GetPullStoppedAt
(
)
;
!
timestamp
.
IsZero
(
)
{
change
.
PullStoppedAt
=
aws
.
Time
(
timestamp
.
UTC
(
)
)
}
if
timestamp
:=
change
.
Task
.
GetExecutionStoppedAt
(
)
;
!
timestamp
.
IsZero
(
)
{
change
.
ExecutionStoppedAt
=
aws
.
Time
(
timestamp
.
UTC
(
)
)
}
}

// SetTaskTimestamps adds the timestamp information of task into the event
// to be sent by SubmitTaskStateChange

SetTaskTimestamps adds the timestamp information of task into the event to be sent by SubmitTaskStateChange


func (change *TaskStateChange) ShouldBeReported() bool {
	// Events that should be reported:
	// 1. Normal task state change: RUNNING/STOPPED
	// 2. Container state change, with task status in CREATED/RUNNING/STOPPED
	// The task timestamp will be sent in both of the event type
	// TODO Move the Attachment statechange check into this method
	if change.Status == apitaskstatus.TaskRunning || change.Status == apitaskstatus.TaskStopped {
		return true
	}

	if len(change.Containers) != 0 {
		return true
	}

	return false
}

// ShouldBeReported checks if the statechange should be reported to backend


func (eni *ENI) GetIPV4Addresses() []string {
	var addresses []string
	for _, addr := range eni.IPV4Addresses {
		addresses = append(addresses, addr.Address)
	}

	return addresses
}

func ( eni * ENI ) GetIPV4Addresses ( ) [ ] string { var addresses [ ] string for _ , addr := range eni . IPV4Addresses { addresses = append ( addresses , addr . Address ) } return addresses }

// GetIPV4Addresses returns a list of ipv4 addresses allocated to the ENI


func (eni *ENI) GetIPV6Addresses() []string {
	var addresses []string
	for _, addr := range eni.IPV6Addresses {
		addresses = append(addresses, addr.Address)
	}

	return addresses
}

func ( eni * ENI ) GetIPV6Addresses ( ) [ ] string { var addresses [ ] string for _ , addr := range eni . IPV6Addresses { addresses = append ( addresses , addr . Address ) } return addresses }

// GetIPV6Addresses returns a list of ipv6 addresses allocated to the ENI


func (eni *ENI) String() string {
	var ipv4Addresses []string
	for _, addr := range eni.IPV4Addresses {
		ipv4Addresses = append(ipv4Addresses, addr.Address)
	}
	var ipv6Addresses []string
	for _, addr := range eni.IPV6Addresses {
		ipv6Addresses = append(ipv6Addresses, addr.Address)
	}
	return fmt.Sprintf(
		"eni id:%s, mac: %s, hostname: %s, ipv4addresses: [%s], ipv6addresses: [%s], dns: [%s], dns search: [%s], gateway ipv4: [%s]",
		eni.ID, eni.MacAddress, eni.GetHostname(), strings.Join(ipv4Addresses, ","), strings.Join(ipv6Addresses, ","),
		strings.Join(eni.DomainNameServers, ","), strings.Join(eni.DomainNameSearchList, ","), eni.SubnetGatewayIPV4Address)
}

func ( eni * ENI ) String ( ) string { var ipv4Addresses [ ] string for _ , addr := range eni . IPV4Addresses { ipv4Addresses = append ( ipv4Addresses , addr . Address ) } var ipv6Addresses [ ] string for _ , addr := range eni . IPV6Addresses { ipv6Addresses = append ( ipv6Addresses , addr . Address ) } return fmt . Sprintf ( " " , eni . ID , eni . MacAddress , eni . GetHostname ( ) , strings . Join ( ipv4Addresses , " " ) , strings . Join ( ipv6Addresses , " " ) , strings . Join ( eni . DomainNameServers , " " ) , strings . Join ( eni . DomainNameSearchList , " " ) , eni . SubnetGatewayIPV4Address ) }

// String returns a human readable version of the ENI object


func ENIFromACS(acsenis []*ecsacs.ElasticNetworkInterface) (*ENI, error) {
	err := ValidateTaskENI(acsenis)
	if err != nil {
		return nil, err
	}

	var ipv4 []*ENIIPV4Address
	var ipv6 []*ENIIPV6Address

	// Read ipv4 address information of the eni
	for _, ec2Ipv4 := range acsenis[0].Ipv4Addresses {
		ipv4 = append(ipv4, &ENIIPV4Address{
			Primary: aws.BoolValue(ec2Ipv4.Primary),
			Address: aws.StringValue(ec2Ipv4.PrivateAddress),
		})
	}

	// Read ipv6 address information of the eni
	for _, ec2Ipv6 := range acsenis[0].Ipv6Addresses {
		ipv6 = append(ipv6, &ENIIPV6Address{
			Address: aws.StringValue(ec2Ipv6.Address),
		})
	}

	eni := &ENI{
		ID:                       aws.StringValue(acsenis[0].Ec2Id),
		IPV4Addresses:            ipv4,
		IPV6Addresses:            ipv6,
		MacAddress:               aws.StringValue(acsenis[0].MacAddress),
		PrivateDNSName:           aws.StringValue(acsenis[0].PrivateDnsName),
		SubnetGatewayIPV4Address: aws.StringValue(acsenis[0].SubnetGatewayIpv4Address),
	}
	for _, nameserverIP := range acsenis[0].DomainNameServers {
		eni.DomainNameServers = append(eni.DomainNameServers, aws.StringValue(nameserverIP))
	}
	for _, nameserverDomain := range acsenis[0].DomainName {
		eni.DomainNameSearchList = append(eni.DomainNameSearchList, aws.StringValue(nameserverDomain))
	}

	return eni, nil
}

// ENIFromACS validates the information from acs message and create the ENI object


func ValidateTaskENI(acsenis []*ecsacs.ElasticNetworkInterface) error {
	// Only one eni should be associated with the task
	// Only one ipv4 should be associated with the eni
	// No more than one ipv6 should be associated with the eni
	if len(acsenis) != 1 {
		return errors.Errorf("eni message validation: more than one ENIs in the message(%d)", len(acsenis))
	} else if len(acsenis[0].Ipv4Addresses) != 1 {
		return errors.Errorf("eni message validation: more than one ipv4 addresses in the message(%d)", len(acsenis[0].Ipv4Addresses))
	} else if len(acsenis[0].Ipv6Addresses) > 1 {
		return errors.Errorf("eni message validation: more than one ipv6 addresses in the message(%d)", len(acsenis[0].Ipv6Addresses))
	}

	if acsenis[0].MacAddress == nil {
		return errors.Errorf("eni message validation: empty eni mac address in the message")
	}

	if acsenis[0].Ec2Id == nil {
		return errors.Errorf("eni message validation: empty eni id in the message")
	}

	return nil
}

// ValidateTaskENI validates the eni informaiton sent from acs


func NewMockPlugins(ctrl *gomock.Controller) *MockPlugins {
	mock := &MockPlugins{ctrl: ctrl}
	mock.recorder = &MockPluginsMockRecorder{mock}
	return mock
}

func NewMockPlugins ( ctrl * gomock . Controller ) * MockPlugins { mock := & MockPlugins { ctrl : ctrl } mock . recorder = & MockPluginsMockRecorder { mock } return mock }

// NewMockPlugins creates a new mock instance


func (m *MockPlugins) Scan() ([]string, error) {
	ret := m.ctrl.Call(m, "Scan")
	ret0, _ := ret[0].([]string)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

func ( m * MockPlugins ) Scan ( ) ( [ ] string , error ) { ret := m . ctrl . Call ( m , " " ) ret0 , _ := ret [ 0 ] . ( [ ] string ) ret1 , _ := ret [ 1 ] . ( error ) return ret0 , ret1 }


func (mr *MockPluginsMockRecorder) Scan() *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scan", reflect.TypeOf((*MockPlugins)(nil).Scan))
}

func ( mr * MockPluginsMockRecorder ) Scan ( ) * gomock . Call { return mr . mock . ctrl . RecordCallWithMethodType ( mr . mock , " " , reflect . TypeOf ( ( * MockPlugins ) ( nil ) . Scan ) ) }

// Scan indicates an expected call of Scan


func TaskFromACS(acsTask *ecsacs.Task, envelope *ecsacs.PayloadMessage) (*Task, error) {
	data, err := jsonutil.BuildJSON(acsTask)
	if err != nil {
		return nil, err
	}
	task := &Task{}
	err = json.Unmarshal(data, task)
	if err != nil {
		return nil, err
	}
	if task.GetDesiredStatus() == apitaskstatus.TaskRunning && envelope.SeqNum != nil {
		task.StartSequenceNumber = *envelope.SeqNum
	} else if task.GetDesiredStatus() == apitaskstatus.TaskStopped && envelope.SeqNum != nil {
		task.StopSequenceNumber = *envelope.SeqNum
	}

	// Overrides the container command if it's set
	for _, container := range task.Containers {
		if (container.Overrides != apicontainer.ContainerOverrides{}) && container.Overrides.Command != nil {
			container.Command = *container.Overrides.Command
		}
		container.TransitionDependenciesMap = make(map[apicontainerstatus.ContainerStatus]apicontainer.TransitionDependencySet)
	}
	// initialize resources map for task
	task.ResourcesMapUnsafe = make(map[string][]taskresource.TaskResource)
	return task, nil
}

// TaskFromACS translates ecsacs.Task to apitask.Task by first marshaling the received
// ecsacs.Task to json and unmarshaling it as apitask.Task

TaskFromACS translates ecsacs . Task to apitask . Task by first marshaling the received ecsacs . Task to json and unmarshaling it as apitask . Task