OCI-based devfile reigstry support patch (#4636)

* fix: starter project overriding issue

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* fix: issues detected from test cases

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* refactor: modify the patch

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* fix: test cases issue

Signed-off-by: jingfu wang <jingfwan@redhat.com>
This commit is contained in:
Jingfu Wang
2021-04-21 05:40:22 -04:00
committed by GitHub
parent 2a0cb0dafd
commit c8a0fe41b2

View File

@@ -767,6 +767,7 @@ func (co *CreateOptions) s2iRun() (err error) {
// Run has the logic to perform the required actions as part of command
func (co *CreateOptions) devfileRun() (err error) {
var devfileData []byte
devfileExist := util.CheckPathExists(DevfilePath)
// Use existing devfile directly from --devfile flag
if co.devfileMetadata.devfilePath.value != "" {
if co.devfileMetadata.devfilePath.protocol == "http(s)" {
@@ -786,7 +787,7 @@ func (co *CreateOptions) devfileRun() (err error) {
}
}
} else {
if util.CheckPathExists(DevfilePath) {
if devfileExist {
// if local devfile already exists read that
// odo create command was expected in a directory already containing devfile
devfileData, err = ioutil.ReadFile(DevfilePath)
@@ -853,12 +854,18 @@ func (co *CreateOptions) devfileRun() (err error) {
return errors.Wrap(err, "failed to download project for devfile component")
}
// save devfile
// save devfile and corresponding resources if possible
// use original devfileData to persist original formatting of the devfile file
err = ioutil.WriteFile(DevfilePath, devfileData, 0644) // #nosec G306
if err != nil {
return errors.Wrapf(err, "unable to save devfile to %s", DevfilePath)
}
if co.devfileMetadata.devfilePath.value == "" && !devfileExist && !strings.Contains(co.devfileMetadata.devfileRegistry.URL, "github") {
err = registryLibrary.PullStackFromRegistry(co.devfileMetadata.devfileRegistry.URL, co.devfileMetadata.componentType, co.componentContext)
if err != nil {
return err
}
}
// Generate env file
err = co.EnvSpecificInfo.SetComponentSettings(envinfo.ComponentSettings{