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 name flag to scaffold Command #92

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ThorstenHans
Copy link

This PR adds an optional name flag to the scaffold command.

Motivation

As a user I want to specify a custom name when scaffolding a Kubernetes Deployment manifest for my Spin App.

Behavior

The name flag is optional. By default the name of the Spin App is generated using the provided OCI artifact reference (as it was before). If the --name flag is specified, its value is validated and used for scaffolding.

Validation

Only valid DNS subdomain names with less than 254 chars are considered valid. If an invalid value is provided, execution is terminated and a corresponding error message is presented to the user

Signed-off-by: Thorsten Hans <thorsten.hans@fermyon.com>
name, err := getNameFromImageReference(opts.from)
if err != nil {
return nil, err
}
if len(opts.name) > 0 {
if !validateName(opts.name) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we should add this validation to the name parsed from docker image ref as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm 🤔 In that case, I would move everything into the getNameFromImageReference function, rename it to getSpinAppName to streamline the code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should be good. My only reason for that was to keep the validation for name consistent irrespective of source of that string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajatjindal I've updated the PR according to the discussion we had here. As part of that, I've also added the name flag to the deploy sub command

Signed-off-by: Thorsten Hans <thorsten.hans@fermyon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants