Comments (8)
Thank you so much for the PR! As you could probably see from the code, I am no master of Go either. I will try to review it this weekend.
from packer-plugin-git.
@sydrawat01 also you can do just packer validate -syntax-only .
which will be checking does code is correctly written (all HCL references and etc.)
from packer-plugin-git.
No, there isn't currently a datasource which returns the branch. However, it should be pretty easy to build. I might add it myself if I have some free time, but PRs are also welcome :)
from packer-plugin-git.
I am not a master of go
but I have created PR to address it. Please take a look when you will have a time
from packer-plugin-git.
Ca we have an example on how to use this? It would add great detail to the documentation!
from packer-plugin-git.
it is documented here:
https://github.com/ethanmdavidson/packer-plugin-git/blob/main/docs/datasources/commit.mdx
In my project I am using this as:
variable "ubuntu_version" {
description = "Variable with version of AMI"
type = string
}
locals {
truncated_sha = substr(data.git-commit.cwd-head.hash, 0, 8)
version = data.git-repository.cwd.head == "master" && data.git-repository.cwd.is_clean ? var.ubuntu_version : "${var.ubuntu_version}-${local.truncated_sha}"
}
data "git-repository" "cwd" {}
data "git-commit" "cwd-head" {}
so on the end local.version
is variable which I am using:
source "amazon-ebs" "ubuntu" {
ami_name = "ubuntu-${local.version}"
.......................
from packer-plugin-git.
Thanks for the example @daroga0002 ! I did try to use this as an example in my packer template, but it throws me an error saying the AMI name is invalid when i run packer validate .
command:
Error: 1 error(s) occurred:
* AMIName should only contain alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_). You can use the `clean_resource_name` template filter to automatically clean your ami name.
on ami.pkr.hcl line 48:
(source code not available)
Here's a snippet of my ami.pkr.hcl
file where it fails:
.....
variable "ubuntu_version" {
type = string
description = "Version of the custom AMI"
}
locals {
truncated_sha = substr(data.git-commit.cwd-head.hash, 0, 8)
version = data.git-repository.cwd.head == "master" && data.git-repository.cwd.is_clean ? var.ubuntu_version : "${var.ubuntu_version}-${local.truncated_sha}"
}
data "git-repository" "cwd" {}
data "git-commit" "cwd-head" {}
source "amazon-ebs" "ubuntu" {
region = "${var.aws_region}"
ami_name = "ubuntu-${local.version}"
.....
Can't seem to find what I'm doing wrong here. I also didn't find any specific rules as to what the AMI name should follow, so it's a bit vague to me what not to name my AMI, because I wanted to have it specific to the PR during CI/CD workflows on GitHub actions.
from packer-plugin-git.
this is packer bug, if you run packer build it should go without issues.
In general looks that validate doesnt trying to predict a values for variables.
from packer-plugin-git.
Related Issues (16)
- The v0.5.0 release does not include assets resulting in failed installs HOT 5
- CVE hits on latest release HOT 3
- New datasource HEAD HOT 1
- Packer 1.12.0-alpha1 testing HOT 1
- Work with remotes? HOT 3
- Update to packer-sdc command for validating plugin compatibility HOT 1
- Automatically find repository root HOT 1
- add ls-files datasource
- Plugin issue when starting the build HOT 5
- Add git-describe datasource
- No evaluation when running in Azure Devops HOT 1
- Doc Issue: README has old name/location HOT 2
- query: is it possible for this plugin to say whether the working dir is "clean" or not? HOT 3
- Feature (or doc) : how to tell which branch is currently checked out. HOT 1
- Support with git worktrees
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from packer-plugin-git.