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

Make k8s plugin fields private #5441

Merged
merged 7 commits into from
Dec 23, 2024
Merged

Conversation

Warashi
Copy link
Contributor

@Warashi Warashi commented Dec 23, 2024

What this PR does:

  • make all the fields of types below private
    • provider.Manifest
    • provider.ResourceKey
  • move findUpdatedWorkloads and findConfigsAndSecrets to provider package
  • Rename findUpdatedWorkloads to FindSameManifests because this function does not see whether the manifests are updated or not.
  • implement provider.FindContainerImages and use it in determineVersions
    • to decouple determineVersions from provider.Manifest.Body

Why we need it:

To restrict updates of field values.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
because it does not treat either the workloads are changed or not

Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 76.87075% with 34 lines in your changes missing coverage. Please review.

Project coverage is 26.24%. Comparing base (b98a963) to head (cb51ac7).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...app/pipedv1/plugin/kubernetes/provider/manifest.go 77.55% 10 Missing and 1 partial ⚠️
...app/pipedv1/plugin/kubernetes/provider/resource.go 55.00% 7 Missing and 2 partials ⚠️
...g/app/pipedv1/plugin/kubernetes/provider/loader.go 25.00% 6 Missing ⚠️
...p/pipedv1/plugin/kubernetes/provider/deployment.go 80.00% 0 Missing and 4 partials ⚠️
.../app/pipedv1/plugin/kubernetes/provider/kubectl.go 0.00% 3 Missing ⚠️
pkg/app/pipedv1/plugin/kubernetes/provider/diff.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5441   +/-   ##
=======================================
  Coverage   26.24%   26.24%           
=======================================
  Files         452      452           
  Lines       48860    48864    +4     
=======================================
+ Hits        12821    12823    +2     
- Misses      35014    35016    +2     
  Partials     1025     1025           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
got := findWorkloadManifests(manifests, tt.refs)
assert.ElementsMatch(t, tt.want, got)
})
}
}

func TestFindUpdatedWorkloads(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests are moved to the provider package.

Comment on lines -237 to -255
{
name: "manifest with non-string image field",
manifests: []string{
`
apiVersion: apps/v1
kind: Deployment
metadata:
name: non-string-image-deployment
spec:
template:
spec:
containers:
- name: nginx
image: 12345
`,
},
want: nil,
wantErr: true,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test case is an irregular case, and it's not critical. So I removed it.

Comment on lines -272 to -287
{
name: "manifest with invalid containers field -- returns error",
manifests: []string{
`
apiVersion: apps/v1
kind: Deployment
metadata:
name: no-containers-deployment
spec:
template:
spec:
containers: "invalid-containers-field"
`,
},
wantErr: true,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test case is an irregular case, and it's not critical. So I removed it.

Comment on lines +27 to +28
key ResourceKey
body *unstructured.Unstructured
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what I want to do.

Comment on lines +69 to +72
apiVersion string
kind string
namespace string
name string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also what I want to do.

@Warashi Warashi marked this pull request as ready for review December 23, 2024 05:57
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

LGTM

@t-kikuc t-kikuc merged commit fdc490c into master Dec 23, 2024
18 checks passed
@t-kikuc t-kikuc deleted the k8s-plugin-make-fields-private branch December 23, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants