Skip to content

pkg/steps: some cleanups for index+bundle image building#1136

Merged
openshift-merge-robot merged 4 commits into
openshift:masterfrom
AlexNPavel:fixup-index
Aug 26, 2020
Merged

pkg/steps: some cleanups for index+bundle image building#1136
openshift-merge-robot merged 4 commits into
openshift:masterfrom
AlexNPavel:fixup-index

Conversation

@AlexNPavel
Copy link
Copy Markdown
Contributor

This PR addresses a variety of comments from #1084 that were unaddressed when the PR merged.
These are the changes:

  • Make functions to create bundle image name and detect if image is bundle name
  • Add brief Godoc for api.Bundle
  • Use find command directly in bundle substitution instead of executing through bash
  • Use exact pullspecs from ResolvePullSpec, which also verifies that the image tag exists
  • Add image substitutions that get built in the pipeline to the required images for bundle-sub
  • Don't change global state (changing directory) in unit tests
  • Handle both yaml and yml file extensions for manifests
  • Handle escaping in dockerfile more cleanly
  • Remove extra, empty "" lines from beginning and end of generated dockerfiles
  • Expand replaceCommand unit tests by adding a .yml and .txt file

/cc @stevekuznetsov

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2020
@AlexNPavel
Copy link
Copy Markdown
Contributor Author

/test e2e

Comment thread pkg/steps/bundle_source.go Outdated
Comment thread pkg/steps/bundle_source.go Outdated
Comment thread pkg/steps/bundle_source.go Outdated
replace := strings.ReplaceAll(replaceCommand(sub.PullSpec, replaceSpec), `\`, `\\`)
dockerCommands = append(dockerCommands, fmt.Sprintf(`RUN ["bash", "-c", "%s"]`, replace))
// format command for dockerfile
dockerFormattedCommand := `"` + strings.Join(replaceCommand(sub.PullSpec, replaceSpec), `" "`) + `"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hrm - shouldn't this be something like

var formattedParts []string
for _, part := range replaceCommand(sub.PullSpec, replaceSpec) {
    formattedParts = append(formattedParts. fmt.Sprintf("%q", part))
}
dockerFormattedCommand := strings.Join(formattedParts, " ")

?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe write a function and unit test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've changed the Dockerfile RUN commands to just take the command directly, without quoting every argument. This way, it is run exactly as it would be in the /bin/sh of the container. This is the easiest to understand way to generate the dockerfile IMO.

Comment thread pkg/steps/bundle_source.go Outdated
@stevekuznetsov
Copy link
Copy Markdown
Contributor

/assign @petr-muller

Comment thread pkg/steps/bundle_source.go Outdated
@stevekuznetsov
Copy link
Copy Markdown
Contributor

/close

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@stevekuznetsov: Closed this PR.

Details

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@stevekuznetsov
Copy link
Copy Markdown
Contributor

/reopen

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@stevekuznetsov: Reopened this PR.

Details

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 26, 2020
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@petr-muller
Copy link
Copy Markdown
Member

/hold

This looks legit:

could not run steps: step ci-index-gen failed: failed to get image digest for bundle `ci-bundle0`: image stream pipeline has no tag ci-bundle0 in spec or status

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 26, 2020
This PR addresses a variety of comments from openshift#1084 that were unaddressed when the PR merged.
These are the changes:

- Make functions to create bundle image name and detect if image is bundle name
- Add brief Godoc for api.Bundle
- Use `find` command directly in bundle substitution instead of executing through bash
- Use exact pullspecs from ResolvePullSpec, which also verifies that the image tag exists
- Add image substitutions that get built in the pipeline to the required images for bundle-sub
- Don't change global state (changing directory) in unit tests
- Handle both yaml and yml file extensions for manifests
- Handle escaping in dockerfile more cleanly
- Remove extra, empty "" lines from beginning and end of generated dockerfiles
- Expand replaceCommand unit tests by adding a .yml and .txt file
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 26, 2020
DependencyParts now detects the bundle and index images as pipeline
images. This commit also adds the PipelineImageStreamTagReference prefix
to the statically named bundle and index images.
@AlexNPavel
Copy link
Copy Markdown
Contributor Author

Everything should be functional now

@AlexNPavel
Copy link
Copy Markdown
Contributor Author

/retest

@stevekuznetsov
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 26, 2020
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlexNPavel, stevekuznetsov

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [AlexNPavel,stevekuznetsov]

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

@AlexNPavel
Copy link
Copy Markdown
Contributor Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 26, 2020
@openshift-merge-robot openshift-merge-robot merged commit 3dfc14b into openshift:master Aug 26, 2020
@AlexNPavel AlexNPavel deleted the fixup-index branch August 26, 2020 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants