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

Move several packages into internal #5681

Closed
wants to merge 1 commit into from
Closed

Conversation

lbernick
Copy link
Member

Changes

This commit moves several packages in pkg/ into pkg/internal. This reduces the Pipelines API surface by ensuring these packages can't be imported and relied on by clients, as we only intend for pkg/apis and pkg/client to be imported outside of Pipelines. Other packages that contain exported functions used outside of pkg/ will be refactored in a later commit.

/kind cleanup

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • n/a Has Docs included if any changes are user facing
  • n/a Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Several packages have been moved into pkg/internal and can no longer be imported.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 24, 2022
@lbernick
Copy link
Member Author

part 1 of #5679

/assign @dibyom @vdemeester @wlynch

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/internal/artifacts/artifacts_storage.go Do not exist 82.2%
pkg/internal/container/container_replacements.go Do not exist 100.0%
pkg/internal/container/sidecar_replacements.go Do not exist 100.0%
pkg/internal/container/step_replacements.go Do not exist 70.0%
pkg/internal/list/diff.go Do not exist 100.0%
pkg/internal/matrix/matrix.go Do not exist 100.0%
pkg/internal/matrix/matrix_types.go Do not exist 100.0%
pkg/internal/names/generate.go Do not exist 100.0%
pkg/internal/pod/creds_init.go Do not exist 93.9%
pkg/internal/pod/entrypoint.go Do not exist 89.5%
pkg/internal/pod/entrypoint_lookup.go Do not exist 86.4%
pkg/internal/pod/entrypoint_lookup_impl.go Do not exist 75.0%
pkg/internal/pod/pod.go Do not exist 89.5%
pkg/internal/pod/script.go Do not exist 100.0%
pkg/internal/pod/status.go Do not exist 90.9%
pkg/internal/pod/workingdir_init.go Do not exist 92.9%
pkg/internal/status/status.go Do not exist 89.2%
pkg/internal/substitution/substitution.go Do not exist 63.0%
pkg/internal/workspace/apply.go Do not exist 99.2%
pkg/internal/workspace/validate.go Do not exist 100.0%

@lbernick lbernick marked this pull request as draft October 24, 2022 19:27
@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2022
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from dibyom after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lbernick lbernick marked this pull request as ready for review October 24, 2022 19:52
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/internal/artifacts/artifacts_storage.go Do not exist 81.9%
pkg/internal/container/container_replacements.go Do not exist 100.0%
pkg/internal/container/sidecar_replacements.go Do not exist 100.0%
pkg/internal/container/step_replacements.go Do not exist 70.0%
pkg/internal/list/diff.go Do not exist 100.0%
pkg/internal/matrix/matrix.go Do not exist 100.0%
pkg/internal/matrix/matrix_types.go Do not exist 100.0%
pkg/internal/pod/creds_init.go Do not exist 93.9%
pkg/internal/pod/entrypoint.go Do not exist 89.5%
pkg/internal/pod/entrypoint_lookup.go Do not exist 86.4%
pkg/internal/pod/entrypoint_lookup_impl.go Do not exist 75.0%
pkg/internal/pod/pod.go Do not exist 89.5%
pkg/internal/pod/script.go Do not exist 100.0%
pkg/internal/pod/status.go Do not exist 90.9%
pkg/internal/pod/workingdir_init.go Do not exist 92.9%
pkg/internal/status/status.go Do not exist 89.2%
pkg/internal/substitution/substitution.go Do not exist 63.0%
pkg/internal/workspace/apply.go Do not exist 99.2%
pkg/internal/workspace/validate.go Do not exist 100.0%

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/entrypoint/runner.go 84.4% 82.8% -1.6
pkg/internal/artifacts/artifacts_storage.go Do not exist 81.9%
pkg/internal/container/container_replacements.go Do not exist 100.0%
pkg/internal/container/sidecar_replacements.go Do not exist 100.0%
pkg/internal/container/step_replacements.go Do not exist 70.0%
pkg/internal/list/diff.go Do not exist 100.0%
pkg/internal/matrix/matrix.go Do not exist 100.0%
pkg/internal/matrix/matrix_types.go Do not exist 100.0%
pkg/internal/pod/creds_init.go Do not exist 93.9%
pkg/internal/pod/entrypoint.go Do not exist 89.5%
pkg/internal/pod/entrypoint_lookup.go Do not exist 86.4%
pkg/internal/pod/entrypoint_lookup_impl.go Do not exist 75.0%
pkg/internal/pod/pod.go Do not exist 89.5%
pkg/internal/pod/script.go Do not exist 100.0%
pkg/internal/pod/status.go Do not exist 90.9%
pkg/internal/pod/workingdir_init.go Do not exist 92.9%
pkg/internal/status/status.go Do not exist 89.2%
pkg/internal/substitution/substitution.go Do not exist 63.0%
pkg/internal/workspace/apply.go Do not exist 99.2%
pkg/internal/workspace/validate.go Do not exist 100.0%

This commit moves several packages in pkg/ into pkg/internal.
This reduces the Pipelines API surface by ensuring these packages can't be imported
and relied on by clients, as we only intend for pkg/apis and pkg/client to be imported
outside of Pipelines. Other packages that contain exported functions used outside
of pkg/ will be refactored in a later commit.
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/internal/artifacts/artifacts_storage.go Do not exist 81.9%
pkg/internal/container/container_replacements.go Do not exist 100.0%
pkg/internal/container/sidecar_replacements.go Do not exist 100.0%
pkg/internal/container/step_replacements.go Do not exist 70.0%
pkg/internal/list/diff.go Do not exist 100.0%
pkg/internal/matrix/matrix.go Do not exist 100.0%
pkg/internal/matrix/matrix_types.go Do not exist 100.0%
pkg/internal/pod/creds_init.go Do not exist 93.9%
pkg/internal/pod/entrypoint.go Do not exist 89.5%
pkg/internal/pod/entrypoint_lookup.go Do not exist 86.4%
pkg/internal/pod/entrypoint_lookup_impl.go Do not exist 75.0%
pkg/internal/pod/pod.go Do not exist 89.5%
pkg/internal/pod/script.go Do not exist 100.0%
pkg/internal/pod/status.go Do not exist 90.9%
pkg/internal/pod/workingdir_init.go Do not exist 92.9%
pkg/internal/status/status.go Do not exist 89.2%
pkg/internal/substitution/substitution.go Do not exist 63.0%
pkg/internal/workspace/apply.go Do not exist 99.2%
pkg/internal/workspace/validate.go Do not exist 100.0%

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Note that today, other tektoncd component might depend on those, for example the cli, or the operator, or triggers or even chains. I think for each package we want to move we need to see if it make sense or not to be "public" (and exported) or not.

For example, github.com/tektoncd/pipeline/pkg/pod is used by results (tektoncd org) in experimental (notifiers and task-loops) and in buildkit-tekton (external, in my own repositories). In results the code that uses it looks like :

        case pod.ReasonCouldntGetTask, pod.ReasonFailedResolution, pod.ReasonFailedValidation, pod.ReasonExceededResourceQuota, pod.ReasonExceededNodeResources, pod.ReasonCreateContainerConfigError, pod.ReasonPodCreationFailed:
                return rpb.RecordSummary_FAILURE
        case pod.ReasonPending:
                return rpb.RecordSummary_UNKNOWN

Those "reason" do make sense to be public, maybe in another package or not, but they are definitely useful.
In buildkit-tekton, the code is more "involved", for example pod.IsContainerStep(c.Name), but it's still valuable to export this kind of functions. buildkit-tekton also uses github.com/tektoncd/pipeline/pkg/substitution (at least the exported ones) because it is useful to re-use (to be able to perform substitution à-la-tekton) and that package is also probably used in some custom task or resolvers I wrote.
github.com/tektoncd/pipeline/pkg/workspace is used in pipeline-in-pod for example. github.com/tektoncd/pipeline/pkg/list is used in triggers, in catlin, in results, in operator, in chains, in buildkit-tekton and in some resolvers I wrote as well.

@lbernick
Copy link
Member Author

Thanks for pointing this out! This change was probably a bit too hasty. Is there a good way to find out which functions are in use by other projects? (I know we can look at package importers on pkg.go.dev, but doesn't tell us which functions/consts are in use.) Maybe a good place to start would be moving the reasons out of the pod package and into apis, and make the rest of the pod package internal? Going to close this out for now.

@lbernick lbernick closed this Oct 26, 2022
@vdemeester
Copy link
Member

Is there a good way to find out which functions are in use by other projects? (I know we can look at package importers on pkg.go.dev, but doesn't tell us which functions/consts are in use.)

Not that I know of. Looking into package importers on pkg.go.dev helps us a bit at least.

Maybe a good place to start would be moving the reasons out of the pod package and into apis, and make the rest of the pod package internal?

I think it's gonna be both. There is probably a lot of things that needs to move in pkg/apis, and some in very specific, non internal package. I think we need to investigate and look into this as time goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants