<@ULVA73B9P> is there a way to get the image tag o...
# ask-marvin
k
@Marvin is there a way to get the image tag of a current deployment via API?
m
To get the image tag of a current deployment via Prefect API, there doesn't seem to be explicit documentation stating a direct API call for this purpose. However, according to the Prefect documentation, you can tag images with a Git SHA in the
prefect.yaml
file using deployment steps. This approach allows you to define the image tag during your deployment process, and it assumes you have the image tagging logic integrated into your deployment flow. Here's a brief step to set up image tagging with Git SHA in your `prefect.yaml`:
Copy code
yaml
build:
  - prefect.deployments.steps.run_shell_script:
      id: get-commit-hash
      script: git rev-parse --short HEAD
      stream_output: false
  - prefect_docker.deployments.steps.build_docker_image:
      id: build-image
      requires: prefect-docker>=0.4.0
      image_name: "{{ $PREFECT_IMAGE_NAME }}"
      tag: "{{ get-commit-hash.stdout }}"
      dockerfile: auto
      platform: "linux/amd64"
Keep in mind, this will only help to tag the images during the build and deployment process, but does not provide a method to directly retrieve the tag via the API post-deployment. If you want to retrieve the image tag after deployment, this information might be accessible through querying your container orchestration service (e.g., Kubernetes API if you're using Kubernetes) to get the deployment details, which include the image tag being used. For further assistance with a specific method to retrieve image tags post-deployment, checking your orchestration service's API or Prefect community resources would be necessary, as this is not detailed in the Prefect documentation excerpts provided. Keep in mind that I'm operating on the information available up to the moment of my knowledge cutoff in April 2023. If Prefect has introduced new functionality since then, consulting current documentation or community forums might shed light on new developments.