diff --git a/.ci_cd/README.md b/.ci_cd/README.md index f923f24bb..f6c95c9d0 100644 --- a/.ci_cd/README.md +++ b/.ci_cd/README.md @@ -1,2 +1,3 @@ # CI/CD workflow files + This directory follows the same structure as the main [OpenRemote repo](https://github.com/openremote/openremote/tree/master/.ci_cd). diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..acfb8bb43 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# https://editorconfig.org/ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 586b69803..ac2f4dcbd 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -5,13 +5,13 @@ on: # Push excluding tags and workflow changes push: branches: - - 'main' + - "main" tags-ignore: - - '*.*' + - "*.*" paths-ignore: - - '.github/**' - - '.ci_cd/**' - - '**/*.md' + - ".github/**" + - ".ci_cd/**" + - "**/*.md" # PR pull_request: @@ -24,16 +24,16 @@ on: workflow_dispatch: inputs: ENVIRONMENT: - description: 'Environment to use (if any)' + description: "Environment to use (if any)" CLEAN_INSTALL: - description: 'Delete data before starting' + description: "Delete data before starting" type: boolean COMMIT: - description: 'Repo branch or commit SHA to checkout' + description: "Repo branch or commit SHA to checkout" OR_HOSTNAME: - description: 'Host to deploy to (e.g. demo.openremote.app)' + description: "Host to deploy to (e.g. demo.openremote.app)" OR_ADMIN_PASSWORD: - description: 'Admin password override' + description: "Admin password override" # Un-comment to monitor manager docker image tags for changes and trigger a redeploy when they change (see .ci_cd/README.md) # schedule: diff --git a/.gitignore b/.gitignore index 363c917d3..27718914c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ console/iOS/Pods manager/.factorypath/ Pods/ node_modules/ +.eslintcache .pnp.* .yarn/* !.yarn/patches diff --git a/README.md b/README.md index efb77888b..0126ed9e8 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,11 @@ This repository is a template for custom projects; showing the recommended proje **[You can find the documentation here](https://docs.openremote.io/docs/user-guide/deploying/custom-deployment/)**. - --- # (PROJECT_NAME) -*(Please describe, in a short summary, the context of the project.)* +_(Please describe, in a short summary, the context of the project.)_ > This repository is set up using the [Custom Project template](https://github.com/openremote/custom-project/). This repository uses the same standards and folder structure. More information about how to use this repository as a template to develop your own agents, services, model classes, setup tasks, tests, and new UI apps can be found in the [OpenRemote documentation](https://docs.openremote.io/docs/developer-guide/creating-a-custom-project). + ## Project context ### Features -*(Please insert a bullet point list with features specific to this custom project.)* + +_(Please insert a bullet point list with features specific to this custom project.)_ ### Vocabulary / common terms -*(Please insert a bullet point list with common terms in this project, with a short explanation.)* + +_(Please insert a bullet point list with common terms in this project, with a short explanation.)_ ### Company background -*(If applicable, write context about the company this custom project is meant for.)* + +_(If applicable, write context about the company this custom project is meant for.)_ ## Architecture -*(Please insert, preferably a diagram, or a short explanation of the high level architecture)* + +_(Please insert, preferably a diagram, or a short explanation of the high level architecture)_ ### Keycloak setup + The identity provider in place is [Keycloak](https://github.com/openremote/keycloak), running in its own container. The default configuration from the repository ([link](https://github.com/openremote/keycloak)) is used. ### Proxy setup + All requests from and towards running services go through the [HAProxy](https://github.com/openremote/proxy) container. The default configuration from the repository ([haproxy.cfg](https://github.com/openremote/proxy/blob/main/haproxy.cfg)) is used. @@ -64,13 +70,16 @@ All requests from and towards running services go through the [HAProxy](https:// ## Developer Guide ### Quickstart + Before starting, make sure you have cloned the Git repository locally, as this is required. Follow the initial guides on the OpenRemote documentation on [preparing the environment](https://docs.openremote.io/docs/developer-guide/preparing-the-environment), [installing and using Docker](https://docs.openremote.io/docs/developer-guide/installing-and-using-docker), and on [setting up an IDE](https://docs.openremote.io/docs/developer-guide/setting-up-an-ide). -*(Please describe the steps necessary to run this custom project locally.)* +_(Please describe the steps necessary to run this custom project locally.)_ ### Docker Compose files + In the `profile` directory you can find different Docker Compose files, each serving a different purpose. To be able to use them, you'll need to download a copy of the `deploy.yml` file from the main OpenRemote repository and place it in the `openremote/profile` directory, to ensure you always have the latest version of the file: + ```bash mkdir -p openremote/profile && curl -L https://github.com/openremote/openremote/raw/refs/heads/master/profile/deploy.yml -o openremote/profile/deploy.yml ``` @@ -78,7 +87,7 @@ mkdir -p openremote/profile && curl -L https://github.com/openremote/openremote/ ### Environment variables | Key | Containers | Description | Default | -|----------------------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------|----------| +| -------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------- | | `OR_HOSTNAME` | All services | **(REQUIRED)** FQDN hostname of where this instance will be exposed (localhost, IP address or public domain) | - | | `OR_ADMIN_PASSWORD` | `keycloak`, `manager` | **(REQUIRED)** Initial admin user password | - | | `DEPLOYMENT_VERSION` | `deployment` | **(REQUIRED)** The custom project version in use. This tag is used for building and deploying the artifacts from this repository. | - | @@ -95,19 +104,31 @@ This custom project is deployed by OpenRemote on their managed infrastructure. I The list of available environments: + ### `staging` + Used by OpenRemote to test new functionality and bugfixes before publishing them to production. Important practices and agreements to be aware of: + - This environment is only used for development purposes, so can be offline at any time. - There is no guarantee that this data will be persisted in the long-term. + + - **OpenRemote Manager:** https://(staging.CUSTOM_HOSTNAME).com/manager - **Custom app:** https://(staging.CUSTOM_HOSTNAME).com/custom + + ### `production` + Used for the live system with devices in the field, with a guarantee of stability and data persistence. Important practices and agreements to be aware of: + - There is a daily backup active for this instance. - This deployment is **manually updated**, and should be communicated with stakeholders. + + - **OpenRemote Manager:** https://(CUSTOM_HOSTNAME).com/manager - **Custom app:** https://(CUSTOM_HOSTNAME).com/custom - \ No newline at end of file + + diff --git a/agent/build.gradle b/agent/build.gradle index c2f7a8158..6178fbfee 100644 --- a/agent/build.gradle +++ b/agent/build.gradle @@ -1,12 +1,12 @@ plugins { - id 'java-library' + id 'java-library' } dependencies { - api project(":model") - api libs.openremote.agent + api project(":model") + api libs.openremote.agent } tasks.register('installDist') { - dependsOn jar + dependsOn jar } diff --git a/agent/src/main/java/org/openremote/agent/custom/CustomAgent.java b/agent/src/main/java/org/openremote/agent/custom/CustomAgent.java index 2a152dec8..a404dc36a 100644 --- a/agent/src/main/java/org/openremote/agent/custom/CustomAgent.java +++ b/agent/src/main/java/org/openremote/agent/custom/CustomAgent.java @@ -1,9 +1,6 @@ /* * Copyright 2017, OpenRemote Inc. * - * See the CONTRIBUTORS.txt file in the distribution for a - * full listing of individual contributors. - * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the @@ -15,10 +12,14 @@ * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-or-later */ package org.openremote.agent.custom; +import jakarta.persistence.Entity; +import java.util.Optional; import org.openremote.model.asset.Asset; import org.openremote.model.asset.agent.Agent; import org.openremote.model.asset.agent.AgentDescriptor; @@ -26,58 +27,56 @@ import org.openremote.model.value.AttributeDescriptor; import org.openremote.model.value.ValueDescriptor; -import jakarta.persistence.Entity; -import java.util.Optional; - /** - * This is an example of a custom {@link Agent} type; this must be registered via an - * {@link org.openremote.model.AssetModelProvider} and must conform to the same requirements as custom {@link Asset}s and - * in addition the following requirements: + * This is an example of a custom {@link Agent} type; this must be registered via an {@link + * org.openremote.model.AssetModelProvider} and must conform to the same requirements as custom + * {@link Asset}s and in addition the following requirements: * * */ @Entity public class CustomAgent extends Agent { - public enum Option { - ONE, - TWO, - THREE - }; + public enum Option { + ONE, + TWO, + THREE + }; - public static final ValueDescriptor