-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefactoring before adding metrics support.
- change deploy tool to use the flag package where appropriate rather than positional arguments for everything, as they would become a mess when another is added, - rename daemonSetTemplate to deploymentTemplate as it already contains more than the daemonset, and will continue to grow soon, - rename some variables to mention CRI to make room for an upcoming non-cri client/connection, - extract a logging package, to be used in upcoming subcommand, - in README and GHA workflow, correct deploy tool usage - in README, mention daemonset in individual commands,
- Loading branch information
Showing
7 changed files
with
103 additions
and
38 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 |
---|---|---|
|
@@ -45,10 +45,10 @@ jobs: | |
- name: Prepare manifests for linting | ||
run: | | ||
mkdir manifests | ||
go run deploy/main.go my-images v0.0.8 vanilla > manifests/vanilla.yaml | ||
go run deploy/main.go my-images v0.0.8 ocp > manifests/ocp.yaml | ||
go run deploy/main.go my-images v0.0.8 vanilla my-secret > manifests/vanilla-with-secret.yaml | ||
go run deploy/main.go my-images v0.0.8 ocp my-secret > manifests/ocp-with-secret.yaml | ||
go run deploy/*.go --k8s-flavor vanilla my-images > manifests/vanilla.yaml | ||
go run deploy/*.go --k8s-flavor ocp my-images > manifests/ocp.yaml | ||
go run deploy/*.go --k8s-flavor vanilla --secret my-secret my-images > manifests/vanilla-with-secret.yaml | ||
go run deploy/*.go --k8s-flavor ocp --secret my-secret my-images > manifests/ocp-with-secret.yaml | ||
- name: kube-linter | ||
uses: stackrox/[email protected] | ||
|
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,29 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"slices" | ||
) | ||
|
||
type k8sFlavorType string | ||
|
||
func (k *k8sFlavorType) UnmarshalText(text []byte) error { | ||
if slices.Contains(allFlavors, string(text)) { | ||
*k = k8sFlavorType(text) | ||
return nil | ||
} | ||
return fmt.Errorf("unknown k8s flavor %q", text) | ||
} | ||
|
||
func (k *k8sFlavorType) MarshalText() (text []byte, err error) { | ||
return []byte(*k), nil | ||
} | ||
|
||
func flavor(flavor string) *k8sFlavorType { | ||
var f k8sFlavorType | ||
if err := f.UnmarshalText([]byte(flavor)); err != nil { | ||
log.Fatal(err) | ||
} | ||
return &f | ||
} |
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,22 @@ | ||
package logging | ||
|
||
import ( | ||
"log/slog" | ||
"os" | ||
|
||
"github.com/spf13/pflag" | ||
) | ||
|
||
var debug bool | ||
|
||
func GetLogger() *slog.Logger { | ||
opts := &slog.HandlerOptions{AddSource: true} | ||
if debug { | ||
opts.Level = slog.LevelDebug | ||
} | ||
return slog.New(slog.NewTextHandler(os.Stderr, opts)) | ||
} | ||
|
||
func AddFlags(flags *pflag.FlagSet) { | ||
flags.BoolVar(&debug, "debug", false, "Whether to enable debug logging.") | ||
} |
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