title: OpenShift : Waiting for image stream to be created
body: <p>I am creating an installation script that will create resources off of YAML files†. This script will do the equivalent of this command:</p>
  
  <pre class="lang-sh prettyprint-override"><code>oc new-app registry.access.redhat.com/rhscl/nginx-114-rhel7~http://github.com/username/repo.git
  </code></pre>
  
  <p>Three YAML files were created as follows:</p>
  
  <ol>
  <li><code>imagestream</code> for <code>nginx-114-rhel7</code> - <code>is-nginx.yaml</code></li>
  </ol>
  
  <pre><code>apiVersion: image.openshift.io/v1
  kind: ImageStream
  metadata:
    labels:
      build: build-repo
    name: nginx-114-rhel7
    namespace: ns
  spec:
    tags:
      - annotations: null
        from:
          kind: DockerImage
          name: registry.access.redhat.com/rhscl/nginx-114-rhel7
        name: latest
        referencePolicy:
          type: Source
  </code></pre>
  
  <ol start="2">
  <li><code>imagestream</code> for <code>repo</code> - <code>is-repo.yaml</code></li>
  </ol>
  
  <pre><code>apiVersion: v1
  kind: ImageStream
  metadata:
    labels:
      application: is-rp
    name: is-rp
    namespace: ns
  </code></pre>
  
  <ol start="3">
  <li><code>buildconfig</code> for <code>repo</code> (output will be <code>imagestream</code> for <code>repo</code>) - <code>bc-repo.yaml</code></li>
  </ol>
  
  <pre><code>
  apiVersion: v1
  kind: BuildConfig
  metadata:
    labels:
      build: rp
    name: bc-rp
    namespace: ns
  spec:
    output:
      to:
        kind: ImageStreamTag
        name: 'is-rp:latest'
    postCommit: {}
    resources: {}
    runPolicy: Serial
    source:
      git:
        ref: dev_1.0
        uri: 'http://github.com/username/repo.git'
      type: Git
    strategy:
      sourceStrategy:
        from:
          kind: ImageStreamTag
          name: 'nginx-114-rhel7:latest'
          namespace: flo
      type: Source
    successfulBuildsHistoryLimit: 5
  </code></pre>
  
  <p>When these commands are run one after another,</p>
  
  <pre class="lang-sh prettyprint-override"><code>oc create -f is-nginx.yaml;oc create -f is-repo.yaml;oc create -f bc-repo.yaml;oc start-build bc/bc-rep --wait
  </code></pre>
  
  <p>I get this error message,</p>
  
  <pre class="lang-sh prettyprint-override"><code>The ImageStreamTag "nginx-114-rhel7:latest" is invalid: from: Error resolving ImageStreamTag nginx-114-rhel7:latest in namespace ns: unable to find latest tagged image
  </code></pre>
  
  <p>But, when I run the commands with a <code>sleep</code> before <code>start-build</code>, the build is triggered correctly.</p>
  
  <pre class="lang-sh prettyprint-override"><code>oc create -f is-nginx.yaml;oc create -f is-repo.yaml;oc create -f bc-repo.yaml;sleep 5;oc start-build bc/bc-rep
  </code></pre>
  
  <p>How do I trigger <code>start-build</code> without entering a <code>sleep</code> command? The <code>oc wait</code> seems to work only for <code>--for=condition</code> and <code>--for=delete</code>. I do not know what value is to be used for <code>--for=condition</code>.</p>
  
  <p>† - I do not see a clear guideline on creating installation scripts - with YAML or equivalent <code>oc</code> commands <em>only</em> - for deploying applications on to OpenShift.</p>