Skip to content

Commit

Permalink
Rename project and add better user-focused docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pwtyler committed Apr 10, 2023
1 parent 537e3fc commit 1f3485c
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 41 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/pyml-validator
/pyml-validator.yml
/sites-yml-validator

.DS_Store

Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
project_name: pyml-validator
project_name: sites-yml-validator

before:
hooks:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APP := pyml-validator
APP := sites-yml-validator

include devops/make/common.mk
include devops/make/common-go.mk
Expand Down
45 changes: 32 additions & 13 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,46 +1,65 @@
# Pantheon YML Validator

A utility for validating a sites.yml file on a Pantheon site during WordPress multisites' search-replace tasks. Asprirationally to include pantheon.yml validation in the future.
[![Early Access](https://img.shields.io/badge/Pantheon-Early_Access-yellow?logo=pantheon&color=FFDC28)](https://docs.pantheon.io/oss-support-levels#early-access)

A utility for validating a `sites.yml` file on a Pantheon site during a WordPress multisite's search and replace tasks. For more information, see [Pantheon's Multisite Docs](https://docs.pantheon.io/guides/multisite/search-replace/).

## Usage

### Sites.yml
### sites.yml
To validate the `sites.yml` file, run:
```
$ pyml-validator sites path/to/sites.yml
$ sites-yml-validator sites path/to/sites.yml
```

See [this annotated fixture](./fixtures/sites/valid.yml) for an example of a valid sites.yml file.
#### Valid File Example
See [this annotated fixture](./fixtures/sites/valid.yml) for an example of a valid `sites.yml` file.

The basic format for the file is:
``` yml
api_version: 1
domain_maps:
{env_name}:
{blog_id}: {site_url}
```
A `sites.yml` file is valid if:
- the `api_version` is `1`
- the key for each item in `domain_maps` is a valid Pantheon environment name (`dev`, `test`, `multidev`, etc.)
- For each subsite listed for an environment:
- the key is an integer
- the value is a valid Pantheon hostname
- there are no more than 25 subsites listed for any environment

## Install

### [Download the latest binary](https://github.com/pantheon-systems/pyml-validator/releases/latest)
### [Download the latest binary](https://github.com/pantheon-systems/sites-yml-validator/releases/latest)

Use wget to download, gzipped pre-compiled binaries:
For instance, VERSION=v0.0.11 and BINARY=pyml-validator_linux_amd64
For instance, VERSION=v0.0.11 and BINARY=sites-yml-validator_linux_amd64

### Compressed via tar.gz
```bash
wget https://github.com/pantheon-systems/pyml-validator/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
tar xz && mv ${BINARY} /usr/bin/pyml-validator
wget https://github.com/pantheon-systems/sites-yml-validator/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
tar xz && mv ${BINARY} /usr/bin/sites-yml-validator
```

### Plain binary

```bash
wget https://github.com/pantheon-systems/pyml-validator/releases/download/${VERSION}/${BINARY} -O /usr/bin/pyml-validator &&\
chmod +x /usr/bin/pyml-validator
wget https://github.com/pantheon-systems/sites-yml-validator/releases/download/${VERSION}/${BINARY} -O /usr/bin/sites-yml-validator &&\
chmod +x /usr/bin/sites-yml-validator
```

### Latest version

```bash
wget https://github.com/pantheon-systems/pyml-validator/releases/latest/download/pyml-validator_linux_amd64 -O /usr/bin/pyml-validator &&\
chmod +x /usr/bin/pyml-validator
wget https://github.com/pantheon-systems/sites-yml-validator/releases/latest/download/sites-yml-validator_linux_amd64 -O /usr/bin/sites-yml-validator &&\
chmod +x /usr/bin/sites-yml-validator
```

## Testing

[![Coverage Status](https://coveralls.io/repos/github/pantheon-systems/pyml-validator/badge.svg?t=PGhafd)](https://coveralls.io/github/pantheon-systems/pyml-validator)
[![Coverage Status](https://coveralls.io/repos/github/pantheon-systems/sites-yml-validator/badge.svg?t=PGhafd)](https://coveralls.io/github/pantheon-systems/sites-yml-validator)

`make test` runs linting and testing.

Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
var FilePath string

var rootCmd = &cobra.Command{
Use: "pyml-validator",
Short: "Pyml-validator validates sites.yml",
Long: `Pyml-validator is a validator for sites.yml, used for WPMS search-replace.
Use: "sites-yml-validator",
Short: "sites-yml-validator validates sites.yml",
Long: `sites-yml-validator is a validator for sites.yml, used for WPMS search-replace.
Ensures that the given config file can be used by the platform.`,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"fmt"
"pyml-validator/pkg/validator"
"sites-yml-validator/pkg/validator"

"github.com/spf13/cobra"
)
Expand Down
20 changes: 5 additions & 15 deletions fixtures/sites/valid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,9 @@ domain_maps:
4: staff-portal.searchreplacetest.com
5: customers.searchreplacetest.com
6: hr-department.searchreplacetest.com
autopilot:
1: autopilot-srtest.pantheonsite.io
2: about.autopilot-srtest.pantheonsite.io
5: customers.autopilot-srtest.pantheonsite.io
6: hr-department.autopilot-srtest.pantheonsite.io
nomatch:
31: jobs.nomatch-srtest.pantheonsite.io
32: legal.nomatch-srtest.pantheonsite.io
domains:
1: searchreplace.com
2: about-searchreplace.com
3: employee-resources-searchreplace.com
4: staff-portal-searchreplace.com
5: customers-searchreplace.com
6: hr-department-searchreplace.com
mdevname:
1: mdevname-srtest.pantheonsite.io
2: about.mdevname-srtest.pantheonsite.io
5: customers.mdevname-srtest.pantheonsite.io
6: hr-department.mdevname-srtest.pantheonsite.io
# Anything else in the file will be ignored, but not rejected.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module pyml-validator
module sites-yml-validator

go 1.20

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "pyml-validator/cmd"
import "sites-yml-validator/cmd"

func main() {
cmd.Execute()
Expand Down
3 changes: 2 additions & 1 deletion pkg/model/sites.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ type SitesYml struct {
DomainMaps DomainMaps `yaml:"domain_maps"`
}

// DomainMaps is a collection of blog ID/blog domains keyed by environment name.
type DomainMaps map[string]DomainMapByEnvironment

// DomainMapByEnvironment is a map of site (blog) domains keyed by blog ID.
// DomainMapByEnvironment is a collection of site (blog) domains keyed by blog ID.
type DomainMapByEnvironment map[int]string
2 changes: 1 addition & 1 deletion pkg/validator/sites.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package validator
import (
"fmt"
"os"
"pyml-validator/pkg/model"
"regexp"
"sites-yml-validator/pkg/model"

"gopkg.in/yaml.v3"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/validator/sites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package validator
import (
"errors"
"fmt"
"pyml-validator/pkg/model"
"sites-yml-validator/pkg/model"
"strings"
"testing"

Expand Down

0 comments on commit 1f3485c

Please sign in to comment.