generated from ZEISS/template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding helm update, logx, errorx
- Loading branch information
1 parent
d3bde3d
commit fe39e75
Showing
11 changed files
with
462 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// A simple package to cast between types. | ||
package cast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"log" | ||
"os" | ||
"strings" | ||
|
||
"github.com/zeiss/pkg/logx" | ||
|
||
"github.com/spf13/pflag" | ||
"golang.org/x/mod/semver" | ||
"helm.sh/helm/pkg/chartutil" | ||
) | ||
|
||
type flags struct { | ||
File string | ||
Version string | ||
} | ||
|
||
func main() { | ||
log.SetFlags(0) | ||
log.SetOutput(os.Stderr) | ||
|
||
logx.RedirectStdLog(logx.LogSink) | ||
|
||
f := &flags{} | ||
|
||
pflag.StringVar(&f.File, "file", f.File, "chart") | ||
pflag.StringVar(&f.Version, "version", f.Version, "version") | ||
pflag.Parse() | ||
|
||
f.Version = semver.Canonical(f.Version) | ||
|
||
ok := semver.IsValid(f.Version) | ||
if !ok { | ||
log.Fatal(errors.New("updater: no valid version")) | ||
} | ||
|
||
f.Version = strings.TrimPrefix(f.Version, "v") | ||
|
||
meta, err := chartutil.LoadChartfile(f.File) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
meta.AppVersion = f.Version | ||
meta.Version = f.Version | ||
|
||
err = chartutil.SaveChartfile(f.File, meta) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// A package to help with errors. | ||
package errorx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package errorx | ||
|
||
// Ignore is a helper function to ignore errors. | ||
func Ignore[T any](val T, err error) T { | ||
return val | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package errorx | ||
|
||
// Must panics if the error is not nil. | ||
func Must[T any](val T, err error) T { | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return val | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package logx | ||
|
||
// Printf .. | ||
func Printf(format string, args ...interface{}) { | ||
LogSink.Infof(format, args...) | ||
} | ||
|
||
// Debugf ... | ||
func Debugf(format string, args ...interface{}) { | ||
LogSink.Debugf(format, args...) | ||
} | ||
|
||
// Infof ... | ||
func Infof(format string, args ...interface{}) { | ||
LogSink.Infof(format, args...) | ||
} | ||
|
||
// Errorf ... | ||
func Errorf(format string, args ...interface{}) { | ||
LogSink.Errorf(format, args...) | ||
} | ||
|
||
// Warnf ... | ||
func Warnf(format string, args ...interface{}) { | ||
LogSink.Warnf(format, args...) | ||
} | ||
|
||
// Panicf ... | ||
func Panicf(format string, args ...interface{}) { | ||
LogSink.Panicf(format, args...) | ||
} | ||
|
||
// Fatalf ... | ||
func Fatalf(format string, args ...interface{}) { | ||
LogSink.Fatalf(format, args...) | ||
} | ||
|
||
// Debugw ... | ||
func Debugw(msg string, keysAndValues ...interface{}) { | ||
LogSink.Debugw(msg, keysAndValues...) | ||
} | ||
|
||
// Infow ... | ||
func Infow(msg string, keysAndValues ...interface{}) { | ||
LogSink.Infow(msg, keysAndValues...) | ||
} | ||
|
||
// Warnw ... | ||
func Warnw(msg string, keysAndValues ...interface{}) { | ||
LogSink.Warnw(msg, keysAndValues...) | ||
} | ||
|
||
// Errorw ... | ||
func Errorw(msg string, keysAndValues ...interface{}) { | ||
LogSink.Errorw(msg, keysAndValues...) | ||
} | ||
|
||
// DPanicw ... | ||
func DPanicw(msg string, keysAndValues ...interface{}) { | ||
LogSink.DPanicw(msg, keysAndValues...) | ||
} | ||
|
||
// Panicw ... | ||
func Panicw(msg string, keysAndValues ...interface{}) { | ||
LogSink.Panicw(msg, keysAndValues...) | ||
} | ||
|
||
// Fatalw ... | ||
func Fatalw(msg string, keysAndValues ...interface{}) { | ||
LogSink.Fatalw(msg, keysAndValues...) | ||
} |
Oops, something went wrong.