Skip to content

Feat: kusion should correctly handle empty spec in preview #1419

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

Closed
ruquanzhao opened this issue Apr 1, 2025 · 4 comments · Fixed by #1423
Closed

Feat: kusion should correctly handle empty spec in preview #1419

ruquanzhao opened this issue Apr 1, 2025 · 4 comments · Fixed by #1423
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/feature Categorizes issue or PR as related to a new feature

Comments

@ruquanzhao
Copy link
Collaborator

ruquanzhao commented Apr 1, 2025

What would you like to be added?

Currently, Kusion will throw a nil with logging No resource change found in this stack... for an empty spec during preview and apply.

However, passing an empty spec during the preview is a possible user path, and the result of the preview should indicate that all resources will be deleted.
Related Code:

// return immediately if no resource found in stack
// todo: if there is no resource, should still do diff job; for now, if output is json format, there is no hint
if sp == nil || len(sp.Resources) == 0 {
logutil.LogToAll(logger, runLogger, "Info", "No resource change found in this stack...")
return nil, nil
}

// return immediately if no resource found in stack
if spec == nil || len(spec.Resources) == 0 {
if o.Output != jsonOutput {
fmt.Println(pretty.GreenBold("\nNo resource found in this stack."))
}
return nil
}

Why is this needed?

It is actually valid to pass an empty spec for a preview, and Kusion should handle the preview result correctly.
This change should not affect how apply and destroy handle an empty spec.

@ruquanzhao ruquanzhao added kind/feature Categorizes issue or PR as related to a new feature help wanted Extra attention is needed good first issue Good for newcomers labels Apr 1, 2025
@7h3-3mp7y-m4n
Copy link
Contributor

hey @ruquanzhao is it okay if I take this ?

@ruquanzhao
Copy link
Collaborator Author

@7h3-3mp7y-m4n Of course! 🎉🎉🎉

@ruquanzhao
Copy link
Collaborator Author

Hi, @7h3-3mp7y-m4n Have you started this? If there are any problems, we can discuss them directly here.😀

@7h3-3mp7y-m4n
Copy link
Contributor

Hey @ruquanzhao — I've already taken a look at the issue and put together a fix. Just shared the PR with you. I'd really appreciate it if you could take a look when you get a chance!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/feature Categorizes issue or PR as related to a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants