View Source PotUtils (Pots v0.1.2)
Utils for running Pot tasks. Most of the logic of Pot tasks are contained here.
Summary
Functions
Get the application name. Thils is either the value of :app
in the
application configuration or the return value of Application.get_all_env(__MODULE__)
Returns a list of Dockerfiles
for Pot. It looks for files that start
with Docker
and end with .pot
.
Trys to run the program docker
. If it errors, it will raise
and error because no suitable container runtime can be found.
Returns a list of all docker containers, filtered by the label of
pot_<app-name>
in JSON format. If none are returned, it returns
an empty list. Uses the command in the format of
<container-runtime> container ls --filter lable=pot_<app-name> --format {{json}}
Gets the name of the Dockerfile. If :no_name
is passed in then it
simply returns Dockerfile.pot
. If any other string is passed to it, it will
return Docerfile.<string>.pot
.
Returns a list of all docker images, filtered by the label of
pot_<app-name>
in JSON format. If none are returned, it returns
an empty list. Uses the command in the format of
<container-runtime> images --filter lable=pot_<app-name> --format {{json}}
Trys to run the program nerdctl
. If it errors, it will move
on to try the next runtime podman
.
Trys to run the program podman
. If it errors, it will move
on to try the next runtime docker
.
Get the current container run time to use. The return values can be the strings of "docker", "podman", or "nerdctl". Currently does not allow for choosing your runtime, this is to be added later.
Similar to PotUtils.get_docker_containers/0
, it filters all containers on the label of
pot_<app-name>
and simply prints the output of the command. Uses the command
in the format of
<container-runtime> container ls --filter lable=pot_<app-name>
Similar to PotUtils.get_docker_images/0
, it filters all images on the label of
pot_<app-name>
and simply prints the output of the command. Uses the command
in the format of
<container-runtime> images --filter lable=pot_<app-name>
Remove all container images created by Pot. This will only touch images labled appropriately
by pot. This runs the command <container-runtime> image rm <img-id>
Takes in the command to be run using the runtime returned from PotUtils.get_runtime/0
.
Splits the cmd
up and passes it to System.cmd
.
Takes in the command to be run using the runtime returned from PotUtils.get_runtime/0
.
Splits the cmd
up and passes it to System.cmd
. This one returns the output from
the command run unlike runtime_cmd/1
Stop all running containers created by Pot. This should
also remove them as all containers are started with the
options --rm
which means to remove them once stopped.
Uses the command in the format of <container-runtime> stop <container-id
Functions
Get the application name. Thils is either the value of :app
in the
application configuration or the return value of Application.get_all_env(__MODULE__)
Returns a list of Dockerfiles
for Pot. It looks for files that start
with Docker
and end with .pot
.
Trys to run the program docker
. If it errors, it will raise
and error because no suitable container runtime can be found.
Returns a list of all docker containers, filtered by the label of
pot_<app-name>
in JSON format. If none are returned, it returns
an empty list. Uses the command in the format of
<container-runtime> container ls --filter lable=pot_<app-name> --format {{json}}
Gets the name of the Dockerfile. If :no_name
is passed in then it
simply returns Dockerfile.pot
. If any other string is passed to it, it will
return Docerfile.<string>.pot
.
Example
iex> PotUtils.get_docker_file_for_pot(:no_name) Dockerfile.pot iex> PotUtils.get_docker_file_for_pot("my_project") Dockerfile.my_project.pot
Returns a list of all docker images, filtered by the label of
pot_<app-name>
in JSON format. If none are returned, it returns
an empty list. Uses the command in the format of
<container-runtime> images --filter lable=pot_<app-name> --format {{json}}
Trys to run the program nerdctl
. If it errors, it will move
on to try the next runtime podman
.
Trys to run the program podman
. If it errors, it will move
on to try the next runtime docker
.
Get the current container run time to use. The return values can be the strings of "docker", "podman", or "nerdctl". Currently does not allow for choosing your runtime, this is to be added later.
Similar to PotUtils.get_docker_containers/0
, it filters all containers on the label of
pot_<app-name>
and simply prints the output of the command. Uses the command
in the format of
<container-runtime> container ls --filter lable=pot_<app-name>
Similar to PotUtils.get_docker_images/0
, it filters all images on the label of
pot_<app-name>
and simply prints the output of the command. Uses the command
in the format of
<container-runtime> images --filter lable=pot_<app-name>
Remove all container images created by Pot. This will only touch images labled appropriately
by pot. This runs the command <container-runtime> image rm <img-id>
Takes in the command to be run using the runtime returned from PotUtils.get_runtime/0
.
Splits the cmd
up and passes it to System.cmd
.
Takes in the command to be run using the runtime returned from PotUtils.get_runtime/0
.
Splits the cmd
up and passes it to System.cmd
. This one returns the output from
the command run unlike runtime_cmd/1
Stop all running containers created by Pot. This should
also remove them as all containers are started with the
options --rm
which means to remove them once stopped.
Uses the command in the format of <container-runtime> stop <container-id