Skip to content

Commit

Permalink
Update to recent changes in the package-registry (elastic#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtojek authored Jul 1, 2020
1 parent 07c536d commit e176d16
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 45 deletions.
19 changes: 9 additions & 10 deletions internal/cluster/boot_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import (
const envFile = ".env"

func BootUp() error {
buildPublicPath, found, err := findBuildPublicDirectory()
buildPackagesPath, found, err := findBuildPackagesDirectory()
if err != nil {
return errors.Wrap(err, "finding build packages directory failed")
}

var envFileContent string
if found {
fmt.Printf("Custom build/public directory found: %s\n", buildPublicPath)
envFileContent = fmt.Sprintf("PACKAGES_PATH=%s\n", buildPublicPath)
fmt.Printf("Custom build packages directory found: %s\n", buildPackagesPath)
envFileContent = fmt.Sprintf("PACKAGES_PATH=%s\n", buildPackagesPath)
}
err = writeEnvFile(buildPublicPath, envFileContent)
err = writeEnvFile(envFileContent)
if err != nil {
return errors.Wrapf(err, "writing .env file failed (packagesPath: %s)", buildPublicPath)
return errors.Wrapf(err, "writing .env file failed (packagesPath: %s)", buildPackagesPath)
}

err = dockerComposeUp(found)
Expand All @@ -37,15 +37,15 @@ func BootUp() error {
return nil
}

func findBuildPublicDirectory() (string, bool, error) {
func findBuildPackagesDirectory() (string, bool, error) {
workDir, err := os.Getwd()
if err != nil {
return "", false, errors.Wrap(err, "locating working directory failed")
}

dir := workDir
for dir != "." {
path := filepath.Join(dir, "build", "public")
path := filepath.Join(dir, "build", "integrations")
fileInfo, err := os.Stat(path)
if err == nil && fileInfo.IsDir() {
return path, true, nil
Expand All @@ -59,7 +59,7 @@ func findBuildPublicDirectory() (string, bool, error) {
return "", false, nil
}

func writeEnvFile(buildPublicPath, content string) error {
func writeEnvFile(content string) error {
clusterDir, err := install.ClusterDir()
if err != nil {
return errors.Wrap(err, "locating cluster directory failed")
Expand All @@ -79,8 +79,7 @@ func dockerComposeUp(useCustomPackagesPath bool) error {
}

var args []string
args = append(args, "-f", filepath.Join(clusterDir, "snapshot.yml"),
"-f", filepath.Join(clusterDir, "local.yml"))
args = append(args, "-f", filepath.Join(clusterDir, "snapshot.yml"))

if useCustomPackagesPath {
args = append(args, "-f", filepath.Join(clusterDir, "package-registry-volume.yml"))
Expand Down
2 changes: 1 addition & 1 deletion internal/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func writeClusterResources(elasticPackagePath string) error {
}

err = writeStaticResource(err, clusterPath, "kibana.config.yml", kibanaConfigYml)
err = writeStaticResource(err, clusterPath, "local.yml", localYml)
err = writeStaticResource(err, clusterPath, "package-registry.config.yml", packageRegistryConfigYml)
err = writeStaticResource(err, clusterPath, "snapshot.yml", snapshotYml)
err = writeStaticResource(err, clusterPath, "package-registry-volume.yml", packageRegistryVolumeYml)

Expand Down
9 changes: 6 additions & 3 deletions internal/install/static_kibana_config_yml.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package install

var kibanaConfigYml = `server.name: kibana
const kibanaConfigYml = `
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
Expand All @@ -12,7 +13,9 @@ xpack.ingestManager.enabled: true
xpack.ingestManager.epm.enabled: true
xpack.ingestManager.epm.registryUrl: "http://package-registry:8080"
xpack.ingestManager.fleet.enabled: true
xpack.ingestManager.fleet.elasticsearch.host: "http://elasticsearch:9200"
xpack.ingestManager.fleet.kibana.host: "http://kibana:5601"
xpack.ingestManager.fleet.elasticsearch.host: "http://localhost:9200"
xpack.ingestManager.fleet.kibana.host: "http://localhost:5601"
xpack.ingestManager.fleet.tlsCheckDisabled: true
xpack.encryptedSavedObjects.encryptionKey: "12345678901234567890123456789012"
`
16 changes: 0 additions & 16 deletions internal/install/static_local_yml.go

This file was deleted.

7 changes: 7 additions & 0 deletions internal/install/static_package_registry_config_yml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package install

const packageRegistryConfigYml = `package_paths:
- /registry/packages/integrations
- /registry/packages/package-storage
dev_mode: true
`
3 changes: 2 additions & 1 deletion internal/install/static_package_registry_volume_yml.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const packageRegistryVolumeYml = `version: '2.3'
services:
package-registry:
volumes:
- ${PACKAGES_PATH}:/registry/public
- ./package-registry.config.yml:/registry/config.yml
- ${PACKAGES_PATH}:/registry/packages/integrations
`
22 changes: 8 additions & 14 deletions internal/install/static_snapshot_yml.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
- "xpack.security.enabled=true"
- "xpack.security.authc.api_key.enabled=true"
- "ELASTIC_PASSWORD=changeme"
ports:
- "127.0.0.1:9200:9200"
kibana:
image: docker.elastic.co/kibana/kibana:8.0.0-SNAPSHOT
Expand All @@ -27,28 +29,20 @@ services:
package-registry:
condition: service_healthy
healthcheck:
test: "curl -f http://localhost:5601/login | grep kbn-injected-metadata 2>&1 >/dev/null"
test: "curl -f http://127.0.0.1:5601/login | grep kbn-injected-metadata 2>&1 >/dev/null"
retries: 600
interval: 1s
volumes:
- ./kibana.config.yml:/usr/share/kibana/config/kibana.yml
ports:
- "127.0.0.1:5601:5601"
package-registry:
image: docker.elastic.co/package-registry/package-registry:master
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
test: ["CMD", "curl", "-f", "http://127.0.0.1:8080"]
retries: 300
interval: 1s
elastic-agent:
image: docker.elastic.co/beats/elastic-agent:8.0.0-SNAPSHOT
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
environment:
- "FLEET_ENROLL=1"
- "FLEET_SETUP=1"
- "KIBANA_HOST=http://kibana:5601"
ports:
- "127.0.0.1:8080:8080"
`

0 comments on commit e176d16

Please sign in to comment.