From c8ea625d6580d271add24403ed4b98a60cf3b234 Mon Sep 17 00:00:00 2001 From: Patrick East Date: Wed, 24 Apr 2019 19:59:23 -0700 Subject: [PATCH] Separate static content specific to doc content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We mixed together doc content and website content. We don’t need to version the website content (logos, main site stuff, etc) but the doc static content (mostly images) should be tied to the markdown that uses it. Signed-off-by: Patrick East --- docs/content/_index.md | 2 +- docs/content/guides-identity.md | 8 ++++---- docs/content/how-does-opa-work.md | 6 +++--- .../img => content/images}/benefits.svg | 0 .../data.plist | Bin .../image3.png | Bin .../image6.png | Bin .../images}/best-practice-identity-bundle.png | Bin .../data.plist | Bin .../image3.png | Bin .../image5.png | Bin .../image6.png | Bin .../images}/best-practice-identity-jwt.png | Bin .../data.plist | Bin .../image3.png | Bin .../image6.png | Bin .../images}/best-practice-identity-push.png | Bin .../data.plist | Bin .../image3.png | Bin .../image6.png | Bin .../images}/best-practice-identity-remote.png | Bin .../images}/data-model-dependencies.svg | 0 .../images}/data-model-logical.svg | 0 .../images}/request-response.svg | 0 docs/layouts/shortcodes/figure.html | 17 +++++++++++++++-- 25 files changed, 23 insertions(+), 10 deletions(-) rename docs/{static/img => content/images}/benefits.svg (100%) rename docs/{static/img => content/images}/best-practice-identity-bundle.graffle/data.plist (100%) rename docs/{static/img => content/images}/best-practice-identity-bundle.graffle/image3.png (100%) rename docs/{static/img => content/images}/best-practice-identity-bundle.graffle/image6.png (100%) rename docs/{static/img => content/images}/best-practice-identity-bundle.png (100%) rename docs/{static/img => content/images}/best-practice-identity-jwt.graffle/data.plist (100%) rename docs/{static/img => content/images}/best-practice-identity-jwt.graffle/image3.png (100%) rename docs/{static/img => content/images}/best-practice-identity-jwt.graffle/image5.png (100%) rename docs/{static/img => content/images}/best-practice-identity-jwt.graffle/image6.png (100%) rename docs/{static/img => content/images}/best-practice-identity-jwt.png (100%) rename docs/{static/img => content/images}/best-practice-identity-push.graffle/data.plist (100%) rename docs/{static/img => content/images}/best-practice-identity-push.graffle/image3.png (100%) rename docs/{static/img => content/images}/best-practice-identity-push.graffle/image6.png (100%) rename docs/{static/img => content/images}/best-practice-identity-push.png (100%) rename docs/{static/img => content/images}/best-practice-identity-remote.graffle/data.plist (100%) rename docs/{static/img => content/images}/best-practice-identity-remote.graffle/image3.png (100%) rename docs/{static/img => content/images}/best-practice-identity-remote.graffle/image6.png (100%) rename docs/{static/img => content/images}/best-practice-identity-remote.png (100%) rename docs/{static/img => content/images}/data-model-dependencies.svg (100%) rename docs/{static/img => content/images}/data-model-logical.svg (100%) rename docs/{static/img => content/images}/request-response.svg (100%) diff --git a/docs/content/_index.md b/docs/content/_index.md index 07a0cca403..a82b302a06 100644 --- a/docs/content/_index.md +++ b/docs/content/_index.md @@ -53,4 +53,4 @@ into OPA via the filesystem or well-defined APIs. ## Why use OPA? -{{< figure src="/img/benefits.svg" width="65" caption="Open Policy Agent: before and after" >}} +{{< figure src="benefits.svg" width="65" caption="Open Policy Agent: before and after" >}} diff --git a/docs/content/guides-identity.md b/docs/content/guides-identity.md index 6f6fb34627..82a8537cb6 100644 --- a/docs/content/guides-identity.md +++ b/docs/content/guides-identity.md @@ -28,7 +28,7 @@ The following diagram shows this process in more detail. 1. The OPA-enabled software system includes that token as part of the usual `input` to OPA. 1. OPA decodes the JWT token and uses the contents to make policy decisions. -{{< figure src="/img/best-practice-identity-jwt.png" width="60" caption="JSON Web Token flow" >}} +{{< figure src="best-practice-identity-jwt.png" width="60" caption="JSON Web Token flow" >}} ### Updates The JWT only gets refreshed when the user authenticates; how often that happens is up to the TTL included in the token. When LDAP/AD information changes, those changes will not be seen by OPA until the user authenticates and gets a new JWT. @@ -58,7 +58,7 @@ Two things happen independently with this kind of LDAP/AD integration. 1. OPA downloads new policy bundles including LDAP/AD 1. OPA-enabled software system asks OPA for policy decisions -{{< figure src="/img/best-practice-identity-bundle.png" width="80" caption="Bundle flow" >}} +{{< figure src="best-practice-identity-bundle.png" width="80" caption="Bundle flow" >}} ### Updates The lag between an LDAP/AD update and OPA having the update is the sum of the lag for an update between LDAP/AD and the central server and the lag for an update between the central server an OPA. So if LDAP/AD updates every 5 minutes, and OPA pulls an update every 2 minutes, then the total maximum lag is 7 minutes. Unlike the JWT case, it is feasible that a user could perform an action requiring authorization on the OPA-enabled service before OPA has the appropriate LDAP/AD policy, but you can account for that when writing policy and reject any request when there is insufficient data. @@ -81,7 +81,7 @@ Two things happen independently with this kind of LDAP/AD integration. 1. Synchronizer keeps OPA up to date with LDAP/AD 1. OPA-enabled software system asks OPA for policy decisions -{{< figure src="/img/best-practice-identity-push.png" width="80" caption="Push flow" >}} +{{< figure src="best-practice-identity-push.png" width="80" caption="Push flow" >}} ### Updates @@ -114,7 +114,7 @@ The key difference here is that every decision requires contacting LDAP/AD. If 1. OPA-enabled service asks OPA for a decision 1. OPA during evaluation asks LDAP/AD for user attributes -{{< figure src="/img/best-practice-identity-remote.png" width="80" caption="Pull flow" >}} +{{< figure src="best-practice-identity-remote.png" width="80" caption="Pull flow" >}} ### Updates LDAP/AD data is perfectly fresh. There is no lag between an update to LDAP/AD and when OPA sees that update. diff --git a/docs/content/how-does-opa-work.md b/docs/content/how-does-opa-work.md index 61e56da810..b6e33cde97 100644 --- a/docs/content/how-does-opa-work.md +++ b/docs/content/how-does-opa-work.md @@ -16,7 +16,7 @@ OPA’s RESTful APIs use JSON over HTTP so you and your users can integrate OPA When your service is integrated with OPA, your users will be able author and deploy custom policies that control the behavior of your service’s policy-enabled features. Furthermore, users can publish data to OPA that is not available to your service about their own deployment context. -{{< figure src="/img/request-response.svg" width="50" caption="OPA's query and decision model" >}} +{{< figure src="request-response.svg" width="50" caption="OPA's query and decision model" >}} In the future, both your service and its users will be able to register for, and react to, notifications triggered when OPA detects a policy-relevant change. @@ -30,7 +30,7 @@ When OPA starts for the first time, it will not contain any policies or data. Po The primary unit of data in OPA is a document, which is similar to a JSON value. Documents typically correspond to single, self-contained objects and are capable of representing both primitive types (strings, numbers, booleans, and null) as well as structured types (objects, and arrays). Documents are created, read, updated, and deleted via OPA’s [RESTful HTTP APIs](../rest-api). -{{< figure src="/img/data-model-dependencies.svg" width="70" caption="OPA data model dependencies" >}} +{{< figure src="data-model-dependencies.svg" width="70" caption="OPA data model dependencies" >}} ### Base Documents @@ -153,7 +153,7 @@ In contrast to base documents, virtual documents embody the results of evaluatin All documents pushed into OPA or computed by rules are nested under a built-in root document named data. -{{< figure src="/img/data-model-logical.svg" width="70" caption="OPA document structure" >}} +{{< figure src="data-model-logical.svg" width="70" caption="OPA document structure" >}} Example `data` document: diff --git a/docs/static/img/benefits.svg b/docs/content/images/benefits.svg similarity index 100% rename from docs/static/img/benefits.svg rename to docs/content/images/benefits.svg diff --git a/docs/static/img/best-practice-identity-bundle.graffle/data.plist b/docs/content/images/best-practice-identity-bundle.graffle/data.plist similarity index 100% rename from docs/static/img/best-practice-identity-bundle.graffle/data.plist rename to docs/content/images/best-practice-identity-bundle.graffle/data.plist diff --git a/docs/static/img/best-practice-identity-bundle.graffle/image3.png b/docs/content/images/best-practice-identity-bundle.graffle/image3.png similarity index 100% rename from docs/static/img/best-practice-identity-bundle.graffle/image3.png rename to docs/content/images/best-practice-identity-bundle.graffle/image3.png diff --git a/docs/static/img/best-practice-identity-bundle.graffle/image6.png b/docs/content/images/best-practice-identity-bundle.graffle/image6.png similarity index 100% rename from docs/static/img/best-practice-identity-bundle.graffle/image6.png rename to docs/content/images/best-practice-identity-bundle.graffle/image6.png diff --git a/docs/static/img/best-practice-identity-bundle.png b/docs/content/images/best-practice-identity-bundle.png similarity index 100% rename from docs/static/img/best-practice-identity-bundle.png rename to docs/content/images/best-practice-identity-bundle.png diff --git a/docs/static/img/best-practice-identity-jwt.graffle/data.plist b/docs/content/images/best-practice-identity-jwt.graffle/data.plist similarity index 100% rename from docs/static/img/best-practice-identity-jwt.graffle/data.plist rename to docs/content/images/best-practice-identity-jwt.graffle/data.plist diff --git a/docs/static/img/best-practice-identity-jwt.graffle/image3.png b/docs/content/images/best-practice-identity-jwt.graffle/image3.png similarity index 100% rename from docs/static/img/best-practice-identity-jwt.graffle/image3.png rename to docs/content/images/best-practice-identity-jwt.graffle/image3.png diff --git a/docs/static/img/best-practice-identity-jwt.graffle/image5.png b/docs/content/images/best-practice-identity-jwt.graffle/image5.png similarity index 100% rename from docs/static/img/best-practice-identity-jwt.graffle/image5.png rename to docs/content/images/best-practice-identity-jwt.graffle/image5.png diff --git a/docs/static/img/best-practice-identity-jwt.graffle/image6.png b/docs/content/images/best-practice-identity-jwt.graffle/image6.png similarity index 100% rename from docs/static/img/best-practice-identity-jwt.graffle/image6.png rename to docs/content/images/best-practice-identity-jwt.graffle/image6.png diff --git a/docs/static/img/best-practice-identity-jwt.png b/docs/content/images/best-practice-identity-jwt.png similarity index 100% rename from docs/static/img/best-practice-identity-jwt.png rename to docs/content/images/best-practice-identity-jwt.png diff --git a/docs/static/img/best-practice-identity-push.graffle/data.plist b/docs/content/images/best-practice-identity-push.graffle/data.plist similarity index 100% rename from docs/static/img/best-practice-identity-push.graffle/data.plist rename to docs/content/images/best-practice-identity-push.graffle/data.plist diff --git a/docs/static/img/best-practice-identity-push.graffle/image3.png b/docs/content/images/best-practice-identity-push.graffle/image3.png similarity index 100% rename from docs/static/img/best-practice-identity-push.graffle/image3.png rename to docs/content/images/best-practice-identity-push.graffle/image3.png diff --git a/docs/static/img/best-practice-identity-push.graffle/image6.png b/docs/content/images/best-practice-identity-push.graffle/image6.png similarity index 100% rename from docs/static/img/best-practice-identity-push.graffle/image6.png rename to docs/content/images/best-practice-identity-push.graffle/image6.png diff --git a/docs/static/img/best-practice-identity-push.png b/docs/content/images/best-practice-identity-push.png similarity index 100% rename from docs/static/img/best-practice-identity-push.png rename to docs/content/images/best-practice-identity-push.png diff --git a/docs/static/img/best-practice-identity-remote.graffle/data.plist b/docs/content/images/best-practice-identity-remote.graffle/data.plist similarity index 100% rename from docs/static/img/best-practice-identity-remote.graffle/data.plist rename to docs/content/images/best-practice-identity-remote.graffle/data.plist diff --git a/docs/static/img/best-practice-identity-remote.graffle/image3.png b/docs/content/images/best-practice-identity-remote.graffle/image3.png similarity index 100% rename from docs/static/img/best-practice-identity-remote.graffle/image3.png rename to docs/content/images/best-practice-identity-remote.graffle/image3.png diff --git a/docs/static/img/best-practice-identity-remote.graffle/image6.png b/docs/content/images/best-practice-identity-remote.graffle/image6.png similarity index 100% rename from docs/static/img/best-practice-identity-remote.graffle/image6.png rename to docs/content/images/best-practice-identity-remote.graffle/image6.png diff --git a/docs/static/img/best-practice-identity-remote.png b/docs/content/images/best-practice-identity-remote.png similarity index 100% rename from docs/static/img/best-practice-identity-remote.png rename to docs/content/images/best-practice-identity-remote.png diff --git a/docs/static/img/data-model-dependencies.svg b/docs/content/images/data-model-dependencies.svg similarity index 100% rename from docs/static/img/data-model-dependencies.svg rename to docs/content/images/data-model-dependencies.svg diff --git a/docs/static/img/data-model-logical.svg b/docs/content/images/data-model-logical.svg similarity index 100% rename from docs/static/img/data-model-logical.svg rename to docs/content/images/data-model-logical.svg diff --git a/docs/static/img/request-response.svg b/docs/content/images/request-response.svg similarity index 100% rename from docs/static/img/request-response.svg rename to docs/content/images/request-response.svg diff --git a/docs/layouts/shortcodes/figure.html b/docs/layouts/shortcodes/figure.html index 0975e2b143..2c4c10644b 100644 --- a/docs/layouts/shortcodes/figure.html +++ b/docs/layouts/shortcodes/figure.html @@ -1,9 +1,22 @@ -{{ $src := .Get "src" | relURL }} +{{ $src := .Get "src" }} +{{ $version := index (split $.Page.File.Path "/") 1 }} +{{/* + TODO: Remove this check once we no longer have doc releases + with non versioned images. As-is just point them to "edge" since + that version will not have the image bundled with the versioned + markdown content. +*/}} +{{ if (hasPrefix $src "/img/") }} +{{ $src = strings.TrimPrefix "/img/" $src }} +{{ $version = "edge" }} +{{ end }} + +{{ $relPath := printf "/docs/%s/images/%s" $version $src }} {{ $caption := .Get "caption" | markdownify }} {{ $width := .Get "width" | default 50 }} {{ $alt := cond (isset .Params "caption") $caption (.Get "alt" | markdownify) }}
- + {{ with $caption }}