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

🌱 Image name edge cases covered #3514

Merged

Conversation

Sajiyah-Salat
Copy link
Contributor

Description:

In generating docs, if there is no image present we can skip running docker command and this was covered in #3508
but if the image name is of single character or in anyother edge case the code would crash.
In this pr I have covered the Edge cases.
Following up on: #3508 (comment)

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 1, 2023
// Remove white space from image name
trimmedImageName := strings.Trim(t.ImageName, "")
// Check trimmedimage name is empty
if len(trimmedImageName) < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if len(trimmedImageName) < 0 {
if len(strings.Trim(t.ImageName, "")) < 0 {

You can do in the same line and you do not need spent a memory space to store the data in a variable

Otherwise it is great !!!

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Can you please squash the commits for we are able to move forward?
@Sajiyah-Salat ?

Copy link
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

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

An important correction! Rest looks good!
Good work! @Sajiyah-Salat

if _, err := t.Run(cmd); err != nil {
warnError(err)
// Check white space from image name
if len(strings.Trim(t.ImageName, "")) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

This should either be:

strings.Trim(t.ImageName, " ")

or

strings.TrimSpace(t.ImageName)

First option has an empty space in the second argument of the trim, which means we are intending to remove all whitespaces. The second one is a helper provided by golang itself: https://pkg.go.dev/strings#TrimSpace

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/lgtm

/approved

/hold cancel

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 10, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, Sajiyah-Salat

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2023
@camilamacedo86 camilamacedo86 dismissed varshaprasad96’s stale review August 10, 2023 12:33

dismissing since the requested is addressed

@camilamacedo86
Copy link
Member

Moving forward with this one since it is blocked by the preview of docs which is an issue that we are sorting out in another PR and has no relation with this one.

@camilamacedo86 camilamacedo86 merged commit 136aac6 into kubernetes-sigs:master Aug 15, 2023
27 of 29 checks passed
Sajiyah-Salat added a commit to Sajiyah-Salat/kubebuilder that referenced this pull request Aug 22, 2023
yyy1000 pushed a commit to yyy1000/kubebuilder that referenced this pull request Aug 27, 2023
yyy1000 added a commit to yyy1000/kubebuilder that referenced this pull request Aug 27, 2023
feat: get data

feat: add change

feat: remove log

feat: add e2e test

build(deps): bump golang.org/x/tools from 0.11.0 to 0.12.0

Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](golang/tools@v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(docs): change folder pkg to internal/controller in the migration guide

fix: ensure external plugin can scaffold files in new dirs

:seedling: Image name edge cases covered (kubernetes-sigs#3514)

imagename edge case cover

:seedling: logs info updated (kubernetes-sigs#3512)

logs info updated

:bug: fix doc preview

🐛: sync kb binary from source code for docs (kubernetes-sigs#3520)

fix: sync kb binary from source code for docs

:bug: fix typos in scaffolded makefiles

:book: fix escaped html in markdown code segments

:bug: (go/v4) fix makefile target to build images ensuring its single responsability

refactor: externalize cfg

:bug: (deployimage): fix e2e tests which are using go/v3 which is deprecated. Ensure that we are using the go/v4

ensure that we call go tidy when we generate sample docs

:sparkles: (Kustomize/v2, go/v4): upgrade controller-tools from 0.12.0 to 0.13.0 (kubernetes-sigs#3561)

(go/v4): Upgrade controller-tools from 0.12.0 to v0.13.0

:sparkles: improve logs from alpha command generate

:bug: (deployimage/v1-beta1): fix scaffold with multigroup and add optional plugins to multigroup sample to validate changes

:bug: change deprecated warning to yellow

feat: remove quota

fix: add space

fix: change kind

Update test/e2e/alphagenerate/generate_test.go

Co-authored-by: Tony (TianYi) <kavinjsir@gmail.com>
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants