Skip to content

Commit

Permalink
Merge pull request #22213 from smarterclayton/info
Browse files Browse the repository at this point in the history
Write image-references to disk after all metadata is fetched
  • Loading branch information
openshift-merge-robot committed Mar 2, 2019
2 parents 6d25311 + 04e2e5a commit 761b685
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions pkg/oc/cli/admin/release/extract.go
Expand Up @@ -255,6 +255,7 @@ func ensureCloneForRepo(dir string, repo string, out, errOut io.Writer) (*git, e
if err != nil {
return nil, err
}
glog.V(4).Infof("Ensure repo is cloned at %s pointing to %s", basePath, repo)
fi, err := os.Stat(basePath)
if err != nil {
if !os.IsNotExist(err) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/admin/release/git.go
Expand Up @@ -52,7 +52,7 @@ func (g *git) streamExec(out, errOut io.Writer, command ...string) error {
func (g *git) ChangeContext(path string) (*git, error) {
location := &git{path: path}
if errOut, err := location.exec("rev-parse", "--git-dir"); err != nil {
if strings.Contains(errOut, "not a git repository") {
if strings.Contains(strings.ToLower(errOut), "not a git repository") {
return location, noSuchRepo
}
return location, err
Expand Down
7 changes: 6 additions & 1 deletion pkg/oc/cli/admin/release/image_mapper.go
Expand Up @@ -190,7 +190,11 @@ func NewTransformFromImageStreamFile(path string, input *imageapi.ImageStream, a
if _, ok := references[tag.Name]; !ok {
continue
}
value := tag.Annotations[annotationBuildVersions]
value, ok := tag.Annotations[annotationBuildVersions]
if !ok {
continue
}
glog.V(4).Infof("Found build versions from %s: %s", tag.Name, value)
items, err := parseComponentVersionsLabel(value)
if err != nil {
return nil, fmt.Errorf("input image stream has an invalid version annotation for tag %q: %v", tag.Name, value)
Expand All @@ -203,6 +207,7 @@ func NewTransformFromImageStreamFile(path string, input *imageapi.ImageStream, a
}
} else {
versions[k] = v
glog.V(4).Infof("Found version %s=%s from %s", k, v, tag.Name)
}
tagsByName[k] = append(tagsByName[k], tag.Name)
}
Expand Down
30 changes: 16 additions & 14 deletions pkg/oc/cli/admin/release/new.go
Expand Up @@ -743,19 +743,6 @@ func (o *NewOptions) extractManifests(is *imageapi.ImageStream, name string, met
fmt.Fprintf(o.ErrOut, "info: Manifests will be extracted to %s\n", dir)
}

if len(is.Spec.Tags) > 0 {
if err := os.MkdirAll(dir, 0770); err != nil {
return err
}
data, err := json.MarshalIndent(is, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(dir, "image-references"), data, 0640); err != nil {
return err
}
}

var lock sync.Mutex
opts := extract.NewOptions(genericclioptions.IOStreams{Out: o.Out, ErrOut: o.ErrOut})
opts.RegistryConfig = o.RegistryConfig
Expand Down Expand Up @@ -847,7 +834,22 @@ func (o *NewOptions) extractManifests(is *imageapi.ImageStream, name string, met
})
}
glog.V(4).Infof("Manifests will be extracted from:\n%#v", opts.Mappings)
return opts.Run()
if err := opts.Run(); err != nil {
return err
}
if len(is.Spec.Tags) > 0 {
if err := os.MkdirAll(dir, 0770); err != nil {
return err
}
data, err := json.MarshalIndent(is, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(dir, "image-references"), data, 0640); err != nil {
return err
}
}
return nil
}

func (o *NewOptions) mirrorImages(is *imageapi.ImageStream, payload *Payload) error {
Expand Down

0 comments on commit 761b685

Please sign in to comment.