Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variable validation for build user case and length #915

Closed
1 task done
JM2K69 opened this issue May 5, 2024 · 6 comments · Fixed by #910
Closed
1 task done

Add variable validation for build user case and length #915

JM2K69 opened this issue May 5, 2024 · 6 comments · Fixed by #910
Assignees
Labels
Milestone

Comments

@JM2K69
Copy link
Contributor

JM2K69 commented May 5, 2024

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

develop

VMware vSphere

7.0.3

HashiCorp Packer

1.10.3

HashiCorp Packer Plugin for VMware vSphere

1.26.7

Guest Operating System

Debian 12.5

Environment Details

No response

Description

Error when username start with un Upercase : I use User.

Expected Behavior

the build must continue

Actual Behavior

the build stop

Steps to Reproduce

Use a username for exemple Packer the build will fail with debian 12;5

Log Fragments and Files

No response

Screenshots

image

Additional Context

No response

@tenthirtyam
Copy link
Contributor

tenthirtyam commented May 5, 2024

This would likely impact more than just Debian 12. Certainly Debian 11 and other Linux distributions.

@tenthirtyam tenthirtyam changed the title Build Debian 12.5 error Build Debian 12.5 error if username is not lowercase May 5, 2024
@tenthirtyam tenthirtyam added type/refactor Refactor and removed type/bug Bug status/needs-triage Needs Triage labels May 5, 2024
@tenthirtyam tenthirtyam self-assigned this May 5, 2024
@tenthirtyam tenthirtyam added this to the v0.20.0 milestone May 5, 2024
@tenthirtyam tenthirtyam changed the title Build Debian 12.5 error if username is not lowercase Add variable validation for build user case and length May 6, 2024
@tenthirtyam
Copy link
Contributor

I've updated the issue description to reflect the changes needed.

@JM2K69
Copy link
Contributor Author

JM2K69 commented May 14, 2024

I try this regex validation without success @tenthirtyam

variable "build_username" {
  type        = string
  description = "The username to login to the guest operating system
  validation {
       condition     = can(regex("^[a-z][a-zA-Z0-9_]*", var.build_username))
    error_message = "The username account must start with a letter in lowercase"
  }
 validation {
    condition     = length(var.build_username) > 4 && length(var.build_username) < 8
    error_message = "The username lenght must between 4 and 8 characters"
  }
}

@tenthirtyam
Copy link
Contributor

We have a PR in with a change that will address this requirement when using an updated build script.

@JM2K69
Copy link
Contributor Author

JM2K69 commented May 14, 2024

We have a PR in with a change that will address this requirement when using an updated build script.
Should we close this issue ? And start a new one ?

@tenthirtyam
Copy link
Contributor

Nah, all good. This issue is linked to the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants