Skip to content
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

feat(configuration): add initial support for Viper command initialization #607

Merged
merged 16 commits into from
Aug 26, 2024

Conversation

brandtkeller
Copy link
Member

Description

Adds initial command support for viper configuration integrated with commands for initializing viper and detecting configuration file and environment variables.

Related Issue

Resolves #596

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

@brandtkeller brandtkeller changed the title 596 baseline viper feat(configuration): Add initial support for Viper command initialization Aug 18, 2024
@brandtkeller brandtkeller changed the title feat(configuration): Add initial support for Viper command initialization feat(configuration): add initial support for Viper command initialization Aug 18, 2024
@brandtkeller brandtkeller marked this pull request as ready for review August 18, 2024 13:46
Copy link
Collaborator

@meganwolf0 meganwolf0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a PersistentPreRun in many of the commands that override the rootCmd version -> specifically the dev ones, I see the viper config enabled there but due to this it doesn't seem to be reading the config data. Locally I removed PersistentPreRun from each of the dev commands and updated the parent devCmd as follows:

var devCmd = &cobra.Command{
	Use:   "dev",
	Short: "Collection of dev commands to make dev life easier",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		// Call the parent's PersistentPreRun
		if parentPreRun := cmd.Parent().PersistentPreRun; parentPreRun != nil {
			parentPreRun(cmd.Parent(), args)
		}
		config.SkipLogFile = true
	},
}

I think this should solve it - the tools cmds also have this prerun, not sure if we want to update those as well/what the intended config recognition is there

(edit - happy to commit that fix ^^ if you agree, but refrained if there's more discussion needed, I might be missing something as well)

src/cmd/common/viper.go Outdated Show resolved Hide resolved
@brandtkeller brandtkeller marked this pull request as draft August 19, 2024 18:00
brandtkeller and others added 2 commits August 19, 2024 20:08
Co-authored-by: Megan Wolf <97549300+meganwolf0@users.noreply.github.com>
@brandtkeller
Copy link
Member Author

@meganwolf0 ended up coming full circle with a slight modification of your proposed solution.

Optimally I wanted to have the inheritance of the PersistentPreRun as much as possible - which does function when you change the child commands to from PersistentPreRun to PreRun. Problem here then become the sequence of operations -> root would call SetupCLI() which logged it's use of a log file before the child/grandchild commands switched the logging file off.

Given we don't have much complexity baked into our command pre-runs this seems adequate for solving the problem on the two dev and tools commands. If we ever define the need we can simply move the PersistentPreRun down one level and re-think sequence.

@brandtkeller brandtkeller marked this pull request as ready for review August 19, 2024 21:51
@brandtkeller brandtkeller requested a review from a team as a code owner August 19, 2024 21:51
src/cmd/dev/common.go Outdated Show resolved Hide resolved
meganwolf0
meganwolf0 previously approved these changes Aug 20, 2024
@brandtkeller brandtkeller merged commit 2c94c83 into main Aug 26, 2024
4 checks passed
@brandtkeller brandtkeller deleted the 596_baseline_viper branch August 26, 2024 19:27
This was referenced Aug 26, 2024
mjnagel referenced this pull request in defenseunicorns/uds-core Aug 31, 2024
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence | Type |
Update |
|---|---|---|---|---|---|---|---|
| [@commitlint/cli](https://commitlint.js.org/)
([source](https://togithub.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/cli))
| `19.3.0` -> `19.4.1` |
[![age](https://developer.mend.io/api/mc/badges/age/npm/@commitlint%2fcli/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@commitlint%2fcli/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@commitlint%2fcli/19.3.0/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@commitlint%2fcli/19.3.0/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| | minor |
| [@commitlint/config-conventional](https://commitlint.js.org/)
([source](https://togithub.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional))
| `19.2.2` -> `19.4.1` |
[![age](https://developer.mend.io/api/mc/badges/age/npm/@commitlint%2fconfig-conventional/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@commitlint%2fconfig-conventional/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@commitlint%2fconfig-conventional/19.2.2/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@commitlint%2fconfig-conventional/19.2.2/19.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| | minor |
|
[actions/upload-artifact](https://togithub.com/actions/upload-artifact)
| `v4.3.4` -> `v4.4.0` |
[![age](https://developer.mend.io/api/mc/badges/age/github-tags/actions%2fupload-artifact/v4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/github-tags/actions%2fupload-artifact/v4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/github-tags/actions%2fupload-artifact/v4.3.4/v4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/github-tags/actions%2fupload-artifact/v4.3.4/v4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| action | minor |
| [defenseunicorns/lula](https://togithub.com/defenseunicorns/lula) |
`v0.5.1` -> `v0.6.0` |
[![age](https://developer.mend.io/api/mc/badges/age/github-tags/defenseunicorns%2flula/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/github-tags/defenseunicorns%2flula/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/github-tags/defenseunicorns%2flula/v0.5.1/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/github-tags/defenseunicorns%2flula/v0.5.1/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| | minor |
|
[opentofu/setup-opentofu](https://togithub.com/opentofu/setup-opentofu)
| `v1.0.3` -> `v1.0.4` |
[![age](https://developer.mend.io/api/mc/badges/age/github-tags/opentofu%2fsetup-opentofu/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/github-tags/opentofu%2fsetup-opentofu/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/github-tags/opentofu%2fsetup-opentofu/v1.0.3/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/github-tags/opentofu%2fsetup-opentofu/v1.0.3/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| action | patch |

---

### Release Notes

<details>
<summary>conventional-changelog/commitlint
(@&#8203;commitlint/cli)</summary>

###
[`v19.4.1`](https://togithub.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/cli/CHANGELOG.md#1941-2024-08-28)

[Compare
Source](https://togithub.com/conventional-changelog/commitlint/compare/v19.4.0...v19.4.1)

**Note:** Version bump only for package
[@&#8203;commitlint/cli](https://togithub.com/commitlint/cli)

###
[`v19.4.0`](https://togithub.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/cli/CHANGELOG.md#1940-2024-08-07)

[Compare
Source](https://togithub.com/conventional-changelog/commitlint/compare/v19.3.0...v19.4.0)

##### Features

- support command line options from a file
([#&#8203;4109](https://togithub.com/conventional-changelog/commitlint/issues/4109))
([a20e890](https://togithub.com/conventional-changelog/commitlint/commit/a20e890f6b6c8bacdc511d40cb41f29415bdd044))
- support linting from the last tag
([#&#8203;4110](https://togithub.com/conventional-changelog/commitlint/issues/4110))
([4b204ec](https://togithub.com/conventional-changelog/commitlint/commit/4b204ecfb43dd6a00e24b51111aadbd78f9d58e1))

</details>

<details>
<summary>conventional-changelog/commitlint
(@&#8203;commitlint/config-conventional)</summary>

###
[`v19.4.1`](https://togithub.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/config-conventional/CHANGELOG.md#1941-2024-08-28)

[Compare
Source](https://togithub.com/conventional-changelog/commitlint/compare/v19.2.2...v19.4.1)

**Note:** Version bump only for package
[@&#8203;commitlint/config-conventional](https://togithub.com/commitlint/config-conventional)

</details>

<details>
<summary>actions/upload-artifact (actions/upload-artifact)</summary>

###
[`v4.4.0`](https://togithub.com/actions/upload-artifact/compare/v4.3.6...v4.4.0)

[Compare
Source](https://togithub.com/actions/upload-artifact/compare/v4.3.6...v4.4.0)

###
[`v4.3.6`](https://togithub.com/actions/upload-artifact/compare/v4.3.5...v4.3.6)

[Compare
Source](https://togithub.com/actions/upload-artifact/compare/v4.3.5...v4.3.6)

###
[`v4.3.5`](https://togithub.com/actions/upload-artifact/compare/v4.3.4...v4.3.5)

[Compare
Source](https://togithub.com/actions/upload-artifact/compare/v4.3.4...v4.3.5)

</details>

<details>
<summary>defenseunicorns/lula (defenseunicorns/lula)</summary>

###
[`v0.6.0`](https://togithub.com/defenseunicorns/lula/releases/tag/v0.6.0)

[Compare
Source](https://togithub.com/defenseunicorns/lula/compare/v0.5.1...v0.6.0)

This release is an exciting advance for Lula and the OSCAL ecosystem. It
includes initial development release of the Terminal User Interface that
can be accessed via `lula console`. Given a specified OSCAL file -> Lula
will now open a TUI in the appropriate OSCAL model format with some
opinionation currently on what is visualized.

Other features include a new viper integration baseline - setting the
stage for future configuration and environment variable driven
operations that enhance the assessment and authoring processes.

A bug fix was included in this release to ensure that any modification
to component definition models updates the `uuid` accordingly -> in
alignment with the model specification.

##### Features

- **configuration:** add initial support for Viper command
initialization
([#&#8203;607](https://togithub.com/defenseunicorns/lula/issues/607))
([2c94c83](https://togithub.com/defenseunicorns/lula/commit/2c94c8312233a40a536d0f98ca513e2bbe8bf720))
- **console:** initial tui for component-definition read
([#&#8203;608](https://togithub.com/defenseunicorns/lula/issues/608))
([a0338af](https://togithub.com/defenseunicorns/lula/commit/a0338affd4934c5100ffc280b6fac016b9eb0b91))

##### Bug Fixes

- **oscal:** ensure component definition UUID is updated on modification
([#&#8203;615](https://togithub.com/defenseunicorns/lula/issues/615))
([5516482](https://togithub.com/defenseunicorns/lula/commit/55164824f9f16c0c76c3a068d68c42aae80bd0f3))

##### Miscellaneous

- **deps:** update anchore/sbom-action action to v0.17.2
([#&#8203;613](https://togithub.com/defenseunicorns/lula/issues/613))
([4fb9090](https://togithub.com/defenseunicorns/lula/commit/4fb909046e769cacf528c88fd46d957c804affd2))
- **deps:** update commitlint monorepo to v19.4.1
([#&#8203;619](https://togithub.com/defenseunicorns/lula/issues/619))
([0adb2d0](https://togithub.com/defenseunicorns/lula/commit/0adb2d0093b035f60af8794722a354128bbc2446))
- **deps:** update github/codeql-action action to v3.26.2
([#&#8203;600](https://togithub.com/defenseunicorns/lula/issues/600))
([6601566](https://togithub.com/defenseunicorns/lula/commit/66015662002d17a7c3182f0c5d4565a50ece8093))
- **deps:** update github/codeql-action action to v3.26.4
([#&#8203;611](https://togithub.com/defenseunicorns/lula/issues/611))
([dd592ce](https://togithub.com/defenseunicorns/lula/commit/dd592ceabc834eeb0a453bc8a0a78b04b4576bfb))
- **deps:** update github/codeql-action action to v3.26.5
([#&#8203;616](https://togithub.com/defenseunicorns/lula/issues/616))
([aa4e122](https://togithub.com/defenseunicorns/lula/commit/aa4e1220c725002e448707f00c456dd09161254e))
- **deps:** update github/codeql-action action to v3.26.6
([#&#8203;626](https://togithub.com/defenseunicorns/lula/issues/626))
([488cd91](https://togithub.com/defenseunicorns/lula/commit/488cd915f7801dddd427edf56bb8effd2d3bbc92))
- **deps:** update kubernetes packages to v0.31.0
([#&#8203;594](https://togithub.com/defenseunicorns/lula/issues/594))
([6dd7463](https://togithub.com/defenseunicorns/lula/commit/6dd7463c724c91f3ec34ddca87605481bdd8356f))
- **deps:** update module github.com/open-policy-agent/opa to v0.68.0
([#&#8203;628](https://togithub.com/defenseunicorns/lula/issues/628))
([914b1f2](https://togithub.com/defenseunicorns/lula/commit/914b1f2717dd30d6c8b2c878da0ec1582e7b047c))
- **deps:** update module github.com/spf13/viper to v1.19.0
([#&#8203;618](https://togithub.com/defenseunicorns/lula/issues/618))
([22fd668](https://togithub.com/defenseunicorns/lula/commit/22fd668d81923f1f098c919d0472637aa63bb451))
- **docs:** add docs generation command
([#&#8203;606](https://togithub.com/defenseunicorns/lula/issues/606))
([4dd0450](https://togithub.com/defenseunicorns/lula/commit/4dd0450fa5f91cf4d1b3dceee52bde8f47f50935))
- **docs:** adding 2024 roadmap to the project documentation
([#&#8203;320](https://togithub.com/defenseunicorns/lula/issues/320))
([120d15a](https://togithub.com/defenseunicorns/lula/commit/120d15a77dbcdc553c117245d392d4dcc3238066))
- **docs:** update CODEOWNERS
([#&#8203;636](https://togithub.com/defenseunicorns/lula/issues/636))
([77e60fe](https://togithub.com/defenseunicorns/lula/commit/77e60fe6ecf13e71acc035139904e1c9aa7ab3b4))

#### What's Changed

- chore(deps): update github/codeql-action action to v3.26.2 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/600](https://togithub.com/defenseunicorns/lula/pull/600)
- refactor(tests): 586 refactor unhappy path e2e tests by
[@&#8203;meganwolf0](https://togithub.com/meganwolf0) in
[https://github.com/defenseunicorns/lula/pull/598](https://togithub.com/defenseunicorns/lula/pull/598)
- docs: adding 2024 roadmap to the project documentation by
[@&#8203;brandtkeller](https://togithub.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/320](https://togithub.com/defenseunicorns/lula/pull/320)
- chore(deps): update anchore/sbom-action action to v0.17.2 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/613](https://togithub.com/defenseunicorns/lula/pull/613)
- chore(deps): update github/codeql-action action to v3.26.4 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/611](https://togithub.com/defenseunicorns/lula/pull/611)
- chore(deps): update github/codeql-action action to v3.26.5 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/616](https://togithub.com/defenseunicorns/lula/pull/616)
- feat(configuration): add initial support for Viper command
initialization by
[@&#8203;brandtkeller](https://togithub.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/607](https://togithub.com/defenseunicorns/lula/pull/607)
- chore(deps): update module github.com/spf13/viper to v1.19.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/618](https://togithub.com/defenseunicorns/lula/pull/618)
- chore(docs): add docs generation command by
[@&#8203;brandtkeller](https://togithub.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/606](https://togithub.com/defenseunicorns/lula/pull/606)
- chore(deps): update commitlint monorepo to v19.4.1 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/619](https://togithub.com/defenseunicorns/lula/pull/619)
- chore(deps): update module github.com/open-policy-agent/opa to v0.68.0
by [@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/628](https://togithub.com/defenseunicorns/lula/pull/628)
- chore(deps): update github/codeql-action action to v3.26.6 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/626](https://togithub.com/defenseunicorns/lula/pull/626)
- feat(console): initial tui for component-defn read by
[@&#8203;meganwolf0](https://togithub.com/meganwolf0) in
[https://github.com/defenseunicorns/lula/pull/608](https://togithub.com/defenseunicorns/lula/pull/608)
- fix(oscal): ensure component definition UUID is updated on
modification by
[@&#8203;brandtkeller](https://togithub.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/615](https://togithub.com/defenseunicorns/lula/pull/615)
- chore(deps): update kubernetes packages to v0.31.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/594](https://togithub.com/defenseunicorns/lula/pull/594)
- feat: update CODEOWNERS by
[@&#8203;daveworth](https://togithub.com/daveworth) in
[https://github.com/defenseunicorns/lula/pull/636](https://togithub.com/defenseunicorns/lula/pull/636)
- chore(main): release 0.6.0 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[https://github.com/defenseunicorns/lula/pull/604](https://togithub.com/defenseunicorns/lula/pull/604)

#### New Contributors

- [@&#8203;daveworth](https://togithub.com/daveworth) made their first
contribution in
[https://github.com/defenseunicorns/lula/pull/636](https://togithub.com/defenseunicorns/lula/pull/636)

**Full Changelog**:
defenseunicorns/lula@v0.5.1...v0.6.0

</details>

<details>
<summary>opentofu/setup-opentofu (opentofu/setup-opentofu)</summary>

###
[`v1.0.4`](https://togithub.com/opentofu/setup-opentofu/releases/tag/v1.0.4)

[Compare
Source](https://togithub.com/opentofu/setup-opentofu/compare/v1.0.3...v1.0.4)

#### What's Changed

- Fix tofu output printing debug information by
[@&#8203;VladMasarik](https://togithub.com/VladMasarik) in
[https://github.com/opentofu/setup-opentofu/pull/31](https://togithub.com/opentofu/setup-opentofu/pull/31)

#### New Contributors

- [@&#8203;VladMasarik](https://togithub.com/VladMasarik) made their
first contribution in
[https://github.com/opentofu/setup-opentofu/pull/31](https://togithub.com/opentofu/setup-opentofu/pull/31)

**Full Changelog**:
opentofu/setup-opentofu@v1...v1.0.4

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/defenseunicorns/uds-core).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM4LjU2LjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Viper support - baseline
2 participants