Any tricks to get deployment time and git hash as ...
# general
Any tricks to get deployment time and git hash as an env-var til a container? i know how to set env vars, but if i simply set
then the pulumi code will obviously/presumably(?) redeploy the service whenever i run pulumi due to the change in values; i don't want that. any ideas?
git hash should be fairly straightforward as it’s locally static, is the issue that you want to get a deployment time only when changes happen?
Yes - i want the "version" of the webapp to be shown in a developer-debug-info view as well as when the service was deployed last. the issue being that the webapp doesn't change everytime i redeploy my stack, so it should only be the specific ressource
thinking out loud, I think that likely wants to be set inside the container rather than at the deployment, the deployment time information doesn’t really have the metadata ability to set values that way. I’ll keep considering if there’s a way to solve
thanks. it's also a nice to have of sorts.
i mean the githash might be of less value, but the datetime would be nice
my issue with setting it in the container is that if it gets restarted that isn't the same as a redeploy.. hmm
maybe it's more of a build time. 🤔
yeah I think that’s gonna be easier
My solution for getting the build time of a docker image, ended up being:
Copy code
def get_build_time(self, image: docker.Image) -> Output[datetime | None]:
        cmd = command.local.Command(
            create='TZ=UTC date +"%Y-%m-%d %H:%M:%S"',

        def to_datetime(stdout: str) -> datetime | None:
            if not stdout.strip():
                return None

            return datetime.strptime(stdout.strip(), "%Y-%m-%d %H:%M:%S")

        return cmd.stdout.apply(to_datetime)
In theory i could add the git hash in a similar way