Initializing docker client lazily when docker.Client is invoked.
In order to mock docker client in UTs, docker.Client is aliased by means of package-level variable. This variable is overridden in UTs with a function that returns a mocked docker client.
No drastic changes in logic are introduced with this change, but merely the way in which the docker client is wired.
Testing
UTs passing, built ecs-init binary and verified it is still able to start and stop the ecs-agent.
New tests cover the changes: yes
Description for the changelog
Enhancement - Initialize docker client lazily
Licensing
This contribution is under the terms of the Apache 2.0 License:
Summary
Initialize docker client lazily. This will help mitigate the issues observed in https://github.com/aws/amazon-ecs-init/issues/448
Implementation details
Initializing docker client lazily when
docker.Client
is invoked.In order to mock docker client in UTs,
docker.Client
is aliased by means of package-level variable. This variable is overridden in UTs with a function that returns a mocked docker client.No drastic changes in logic are introduced with this change, but merely the way in which the docker client is wired.
Testing
UTs passing, built ecs-init binary and verified it is still able to start and stop the ecs-agent.
New tests cover the changes: yes
Description for the changelog
Licensing
This contribution is under the terms of the Apache 2.0 License: