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: yaml map injection #568

Merged
merged 9 commits into from
Sep 3, 2024
Merged

Conversation

meganwolf0
Copy link
Collaborator

@meganwolf0 meganwolf0 commented Jul 28, 2024

Description

Generic library function to inject a "subset" map into a "target" map. Merging supports appending lists instead of replacing them, as it was assumed that appending to an existing list would be more appropriate but replacement could be supported if we wanted to as well.

Updated to add OSCAL map merge as well to paint a broader picture of the intended use case

Related Issue

Fixes #567

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

@meganwolf0 meganwolf0 marked this pull request as ready for review July 28, 2024 18:50
@brandtkeller
Copy link
Member

Tests helped provide some basic insights into intent.

Thinking about where we might be able to put this into use - I imagine, as discussed previously, that this would be for common config merging into OSCAL models. From a sequence perspective -> we have an OSCAL model + some config -> we read the model and config into maps -> perform the injection -> convert to bytes and then marshall to oscal model?

Given the map parameters I imagine we can support json in an intended workflow?

@meganwolf0
Copy link
Collaborator Author

Thinking about where we might be able to put this into use - I imagine, as discussed previously, that this would be for common config merging into OSCAL models. From a sequence perspective -> we have an OSCAL model + some config -> we read the model and config into maps -> perform the injection -> convert to bytes and then marshall to oscal model?

Yep, that's exactly what I was thinking!

Given the map parameters I imagine we can support json in an intended workflow?

Also, yep JSON should work

@meganwolf0 meganwolf0 marked this pull request as draft August 6, 2024 19:46
@meganwolf0 meganwolf0 mentioned this pull request Aug 7, 2024
6 tasks
@meganwolf0 meganwolf0 marked this pull request as ready for review August 27, 2024 12:48
@meganwolf0 meganwolf0 requested a review from a team as a code owner August 27, 2024 12:48
brandtkeller
brandtkeller previously approved these changes Aug 28, 2024
Copy link
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

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

Created #624 to track future implementation of this functionality. Does not necessarily require the templating decisions given this is separate scope and the viper configuration is already present.

@brandtkeller brandtkeller dismissed their stale review August 28, 2024 20:47

Dismiss to discuss package naming and location further

Copy link
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

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

determine package naming and evaluate placement in src/internal for lula internal use only.

@meganwolf0
Copy link
Collaborator Author

determine package naming and evaluate placement in src/internal for lula internal use only.

changed package name to inject, moved to internal. Also happy to call merge if we think inject doesn't make a ton of sense... there's just a lot of "merges" out there

@brandtkeller brandtkeller merged commit 3babbc8 into main Sep 3, 2024
4 checks passed
@brandtkeller brandtkeller deleted the 567-generic-yaml-merge-functionality branch September 3, 2024 22:14
mjnagel referenced this pull request in defenseunicorns/uds-core Sep 16, 2024
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence | Update |
|---|---|---|---|---|---|---|
| [@commitlint/cli](https://commitlint.js.org/)
([source](https://redirect.github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/cli))
| `19.4.1` -> `19.5.0` |
[![age](https://developer.mend.io/api/mc/badges/age/npm/@commitlint%2fcli/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@commitlint%2fcli/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@commitlint%2fcli/19.4.1/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@commitlint%2fcli/19.4.1/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| minor |
| [@commitlint/config-conventional](https://commitlint.js.org/)
([source](https://redirect.github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional))
| `19.4.1` -> `19.5.0` |
[![age](https://developer.mend.io/api/mc/badges/age/npm/@commitlint%2fconfig-conventional/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@commitlint%2fconfig-conventional/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@commitlint%2fconfig-conventional/19.4.1/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@commitlint%2fconfig-conventional/19.4.1/19.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| minor |
|
[defenseunicorns/lula](https://redirect.github.com/defenseunicorns/lula)
| `v0.6.0` -> `v0.7.0` |
[![age](https://developer.mend.io/api/mc/badges/age/github-tags/defenseunicorns%2flula/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/github-tags/defenseunicorns%2flula/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/github-tags/defenseunicorns%2flula/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/github-tags/defenseunicorns%2flula/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| minor |

---

### Release Notes

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

###
[`v19.5.0`](https://redirect.github.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/cli/CHANGELOG.md#1950-2024-09-11)

[Compare
Source](https://redirect.github.com/conventional-changelog/commitlint/compare/v19.4.1...v19.5.0)

##### Features

- **cli:** use special errorCode for missing rules/config
[#&#8203;4142](https://redirect.github.com/conventional-changelog/commitlint/issues/4142)
([#&#8203;4143](https://redirect.github.com/conventional-changelog/commitlint/issues/4143))
([d7070d8](https://redirect.github.com/conventional-changelog/commitlint/commit/d7070d8a4905da7834a018825b37d52c2dd29f62))

####
[19.4.1](https://redirect.github.com/conventional-changelog/commitlint/compare/v19.4.0...v19.4.1)
(2024-08-28)

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

</details>

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

###
[`v19.5.0`](https://redirect.github.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/config-conventional/CHANGELOG.md#1950-2024-09-11)

[Compare
Source](https://redirect.github.com/conventional-changelog/commitlint/compare/v19.4.1...v19.5.0)

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

####
[19.4.1](https://redirect.github.com/conventional-changelog/commitlint/compare/v19.4.0...v19.4.1)
(2024-08-28)

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

####
[19.2.2](https://redirect.github.com/conventional-changelog/commitlint/compare/v19.2.1...v19.2.2)
(2024-04-14)

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

</details>

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

###
[`v0.7.0`](https://redirect.github.com/defenseunicorns/lula/releases/tag/v0.7.0)

[Compare
Source](https://redirect.github.com/defenseunicorns/lula/compare/v0.6.0...v0.7.0)

This release includes a new lula tools template command for generically
templating your oscal/validations/any file of your choice using go
templating syntax. It also includes greater support for some of the root
level configurations that you might want to set via configuration file
such as target or summary.

It also includes some additional testing and internal improvements to
the lula test/docs/release process.

##### Features

- **config:** support for target/summary in lula config
([#&#8203;640](https://redirect.github.com/defenseunicorns/lula/issues/640))
([28ce6e5](https://redirect.github.com/defenseunicorns/lula/commit/28ce6e57b8ce9490e6c39f9c0f6c6c8df77a5a74))
- **template:** template command with initial docs
([#&#8203;644](https://redirect.github.com/defenseunicorns/lula/issues/644))
([89be460](https://redirect.github.com/defenseunicorns/lula/commit/89be4609caa7fcd1e39036d12a67b0c7a72ea97f))
- yaml map injection
([#&#8203;568](https://redirect.github.com/defenseunicorns/lula/issues/568))
([3babbc8](https://redirect.github.com/defenseunicorns/lula/commit/3babbc8c41047c27b5586744e4f3f5f1c19ff1ce))

##### Bug Fixes

- **console:** console testing
([#&#8203;629](https://redirect.github.com/defenseunicorns/lula/issues/629))
([78e4ae9](https://redirect.github.com/defenseunicorns/lula/commit/78e4ae9f930c0ef9b47f65bea1c2a54906717ae3))
- **gen-cli-docs:** fix path for gen-cli-docs
([#&#8203;646](https://redirect.github.com/defenseunicorns/lula/issues/646))
([6ec6e6f](https://redirect.github.com/defenseunicorns/lula/commit/6ec6e6fb39d7d22366847b781891d0141f069331))
- **test:** decouple unit from e2e test workflows
([#&#8203;662](https://redirect.github.com/defenseunicorns/lula/issues/662))
([a4097a1](https://redirect.github.com/defenseunicorns/lula/commit/a4097a1fbc2e01a0feb37f368fc126b0de7f5e2e))

##### Miscellaneous

- **deps:** update actions/github-script digest to
[`58d7008`](https://redirect.github.com/defenseunicorns/lula/commit/58d7008)
([#&#8203;660](https://redirect.github.com/defenseunicorns/lula/issues/660))
([642cfa3](https://redirect.github.com/defenseunicorns/lula/commit/642cfa3474848297481a58969717c41cbf53dc42))
- **deps:** update actions/upload-artifact action to v4.4.0
([#&#8203;635](https://redirect.github.com/defenseunicorns/lula/issues/635))
([b342f63](https://redirect.github.com/defenseunicorns/lula/commit/b342f63c06be37ff2dda332bc83bc561b22f054f))
- **deps:** update commitlint monorepo to v19.5.0
([#&#8203;656](https://redirect.github.com/defenseunicorns/lula/issues/656))
([031b524](https://redirect.github.com/defenseunicorns/lula/commit/031b5245848c393f4e6d40cbd749e6b3e3fd01f3))
- **deps:** update github.com/charmbracelet/x/exp/teatest digest to
[`162f303`](https://redirect.github.com/defenseunicorns/lula/commit/162f303)
([#&#8203;643](https://redirect.github.com/defenseunicorns/lula/issues/643))
([4323cb0](https://redirect.github.com/defenseunicorns/lula/commit/4323cb08671ee36f16bb0f0dfe876a9dc6dc6186))
- **deps:** update github.com/charmbracelet/x/exp/teatest digest to
[`9ef7ff4`](https://redirect.github.com/defenseunicorns/lula/commit/9ef7ff4)
([#&#8203;655](https://redirect.github.com/defenseunicorns/lula/issues/655))
([27bff1c](https://redirect.github.com/defenseunicorns/lula/commit/27bff1c4c7f114675ff7375b59f449fc43c5b9f4))
- **deps:** update github/codeql-action action to v3.26.7
([#&#8203;659](https://redirect.github.com/defenseunicorns/lula/issues/659))
([51025b4](https://redirect.github.com/defenseunicorns/lula/commit/51025b427123964b0712283634c58debba0543ab))
- **deps:** update kubernetes packages to v0.31.1
([#&#8203;658](https://redirect.github.com/defenseunicorns/lula/issues/658))
([fbe7b8f](https://redirect.github.com/defenseunicorns/lula/commit/fbe7b8f616a682f1099476b0d929a24a267e4eeb))
- **deps:** update module github.com/charmbracelet/bubbles to v0.20.0
([#&#8203;630](https://redirect.github.com/defenseunicorns/lula/issues/630))
([4f1f3de](https://redirect.github.com/defenseunicorns/lula/commit/4f1f3debfd050269776767ae69290d51b2fc2e0e))
- **deps:** update module github.com/charmbracelet/bubbletea to v1.1.1
([#&#8203;633](https://redirect.github.com/defenseunicorns/lula/issues/633))
([394b48d](https://redirect.github.com/defenseunicorns/lula/commit/394b48d19a6d56c9ac196e7717ec37e55ad7f606))
- **deps:** update module sigs.k8s.io/kustomize/kyaml to v0.17.2
([#&#8203;638](https://redirect.github.com/defenseunicorns/lula/issues/638))
([c66df44](https://redirect.github.com/defenseunicorns/lula/commit/c66df449358a00f9c7dbf0b0c71dacb56f229e44))

#### What's Changed

- feat: yaml map injection by
[@&#8203;meganwolf0](https://redirect.github.com/meganwolf0) in
[https://github.com/defenseunicorns/lula/pull/568](https://redirect.github.com/defenseunicorns/lula/pull/568)
- chore(deps): update actions/upload-artifact action to v4.4.0 by
[@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/635](https://redirect.github.com/defenseunicorns/lula/pull/635)
- test(console): console testing by
[@&#8203;meganwolf0](https://redirect.github.com/meganwolf0) in
[https://github.com/defenseunicorns/lula/pull/629](https://redirect.github.com/defenseunicorns/lula/pull/629)
- chore(deps): update module github.com/charmbracelet/bubbles to v0.20.0
by [@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/630](https://redirect.github.com/defenseunicorns/lula/pull/630)
- chore(deps): update github.com/charmbracelet/x/exp/teatest digest to
[`162f303`](https://redirect.github.com/defenseunicorns/lula/commit/162f303)
by [@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/643](https://redirect.github.com/defenseunicorns/lula/pull/643)
- chore(deps): update module sigs.k8s.io/kustomize/kyaml to v0.17.2 by
[@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/638](https://redirect.github.com/defenseunicorns/lula/pull/638)
- feat(config): support for target in lula config by
[@&#8203;brandtkeller](https://redirect.github.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/640](https://redirect.github.com/defenseunicorns/lula/pull/640)
- fix(gen-cli-docs): fix path for gen-cli-docs by
[@&#8203;brandtkeller](https://redirect.github.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/646](https://redirect.github.com/defenseunicorns/lula/pull/646)
- chore(deps): update module github.com/charmbracelet/bubbletea to
v1.1.1 by [@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/633](https://redirect.github.com/defenseunicorns/lula/pull/633)
- chore(deps): update actions/github-script digest to
[`58d7008`](https://redirect.github.com/defenseunicorns/lula/commit/58d7008)
by [@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/660](https://redirect.github.com/defenseunicorns/lula/pull/660)
- chore(deps): update github/codeql-action action to v3.26.7 by
[@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/659](https://redirect.github.com/defenseunicorns/lula/pull/659)
- chore(deps): update commitlint monorepo to v19.5.0 by
[@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/656](https://redirect.github.com/defenseunicorns/lula/pull/656)
- chore(deps): update kubernetes packages to v0.31.1 by
[@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/658](https://redirect.github.com/defenseunicorns/lula/pull/658)
- feat(template): template command with initial docs by
[@&#8203;brandtkeller](https://redirect.github.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/644](https://redirect.github.com/defenseunicorns/lula/pull/644)
- fix(test): decouple unit from e2e test workflows by
[@&#8203;brandtkeller](https://redirect.github.com/brandtkeller) in
[https://github.com/defenseunicorns/lula/pull/662](https://redirect.github.com/defenseunicorns/lula/pull/662)
- chore(deps): update github.com/charmbracelet/x/exp/teatest digest to
[`9ef7ff4`](https://redirect.github.com/defenseunicorns/lula/commit/9ef7ff4)
by [@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/defenseunicorns/lula/pull/655](https://redirect.github.com/defenseunicorns/lula/pull/655)
- chore(main): release 0.7.0 by
[@&#8203;github-actions](https://redirect.github.com/github-actions) in
[https://github.com/defenseunicorns/lula/pull/637](https://redirect.github.com/defenseunicorns/lula/pull/637)

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

</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://redirect.github.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:eyJjcmVhdGVkSW5WZXIiOiIzOC43NC4xIiwidXBkYXRlZEluVmVyIjoiMzguNzQuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Micah Nagel <micah.nagel@defenseunicorns.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.

Generic yaml merge functionality
2 participants