generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
builder: no delete logs OSLogin ssh key if not set #162
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
01eaee2
builder: don't upload pubkey if private specified
lbajolet-hashicorp 938689a
os_login: remove redundant check on cleanup
lbajolet-hashicorp 6b8174a
os_login: don't upload key if private key is spec
lbajolet-hashicorp 957770e
builder: add os-login acceptance test with privkey
lbajolet-hashicorp b1d69ab
step_oslogin: update ssh priv key test
lbajolet-hashicorp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
builder/googlecompute/testdata/oslogin/default-token-and-pkey.pkr.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
variable "project" { | ||
type = string | ||
default = env("GOOGLE_PROJECT_ID") | ||
} | ||
|
||
variable "ssh_private_key" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "ssh_username" { | ||
type = string | ||
default = "root" | ||
} | ||
|
||
variable "zone" { | ||
type = string | ||
default = "us-central1-a" | ||
} | ||
|
||
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") } | ||
|
||
# No provided access_token or account_file should read contents of env GOOGLE_APPLICATION_CREDENTIALS | ||
source "googlecompute" "autogenerated_1" { | ||
image_name = "packer-oslogin-tester-${local.timestamp}" | ||
project_id = var.project | ||
source_image_family = "centos-7" | ||
ssh_username = var.ssh_username | ||
ssh_private_key_file = "%s" | ||
ssh_timeout = "30s" | ||
use_os_login = true | ||
skip_create_image = true | ||
zone = var.zone | ||
} | ||
|
||
build { | ||
sources = ["source.googlecompute.autogenerated_1"] | ||
|
||
provisioner "shell" { | ||
inline = ["echo hello from the other side, username is $(whoami)"] | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test
I think we should also update this unit test so that public key is not set to nil. It should still pass
packer-plugin-googlecompute/builder/googlecompute/step_import_os_login_ssh_key_test.go
Line 200 in 957770e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! I've updated it with a generated private key file, and it indeed still passes