diff --git a/cmd/gen.go b/cmd/gen.go index c2e62e4..158a749 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -131,8 +131,10 @@ var genCmd = &cobra.Command{ Image: platys.Platys.PlatformStack + ":" + platys.Platys.PlatformStackVersion, Tty: true, Env: env, + User: currentUser(), }, &container.HostConfig{ + Mounts: []mount.Mount{ { Target: "/tmp/config.yml", // path in the container diff --git a/cmd/init.go b/cmd/init.go index 588ab52..e42c499 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -68,10 +68,13 @@ By default 'config.yml' is used for the name of the config file, which is create copied := 0 copyNext := false - for _, n := range servicesYml { + for i, n := range servicesYml { if copyNext { - n.Value = "true" + if strings.Contains(servicesYml[i-1].Value, "_enable") { // change the value of the key only if it's a service (i.e don't do this for use timezone etc.) + n.Value = "true" + } + updatedYml = append(updatedYml, n) copied++ copyNext = false @@ -111,7 +114,7 @@ By default 'config.yml' is used for the name of the config file, which is create } } - updatedYml = updatedYml[:copied] + updatedYml = updatedYml[:copied] //create a new slice by copying the updated one ymlConfig.Content[0].Content = updatedYml } @@ -130,13 +133,16 @@ By default 'config.yml' is used for the name of the config file, which is create b, _ := yaml.Marshal(&ymlConfig) b = addRootIndent(b, 6) - file, err := os.OpenFile(configFile, os.O_WRONLY|os.O_CREATE, 0755) - + file, err := os.OpenFile(configFile, os.O_RDWR|os.O_CREATE, 0755) + defer file.Close() if err != nil { log.Fatal(fmt.Sprintf("Unable to open file %v", err)) } - defer file.Close() + err = file.Truncate(0) // clear the contents of the file as to do not have stale data when writing (will append) + if err != nil { + log.Fatal(fmt.Sprintf("Unable to clear file [%v] contents [%v]", configFile, err)) + } for _, s := range strings.SplitN(string(b), "\n", -1) { // write updated config file _, err = file.Write([]byte(s + "\n")) diff --git a/cmd/root.go b/cmd/root.go index bb42845..373b82c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -14,6 +14,7 @@ import ( "io" "log" "os" + "os/user" ) var Stack string @@ -216,3 +217,11 @@ func in_array(val string, list []string) bool { } return false } + +func currentUser() string { + usr, err := user.Current() + if err != nil { + log.Fatal("Unable to start docker container as current user cannot be determined") + } + return usr.Uid + ":" + usr.Gid +} diff --git a/config.yml b/config.yml deleted file mode 100644 index 94e5275..0000000 --- a/config.yml +++ /dev/null @@ -1,252 +0,0 @@ - # Default values for the generator - # this file can be used as a template for a custom configuration - # or to know about the different variables available for the generator - platys: - platform-name: 'default' - stack-image-name: 'trivadis/platys-modern-data-platform' - stack-image-version: '1.6.0' - structure: 'flat' - # ===== Global configuation, valid for all or a group of services ======== - # Timezone, use a Linux string such as Europe/Zurich or America/New_York - use_timezone: 'true' - # the name of the repository to use for private images, which are not on docker hub (currently only Oracle images) - private_docker_repository_name: 'true' - # ===== Apache Kafka ======== - KAFKA_enable: true - -se - ZOOKEEPER_volume_map_data: false - ZOOKEEPER_nodes: 1 # either 1 or 3 - ZOOKEEPER_navigator_enable: false - # ===== Apache Kafka ======== - KAFKA_enable: false - # one of enterprise, community - KAFKA_edition: 'community' - KAFKA_volume_map_data: false - KAFKA_broker_nodes: 3 - KAFKA_internal_replication_factor: 3 - KAFKA_delete_topic_enable: false - KAFKA_auto_create_topics_enable: false - #kafka schema registry - KAFKA_SCHEMA_REGISTRY_enable: false - KAFKA_SCHEMA_REGISTRY_nodes: 1 - KAFKA_SCHEMA_REGISTRY_use_zookeeper_election: false - KAFKA_SCHEMA_REGISTRY_replication_factor: 1 - #kafka connect - KAFKA_CONNECT_enable: false - KAFKA_CONNECT_nodes: 2 - KAFKA_CONNECT_connectors: - #ksqldb - KAFKA_KSQLDB_enable: false - KAFKA_KSQLDB_edition: 'oss' - KAFKA_KSQLDB_nodes: 1 - #confluent control center - KAFKA_CCC_enable: false - #confluent replicator - KAFKA_REPLICATOR_enable: false - KAFKA_RESTPROXY_enable: false - KAFKA_MQTTPROXY_enable: false - KAFKACAT_enable: false - KAFKA_SCHEMA_REGISTRY_UI_enable: false - KAFKA_TOPICS_UI_enable: false - KAFKA_CONNECT_UI_enable: false - KAFKA_CMAK_enable: false - KAFKA_KAFDROP_enable: false - KAFKA_KADMIN_enable: false - KAFKA_AKHQ_enable: false - KAFKA_BURROW_enable: false - # ===== Hadoop ======== - HADOOP_enable: false - HADOOP_datanodes: 2 - # ===== Spark ======== - SPARK_enable: false - # "hive" or "in-memory" - SPARK_catalog: in-memory - SPARK_workers: 2 - SPARK_jars_repositories: '' - SPARK_jars_packages: '' - SPARK_jars: '' - SPARK_jars_ivySettings: '' - SPARK_driver_extraJavaOptions: '' - SPARK_executor_extraJavaOptions: '' - # misc spark 'addons' - SPARK_HISTORY_enable: false - SPARK_THRIFT_enable: false - # ===== Apache Livy ======== - LIVY_enable: false - # ===== Apache Hive ======== - HIVE_SERVER_enable: false - # ===== Apache Hive Metastore ======== - HIVE_METASTORE_enable: false - # ===== Apache Ranger ======== - RANGER_enable: false - RANGER_POSTRESQL_volume_map_data: false - # ===== Apache Atlas ======== - ATLAS_enable: false - ATLAS_provision_atlas_sample_data: false - ATLAS_provision_amundsen_sample_data: false - ATLAS_install_hive_hook: false - # ===== Data Hub ======== - DATAHUB_enable: false - DATAHUB_volume_map_data: false - #===== Amundsen ======== - AMUNDSEN_enable: false - # one of 'amundsen' or 'atlas' - AMUNDSEN_metastore: 'amundsen' - #===== Marquez ======== - MARQUEZ_enable: false - MARQUEZ_volume_map_data: false - MARQUEZ_provision_marquez_sample_data: false - # ===== Hue ======== - HUE_enable: false - # ===== Streamsets and stremsets edge ======== - STREAMSETS_enable: false - STREAMSETS_volume_map_data: false - STREAMSETS_activate_https: false - STREAMSETS_additional_port_mappings: 0 - STREAMSETS_TRANSFORMER_enable: false - STREAMSETS_TRANSFORMER_volume_map_data: false - STREAMSETS_EDGE_enable: false - STREAMSETS_EDGE_volume_map_data: false - # ===== Nifi ======== - NIFI_enable: false - # ===== Node Red ======== - NODERED_enable: false - NODERED_volume_map_data: false - # ===== Streamsheets ======== - STREAMSHEETS_enable: false - # ===== Sqoop ======== - SQOOP_enable: false - # ===== Apache Airflow ======== - AIRFLOW_enable: false - AIRFLOW_provision_examples: false - # ===== Zeppelin ======== - ZEPPELIN_enable: false - ZEPPELIN_volume_map_data: false - # ===== Jupyter ======== - JUPYTER_enable: false - # one of 'minimal', 'r', 'scipy', 'tensorflow', 'datascience', 'all-spark' - JUPYTER_edition: 'minimal' - JUPYTER_volume_map_data: false - # ===== Visualization ======== - GRAFANA_enable: false - # one of 'oss', 'elastic', - KIBANA_edition: 'oss' - KIBANA_enable: false #needs to have elasticsearch enabled to work - SUPERSET_enable: false - # ===== NoSQL ======== - REDIS_enable: false - CASSANDRA_enable: false - DATASTAX_enable: false - DATASTAX_nodes: 3 - MONGO_enable: false - MONGO_nodes: 1 - SOLR_enable: false - ELASTICSEARCH_enable: false - # one of 'oss', 'elastic', - ELASTICSEARCH_edition: 'oss' - DEJAVU_enable: false - CEREBRO_enable: false - ELASTICHQ_enable: false - NEO4J_enable: false - NEO4J_volume_map_data: false - NEO4J_volume_map_logs: false - # ===== Influx DB 1.x ======== - INFLUXDB_enable: false - INFLUXDB_volume_map_data: false - INFLUXDB_TELEGRAF_enable: false - INFLUXDB_CHRONOGRAF_enable: false - INFLUXDB_CHRONOGRAF_volume_map_data: false - INFLUXDB_KAPACITOR_enable: false - INFLUXDB_KAPACITOR_volume_map_data: false - # ===== Influx DB 2.x ======== - INFLUXDB2_enable: false - INFLUXDB2_volume_map_data: false - # ===== Kudo ======== - KUDO_enable: false - # ===== Druid ======== - DRUID_enable: false - # one of 'oss-sandbox', 'oss-cluster' - DRUID_edition: 'oss-sandbox' - DRUID_volume_map_data: false - # ===== NoSQL - Prometeus ======== - PROMETHEUS_enable: false - PROMETHEUS_volume_map_data: false - PROMETHEUS_PUSHGATEWAY_enable: false - # ===== NoSQL - Tile38 ======== - TILE38_enable: false - # ===== Yugabyte ======== - YUGABYTE_enable: false - # ===== Oracle ======== - ORACLE_enable: false - ORACLE_edition: 'ee' - ORACLE_volume_map_data: false - ORACLE_REST_DATA_SERVICE_enable: false - # ===== Other RDBMS ======== - MYSQL_enable: false - SQLSERVER_enable: false - POSTGRESQL_enable: false - POSTGRESQL_volume_map_data: false - TIMESCALEDB_enable: false - TIMESCALEDB_volume_map_data: false - # ===== Database Frontends ======== - ADMINER_enable: false - CLOUDBEAVER_enable: false - QUIX_enable: false - # ===== Event Store ======== - AXON_enable: false - # ===== Presto ======== - PRESTO_enable: false - # "single" or "cluster" install - PRESTO_install: single - PRESTO_workers: 3 - # one of starburstdata, prestosql, prestodb, ahana - PRESTO_edition: 'starburstdata' - # Presto-CLI is enabled by default - PRESTO_CLI_enable: true - # ===== Dremio ======== - DREMIO_enable: false - # ===== Apache Drill ======== - DRILL_enable: false - # ===== MQTT ======== - MOSQUITTO_enable: false - MOSQUITTO_nodes: 1 - MOSQUITTO_volume_map_data: false - HIVEMQ3_enable: false - HIVEMQ4_enable: false - MQTT_UI_enable: false - # ===== ActiveMQ ======== - ACTIVEMQ_enable: false - ACTIVEMQ_volume_map_data: false - # ===== RabbitMQ ======== - RABBITMQ_enable: false - RABBITMQ_volume_map_data: false - RABBITMQ_volume_map_logs: false - #===== MinIO Object Storage ======== - MINIO_enable: false - MINIO_volume_map_data: false - AWSCLI_enable: false - # ===== FTP ======== - FTP_enable: false - # ===== Penthao Webspoon ======== - PENTHAO_enable: false - # ===== Code Server ======== - CODE_SERVER_enable: false - CODE_SERVER_volume_map_platform_root: false - # ===== Vault ======== - VAULT_enable: false - VAULT_volume_map_data: false - # ===== Swagger API Management ======== - SWAGGER_EDITOR_enable: false - SWAGGER_UI_enable: false - # ===== Container Mgmt ======== - PORTAINER_enable: false - CADVISOR_enable: false - # ===== Hawtio ======== - HAWTIO_enable: false - # ===== Python image ======== - PYTHON_enable: false - PYTHON_script_folder: '' - PYTHON_script: '' - -