CLI utility for WordPress VIP data sync management.
To validate the environment-specific YAML config file against production URLs:
- Download the environment-specific YAML config file from the
masterbranches of wpcomvip repos - Export the production URLs via:
vip @my-app.produciton -- wp site list --fields=url --format=json
- Run the
validatecommand:vipdatasync validate --config=config.yml --urls=sites.json
Example: Bash Script
gh api \
-H "Accept: application/vnd.github.raw+yaml" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/wpcomvip/my-app/contents/config/.vip.my-app.staging.yml\?ref=preprod \
> ~/Desktop/.vip.my-app.staging.yml
vip @my-app.production --yes -- wp site list --fields=url --format=json > ~/Desktop/my-app-production-sites.json
vipdatasync validate --config=~/Desktop/.vip.my-app.staging.yml --urls=~/Desktop/my-app-production-sites.jsonMultiple domain map items to the same destination.
Important
Special case:
It is considered valid if both www and non-www sources are mapped to the same destination where the www item comes first.
Duplication
data_sync:
domain_map:
vip-example.com: example-com-staging.go-vip.net
example.go-vip.net: example-com-staging.go-vip.net$ vipdatasync validate
DUPLICATED DESTINATIONS
1. example-com-staging.go-vip.net
- vip-example.com
- example.go-vip.netSpecial case: www and non-www with good ordering
data_sync:
domain_map:
www.vip-example.com: example-com-staging.go-vip.net
vip-example.com: example-com-staging.go-vip.net$ vipdatasync validate
DUPLICATED DESTINATIONS
No problems foundSee validate_duplicated_destinations_www_ordering_good.txtar.
Exact duplication
data_sync:
domain_map:
vip-example.com: example-com-staging.go-vip.net
vip-example.com: example-com-staging.go-vip.net$ vipdatasync validate
DUPLICATED DESTINATIONS
1. example-com-staging.go-vip.net
- vip-example.com
- vip-example.comwww and non-www with extra items
data_sync:
domain_map:
www.vip-example.com: example-com-staging.go-vip.net
vip-example.com: example-com-staging.go-vip.net
foo.com: example-com-staging.go-vip.net$ vipdatasync validate
DUPLICATED DESTINATIONS
1. example-com-staging.go-vip.net
- www.vip-example.com
- vip-example.com
- foo.comwww and non-www with bad ordering
data_sync:
domain_map:
vip-example.com: example-com-staging.go-vip.net
www.vip-example.com: example-com-staging.go-vip.net$ vipdatasync validate
DUPLICATED DESTINATIONS
1. example-com-staging.go-vip.net
- vip-example.com
- www.vip-example.comSee validate_duplicated_destinations_www_ordering_bad.txtar.
Note
It is safe to ignore catch-all items which map both convenience and production domains to the same destination.
The command reports duplicated destination problems for catch-all items. There is no plan to fix this false-alarm because of the complexity to reliably identify the main production domain.
Example: Catch-all
This is safe to ignore.
data_sync:
domain_map:
vip-example.com: example-com-staging.go-vip.net
vip-example.go-vip.net: example-com-staging.go-vip.net# This is safe to ignore
$ vipdatasync validate
DUPLICATED DESTINATIONS
1. example-com-staging.go-vip.net
- vip-example.com
- vip-example.go-vip.netMultiple production URLs map to the same environment-specific URL.
Duplication
data_sync:
domain_map:
vip-example.com: example-com-staging.go-vip.net
example.go-vip.net/zh: example-com-staging.go-vip.net/en[
{
"url": "https://vip-example.com/en"
},
{
"url": "https://example.go-vip.net/zh"
}
]$ vipdatasync validate
DUPLICATED TOS
1. https://example-com-staging.go-vip.net/en
- https://vip-example.com/en
vip-example.com
-> example-com-staging.go-vip.net
- https://example.go-vip.net/zh
example.go-vip.net/zh
-> example-com-staging.go-vip.net/enUnreplaced
data_sync:
domain_map:
vip-example.com: example-com-staging.go-vip.net[
{
"url": "https://vip-example.com/en"
},
{
"url": "https://example-com-staging.go-vip.net/en"
}
]$ vipdatasync validate
DUPLICATED TOS
1. https://example-com-staging.go-vip.net/en
- https://vip-example.com/en
vip-example.com
-> example-com-staging.go-vip.net
- https://example-com-staging.go-vip.net/enProduction URLs that are not replaced by any domain map item.
Unreplaced
data_sync:
domain_map:
vip-example.com: example-com-staging.go-vip.net
example.go-vip.net/zh: example-com-staging.go-vip.net/zh[
{
"url": "https://example.go-vip.net"
},
{
"url": "https://vip-example.com/en"
},
{
"url": "https://example.go-vip.net/en"
},
{
"url": "https://example.go-vip.net/zh"
}
]$ vipdatasync validate
UNREPLACED URLS
1. https://example.go-vip.net
2. https://example.go-vip.net/enDomain map items that are not used by any production URLs.
Unused
data_sync:
domain_map:
foo.com/zh: foo-com-staging.go-vip.net/zh
foo.com: foo-com-staging.go-vip.net
bar.com/zh: bar-com-staging.go-vip.net/zh
bar.com/fr: bar-com-staging.go-vip.net/fr
bar.com: bar-com-staging.go-vip.net
vip-example.com: example-com-staging.go-vip.net[
{
"url": "https://vip-example.com"
},
{
"url": "https://vip-example.com/en"
},
{
"url": "https://foo.com/zh"
},
{
"url": "https://bar.com/en"
},
{
"url": "https://bar.com/zh"
},
{
"url": "https://bar.com"
}
]$ vipdatasync validate
UNUSED DOMAIN MAP ITEMS
1. foo.com
-> foo-com-staging.go-vip.net
2. bar.com/fr
-> bar-com-staging.go-vip.net/frBad ordering
data_sync:
domain_map:
foo.com: foo-com-staging.go-vip.net
foo.com/zh: foo-com-staging.go-vip.net/zh
bar.com: bar-com-staging.go-vip.net
bar.com/fr: bar-com-staging.go-vip.net/fr
bar.com/zh: bar-com-staging.go-vip.net/zh
vip-example.com: example-com-staging.go-vip.net[
{
"url": "https://vip-example.com"
},
{
"url": "https://vip-example.com/en"
},
{
"url": "https://foo.com/zh"
},
{
"url": "https://bar.com/en"
},
{
"url": "https://bar.com/zh"
},
{
"url": "https://bar.com"
}
]$ vipdatasync validate
UNUSED DOMAIN MAP ITEMS
1. foo.com/zh
-> foo-com-staging.go-vip.net/zh
2. bar.com/fr
-> bar-com-staging.go-vip.net/fr
3. bar.com/zh
-> bar-com-staging.go-vip.net/zhTip
Find your operating system and hardware architecture via:
$ uname -om
Darwin arm64Prebuilt binaries are available for a variety of operating systems and architectures. Visit the latest release page, and scroll down to the Assets section.
- Download the archive for the desired edition, operating system, and architecture
- Extract the archive
- (Optional) Verify the integrity and provenance of the executable
$ gh attestation verify /path/to/vipdatasync_999.888.777_xxx_yyy/vipdatasync --repo typisttech/vipdatasync --signer-repo typisttech/vipdatasync Loaded digest sha256:xxxxxxxxxxxxxxxxxx for file:///path/to/vipdatasync_999.888.777_xxx_yyy/vipdatasync Loaded 1 attestation from GitHub API ✓ Verification succeeded! sha256:xxxxxxxxxxxxxxxxxx was attested by: REPO PREDICATE_TYPE WORKFLOW typisttech/vipdatasync https://slsa.dev/provenance/v1 .github/workflows/go-release.yml@refs/tags/v999.888.777
- Move the executable to the desired directory
- Add this directory to the
PATHenvironment variable - Verify that you have execute permission on the file
Please consult your operating system documentation if you need help setting file permissions or modifying your PATH environment variable.
If you do not see a prebuilt binary for the desired edition, operating system, and architecture, install using one of the methods described below.
Tip
See $ go help install or https://golang.org/ref/mod#go-install for details.
go install github.com/typisttech/vipdatasync/cmd/vipdatasync@latest# Run the tests
go test -v -count=1 -race -shuffle=on ./...
# Update testscript golden files
# Note: This doesn't update the README.md examples
UPDATE_SCRIPTS=true go test ./cmd/...
# Lint
golangci-lint run
goreleaser check