Skip to content

Commit

Permalink
internal/doc: remove previous experimental doc during stabilization
Browse files Browse the repository at this point in the history
  • Loading branch information
bgilbert committed Mar 27, 2023
1 parent 379d481 commit f86b410
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/stabilize-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ The changes that are required to achieve these effects are typically the followi
## Update docs

- [ ] Update `internal/doc/main.go` to add the new stable spec and reference the new experimental spec in `generate()`.
- [ ] Remove `docs/configuration-vX_Y-experimental.md`.
- [ ] Run `generate` to regenerate Go schemas and spec docs.
- [ ] Add a section to `docs/migrating-configs.md`.
- [ ] In `docs/specs.md`, update the list of stable and experimental spec versions (listing the latest stable release first) and update the table listing the Ignition release where a spec has been marked as stable.
Expand Down
21 changes: 17 additions & 4 deletions internal/doc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ package main

import (
_ "embed"
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"text/template"
Expand Down Expand Up @@ -59,12 +61,23 @@ func generate(dir string) error {
for i, c := range configs {
ver := semver.New(c.version)

// clean up any previous experimental spec doc, for use
// during spec stabilization
experimentalPath := filepath.Join(dir, fmt.Sprintf("configuration-v%d_%d_experimental.md", ver.Major, ver.Minor))
if err := os.Remove(experimentalPath); err != nil && !errors.Is(err, fs.ErrNotExist) {
return err
}

// open file
prerelease := ""
if ver.PreRelease != "" {
prerelease = "_" + string(ver.PreRelease)
var path string
switch ver.PreRelease {
case "":
path = filepath.Join(dir, fmt.Sprintf("configuration-v%d_%d.md", ver.Major, ver.Minor))
case "experimental":
path = experimentalPath
default:
panic(fmt.Errorf("unexpected prerelease: %v", ver.PreRelease))
}
path := filepath.Join(dir, fmt.Sprintf("configuration-v%d_%d%s.md", ver.Major, ver.Minor, prerelease))
f, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
Expand Down

0 comments on commit f86b410

Please sign in to comment.