Bug 1450743

Summary: --build-secret option of oc new-build command does not add sourceSecret to BC
Product: OpenShift Container Platform Reporter: Takayuki Konishi <tkonishi>
Component: BuildAssignee: Cesar Wong <cewong>
Status: CLOSED NOTABUG QA Contact: Wenjing Zheng <wzheng>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.4.1CC: aos-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-24 12:20:53 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:

Description Takayuki Konishi 2017-05-15 06:16:15 UTC
Description of problem:
--build-secret option of oc new-build command does not add sourceSecret to BC.

How reproducible: 100%

Steps to Reproduce:

1. create a private rerposty that authentication method is basic authentication
2. oc secrets new-basicauth <credential_name> --username=<username of the repoitry> --password=<password>
3. oc new-build <git_repo> --build-secret=<credential_name>
4. oc edit bc <build_config_name>

Actual results:
spec.source.sourceSecret does not exit

Expected results:
spec.source.sourceSecret exits

Additional info:
After created a bc, "oc set build-secret" command adds sourceSecret to the bc.
oc set build-secret --source bc/<build_config_name> <credential_name>

Comment 1 Wenjing Zheng 2017-05-15 07:08:40 UTC
There only is a Build Secrets in buildconfig and no Source Secret till use oc set build-secret:
$ oc describe bc ruby-hello-world
Name:		ruby-hello-world
Namespace:	wzheng
Created:	15 seconds ago
Labels:		build=ruby-hello-world
Annotations:	openshift.io/generated-by=OpenShiftNewBuild
Latest Version:	1

Strategy:	Source
URL:		https://wzheng@gitlab.com/wzheng/ruby-hello-world.git
From Image:	ImageStreamTag openshift/ruby:2.3
Output to:	ImageStreamTag ruby-hello-world:latest
Build Secrets:	testsecret->.

After use oc set build-secret:

$ oc describe bc ruby-hello-world
Name:		ruby-hello-world
Namespace:	wzheng
Created:	2 minutes ago
Labels:		build=ruby-hello-world
Annotations:	openshift.io/generated-by=OpenShiftNewBuild
Latest Version:	1

Strategy:	Source
URL:		https://wzheng@gitlab.com/wzheng/ruby-hello-world.git
Source Secret:	testsecret
From Image:	ImageStreamTag openshift/ruby:2.3
Output to:	ImageStreamTag ruby-hello-world:latest
Build Secrets:	testsecret->.

Here is my oc version:
oc v3.6.24
kubernetes v1.5.2+43a9be4

Comment 2 Cesar Wong 2017-05-24 12:20:53 UTC
This is working as designed, the --build-secret option in new-build is to add secrets to be used during the build and not a source secret. Methods for adding source secrets are described here: https://docs.openshift.org/latest/dev_guide/builds/build_inputs.html#source-clone-secrets

The secrets that you can specify using the --build-secret flag are described here:
https://docs.openshift.org/latest/dev_guide/builds/build_inputs.html#using-secrets-during-build