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

chore: fix circular dependencies related to assets.ts #1357

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

schaeferka
Copy link
Contributor

Description

The assets modules have several circular dependencies between them. These should be fixed.
...

End to End Test:

Related Issue

Fixes #1340

Relates to #

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

@schaeferka schaeferka self-assigned this Oct 29, 2024
@schaeferka schaeferka requested a review from a team as a code owner October 29, 2024 22:46
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 89.92248% with 13 lines in your changes missing coverage. Please review.

Project coverage is 75.21%. Comparing base (cedad18) to head (ba235a1).

Files with missing lines Patch % Lines
src/lib/assets/assetsDeployer.ts 87.77% 11 Missing ⚠️
src/lib/assets/deploy.ts 33.33% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1357      +/-   ##
==========================================
- Coverage   79.57%   75.21%   -4.36%     
==========================================
  Files          39       49      +10     
  Lines        1816     2255     +439     
  Branches      396      444      +48     
==========================================
+ Hits         1445     1696     +251     
- Misses        342      520     +178     
- Partials       29       39      +10     
Files with missing lines Coverage Δ
src/lib/assets/assetsConfig.ts 100.00% <100.00%> (ø)
src/lib/assets/index.ts 100.00% <100.00%> (ø)
src/lib/assets/pods.ts 94.54% <100.00%> (ø)
src/lib/assets/webhooks.ts 12.76% <100.00%> (ø)
src/lib/assets/yaml.ts 30.76% <100.00%> (ø)
src/lib/capability.ts 94.90% <100.00%> (ø)
src/lib/enums.ts 100.00% <100.00%> (ø)
src/lib/filter/adjudicators.ts 100.00% <ø> (ø)
src/lib/finalizer.ts 100.00% <100.00%> (ø)
src/lib/module.ts 81.25% <100.00%> (ø)
... and 4 more

... and 5 files with indirect coverage changes

@schaeferka schaeferka marked this pull request as draft October 30, 2024 21:40
@schaeferka schaeferka marked this pull request as ready for review October 31, 2024 02:47
src/lib/assets/assetsDeployer.ts Outdated Show resolved Hide resolved
src/lib/assets/assetsDeployer.ts Outdated Show resolved Hide resolved
src/lib/assets/index.test.ts Outdated Show resolved Hide resolved
src/lib/finalizer.ts Outdated Show resolved Hide resolved
src/cli/build.ts Outdated
} else {
zarf = assets.zarfYaml(yamlFile);
zarf = await assets.zarfYaml(yamlFile);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
zarf = await assets.zarfYaml(yamlFile);
zarf = await assets.zarfYaml(yamlFile);

Why is this async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The return value is a Promise so the await is needed or you get:

Type 'Promise<string>' is not assignable to type 'string'.ts(2322)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed these by making the functions in assetsDeployer.ts no be async.

src/cli/build.ts Outdated
@@ -180,9 +176,9 @@ export default function (program: RootCmd) {

let zarf = "";
if (opts.zarf === "chart") {
zarf = assets.zarfYamlChart(chartPath);
zarf = await assets.zarfYamlChart(chartPath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should not be async

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed these by making the functions in assetsDeployer.ts no be async.

Copy link
Collaborator

@cmwylie19 cmwylie19 left a comment

Choose a reason for hiding this comment

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

Still need to clean up some async functions, needs further review. looks good though

src/cli/build.ts Outdated
@@ -111,7 +103,9 @@ export default function (program: RootCmd) {
// only actually build/push if there are files to include
if (includedFiles.length > 0) {
await createDockerfile(cfg.pepr.peprVersion, cfg.description, includedFiles);
execSync(`docker build --tag ${image} -f Dockerfile.controller .`, { stdio: "inherit" });
execSync(`docker build --tag ${image} -f Dockerfile.controller .`, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happened to the customImage flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it by accident when I was fixes merge conflicts yesterday.

return allYaml(this.assetsConfig, imagePullSecret);
}

async zarfYaml(path: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't this just return some json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

return zarfYaml(this.assetsConfig, path);
}

async zarfYamlChart(path: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't this just return some json? not async needed unless i am missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@cmwylie19
Copy link
Collaborator

this also breaks customImage and image in the build cli command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

chore: fix circular dependencies between assets modules
3 participants