-
Notifications
You must be signed in to change notification settings - Fork 0
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
docs: cluster scanner first commit #2
base: main
Are you sure you want to change the base?
Conversation
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.
Left you comments around style and organization, but I'm so impressed with your Go knowledge. Let me know if you want to chat about anything ❤️
Co-authored-by: Adelina Simion <[email protected]>
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.
Great work here @caroldelwing
if err != nil { | ||
return nil, err | ||
} | ||
message := fmt.Sprintf("The %s cluster named %s has been running for %s. Are you sure you need this cluster?", cluster.SpecSummary.CloudConfig.CloudType, cluster.Metadata.Name, *age) |
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.
Food for thought. Say you have lots of clusters that are past 24 hrs in age. Do you want the output to include the "Are you sure you need this cluster?" in every line?
weeks := hoursAge / hoursPerWeek | ||
remainingHours := hoursAge - weeks*hoursPerWeek | ||
days := remainingHours / 24 | ||
hours := remainingHours % 24 | ||
return &FormattedAge{ | ||
Days: days, | ||
Weeks: weeks, | ||
Hours: hours, | ||
}, nil |
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.
Clever 🤓
found := false | ||
for _, want := range value.output { | ||
if got == want { | ||
found = true |
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.
You could make the argument the assignment here plays no purpose. The reason I say that is because you immediately return, so nothing ever uses it if it's ever true
.
found = true | |
found = true |
// Iterate through the clusters to find those running for more than 24 hours | ||
for _, cluster := range clusters { | ||
timeValue := time.Time(cluster.Metadata.CreationTimestamp) | ||
clusterAge := time.Now().Sub(timeValue) |
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.
This is 100% valid - but if you want to be hip ✨, then you can use the new function released recently time.Since(t)
Describe the Change
This PR adds a tool that uses the Palette Go SDK to find clusters running for more than 24 hours.
Checklist
README updated?
Content added contains comments that explain the purpose of the script and usage.