-
Notifications
You must be signed in to change notification settings - Fork 1
Improve deployment functionality #202
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,128 @@ | ||||||||||||||
| package horoscope | ||||||||||||||
|
|
||||||||||||||
| import ( | ||||||||||||||
| "fmt" | ||||||||||||||
| "strings" | ||||||||||||||
| "time" | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| // ZodiacSign represents an astrological zodiac sign. | ||||||||||||||
| type ZodiacSign struct { | ||||||||||||||
| Name string | ||||||||||||||
| StartDay int | ||||||||||||||
| StartMonth time.Month | ||||||||||||||
| EndDay int | ||||||||||||||
| EndMonth time.Month | ||||||||||||||
| Element string | ||||||||||||||
| Ruler string | ||||||||||||||
| Lucky int | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| var signs = []ZodiacSign{ | ||||||||||||||
| {"Aries", 21, time.March, 19, time.April, "Fire", "Mars", 9}, | ||||||||||||||
| {"Taurus", 20, time.April, 20, time.May, "Earth", "Venus", 6}, | ||||||||||||||
| {"Gemini", 21, time.May, 20, time.June, "Air", "Mercury", 5}, | ||||||||||||||
| {"Cancer", 21, time.June, 22, time.July, "Water", "Moon", 2}, | ||||||||||||||
| {"Leo", 23, time.July, 22, time.August, "Fire", "Sun", 1}, | ||||||||||||||
| {"Virgo", 23, time.August, 22, time.September, "Earth", "Mercury", 5}, | ||||||||||||||
| {"Libra", 23, time.September, 22, time.October, "Air", "Venus", 6}, | ||||||||||||||
| {"Scorpio", 23, time.October, 21, time.November, "Water", "Pluto", 8}, | ||||||||||||||
| {"Sagittarius", 22, time.November, 21, time.December, "Fire", "Jupiter", 3}, | ||||||||||||||
| {"Capricorn", 22, time.December, 19, time.January, "Earth", "Saturn", 7}, | ||||||||||||||
| {"Aquarius", 20, time.January, 18, time.February, "Air", "Uranus", 4}, | ||||||||||||||
| {"Pisces", 19, time.February, 20, time.March, "Water", "Neptune", 7}, | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| var fortunes = []string{ | ||||||||||||||
| "Your Kubernetes pods will achieve perfect harmony today.", | ||||||||||||||
| "A mysterious YAML indentation error will reveal hidden truths.", | ||||||||||||||
| "The stars suggest you should rebase before pushing.", | ||||||||||||||
| "Mercury is in retrograde — avoid force-pushing to main.", | ||||||||||||||
| "Today is an auspicious day for container orchestration.", | ||||||||||||||
| "A rogue init container will bring unexpected joy.", | ||||||||||||||
| "Your PersistentVolumeClaim will be fulfilled by the cosmos.", | ||||||||||||||
| "Beware of ConfigMaps created during a full moon.", | ||||||||||||||
| "The alignment of Jupiter and Saturn favors blue-green deployments.", | ||||||||||||||
| "An unexpected OOMKill will teach you the value of resource limits.", | ||||||||||||||
| "Your service mesh will untangle itself by Thursday.", | ||||||||||||||
| "A CrashLoopBackOff in your chart signals personal growth.", | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // ForToday returns the horoscope for today's date. | ||||||||||||||
| func ForToday() string { | ||||||||||||||
| return ForDate(time.Now()) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // ForDate returns the horoscope for a given date. | ||||||||||||||
| func ForDate(t time.Time) string { | ||||||||||||||
| sign := signForDate(t) | ||||||||||||||
| fortune := pickFortune(t, sign) | ||||||||||||||
|
|
||||||||||||||
| var b strings.Builder | ||||||||||||||
| b.WriteString(fmt.Sprintf("Your Daily ACS Horoscope (%s)\n", t.Format("January 2, 2006"))) | ||||||||||||||
| b.WriteString(strings.Repeat("*", 42) + "\n\n") | ||||||||||||||
| b.WriteString(fmt.Sprintf(" Sign: %s\n", sign.Name)) | ||||||||||||||
| b.WriteString(fmt.Sprintf(" Element: %s\n", sign.Element)) | ||||||||||||||
| b.WriteString(fmt.Sprintf(" Ruler: %s\n", sign.Ruler)) | ||||||||||||||
| b.WriteString(fmt.Sprintf(" Lucky #: %d\n\n", sign.Lucky)) | ||||||||||||||
| b.WriteString(fmt.Sprintf(" %s\n\n", fortune)) | ||||||||||||||
| b.WriteString(cosmicAdvice(sign)) | ||||||||||||||
| return b.String() | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| func signForDate(t time.Time) ZodiacSign { | ||||||||||||||
| day := t.Day() | ||||||||||||||
| month := t.Month() | ||||||||||||||
| for _, s := range signs { | ||||||||||||||
| if month == s.StartMonth && day >= s.StartDay { | ||||||||||||||
| return s | ||||||||||||||
| } | ||||||||||||||
| if month == s.EndMonth && day <= s.EndDay { | ||||||||||||||
| return s | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| return signs[9] | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| func pickFortune(t time.Time, sign ZodiacSign) string { | ||||||||||||||
| idx := (t.YearDay() + sign.Lucky) % len(fortunes) | ||||||||||||||
| return fortunes[idx] | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| func cosmicAdvice(sign ZodiacSign) string { | ||||||||||||||
| var b strings.Builder | ||||||||||||||
| b.WriteString(" Cosmic Deployment Advice:\n") | ||||||||||||||
| switch sign.Element { | ||||||||||||||
| case "Fire": | ||||||||||||||
| b.WriteString(" Deploy boldly. Scale horizontally. Ignore the linter.\n") | ||||||||||||||
| case "Earth": | ||||||||||||||
| b.WriteString(" Pin your image tags. Rotate your secrets. Trust the operator.\n") | ||||||||||||||
| case "Air": | ||||||||||||||
| b.WriteString(" Let your microservices breathe. Embrace eventual consistency.\n") | ||||||||||||||
| case "Water": | ||||||||||||||
| b.WriteString(" Go with the flow of GitOps. Let ArgoCD guide your path.\n") | ||||||||||||||
| } | ||||||||||||||
| b.WriteString(fmt.Sprintf("\n Auspicious namespaces: %s\n", auspiciousNamespace(sign))) | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix staticcheck violation blocking the pipeline. Same issue as in 🔧 Proposed fix case "Water":
b.WriteString(" Go with the flow of GitOps. Let ArgoCD guide your path.\n")
}
- b.WriteString(fmt.Sprintf("\n Auspicious namespaces: %s\n", auspiciousNamespace(sign)))
+ fmt.Fprintf(&b, "\n Auspicious namespaces: %s\n", auspiciousNamespace(sign))
return b.String()As per static analysis hints, staticcheck reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)). 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: Code Quality Checks[failure] 105-105: 🤖 Prompt for AI Agents |
||||||||||||||
| return b.String() | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| func auspiciousNamespace(sign ZodiacSign) string { | ||||||||||||||
| namespaces := map[string]string{ | ||||||||||||||
| "Aries": "stackrox-blaze", | ||||||||||||||
| "Taurus": "stackrox-steady", | ||||||||||||||
| "Gemini": "stackrox-twin-a, stackrox-twin-b", | ||||||||||||||
| "Cancer": "stackrox-sanctuary", | ||||||||||||||
| "Leo": "stackrox-royal", | ||||||||||||||
| "Virgo": "stackrox-pristine", | ||||||||||||||
| "Libra": "stackrox-balanced", | ||||||||||||||
| "Scorpio": "stackrox-shadow", | ||||||||||||||
| "Sagittarius": "stackrox-adventure", | ||||||||||||||
| "Capricorn": "stackrox-summit", | ||||||||||||||
| "Aquarius": "stackrox-innovation", | ||||||||||||||
| "Pisces": "stackrox-drift", | ||||||||||||||
| } | ||||||||||||||
| if ns, ok := namespaces[sign.Name]; ok { | ||||||||||||||
| return ns | ||||||||||||||
| } | ||||||||||||||
| return "stackrox-unknown" | ||||||||||||||
| } | ||||||||||||||
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.
Fix staticcheck violations blocking the pipeline.
The code uses
b.WriteString(fmt.Sprintf(...))which is inefficient and causes pipeline failures.strings.Builderimplementsio.Writer, so usefmt.Fprintfdirectly.🔧 Proposed fix to use fmt.Fprintf
As per static analysis hints, staticcheck reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)).
Also applies to: 64-68
🧰 Tools
🪛 GitHub Actions: Code Quality / 0_Code Quality Checks.txt
[error] 62-62: golangci-lint (staticcheck) reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)).
🪛 GitHub Actions: Code Quality / Code Quality Checks
[error] 62-62: golangci-lint (staticcheck) reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...))
🪛 GitHub Check: Code Quality Checks
[failure] 62-62:
QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
🤖 Prompt for AI Agents