Resolve misc issues#40
Merged
Merged
Conversation
The --kustomize/-k flag was defined on rootCmd but never read via
GetString("kustomize") anywhere in the codebase. Removing it avoids
confusing help output and frees up the -k shorthand for future use.
Closes #28
These methods masqueraded as runtime.Object accessors but the type does not implement that interface, and GetName always returned "". Readers could be misled into thinking GenesisSecret carried an identity; the empty-string GetName would silently break any caller that trusted it. No production code referenced either method. Closes #33
check uniquely piped the runner logger to io.Discard, so --log-level silently had no effect and any validation diagnostics from the runner were swallowed. Match the apply/build/destroy pattern: parse --log-level and write structured logs to stderr. Closes #31
Tazuna lacked TypeMeta fields, so 'apiVersion: totally.wrong/v999' and 'kind: NotTazuna' parsed cleanly and 'tazuna check' returned ok. Add APIVersion/Kind to the schema with omitempty, define the expected values as constants, and have the validator reject mismatches when they are set. Empty values stay accepted for backward compatibility with tazuna.yaml files written before this field existed. Closes #25
Every subcommand opened tazuna.yaml with the same defer pattern, but the close branch overwrote any error already accumulated by Decode or later steps. A spurious 'file already closed' on shutdown would silently mask the real YAML parse or runtime failure, making bugs much harder to diagnose. Wrap with errors.Join so both errors survive. Closes #26
…anifests Apply and friends receive Tazuna by value, but the slice header still shares its backing array with the caller. ConvertManifestPathFromCwd indexed into that shared array, so feeding the same Tazuna into a runner twice prefixed baseDir twice and produced baseDir/baseDir/<path>. Allocate a fresh slice and mutate the copy, leaving the caller's input untouched. Add tests that pin both invariants. Closes #30
CommandClient's three op invocations accepted ctx but called exec.Command, and getGitCommitHash had no ctx at all. Both would ignore tazuna's cancellation: Ctrl-C left op processes orphaned and the git rev-parse could not be timed out. Switch to exec.CommandContext and thread ctx through getGitCommitHash and its StateSync caller. Closes #27
Identifiers passed to the 1Password CLI now pass through ValidateIdentifier, which restricts them to `[A-Za-z0-9_.\- ]+`. This turns unusual inputs (control characters, shell metacharacters, etc.) into an early, recognisable error instead of an opaque failure from op. Closes #36
Each subcommand was re-parsing --log-level, building a slog logger, opening tazuna.yaml with a defer-close dance, and standing up a controller-runtime client by hand. The duplication made adding a subcommand noisy and meant cross-cutting changes (e.g. how Close errors join the return value) had to be repeated everywhere. Introduce cmd/internal/cliutil with ParseLogLevel, NewLogger, LoadTazunaYAML, and NewK8sClient, and route every subcommand's RunE through them so each body focuses on its own orchestration. Closes #29
cmd/ only had oras_flags_test.go, so RunE bodies and flag wiring (defaults, required, exclusion, subcommand registration) were untested. Adds three small files modelled on oras_flags_test.go: - flags_test.go covers root persistent flags, per-subcommand flag defaults, the required marker on --op-host, and subcommand registration on rootCmd / stateCmd. - check_test.go drives checkCmd.RunE end-to-end with a temp tazuna.yaml, covering success, missing file, invalid YAML, validation failure, and --fix writing the file back. - tags_test.go drives tagsCmd.RunE the same way for success / validation failure / missing file. Closes #37
apply / destroy / build each redeclared `--tags / -t` inline with slightly different help text and a 3-line getter, while the `tags` subcommand had no --tags at all even though "show me only these tags" is the obvious UX. Add cmd/tags_flag.go with addTagsFlag(cmd, usage) and getTags(cmd) so the flag's name, shorthand, default, and reader live in one place, and register it on the four subcommands. `tazuna tags --tags X,Y` now restricts the listing; output keys are also sorted for stable display. Closes #34
Tazuna had both yaml.v3 and sigs.k8s.io/yaml as direct dependencies: yaml.v3 decoded the Tazuna / GenesisSecret CRs (via `yaml:` struct tags), while sigs.k8s.io/yaml was used only to marshal the corev1.Secret that GenesisSecret.Build produces. Maintaining both parsers means every api/v1 struct needs synchronised `yaml:` and `json:` tags, and divergent parser behaviour (already pulled in transitively via goccy/go-yaml, ghodss/yaml, etc.) can produce hard-to-repro bugs. Unify on sigs.k8s.io/yaml: - Replace `yaml:` tags with `json:` tags across api/v1, fixing the pre-existing mismatch on TazunaHint where YAML wrote `apiVersion` but JSON wrote `APIVersion`. Update the FormatJSON test accordingly. - Swap `gopkg.in/yaml.v3` imports for `sigs.k8s.io/yaml` in cmd/, pkg/ source files, and (//go:build integration) test files. The streaming decoder pattern (Open → NewDecoder.Decode → defer Close) becomes ReadFile → Unmarshal since kyaml has no Decoder type. - `go mod tidy` demotes yaml.v3 to an indirect dependency pulled by upstream packages — Tazuna no longer pins it. Closes #32
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 概要
Changes / 変更点
Test plan / 動作確認
make testmake lintmake test-integration(if relevant / 関連する場合)make test-e2e(if relevant / 関連する場合)Related issues / 関連 issue