openshift-evangelists / workshopper

Workshop content rendering tool
63 stars 40 forks source link

Calculate CONTENT_URL_PREFIX if not specified and 'content.url' not set in workshops file. #68

Open GrahamDumpleton opened 5 years ago

GrahamDumpleton commented 5 years ago

If CONTENT_URL_PREFIX is not being set, but WORKSHOPS_URL is, and content.url is not set in the workshop file, calculate what CONTENT_URL_PREFIX would be by using the directory of the URI that specifies the location of the workshop file.

Thus if _workshop.yml file is just:

---
id: "starter-lab"
name: "Starter Lab"

modules:
  activate:
  - lab1

and WORKSHOPS_URL was:

https://someserver/some/path/_workshop.yml

for content.url use:

https://someserver/some/path

Further, if content.url does exist, but includes a relative filename path, append that to the end of the calculated location. Thus if had:

--
id: "starter-lab"
name: "Starter Lab"

content:
    url: ..

modules:
  activate:
  - lab1

would use:

https://someserver/some/path/..

or when normalised:

https://someserver/some

This would make it easier to avoid situations like:

where even though in ocp-3.11 branch it has:

content:
  url: https://raw.githubusercontent.com/openshift-labs/starter-guides/ocp-3.9

which forces people to fix it by setting CONTENT_URL_PREFIX.

That is, it points at ocp-3.9 when should be ocp-3.11. It could instead use .. for content.url and wouldn't have to worry then about it ever needing to be updated.

Note, if it is mean't to work like this in any way I am not seeing it, and get errors when content.url is not set or when putting . as value.

GrahamDumpleton commented 5 years ago

cc @jorgemoralespou