Skip to content

Commit

Permalink
added wasm rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed May 23, 2024
1 parent a686cc9 commit 6bd2917
Show file tree
Hide file tree
Showing 9 changed files with 7,334 additions and 108 deletions.
4 changes: 2 additions & 2 deletions pkg/create_html_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func RenderContent(w io.Writer, crdContent []byte, comments, minimal bool) error
parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, comments, minimal)

for _, version := range crd.Spec.Versions {
out, err := parseCRD(version.Schema.OpenAPIV3Schema.Properties, version.Name, minimal, rootRequiredFields)
out, err := parseCRD(version.Schema.OpenAPIV3Schema.Properties, version.Name, minimal, RootRequiredFields)
if err != nil {
return fmt.Errorf("failed to parse properties: %w", err)
}
var buffer []byte
buf := bytes.NewBuffer(buffer)
if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields); err != nil {
if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields); err != nil {
return fmt.Errorf("failed to generate yaml sample: %w", err)
}
versions = append(versions, Version{
Expand Down
4 changes: 2 additions & 2 deletions pkg/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const array = "array"

var rootRequiredFields = []string{"apiVersion", "kind", "spec"}
var RootRequiredFields = []string{"apiVersion", "kind", "spec"}

// Generate takes a CRD content and path, and outputs.
func Generate(crd *v1beta1.CustomResourceDefinition, w io.WriteCloser, enableComments, minimal bool) (err error) {
Expand All @@ -24,7 +24,7 @@ func Generate(crd *v1beta1.CustomResourceDefinition, w io.WriteCloser, enableCom
}()
parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, enableComments, minimal)
for i, version := range crd.Spec.Versions {
if err := parser.ParseProperties(version.Name, w, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields); err != nil {
if err := parser.ParseProperties(version.Name, w, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields); err != nil {
return fmt.Errorf("failed to parse properties: %w", err)
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestGenerate(t *testing.T) {

version := crd.Spec.Versions[0]
parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, false, false)
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields))
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields))

golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_golden.yaml"))
require.NoError(t, err)
Expand All @@ -44,7 +44,7 @@ func TestGenerateWithExample(t *testing.T) {

parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, false, false)
version := crd.Spec.Versions[0]
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields))
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields))

golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_with_example_golden.yaml"))
require.NoError(t, err)
Expand All @@ -64,7 +64,7 @@ func TestGenerateWithComments(t *testing.T) {

parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, true, false)
version := crd.Spec.Versions[0]
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields))
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields))

golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_with_comments_golden.yaml"))
require.NoError(t, err)
Expand All @@ -84,7 +84,7 @@ func TestGenerateMinimal(t *testing.T) {

parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, false, true)
version := crd.Spec.Versions[0]
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields))
require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields))

golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_with_minimal_example_golden.yaml"))
require.NoError(t, err)
Expand Down
7,388 changes: 7,307 additions & 81 deletions sample-crd/awsclusters.infrastructure.cluster.x-k8s.io_sample.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions wasm/app-worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const cacheName = "app-" + "f12aae0089af3c57e2d86eef472876387bf42dc1";
const cacheName = "app-" + "0bbe4f618b019a028888bfd14fb564d3bd34e87d";
const resourcesToCache = ["/","/app.css","/app.js","/manifest.webmanifest","/wasm_exec.js","/web/app.wasm","/web/css/alert.css","/web/img/logo.png","https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js","https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css","https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js","https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css","https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css"];

self.addEventListener("install", (event) => {
console.log("installing app worker f12aae0089af3c57e2d86eef472876387bf42dc1");
console.log("installing app worker 0bbe4f618b019a028888bfd14fb564d3bd34e87d");

event.waitUntil(
caches
Expand All @@ -28,7 +28,7 @@ self.addEventListener("activate", (event) => {
);
})
);
console.log("app worker f12aae0089af3c57e2d86eef472876387bf42dc1 is activated");
console.log("app worker 0bbe4f618b019a028888bfd14fb564d3bd34e87d is activated");
});

self.addEventListener("fetch", (event) => {
Expand Down
6 changes: 3 additions & 3 deletions wasm/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ func (h *crdView) Render() app.UI {
}

versions := make([]Version, 0)
parser := pkg.NewParser(crd.Spec.Group, crd.Spec.Names.Kind, h.comment)
parser := pkg.NewParser(crd.Spec.Group, crd.Spec.Names.Kind, h.comment, false)
for _, version := range crd.Spec.Versions {
out, err := parseCRD(version.Schema.OpenAPIV3Schema.Properties, version.Name, version.Schema.OpenAPIV3Schema.Required)
out, err := parseCRD(version.Schema.OpenAPIV3Schema.Properties, version.Name, pkg.RootRequiredFields)
if err != nil {
return h.buildError(err)
}
var buffer []byte
buf := bytes.NewBuffer(buffer)
if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties); err != nil {
if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties, pkg.RootRequiredFields); err != nil {
return h.buildError(err)
}
versions = append(versions, Version{
Expand Down
2 changes: 1 addition & 1 deletion wasm/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var goappNav = function () {};
var goappOnUpdate = function () {};
var goappOnAppInstallChange = function () {};

const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"f12aae0089af3c57e2d86eef472876387bf42dc1"};
const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"0bbe4f618b019a028888bfd14fb564d3bd34e87d"};
const goappLoadingLabel = "{progress}%";
const goappWasmContentLengthHeader = "";

Expand Down
24 changes: 12 additions & 12 deletions wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
<meta name="description" content>
<meta name="keywords" content>
<meta name="theme-color" content="#2d2c2c">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover">
<meta property="og:url" content="http://127.0.0.1:55423/">
<meta property="og:title" content="Preview CRDs">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover" name="viewport">
<meta property="og:url" content="http://127.0.0.1:50903/">
<meta content="Preview CRDs" property="og:title">
<meta property="og:description" content>
<meta property="og:type" content="website">
<meta content="website" property="og:type">
<meta property="og:image" content>
<title>Preview CRDs</title>
<link as="style" type="text/css" rel="preload" href="/app.css">
<link type="text/css" rel="preload" href="/web/css/alert.css" as="style">
<link type="text/css" rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css" as="style">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" as="style" type="text/css">
<link href="/web/css/alert.css" as="style" type="text/css" rel="preload">
<link as="style" type="text/css" rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css">
<link type="text/css" rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" as="style">
<link type="text/css" rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" as="style">
<link rel="icon" href="https://raw.githubusercontent.com/maxence-charriere/go-app/master/docs/web/icon.svg">
<link rel="apple-touch-icon" href="/web/img/logo.png">
<link href="/manifest.webmanifest" rel="manifest">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="stylesheet" type="text/css" href="/app.css">
<link type="text/css" href="/web/css/alert.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css" rel="stylesheet" type="text/css">
<link type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/web/css/alert.css">
<link type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script defer src="/wasm_exec.js"></script>
<script defer src="/app.js"></script>
Expand Down Expand Up @@ -62,7 +62,7 @@
<body>
<main></main>
<aside id="app-wasm-loader" class="goapp-app-info">
<img id="app-wasm-loader-icon" class="goapp-logo goapp-spin" src="/web/img/logo.png">
<img class="goapp-logo goapp-spin" src="/web/img/logo.png" id="app-wasm-loader-icon">
<p id="app-wasm-loader-label" class="goapp-label">0%</p>
</aside>
</body>
Expand Down
Binary file modified wasm/web/app.wasm
Binary file not shown.

0 comments on commit 6bd2917

Please sign in to comment.