Skip to content

Commit

Permalink
Rename metastore to flagstate
Browse files Browse the repository at this point in the history
The name flagstate is meant to be reminsicent of the fact that the
service stores important information about containers - just as
the "Flag State" is important information about a shipping vessel
that would be stored in a shipping registry. But in the end, it's
just a easy-to-search name.
  • Loading branch information
owtaylor committed Jan 22, 2018
1 parent 648d402 commit 887768a
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codehilite.css
coverage.out
metastore
flagstate
html
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM fedora:26

ENV DISTRIBUTION_DIR /go/src/github.com/owtaylor/metastore
ENV DISTRIBUTION_DIR /go/src/github.com/owtaylor/flagstate

# https://bugzilla.redhat.com/show_bug.cgi?id=1483553
RUN ( dnf --refresh -y update glibc || true ) && \
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ coverage:

reset-data:
docker-compose down || true
docker volume rm metastore_db metastore_registry || true
docker volume rm flagstate_db flagstate_registry || true

trust-local:
docker-compose exec frontend cat /etc/pki/tls/certs/metastore_ca.crt > metastore.crt
sudo sh -c 'cp metastore.crt /etc/pki/ca-trust/source/anchors/ && update-ca-trust'
docker-compose exec frontend cat /etc/pki/tls/certs/flagstate_ca.crt > flagstate.crt
sudo sh -c 'cp flagstate.crt /etc/pki/ca-trust/source/anchors/ && update-ca-trust'
sudo sh -c 'grep -l registry.local.fishsoup.net /etc/hosts > /dev/null || echo "127.0.0.1 registry.local.fishsoup.net" >> /etc/hosts'
rm -f metastore.crt
rm -f flagstate.crt

untrust-local:
sudo sh -c 'rm /etc/pki/ca-trust/source/anchors/metastore.crt && update-ca-trust'
sudo sh -c 'rm /etc/pki/ca-trust/source/anchors/flagstate.crt && update-ca-trust'
sudo sh -c 'sed -i /registry.local.fishsoup.net/d /etc/hosts'

MARKDOWN= \
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metastore
Flagstate
---------
metastore is a service designed to be deployed alongside a
flagstate is a service designed to be deployed alongside a
[docker/distribution](https://github.com/docker/distribution/) registry instance
to collect and serve up metadata for images in the registry. Being separate from
the registry has a number of advantages:
Expand All @@ -12,15 +12,15 @@ the registry has a number of advantages:

See https://github.com/docker/distribution/issues/206

Some possible ways that metastore could be used:
Some possible ways that flagstate could be used:

* Providing comprehensive dumps of metadata
* Providing a simple web interface to allow seeing what is in the registry
* Providing an implementation of the `/v1/search/` API behind `docker search`

Design
------
The basic idea is that metastore scans the registry, either entirely, or as
The basic idea is that flagstate scans the registry, either entirely, or as
updated by [webhook notifications](https://docs.docker.com/registry/notifications/),
and then the information that is harvested is stored into a database.
The current code stores the metadata in a Postgresql database, using a
Expand Down Expand Up @@ -89,8 +89,8 @@ There is a test environment that can be started with:
docker-compose up
```
This starts a cluster of database, registry, metastore and a web proxy that joins
the registry and metastore into a single web presence, available on
This starts a cluster of database, registry, flagstate and a web proxy that joins
the registry and flagstate into a single web presence, available on
http://127.0.0.1:7080, or https://127.0.0.1:7443. On Fedora or RHEL you can
```
Expand All @@ -105,4 +105,4 @@ via HTTPS and expect a verifiable certificate.)
License
-------
metastore is distributed is distributed under the [Apache License, Version 2.0](LICENSE).
flagstate is distributed is distributed under the [Apache License, Version 2.0](LICENSE).
2 changes: 1 addition & 1 deletion config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ registry:
url: https://candidate-registry.fedoraproject.org
database:
postgres:
url: postgres://metastore:mypassword@localhost:7432/metastore?sslmode=disable
url: postgres://flagstate:mypassword@localhost:7432/flagstate?sslmode=disable
interval:
fetch_all: 1h
garbage_collect: 30m
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ services:
ports:
- 7432:5432
environment:
- POSTGRES_DB=metastore
- POSTGRES_USER=metastore
- POSTGRES_DB=flagstate
- POSTGRES_USER=flagstate
- POSTGRES_PASSWORD=mypassword
volumes:
- db:/var/lib/postgresql/data:z
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"
)

var configFile = flag.String("config", "/etc/metastore/config.yaml", "Path to configuration file")
var configFile = flag.String("config", "/etc/flagstate/config.yaml", "Path to configuration file")

func internalError(w http.ResponseWriter, err error) {
w.Header().Set("Content-Type", "text/plain")
Expand Down Expand Up @@ -94,6 +94,6 @@ func main() {
})
}

log.Printf("metastore: %s", BuildString)
log.Printf("flagstate: %s", BuildString)
log.Fatal(http.ListenAndServe(":8088", handlers.LoggingHandler(os.Stdout, http.DefaultServeMux)))
}
2 changes: 1 addition & 1 deletion psql.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
PGPASSWORD=mypassword psql -h 127.0.0.1 -U metastore -p 7432 "$@"
PGPASSWORD=mypassword psql -h 127.0.0.1 -U flagstate -p 7432 "$@"

2 changes: 1 addition & 1 deletion services/frontend/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

if ! [ -e /etc/pki/tls/certs/metastore.crt ] ; then
if ! [ -e /etc/pki/tls/certs/flagstate.crt ] ; then
generate-cert.sh
fi

Expand Down
4 changes: 2 additions & 2 deletions services/frontend/frontend.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ ProxyPassReverse "/" "http://index:8088/"

<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/metastore.crt
SSLCertificateKeyFile /etc/pki/tls/private/metastore.key
SSLCertificateFile /etc/pki/tls/certs/flagstate.crt
SSLCertificateKeyFile /etc/pki/tls/private/flagstate.key
</VirtualHost>
22 changes: 11 additions & 11 deletions services/frontend/generate-cert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ trap cleanup EXIT
cd $work

# Generate private keys
openssl genrsa -out metastore_ca.key 2048
openssl genrsa -out metastore.key 2048
openssl genrsa -out flagstate_ca.key 2048
openssl genrsa -out flagstate.key 2048

# Generate CSRs
cat > ca.config <<EOF
Expand All @@ -24,8 +24,8 @@ req_extensions=v3_req
basicConstraints=critical,CA:TRUE,pathlen:0
[cadn]
CN=Metastore CA
OU=Metastore
CN=Flagstate CA
OU=Flagstate
[email protected]
EOF

Expand All @@ -41,19 +41,19 @@ basicConstraints=critical,CA:FALSE
[certdn]
CN=registry.local.fishsoup.net
OU=Metastore
OU=Flagstate
[email protected]
EOF

openssl req -new -config ca.config -key metastore_ca.key -out metastore_ca.csr
openssl req -new -config cert.config -key metastore.key -out metastore_cert.csr
openssl req -new -config ca.config -key flagstate_ca.key -out flagstate_ca.csr
openssl req -new -config cert.config -key flagstate.key -out flagstate_cert.csr

# Generate Root Certificate
openssl x509 -req -in metastore_ca.csr -days 365 -extfile ca.config -extensions v3_req -signkey metastore_ca.key -out metastore_ca.crt
openssl x509 -req -in flagstate_ca.csr -days 365 -extfile ca.config -extensions v3_req -signkey flagstate_ca.key -out flagstate_ca.crt

# Generate Server Certificate
openssl x509 -req -in metastore_cert.csr -days 365 -extfile cert.config -extensions v3_req -CA metastore_ca.crt -CAkey metastore_ca.key -CAcreateserial -out metastore.crt
openssl x509 -req -in flagstate_cert.csr -days 365 -extfile cert.config -extensions v3_req -CA flagstate_ca.crt -CAkey flagstate_ca.key -CAcreateserial -out flagstate.crt

# Copy the files to the correct locations
cp metastore.crt metastore_ca.crt /etc/pki/tls/certs
cp metastore.key /etc/pki/tls/private/
cp flagstate.crt flagstate_ca.crt /etc/pki/tls/certs
cp flagstate.key /etc/pki/tls/private/
2 changes: 1 addition & 1 deletion services/index/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ events:
token: "OPEN_SESAME"
database:
postgres:
url: postgres://metastore:mypassword@db:5432/metastore?sslmode=disable
url: postgres://flagstate:mypassword@db:5432/flagstate?sslmode=disable
cache:
max_age_index: 1s
max_age_html: 1s
Expand Down
6 changes: 3 additions & 3 deletions services/index/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

psql() {
PGPASSWORD=mypassword /usr/bin/psql -h db -U metastore "$@"
PGPASSWORD=mypassword /usr/bin/psql -h db -U flagstate "$@"
}

topdir=$(dirname $0)/../..

while true ; do
if psql -l | grep -q metastore ; then
if psql -l | grep -q flagstate ; then
break
fi
sleep 1
Expand All @@ -22,4 +22,4 @@ if ! $exists ; then
psql < schema.sql
fi

exec $topdir/metastore -config $(dirname $0)/config.yaml
exec $topdir/flagstate -config $(dirname $0)/config.yaml
18 changes: 9 additions & 9 deletions start-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ if [ "$1" = "--refresh" ] ; then
refresh=true
fi

if docker ps -f name=metastore-db | grep metastore-db > /dev/null ; then
if docker ps -f name=flagstate-db | grep flagstate-db > /dev/null ; then
if $refresh ; then
docker rm -f metastore-db
docker rm -f flagstate-db
else
echo "Already running"
exit 1
fi
fi

exists=false
if docker volume ls | grep metastore-db > /dev/null ; then
if docker volume ls | grep flagstate-db > /dev/null ; then
exists=true
fi

if $refresh ; then
docker volume rm metastore-db || true
docker volume rm flagstate-db || true
exists=false
fi

docker run \
--detach \
--rm=true \
--name=metastore-db \
-v metastore-db:/var/lib/pgsql/data \
--name=flagstate-db \
-v flagstate-db:/var/lib/pgsql/data \
-p 7432:5432 \
-e POSTGRES_DB=metastore \
-e POSTGRES_USER=metastore \
-e POSTGRES_DB=flagstate \
-e POSTGRES_USER=flagstate \
-e POSTGRES_PASSWORD=mypassword \
postgres

while true ; do
if $(dirname $0)/psql.sh -l 2>/dev/null | grep metastore ; then
if $(dirname $0)/psql.sh -l 2>/dev/null | grep flagstate ; then
break
fi
sleep 1
Expand Down

0 comments on commit 887768a

Please sign in to comment.