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

regex failure when passing in sourceToBuild #172

Open
muschellij2 opened this issue Feb 11, 2022 · 1 comment · May be fixed by #198
Open

regex failure when passing in sourceToBuild #172

muschellij2 opened this issue Feb 11, 2022 · 1 comment · May be fixed by #198

Comments

@muschellij2
Copy link
Contributor

I don't know what the purpose of the failed regex created in cr_buildtrigger_repo so I'll just show the (what I believe) to be standard use case for using googleCloudRunner::cr_buildtrigger with a GitHub repo. Making a cr_trigger_repo output with the source as the sourceToBuild as well as trigger:

repo_name = "StreamlineDataScience/targets-minimal"
github_secret = "ssh-deploy-key"

sourceToBuild = googleCloudRunner::cr_buildtrigger_repo(
  repo_name = repo_name,
  github_secret = github_secret,
  type = "github"
)
googleCloudRunner::cr_buildtrigger(
  build = "blah.yaml",
  name = "blah", 
  trigger = sourceToBuild,
  sourceToBuild = sourceToBuild)
#> Error: !grepl("[^A-Za-z0-9/.]", ref) is not TRUE

Drilldown

This drills down in different evaluations of the sub functions that are gone through before the error:

# inside cr_buildtrigger
if (!is.null(sourceToBuild)) {
  assertthat::assert_that(googleCloudRunner:::is.buildtrigger_repo(sourceToBuild))
  sourceToBuild <- googleCloudRunner:::as.gitRepoSource(sourceToBuild)
}
#> Error: !grepl("[^A-Za-z0-9/.]", ref) is not TRUE

# googleCloudRunner:::as.gitRepoSource
x = sourceToBuild
ref <- paste0("refs/heads/", x$repo$branchName)
ref
#> [1] "refs/heads/"

# 181
# GitRepoSource
!grepl("[^A-Za-z0-9/.]", ref) # regex not allowed
#> [1] TRUE

I don't know why this is excluded in your code as I don't see anything related to this and the docs don't indicate this: https://cloud.google.com/build/docs/api/reference/rest/v1/projects.locations.triggers#BuildTrigger.GitRepoSource

Created on 2022-02-11 by the reprex package (v2.0.1)

@MarkEdmondson1234
Copy link
Owner

The default for cr_buildtrigger_repo() includes a Regex for the git branch, which is fine for the trigger but sourceToBuild does not accept regex only specific branches. Some useful error messages are needed here and perhaps the default .* changed or even altered when it's being used as a sourceToBuild although it's not standard anymore what the main/master branch is called.

Short term the fix is to specify the branch or tag for the sourceToBuild

ghstreamline pushed a commit to muschellij2/googleCloudRunner that referenced this issue Aug 4, 2022
@muschellij2 muschellij2 linked a pull request Aug 4, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants