Bug 1819112

Summary: Git repository ssh url format
Product: OpenShift Container Platform Reporter: Maria Alonso <malonso>
Component: Dev ConsoleAssignee: cvogt
Status: CLOSED CURRENTRELEASE QA Contact: Gajanan More <gamore>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.2.zCC: aos-bugs, jhadvig, jokerman, nmukherj, rmarasch, wzheng
Target Milestone: ---   
Target Release: 4.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Import from Git form used a regular expression to validate the Git URL. Unfortunately it was too restrictive and disallowed certain URLs which are actually valid. Consequence: The user could not enter what they considered to be a valid Git URL and complete the form. Fix: The Git URL regular expression used for validation has been updated. Result: All valid Git URLs are now accepted.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-21 22:03:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1766350, 1771851    
Bug Blocks:    

Description Maria Alonso 2020-03-31 08:50:26 UTC
Description of problem: 

 Want that all standards url be posible when setting ssh git url.
 OCP 4 doesn't allow to set 'ssh://[user@]server/project.git' as git repository 
 url, only '[user@]server:project.git' format is allowed

Version-Release number of selected component (if applicable):

 OCP 4

How reproducible:

 Always.

Steps to Reproduce:
1. Try to create a new build with the following ssh url:
   ssh://git/example/example1.git

2. You get 'Invalid Git URL.' error
3. Only the following format is allowed:
   git:example/example1.git


Actual results:
  'Invalid Git URL.' error appears

Expected results:
   That this url format is accepted

Additional info:

Comment 2 Adam Kaplan 2020-03-31 13:32:55 UTC
Referring to our docs, it isn't entirely clear which URI formats are supported for git source [1]. `ssh://` support is implied by the automatic source secret linking feature [2].

As mentioned in the description, the `[user@]server:project.git` is a valid work-around.

[1] https://docs.openshift.com/container-platform/4.3/builds/creating-build-inputs.html#source-code_creating-build-inputs
[2] https://docs.openshift.com/container-platform/4.3/builds/creating-build-inputs.html#build-auto-add-source-clone-secrets_creating-build-inputs

Comment 3 Ricardo Maraschini 2020-04-16 08:56:01 UTC
For the record: I managed to run a build successfully with the following BuildConfig(using version 4.5):

kind: BuildConfig
apiVersion: v1
metadata:
  name: hi 
spec:
  runPolicy: Serial 
  source: 
    git:
      uri: ssh://git/ricardomaraschini/hi
    sourceSecret:
      name: hi
  strategy:
    dockerStrategy: {}
  output: 
    to:
      kind: ImageStreamTag
      name: hi:latest

I had to create a secret containing my ssh private keys(see below) but it worked as expected.

$ oc create secret generic git-secret          \
     --from-file=ssh-privatekey=private.key    \
     --type=kubernetes.io/ssh-auth

Comment 4 Ricardo Maraschini 2020-04-16 10:01:38 UTC
Just checked on a cluster version 4.2[1] and it works using the same approach I have used on Comment 3. I have also tested directly from the command line[2] and it works as well. Maria, add to this ticket the exact commands you are running so I can replicate.

[1]:
[rmarasch@loaner ~]$ oc version
Client Version: openshift-clients-4.2.29-202004110432
Server Version: 4.2.29
Kubernetes Version: v1.14.6-152-g117ba1f
[rmarasch@loaner ~]$ 


[2]:
oc create secret generic hi                             \
        --from-file=ssh-privatekey=resources/github.key \
        --type=kubernetes.io/ssh-auth

oc new-app ssh://git/ricardomaraschini/hi --source-secret=hi

Comment 5 Maria Alonso 2020-04-16 12:51:23 UTC
Hi Ricardo,

Sorry, I thought I put it in the description but I didn't... 

This issue happens when creating new-app from console, not when creating it from the cli.

Sorry for the inconvenience.

Regards

  MarĂ­a

Comment 6 Ricardo Maraschini 2020-04-16 14:49:21 UTC
Thanks Maria, I am migrating this to Management Console component as it seems more adequate.

Comment 7 Jakub Hadvig 2020-04-21 10:03:21 UTC
Re-assigning to the DevConsole team since this belongs to their package.

Comment 8 cvogt 2020-04-21 22:03:56 UTC
This issue was addressed in 4.3 by improving the validation regex.