Skip to content

Commit

Permalink
Remove logic for overlays schema
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Mar 20, 2023
1 parent c33fec1 commit f08646f
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions tools/resourcedocsgen/cmd/docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package docs

import (
"embed"
"encoding/json"
"fmt"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/ghodss/yaml"
Expand Down Expand Up @@ -35,27 +32,9 @@ var (
// could have a hand-authored overlays schema spec in the overlays folder that could be
// merged into it.
mainSpec *pschema.PackageSpec
//go:embed overlays/**/*.json
overlays embed.FS
)

func getPulumiPackageFromSchema(docsOutDir string) (*pschema.Package, error) {
overlaysSchemaFile, err := getOverlaySchema()
if err != nil {
return nil, errors.Wrap(err, "getting overlays schema")
}

if overlaysSchemaFile != nil {
overlaySpec := &pschema.PackageSpec{}

if err := json.Unmarshal(overlaysSchemaFile, overlaySpec); err != nil {
return nil, errors.Wrap(err, "unmarshalling overlay schema into a PackageSpec")
}

if err := mergeOverlaySchemaSpec(mainSpec, overlaySpec); err != nil {
return nil, errors.Wrap(err, "merging the overlay schema spec with the main spec")
}
}

// Delete existing docs before generating new ones.
if err := os.RemoveAll(docsOutDir); err != nil {
Expand All @@ -79,38 +58,6 @@ func getPulumiPackageFromSchema(docsOutDir string) (*pschema.Package, error) {
return pulPkg, nil
}

// getOverlaySchema returns the overlay file contents for the package.
// Returns nil if there is no overlay file for the package.
func getOverlaySchema() ([]byte, error) {
glog.Infoln("Checking if the package has an overlays schema...")
// Test the expected path for an overlays file. If there is no such file, assume
// that the package has no overlays.
overlayFilePath := filepath.Join("overlays", mainSpec.Name, "overlays.json")
f, err := overlays.Open(overlayFilePath)
if err != nil {
pathErr := err.(*fs.PathError)
if pathErr.Err == fs.ErrNotExist {
glog.Infoln("Didn't find an overlays schema...")
overlayFilePath = ""
} else {
return nil, errors.Wrap(err, "checking embedded overlays fs for overlay file")
}
}

if overlayFilePath == "" {
return nil, nil
}

glog.Infoln("Using the overlays schema file from", overlayFilePath)

b, err := ioutil.ReadAll(f)
if err != nil {
return nil, errors.Wrap(err, "reading overlay file from embedded fs")
}

return b, nil
}

func ResourceDocsCmd() *cobra.Command {
var schemaFile string
var version string
Expand Down

0 comments on commit f08646f

Please sign in to comment.