├── .github └── workflows │ └── ci.yaml ├── .gitignore ├── .golangci.yaml ├── .goreleaser-iofogctl-dev.yml ├── .goreleaser-iofogctl.yml ├── .packagecloud-publish.sh ├── CHANGELOG.md ├── CONTRIBUTING ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── assets ├── agent │ ├── check_prereqs.sh │ ├── init.sh │ ├── install_deps.sh │ ├── install_docker.sh │ ├── install_iofog.sh │ ├── install_java.sh │ └── uninstall_iofog.sh └── controller │ ├── check_prereqs.sh │ ├── install_iofog.sh │ ├── install_node.sh │ ├── service │ ├── iofog-controller.initctl │ ├── iofog-controller.systemd │ └── iofog-controller.update-rc │ ├── set_env.sh │ └── uninstall_iofog.sh ├── azure-pipelines.yaml ├── cmd └── iofogctl │ └── main.go ├── docs └── md │ ├── iofogctl.md │ ├── iofogctl_attach.md │ ├── iofogctl_attach_agent.md │ ├── iofogctl_attach_edge-resource.md │ ├── iofogctl_configure.md │ ├── iofogctl_connect.md │ ├── iofogctl_create.md │ ├── iofogctl_create_namespace.md │ ├── iofogctl_delete.md │ ├── iofogctl_delete_agent.md │ ├── iofogctl_delete_all.md │ ├── iofogctl_delete_application-template.md │ ├── iofogctl_delete_application.md │ ├── iofogctl_delete_catalogitem.md │ ├── iofogctl_delete_controller.md │ ├── iofogctl_delete_edge-resource.md │ ├── iofogctl_delete_microservice.md │ ├── iofogctl_delete_namespace.md │ ├── iofogctl_delete_registry.md │ ├── iofogctl_delete_route.md │ ├── iofogctl_delete_volume.md │ ├── iofogctl_deploy.md │ ├── iofogctl_describe.md │ ├── iofogctl_describe_agent-config.md │ ├── iofogctl_describe_agent.md │ ├── iofogctl_describe_application-template.md │ ├── iofogctl_describe_application.md │ ├── iofogctl_describe_controller.md │ ├── iofogctl_describe_controlplane.md │ ├── iofogctl_describe_edge-resource.md │ ├── iofogctl_describe_microservice.md │ ├── iofogctl_describe_namespace.md │ ├── iofogctl_describe_registry.md │ ├── iofogctl_describe_route.md │ ├── iofogctl_describe_volume.md │ ├── iofogctl_detach.md │ ├── iofogctl_detach_agent.md │ ├── iofogctl_detach_edge-resource.md │ ├── iofogctl_disconnect.md │ ├── iofogctl_get.md │ ├── iofogctl_legacy.md │ ├── iofogctl_logs.md │ ├── iofogctl_move.md │ ├── iofogctl_move_agent.md │ ├── iofogctl_move_microservice.md │ ├── iofogctl_prune.md │ ├── iofogctl_prune_agent.md │ ├── iofogctl_rename.md │ ├── iofogctl_rename_agent.md │ ├── iofogctl_rename_application.md │ ├── iofogctl_rename_controller.md │ ├── iofogctl_rename_edge-resource.md │ ├── iofogctl_rename_microservice.md │ ├── iofogctl_rename_namespace.md │ ├── iofogctl_rename_route.md │ ├── iofogctl_rollback.md │ ├── iofogctl_start.md │ ├── iofogctl_start_application.md │ ├── iofogctl_stop.md │ ├── iofogctl_stop_application.md │ ├── iofogctl_upgrade.md │ ├── iofogctl_version.md │ └── iofogctl_view.md ├── gitHooks └── pre-commit ├── go.mod ├── go.sum ├── internal ├── attach │ ├── agent │ │ └── execute.go │ └── edgeresource │ │ └── execute.go ├── cmd │ ├── attach.go │ ├── attach_agent.go │ ├── attach_edge_resource.go │ ├── bash_complete.go │ ├── configure.go │ ├── connect.go │ ├── create.go │ ├── create_namespace.go │ ├── delete.go │ ├── delete_agent.go │ ├── delete_all.go │ ├── delete_application.go │ ├── delete_catalog_item.go │ ├── delete_controller.go │ ├── delete_edge_resource.go │ ├── delete_microservice.go │ ├── delete_namespace.go │ ├── delete_registry.go │ ├── delete_route.go │ ├── delete_template.go │ ├── delete_volume.go │ ├── deploy.go │ ├── describe.go │ ├── describe_agent.go │ ├── describe_agent_config.go │ ├── describe_application.go │ ├── describe_controller.go │ ├── describe_controlplane.go │ ├── describe_edge_resource.go │ ├── describe_microservice.go │ ├── describe_namespace.go │ ├── describe_registry.go │ ├── describe_route.go │ ├── describe_template.go │ ├── describe_volume.go │ ├── detach.go │ ├── detach_agent.go │ ├── detach_edge_resource.go │ ├── disconnect.go │ ├── generate_documentation.go │ ├── get.go │ ├── legacy.go │ ├── logs.go │ ├── move.go │ ├── move_agent.go │ ├── move_microservice.go │ ├── pkg.go │ ├── prune.go │ ├── prune_agent.go │ ├── rename.go │ ├── rename_agent.go │ ├── rename_application.go │ ├── rename_controller.go │ ├── rename_edge_resource.go │ ├── rename_microservice.go │ ├── rename_namespace.go │ ├── rename_route.go │ ├── rollback.go │ ├── root.go │ ├── start.go │ ├── start_application.go │ ├── stop.go │ ├── stop_application.go │ ├── upgrade.go │ ├── version.go │ └── view.go ├── config │ ├── config.go │ ├── detached_agent.go │ ├── namespace.go │ └── types.go ├── configure │ ├── agent.go │ ├── controller.go │ ├── controlplane.go │ ├── default_namespace.go │ ├── factory.go │ └── multiple.go ├── connect │ ├── controlplane │ │ ├── connect.go │ │ ├── k8s │ │ │ └── k8s.go │ │ └── remote │ │ │ ├── fmt_test.go │ │ │ └── remote.go │ └── execute.go ├── create │ └── namespace │ │ └── namespace.go ├── delete │ ├── agent │ │ ├── execute.go │ │ ├── local.go │ │ └── remote.go │ ├── all │ │ └── all.go │ ├── application │ │ ├── execute.go │ │ ├── legacy.go │ │ └── remote.go │ ├── catalogitem │ │ └── catalog_item.go │ ├── controller │ │ ├── execute.go │ │ ├── factory.go │ │ ├── local.go │ │ └── remote.go │ ├── controlplane │ │ ├── factory.go │ │ ├── k8s │ │ │ └── k8s.go │ │ ├── local │ │ │ └── local.go │ │ └── remote │ │ │ └── remote.go │ ├── edgeresource │ │ └── factory.go │ ├── execute.go │ ├── microservice │ │ └── microservice.go │ ├── namespace │ │ └── namespace.go │ ├── registry │ │ └── registry.go │ ├── route │ │ └── factory.go │ ├── template │ │ └── execute.go │ └── volume │ │ ├── local.go │ │ ├── remote.go │ │ └── volume.go ├── deploy │ ├── agent │ │ ├── execute.go │ │ ├── factory.go │ │ ├── local.go │ │ └── remote.go │ ├── agentconfig │ │ ├── factory.go │ │ └── utils.go │ ├── application │ │ └── factory.go │ ├── applicationtemplate │ │ └── factory.go │ ├── catalogitem │ │ └── catalog_item.go │ ├── controller │ │ ├── local │ │ │ └── local.go │ │ └── remote │ │ │ └── remote.go │ ├── controlplane │ │ ├── k8s │ │ │ └── execute.go │ │ ├── local │ │ │ └── execute.go │ │ └── remote │ │ │ └── execute.go │ ├── edgeresource │ │ └── factory.go │ ├── execute.go │ ├── microservice │ │ └── factory.go │ ├── registry │ │ └── factory.go │ ├── route │ │ └── factory.go │ └── volume │ │ ├── factory.go │ │ ├── local.go │ │ └── remote.go ├── describe │ ├── agent.go │ ├── agent_config.go │ ├── application.go │ ├── application_legacy.go │ ├── controller.go │ ├── controlplane.go │ ├── edge_resource.go │ ├── factory.go │ ├── microservice.go │ ├── namespace.go │ ├── registry.go │ ├── route.go │ ├── template.go │ ├── utils.go │ └── volume.go ├── detach │ ├── agent │ │ ├── execute.go │ │ ├── local.go │ │ └── remote.go │ └── edgeresource │ │ └── execute.go ├── disconnect │ └── disconnect.go ├── execute │ ├── executor.go │ ├── parallel.go │ └── utils.go ├── get │ ├── agents.go │ ├── all.go │ ├── applications.go │ ├── applications_legacy.go │ ├── catalog.go │ ├── controllers.go │ ├── edge_resources.go │ ├── factory.go │ ├── microservices.go │ ├── namespaces.go │ ├── print.go │ ├── registry.go │ ├── routes.go │ ├── templates.go │ ├── util.go │ ├── util_test.go │ └── volumes.go ├── logs │ ├── agent.go │ ├── factory.go │ ├── k8s_controller.go │ ├── local_controller.go │ ├── microservice.go │ ├── remote_controller.go │ └── utils.go ├── move │ └── microservice │ │ └── executor.go ├── prune │ └── agent │ │ ├── execute.go │ │ ├── local.go │ │ └── remote.go ├── rename │ ├── agent │ │ └── executor.go │ ├── application │ │ └── executor.go │ ├── controller │ │ └── executor.go │ ├── edgeresource │ │ └── executor.go │ ├── microservice │ │ └── executor.go │ ├── namespace │ │ └── executor.go │ └── route │ │ └── executor.go ├── resource │ ├── agent.go │ ├── controller.go │ ├── controlplane.go │ ├── controlplane_test.go │ ├── errors.go │ ├── k8s_controller.go │ ├── k8s_controlplane.go │ ├── local_agent.go │ ├── local_controller.go │ ├── local_controlplane.go │ ├── namespace.go │ ├── namespace_test.go │ ├── remote_agent.go │ ├── remote_controller.go │ ├── remote_controlplane.go │ ├── types.go │ ├── user.go │ └── yaml.go ├── rollback │ ├── agent.go │ └── factory.go ├── start │ └── application.go ├── stop │ └── application.go ├── upgrade │ ├── agent.go │ └── factory.go └── util │ ├── client │ ├── api.go │ ├── client.go │ └── pkg.go │ └── misc.go ├── iofogctl-logo.png ├── pipeline ├── ha.yaml ├── k8s.yaml ├── local.yaml ├── steps │ ├── configure-env.sh │ ├── configure-remote-tests.yaml │ ├── functional-clean-vm.yaml │ ├── functional-post-test.yaml │ ├── init-gcloud-steps.yaml │ ├── init-ssh.yaml │ ├── init-vms.yaml │ ├── install-test-deps.yaml │ ├── postinstall.yaml │ ├── prebuild.yaml │ ├── publish-deps.yaml │ ├── vanilla.yaml │ └── version.yaml ├── vanilla.yaml ├── win-k8s.yaml ├── win-local.yaml └── win-vanilla.yaml ├── pkg ├── iofog │ ├── constants.go │ └── install │ │ ├── agent.go │ │ ├── controller.go │ │ ├── k8s.go │ │ ├── k8s_microservices.go │ │ ├── k8s_util.go │ │ ├── local_agent.go │ │ ├── local_container.go │ │ ├── pkg.go │ │ ├── remote_agent.go │ │ ├── remote_agent_test.go │ │ ├── types.go │ │ └── verbosity.go └── util │ ├── assets.go │ ├── debug.go │ ├── errors.go │ ├── exec.go │ ├── get_controller_endpoint.go │ ├── get_controller_endpoint_test.go │ ├── is_local.go │ ├── is_system_msvc.go │ ├── print.go │ ├── rand.go │ ├── rice-box.go │ ├── spinner.go │ ├── ssh.go │ ├── strings.go │ ├── time.go │ ├── url.go │ ├── version.go │ └── yaml.go ├── script ├── bootstrap.sh ├── bump.sh ├── check_fmt.sh └── utils.sh ├── test ├── bats │ ├── common-k8s.bats │ ├── ha.bats │ ├── k8s.bats │ ├── local.bats │ ├── smoke.bats │ └── vanilla.bats ├── clean.bash ├── conf │ └── .gitignore ├── env.sh ├── func │ ├── alias.bash │ ├── check.bash │ ├── include.bash │ ├── init.bash │ ├── run.bash │ ├── test.bash │ ├── vars.bash │ └── wait.bash └── run.bash └── version.sh /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | reports/* 3 | 4 | .idea/ 5 | 6 | test.txt 7 | test-report.xml 8 | 9 | .vscode/* 10 | dist/ 11 | vendor/ 12 | bats-core/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | # Notices for Eclipse ioFog 2 | 3 | This content is produced and maintained by the Eclipse ioFog project. 4 | 5 | * Project home: https://projects.eclipse.org/projects/iot.iofog 6 | 7 | ## Trademarks 8 | 9 | Eclipse ioFog is a trademark of the Eclipse Foundation. 10 | 11 | ## Copyright 12 | 13 | All content is the property of the respective authors or their employers. For 14 | more information regarding authorship of content, please consult the listed 15 | source code repository logs. 16 | 17 | ## Declared Project Licenses 18 | 19 | This program and the accompanying materials are made available under the terms 20 | of the Eclipse Public License v. 2.0 which is available at 21 | http://www.eclipse.org/legal/epl-2.0. 22 | 23 | SPDX-License-Identifier: EPL-2.0 24 | 25 | ## Source Code 26 | 27 | The project maintains the following source code repositories: 28 | 29 | * https://github.com/eclipse-iofog 30 | * http://git.eclipse.org/c/iofog/org.eclipse.iofog.git 31 | 32 | ## Third-party Content 33 | 34 | ## Cryptography 35 | 36 | Content may contain encryption software. The country in which you are currently 37 | may have restrictions on the import, possession, and use, and/or re-export to 38 | another country, of encryption software. BEFORE using any encryption software, 39 | please check the country's laws, regulations and policies concerning the import, 40 | possession, or use, and re-export of encryption software, to see if this is 41 | permitted. 42 | -------------------------------------------------------------------------------- /assets/agent/check_prereqs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | 4 | # Check can sudo without password 5 | if ! $(sudo ls /tmp/ > /dev/null); then 6 | MSG="Unable to successfully use sudo with user $USER on this host.\nUser $USER must be in sudoers group and using sudo without password must be enabled.\nPlease see iofog.org documentation for more details." 7 | echo $MSG 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /assets/agent/install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | set -e 4 | 5 | /etc/iofog/agent/install_java.sh 6 | /etc/iofog/agent/install_docker.sh 7 | -------------------------------------------------------------------------------- /assets/agent/uninstall_iofog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | set -e 4 | 5 | AGENT_CONFIG_FOLDER=/etc/iofog-agent/ 6 | AGENT_LOG_FOLDER=/var/log/iofog-agent/ 7 | 8 | do_uninstall_iofog() { 9 | echo "# Removing ioFog agent..." 10 | 11 | case "$lsb_dist" in 12 | ubuntu) 13 | $sh_c "apt-get -y --purge autoremove iofog-agent" 14 | ;; 15 | fedora|centos) 16 | $sh_c "yum remove -y iofog-agent" 17 | ;; 18 | debian|raspbian) 19 | $sh_c "apt-get -y --purge autoremove iofog-agent" 20 | ;; 21 | esac 22 | 23 | # Remove config files 24 | $sh_c "rm -rf ${AGENT_CONFIG_FOLDER}" 25 | 26 | # Remove log files 27 | $sh_c "rm -rf ${AGENT_LOG_FOLDER}" 28 | } 29 | 30 | . /etc/iofog/agent/init.sh 31 | init 32 | 33 | do_uninstall_iofog -------------------------------------------------------------------------------- /assets/controller/check_prereqs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | 4 | # Check can sudo without password 5 | if ! $(sudo ls /tmp/ > /dev/null); then 6 | MSG="Unable to successfully use sudo with user $USER on this host.\nUser $USER must be in sudoers group and using sudo without password must be enabled.\nPlease see iofog.org documentation for more details." 7 | echo $MSG 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /assets/controller/install_node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | set -e 4 | 5 | load_existing_nvm() { 6 | set +e 7 | if [ -z "$(command -v nvm)" ]; then 8 | export NVM_DIR="${HOME}/.nvm" 9 | mkdir -p $NVM_DIR 10 | if [ -f "$NVM_DIR/nvm.sh" ]; then 11 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm 12 | fi 13 | fi 14 | set -e 15 | } 16 | 17 | install_node() { 18 | load_existing_nvm 19 | if [ -z "$(command -v nvm)" ]; then 20 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash 21 | export NVM_DIR="${HOME}/.nvm" 22 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" 23 | fi 24 | nvm install v18.15.0 25 | nvm use v18.15.0 26 | ln -Ffs $(which node) /usr/local/bin/node 27 | ln -Ffs $(which npm) /usr/local/bin/npm 28 | 29 | # npmrc 30 | if [ -z "$(command -v npmrc)" ]; then 31 | npm i npmrc -g 32 | fi 33 | ln -Ffs $(which npmrc) /usr/local/bin/npmrc 34 | } 35 | 36 | install_node -------------------------------------------------------------------------------- /assets/controller/service/iofog-controller.initctl: -------------------------------------------------------------------------------- 1 | description "ioFog Controller" 2 | 3 | start on (runlevel [2345]) 4 | stop on (runlevel [!2345]) 5 | 6 | respawn 7 | 8 | script 9 | . /opt/iofog/config/controller/env.sh 10 | exec /usr/local/bin/iofog-controller start 11 | end script -------------------------------------------------------------------------------- /assets/controller/service/iofog-controller.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=ioFog Controller 3 | 4 | [Service] 5 | Type=forking 6 | ExecStart=/usr/local/bin/iofog-controller start 7 | ExecStop=/usr/local/bin/iofog-controller stop 8 | EnvironmentFile=/opt/iofog/config/controller/env.env 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /assets/controller/service/iofog-controller.update-rc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case "$1" in 4 | start) 5 | . /opt/iofog/controller/env.env 6 | /usr/local/bin/iofog-controller start 7 | ;; 8 | stop) 9 | /usr/local/bin/iofog-controller stop 10 | ;; 11 | restart) 12 | /usr/local/bin/iofog-controller stop 13 | . /opt/iofog/config/controller/env.sh 14 | /usr/local/bin/iofog-controller start 15 | ;; 16 | *) 17 | echo "Usage: $0 {start|stop|restart}" 18 | esac 19 | -------------------------------------------------------------------------------- /assets/controller/set_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | set -e 4 | 5 | CONF_FOLDER=/opt/iofog/config/controller 6 | SOURCE_FILE_NAME=env.sh # Used to source env variables 7 | ENV_FILE_NAME=env.env # Used as an env file in systemd 8 | 9 | SOURCE_FILE="$CONF_FOLDER/$SOURCE_FILE_NAME" 10 | ENV_FILE="$CONF_FOLDER/$ENV_FILE_NAME" 11 | 12 | # Create folder 13 | mkdir -p "$CONF_FOLDER" 14 | 15 | # Source file 16 | echo "#!/bin/sh" > "$SOURCE_FILE" 17 | 18 | # Env file (for systemd) 19 | rm -f "$ENV_FILE" 20 | touch "$ENV_FILE" 21 | 22 | for var in "$@" 23 | do 24 | echo "export $var" >> "$SOURCE_FILE" 25 | echo "$var" >> "$ENV_FILE" 26 | done -------------------------------------------------------------------------------- /assets/controller/uninstall_iofog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | set -e 4 | 5 | CONTROLLER_DIR="/opt/iofog/controller/" 6 | CONTROLLER_LOG_DIR="/var/log/iofog/" 7 | 8 | do_uninstall_controller() { 9 | # Remove folders 10 | sudo rm -rf $CONTROLLER_DIR 11 | sudo rm -rf $CONTROLLER_LOG_DIR 12 | 13 | # Remove symbolic links 14 | rm -f /usr/local/bin/iofog-controller 15 | 16 | # Remove service files 17 | USE_SYSTEMD=`grep -m1 -c systemd /proc/1/comm` 18 | USE_INITCTL=`which initctl | wc -l` 19 | USE_SERVICE=`which service | wc -l` 20 | 21 | if [ $USE_SYSTEMD -eq 1 ]; then 22 | systemctl stop iofog-controller.service 23 | rm -f /etc/systemd/system/iofog-controller.service 24 | elif [ $USE_INITCTL -eq 1 ]; then 25 | rm -f /etc/init/iofog-controller.conf 26 | elif [ $USE_SERVICE -eq 1 ]; then 27 | rm -f /etc/init.d/iofog-controller 28 | else 29 | echo "Unable to setup Controller startup script." 30 | fi 31 | } 32 | 33 | do_uninstall_controller -------------------------------------------------------------------------------- /cmd/iofogctl/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package main 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/cmd" 18 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 19 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 20 | ) 21 | 22 | func main() { 23 | config.Init("") 24 | rootCmd := cmd.NewRootCommand() 25 | err := rootCmd.Execute() 26 | util.Check(err) 27 | } 28 | -------------------------------------------------------------------------------- /docs/md/iofogctl_attach.md: -------------------------------------------------------------------------------- 1 | ## iofogctl attach 2 | 3 | Attach one ioFog resource to another 4 | 5 | ### Synopsis 6 | 7 | Attach one ioFog resource to another. 8 | 9 | ### Examples 10 | 11 | ``` 12 | attach 13 | ``` 14 | 15 | ### Options 16 | 17 | ``` 18 | -h, --help help for attach 19 | ``` 20 | 21 | ### Options inherited from parent commands 22 | 23 | ``` 24 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 25 | -n, --namespace string Namespace to execute respective command within (default "default") 26 | -v, --verbose Toggle for displaying verbose output of iofogctl 27 | ``` 28 | 29 | ### SEE ALSO 30 | 31 | * [iofogctl](iofogctl.md) - 32 | * [iofogctl attach agent](iofogctl_attach_agent.md) - Attach an Agent to an existing Namespace 33 | * [iofogctl attach edge-resource](iofogctl_attach_edge-resource.md) - Attach an Edge Resource to an existing Agent 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/md/iofogctl_attach_agent.md: -------------------------------------------------------------------------------- 1 | ## iofogctl attach agent 2 | 3 | Attach an Agent to an existing Namespace 4 | 5 | ### Synopsis 6 | 7 | Attach a detached Agent to an existing Namespace. 8 | 9 | The Agent will be provisioned with the Controller within the Namespace. 10 | 11 | ``` 12 | iofogctl attach agent NAME [flags] 13 | ``` 14 | 15 | ### Examples 16 | 17 | ``` 18 | iofogctl attach agent NAME 19 | ``` 20 | 21 | ### Options 22 | 23 | ``` 24 | -h, --help help for agent 25 | ``` 26 | 27 | ### Options inherited from parent commands 28 | 29 | ``` 30 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 31 | -n, --namespace string Namespace to execute respective command within (default "default") 32 | -v, --verbose Toggle for displaying verbose output of iofogctl 33 | ``` 34 | 35 | ### SEE ALSO 36 | 37 | * [iofogctl attach](iofogctl_attach.md) - Attach one ioFog resource to another 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/md/iofogctl_attach_edge-resource.md: -------------------------------------------------------------------------------- 1 | ## iofogctl attach edge-resource 2 | 3 | Attach an Edge Resource to an existing Agent 4 | 5 | ### Synopsis 6 | 7 | Attach an Edge Resource to an existing Agent. 8 | 9 | ``` 10 | iofogctl attach edge-resource NAME VERSION AGENT_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl attach edge-resource NAME VERSION AGENT_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for edge-resource 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl attach](iofogctl_attach.md) - Attach one ioFog resource to another 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_configure.md: -------------------------------------------------------------------------------- 1 | ## iofogctl configure 2 | 3 | Configure iofogctl or ioFog resources 4 | 5 | ### Synopsis 6 | 7 | Configure iofogctl or ioFog resources 8 | 9 | If you would like to replace the host value of Remote Controllers or Agents, you should delete and redeploy those resources. 10 | 11 | ``` 12 | iofogctl configure RESOURCE NAME [flags] 13 | ``` 14 | 15 | ### Examples 16 | 17 | ``` 18 | iofogctl configure current-namespace NAME 19 | 20 | iofogctl configure controller NAME --user USER --key KEYFILE --port PORTNUM 21 | controllers 22 | agent 23 | agents 24 | 25 | iofogctl configure controlplane --kube FILE 26 | ``` 27 | 28 | ### Options 29 | 30 | ``` 31 | --detached Specify command is to run against detached resources 32 | -h, --help help for configure 33 | --key string Path to private SSH key 34 | --kube string Path to Kubernetes configuration file 35 | --port int Port number that iofogctl uses to SSH into remote hosts 36 | --user string Username of remote host 37 | ``` 38 | 39 | ### Options inherited from parent commands 40 | 41 | ``` 42 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 43 | -n, --namespace string Namespace to execute respective command within (default "default") 44 | -v, --verbose Toggle for displaying verbose output of iofogctl 45 | ``` 46 | 47 | ### SEE ALSO 48 | 49 | * [iofogctl](iofogctl.md) - 50 | 51 | 52 | -------------------------------------------------------------------------------- /docs/md/iofogctl_create.md: -------------------------------------------------------------------------------- 1 | ## iofogctl create 2 | 3 | Create a resource 4 | 5 | ### Synopsis 6 | 7 | Create a component of an Edge Compute Network. 8 | 9 | ### Options 10 | 11 | ``` 12 | -h, --help help for create 13 | ``` 14 | 15 | ### Options inherited from parent commands 16 | 17 | ``` 18 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 19 | -n, --namespace string Namespace to execute respective command within (default "default") 20 | -v, --verbose Toggle for displaying verbose output of iofogctl 21 | ``` 22 | 23 | ### SEE ALSO 24 | 25 | * [iofogctl](iofogctl.md) - 26 | * [iofogctl create namespace](iofogctl_create_namespace.md) - Create a Namespace 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/md/iofogctl_create_namespace.md: -------------------------------------------------------------------------------- 1 | ## iofogctl create namespace 2 | 3 | Create a Namespace 4 | 5 | ### Synopsis 6 | 7 | Create a Namespace. 8 | 9 | A Namespace contains all components of an Edge Compute Network. 10 | 11 | A single instance of iofogctl can be used to manage any number of Edge Compute Networks. 12 | 13 | ``` 14 | iofogctl create namespace NAME [flags] 15 | ``` 16 | 17 | ### Examples 18 | 19 | ``` 20 | iofogctl create namespace NAME 21 | ``` 22 | 23 | ### Options 24 | 25 | ``` 26 | -h, --help help for namespace 27 | ``` 28 | 29 | ### Options inherited from parent commands 30 | 31 | ``` 32 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 33 | -n, --namespace string Namespace to execute respective command within (default "default") 34 | -v, --verbose Toggle for displaying verbose output of iofogctl 35 | ``` 36 | 37 | ### SEE ALSO 38 | 39 | * [iofogctl create](iofogctl_create.md) - Create a resource 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_agent.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete agent 2 | 3 | Delete an Agent 4 | 5 | ### Synopsis 6 | 7 | Delete an Agent. 8 | 9 | The Agent will be unprovisioned from the Controller within the namespace. 10 | 11 | The Agent stack will be uninstalled from the host. 12 | 13 | If you wish to not remove the Agent stack from the host, please use iofogctl detach agent 14 | 15 | ``` 16 | iofogctl delete agent NAME [flags] 17 | ``` 18 | 19 | ### Examples 20 | 21 | ``` 22 | iofogctl delete agent NAME 23 | ``` 24 | 25 | ### Options 26 | 27 | ``` 28 | --detached Specify command is to run against detached resources 29 | --force Remove even if there are still resource running on the Agent 30 | -h, --help help for agent 31 | ``` 32 | 33 | ### Options inherited from parent commands 34 | 35 | ``` 36 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 37 | -n, --namespace string Namespace to execute respective command within (default "default") 38 | -v, --verbose Toggle for displaying verbose output of iofogctl 39 | ``` 40 | 41 | ### SEE ALSO 42 | 43 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_all.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete all 2 | 3 | Delete all resources within a namespace 4 | 5 | ### Synopsis 6 | 7 | Delete all resources within a namespace. 8 | 9 | Tears down all components of an Edge Compute Network. 10 | 11 | If you don't want to tear down the deployments but would like to free up the Namespace, use the disconnect command instead. 12 | 13 | ``` 14 | iofogctl delete all [flags] 15 | ``` 16 | 17 | ### Examples 18 | 19 | ``` 20 | iofogctl delete all -n NAMESPACE 21 | ``` 22 | 23 | ### Options 24 | 25 | ``` 26 | --detached Specify command is to run against detached resources 27 | --force Force deletion of Agents 28 | -h, --help help for all 29 | ``` 30 | 31 | ### Options inherited from parent commands 32 | 33 | ``` 34 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 35 | -n, --namespace string Namespace to execute respective command within (default "default") 36 | -v, --verbose Toggle for displaying verbose output of iofogctl 37 | ``` 38 | 39 | ### SEE ALSO 40 | 41 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_application-template.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete application-template 2 | 3 | Delete an application-template 4 | 5 | ### Synopsis 6 | 7 | Delete an application-template 8 | 9 | ``` 10 | iofogctl delete application-template NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl delete application-template NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for application-template 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_application.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete application 2 | 3 | Delete an application 4 | 5 | ### Synopsis 6 | 7 | Delete an application and all its components 8 | 9 | ``` 10 | iofogctl delete application NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl delete application NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for application 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_catalogitem.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete catalogitem 2 | 3 | Delete a Catalog item 4 | 5 | ### Synopsis 6 | 7 | Delete a Catalog item from the Controller. 8 | 9 | ``` 10 | iofogctl delete catalogitem NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl delete catalogitem NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for catalogitem 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_controller.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete controller 2 | 3 | Delete a Controller 4 | 5 | ### Synopsis 6 | 7 | Delete a Controller. 8 | 9 | ``` 10 | iofogctl delete controller NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl delete controller NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for controller 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_edge-resource.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete edge-resource 2 | 3 | Delete an Edge Resource 4 | 5 | ### Synopsis 6 | 7 | Delete an Edge Resource. 8 | 9 | Only the specified version will be deleted. 10 | Agents that this Edge Resource are attached to will be notified of the deletion. 11 | 12 | ``` 13 | iofogctl delete edge-resource NAME VERSION [flags] 14 | ``` 15 | 16 | ### Examples 17 | 18 | ``` 19 | iofogctl delete edge-resource NAME VERSION 20 | ``` 21 | 22 | ### Options 23 | 24 | ``` 25 | -h, --help help for edge-resource 26 | ``` 27 | 28 | ### Options inherited from parent commands 29 | 30 | ``` 31 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 32 | -n, --namespace string Namespace to execute respective command within (default "default") 33 | -v, --verbose Toggle for displaying verbose output of iofogctl 34 | ``` 35 | 36 | ### SEE ALSO 37 | 38 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_microservice.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete microservice 2 | 3 | Delete a Microservice 4 | 5 | ### Synopsis 6 | 7 | Delete a Microservice 8 | 9 | ``` 10 | iofogctl delete microservice NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl delete microservice NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for microservice 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_namespace.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete namespace 2 | 3 | Delete a Namespace 4 | 5 | ### Synopsis 6 | 7 | Delete a Namespace. 8 | 9 | The Namespace must be empty. 10 | 11 | If you would like to delete all resources in the Namespace, use the --force flag. 12 | 13 | ``` 14 | iofogctl delete namespace NAME [flags] 15 | ``` 16 | 17 | ### Examples 18 | 19 | ``` 20 | iofogctl delete namespace NAME 21 | ``` 22 | 23 | ### Options 24 | 25 | ``` 26 | --force Force deletion of all resources within the namespace 27 | -h, --help help for namespace 28 | ``` 29 | 30 | ### Options inherited from parent commands 31 | 32 | ``` 33 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 34 | -n, --namespace string Namespace to execute respective command within (default "default") 35 | -v, --verbose Toggle for displaying verbose output of iofogctl 36 | ``` 37 | 38 | ### SEE ALSO 39 | 40 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_registry.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete registry 2 | 3 | Delete a Registry 4 | 5 | ### Synopsis 6 | 7 | Delete a Registry from the Controller. 8 | 9 | ``` 10 | iofogctl delete registry ID [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl delete registry ID 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for registry 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_route.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete route 2 | 3 | Delete a Route 4 | 5 | ### Synopsis 6 | 7 | Delete a Route. 8 | 9 | The corresponding Microservices will no longer be able to reach each other using ioMessages. 10 | 11 | ``` 12 | iofogctl delete route NAME [flags] 13 | ``` 14 | 15 | ### Examples 16 | 17 | ``` 18 | iofogctl delete route NAME 19 | ``` 20 | 21 | ### Options 22 | 23 | ``` 24 | -h, --help help for route 25 | ``` 26 | 27 | ### Options inherited from parent commands 28 | 29 | ``` 30 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 31 | -n, --namespace string Namespace to execute respective command within (default "default") 32 | -v, --verbose Toggle for displaying verbose output of iofogctl 33 | ``` 34 | 35 | ### SEE ALSO 36 | 37 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/md/iofogctl_delete_volume.md: -------------------------------------------------------------------------------- 1 | ## iofogctl delete volume 2 | 3 | Delete an Volume 4 | 5 | ### Synopsis 6 | 7 | Delete an Volume. 8 | 9 | The Volume will be deleted from the Agents that it is stored on. 10 | 11 | ``` 12 | iofogctl delete volume NAME [flags] 13 | ``` 14 | 15 | ### Examples 16 | 17 | ``` 18 | iofogctl delete volume NAME 19 | ``` 20 | 21 | ### Options 22 | 23 | ``` 24 | -h, --help help for volume 25 | ``` 26 | 27 | ### Options inherited from parent commands 28 | 29 | ``` 30 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 31 | -n, --namespace string Namespace to execute respective command within (default "default") 32 | -v, --verbose Toggle for displaying verbose output of iofogctl 33 | ``` 34 | 35 | ### SEE ALSO 36 | 37 | * [iofogctl delete](iofogctl_delete.md) - Delete an existing ioFog resource 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/md/iofogctl_deploy.md: -------------------------------------------------------------------------------- 1 | ## iofogctl deploy 2 | 3 | Deploy Edge Compute Network components on existing infrastructure 4 | 5 | ### Synopsis 6 | 7 | Deploy Edge Compute Network components on existing infrastructure. 8 | Visit iofog.org to view all YAML specifications usable with this command. 9 | 10 | ``` 11 | iofogctl deploy [flags] 12 | ``` 13 | 14 | ### Examples 15 | 16 | ``` 17 | deploy -f ecn.yaml 18 | application-template.yaml 19 | application.yaml 20 | microservice.yaml 21 | edge-resource.yaml 22 | catalog.yaml 23 | volume.yaml 24 | route.yaml 25 | ``` 26 | 27 | ### Options 28 | 29 | ``` 30 | -f, --file string YAML file containing specifications for ioFog resources to deploy 31 | -h, --help help for deploy 32 | ``` 33 | 34 | ### Options inherited from parent commands 35 | 36 | ``` 37 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 38 | -n, --namespace string Namespace to execute respective command within (default "default") 39 | -v, --verbose Toggle for displaying verbose output of iofogctl 40 | ``` 41 | 42 | ### SEE ALSO 43 | 44 | * [iofogctl](iofogctl.md) - 45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_agent-config.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe agent-config 2 | 3 | Get detailed information about an Agent's configuration 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about an Agent's configuration. 8 | 9 | ``` 10 | iofogctl describe agent-config NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe agent-config NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for agent-config 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_agent.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe agent 2 | 3 | Get detailed information about an Agent 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about a named Agent. 8 | 9 | ``` 10 | iofogctl describe agent NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe agent NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for agent 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_application-template.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe application-template 2 | 3 | Get detailed information about an Application Template 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about an Application Template. 8 | 9 | ``` 10 | iofogctl describe application-template NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe application-template NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for application-template 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_application.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe application 2 | 3 | Get detailed information about an Application 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about an Application. 8 | 9 | ``` 10 | iofogctl describe application NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe application NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for application 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_controller.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe controller 2 | 3 | Get detailed information about a Controller 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about a named Controller. 8 | 9 | ``` 10 | iofogctl describe controller NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe controller NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for controller 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_controlplane.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe controlplane 2 | 3 | Get detailed information about a Control Plane 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about the Control Plane in a single Namespace. 8 | 9 | ``` 10 | iofogctl describe controlplane [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe controlplane 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for controlplane 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_edge-resource.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe edge-resource 2 | 3 | Get detailed information about an Edge Resource 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about an Edge Resource. 8 | 9 | ``` 10 | iofogctl describe edge-resource NAME VERSION [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe edge-resource NAME VERSION 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for edge-resource 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_microservice.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe microservice 2 | 3 | Get detailed information about a Microservice 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about a Microservice. 8 | 9 | ``` 10 | iofogctl describe microservice NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe microservice NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for microservice 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_namespace.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe namespace 2 | 3 | Get detailed information about a Namespace 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about a Namespace. 8 | 9 | ``` 10 | iofogctl describe namespace NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe namespace NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for namespace 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_registry.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe registry 2 | 3 | Get detailed information about a Microservice Registry 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about a Microservice Registry. 8 | 9 | ``` 10 | iofogctl describe registry NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe registry NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for registry 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_route.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe route 2 | 3 | Get detailed information about a Route 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about a Route. 8 | 9 | ``` 10 | iofogctl describe route NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe route NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for route 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_describe_volume.md: -------------------------------------------------------------------------------- 1 | ## iofogctl describe volume 2 | 3 | Get detailed information about a Volume 4 | 5 | ### Synopsis 6 | 7 | Get detailed information about a Volume. 8 | 9 | ``` 10 | iofogctl describe volume NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl describe volume NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for volume 23 | -o, --output-file string YAML output file 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl describe](iofogctl_describe.md) - Get detailed information of an existing resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_detach.md: -------------------------------------------------------------------------------- 1 | ## iofogctl detach 2 | 3 | Detach one ioFog resource from another 4 | 5 | ### Synopsis 6 | 7 | Detach one ioFog resource from another. 8 | 9 | ### Examples 10 | 11 | ``` 12 | detach 13 | ``` 14 | 15 | ### Options 16 | 17 | ``` 18 | -h, --help help for detach 19 | ``` 20 | 21 | ### Options inherited from parent commands 22 | 23 | ``` 24 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 25 | -n, --namespace string Namespace to execute respective command within (default "default") 26 | -v, --verbose Toggle for displaying verbose output of iofogctl 27 | ``` 28 | 29 | ### SEE ALSO 30 | 31 | * [iofogctl](iofogctl.md) - 32 | * [iofogctl detach agent](iofogctl_detach_agent.md) - Detaches an Agent 33 | * [iofogctl detach edge-resource](iofogctl_detach_edge-resource.md) - Detaches an Edge Resource from an Agent 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/md/iofogctl_detach_agent.md: -------------------------------------------------------------------------------- 1 | ## iofogctl detach agent 2 | 3 | Detaches an Agent 4 | 5 | ### Synopsis 6 | 7 | Detaches an Agent. 8 | 9 | The Agent will be deprovisioned from the Controller within the namespace. 10 | The Agent will be removed from Controller. 11 | 12 | You cannot detach unprovisioned Agents. 13 | 14 | The Agent stack will not be uninstalled from the host. 15 | 16 | ``` 17 | iofogctl detach agent NAME [flags] 18 | ``` 19 | 20 | ### Examples 21 | 22 | ``` 23 | iofogctl detach agent NAME 24 | ``` 25 | 26 | ### Options 27 | 28 | ``` 29 | --force Detach Agent, even if it still uses resources 30 | -h, --help help for agent 31 | ``` 32 | 33 | ### Options inherited from parent commands 34 | 35 | ``` 36 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 37 | -n, --namespace string Namespace to execute respective command within (default "default") 38 | -v, --verbose Toggle for displaying verbose output of iofogctl 39 | ``` 40 | 41 | ### SEE ALSO 42 | 43 | * [iofogctl detach](iofogctl_detach.md) - Detach one ioFog resource from another 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/md/iofogctl_detach_edge-resource.md: -------------------------------------------------------------------------------- 1 | ## iofogctl detach edge-resource 2 | 3 | Detaches an Edge Resource from an Agent 4 | 5 | ### Synopsis 6 | 7 | Detaches an Edge Resource from an Agent. 8 | 9 | ``` 10 | iofogctl detach edge-resource NAME VERSION AGENT_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl detach edge-resource NAME VERSION AGENT_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for edge-resource 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl detach](iofogctl_detach.md) - Detach one ioFog resource from another 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_disconnect.md: -------------------------------------------------------------------------------- 1 | ## iofogctl disconnect 2 | 3 | Disconnect from an ioFog cluster 4 | 5 | ### Synopsis 6 | 7 | Disconnect from an ioFog cluster. 8 | 9 | This will remove all client-side information for this Namespace. The Namespace will itself be deleted. 10 | Use the connect command to reconnect after a disconnect. 11 | If you would like to uninstall the Control Plane and/or Agents, use the delete command instead. 12 | 13 | ``` 14 | iofogctl disconnect [flags] 15 | ``` 16 | 17 | ### Examples 18 | 19 | ``` 20 | iofogctl disconnect -n NAMESPACE 21 | ``` 22 | 23 | ### Options 24 | 25 | ``` 26 | -h, --help help for disconnect 27 | ``` 28 | 29 | ### Options inherited from parent commands 30 | 31 | ``` 32 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 33 | -n, --namespace string Namespace to execute respective command within (default "default") 34 | -v, --verbose Toggle for displaying verbose output of iofogctl 35 | ``` 36 | 37 | ### SEE ALSO 38 | 39 | * [iofogctl](iofogctl.md) - 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/md/iofogctl_get.md: -------------------------------------------------------------------------------- 1 | ## iofogctl get 2 | 3 | Get information of existing resources 4 | 5 | ### Synopsis 6 | 7 | Get information of existing resources. 8 | 9 | Resources like Agents will require a working Controller in the namespace to display all information. 10 | 11 | ``` 12 | iofogctl get RESOURCE [flags] 13 | ``` 14 | 15 | ### Examples 16 | 17 | ``` 18 | iofogctl get all 19 | namespaces 20 | controllers 21 | agents 22 | edge-resources 23 | application-templates 24 | applications 25 | microservices 26 | catalog 27 | registries 28 | volumes 29 | routes 30 | ``` 31 | 32 | ### Options 33 | 34 | ``` 35 | --detached Specify command is to run against detached resources 36 | -h, --help help for get 37 | ``` 38 | 39 | ### Options inherited from parent commands 40 | 41 | ``` 42 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 43 | -n, --namespace string Namespace to execute respective command within (default "default") 44 | -v, --verbose Toggle for displaying verbose output of iofogctl 45 | ``` 46 | 47 | ### SEE ALSO 48 | 49 | * [iofogctl](iofogctl.md) - 50 | 51 | 52 | -------------------------------------------------------------------------------- /docs/md/iofogctl_legacy.md: -------------------------------------------------------------------------------- 1 | ## iofogctl legacy 2 | 3 | Execute commands using legacy CLI 4 | 5 | ### Synopsis 6 | 7 | Execute commands using legacy Controller and Agent CLI. 8 | 9 | Legacy commands require SSH access to the corresponding Agent or Controller. 10 | 11 | Use the configure command to add SSH details to Agents and Controllers if necessary. 12 | 13 | ``` 14 | iofogctl legacy resource NAME COMMAND ARGS... [flags] 15 | ``` 16 | 17 | ### Examples 18 | 19 | ``` 20 | iofogctl legacy controller NAME COMMAND 21 | iofogctl legacy agent NAME COMMAND 22 | ``` 23 | 24 | ### Options 25 | 26 | ``` 27 | --detached Specify command is to run against detached resources 28 | -h, --help help for legacy 29 | ``` 30 | 31 | ### Options inherited from parent commands 32 | 33 | ``` 34 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 35 | -n, --namespace string Namespace to execute respective command within (default "default") 36 | -v, --verbose Toggle for displaying verbose output of iofogctl 37 | ``` 38 | 39 | ### SEE ALSO 40 | 41 | * [iofogctl](iofogctl.md) - 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/md/iofogctl_logs.md: -------------------------------------------------------------------------------- 1 | ## iofogctl logs 2 | 3 | Get log contents of deployed resource 4 | 5 | ### Synopsis 6 | 7 | Get log contents of deployed resource 8 | 9 | ``` 10 | iofogctl logs RESOURCE NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl logs controller NAME 17 | agent NAME 18 | microservice NAME 19 | ``` 20 | 21 | ### Options 22 | 23 | ``` 24 | -h, --help help for logs 25 | ``` 26 | 27 | ### Options inherited from parent commands 28 | 29 | ``` 30 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 31 | -n, --namespace string Namespace to execute respective command within (default "default") 32 | -v, --verbose Toggle for displaying verbose output of iofogctl 33 | ``` 34 | 35 | ### SEE ALSO 36 | 37 | * [iofogctl](iofogctl.md) - 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/md/iofogctl_move.md: -------------------------------------------------------------------------------- 1 | ## iofogctl move 2 | 3 | Move an existing resources inside the current Namespace 4 | 5 | ### Synopsis 6 | 7 | Move an existing resources inside the current Namespace 8 | 9 | ### Options 10 | 11 | ``` 12 | -h, --help help for move 13 | ``` 14 | 15 | ### Options inherited from parent commands 16 | 17 | ``` 18 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 19 | -n, --namespace string Namespace to execute respective command within (default "default") 20 | -v, --verbose Toggle for displaying verbose output of iofogctl 21 | ``` 22 | 23 | ### SEE ALSO 24 | 25 | * [iofogctl](iofogctl.md) - 26 | * [iofogctl move agent](iofogctl_move_agent.md) - Move an Agent to another Namespace 27 | * [iofogctl move microservice](iofogctl_move_microservice.md) - Move a Microservice to another Agent in the same Namespace 28 | 29 | 30 | -------------------------------------------------------------------------------- /docs/md/iofogctl_move_agent.md: -------------------------------------------------------------------------------- 1 | ## iofogctl move agent 2 | 3 | Move an Agent to another Namespace 4 | 5 | ### Synopsis 6 | 7 | Move an Agent to another Namespace 8 | 9 | ``` 10 | iofogctl move agent NAME DEST_NAMESPACE [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl move agent NAME DEST_NAMESPACE 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | --force Move Agent, even if it still uses resources 23 | -h, --help help for agent 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl move](iofogctl_move.md) - Move an existing resources inside the current Namespace 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_move_microservice.md: -------------------------------------------------------------------------------- 1 | ## iofogctl move microservice 2 | 3 | Move a Microservice to another Agent in the same Namespace 4 | 5 | ### Synopsis 6 | 7 | Move a Microservice to another Agent in the same Namespace 8 | 9 | ``` 10 | iofogctl move microservice NAME AGENT_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl move microservice NAME AGENT_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for microservice 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl move](iofogctl_move.md) - Move an existing resources inside the current Namespace 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_prune.md: -------------------------------------------------------------------------------- 1 | ## iofogctl prune 2 | 3 | prune ioFog resources 4 | 5 | ### Synopsis 6 | 7 | prune ioFog resources 8 | 9 | ### Options 10 | 11 | ``` 12 | -h, --help help for prune 13 | ``` 14 | 15 | ### Options inherited from parent commands 16 | 17 | ``` 18 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 19 | -n, --namespace string Namespace to execute respective command within (default "default") 20 | -v, --verbose Toggle for displaying verbose output of iofogctl 21 | ``` 22 | 23 | ### SEE ALSO 24 | 25 | * [iofogctl](iofogctl.md) - 26 | * [iofogctl prune agent](iofogctl_prune_agent.md) - Remove all dangling images from Agent 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/md/iofogctl_prune_agent.md: -------------------------------------------------------------------------------- 1 | ## iofogctl prune agent 2 | 3 | Remove all dangling images from Agent 4 | 5 | ### Synopsis 6 | 7 | Remove all the images which are not used by existing containers on the specified Agent 8 | 9 | ``` 10 | iofogctl prune agent NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl prune agent NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | --detached Specify command is to run against detached resources 23 | -h, --help help for agent 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl prune](iofogctl_prune.md) - prune ioFog resources 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename 2 | 3 | Rename the iofog resources that are currently deployed 4 | 5 | ### Synopsis 6 | 7 | Rename the iofog resources that are currently deployed 8 | 9 | ### Options 10 | 11 | ``` 12 | -h, --help help for rename 13 | ``` 14 | 15 | ### Options inherited from parent commands 16 | 17 | ``` 18 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 19 | -n, --namespace string Namespace to execute respective command within (default "default") 20 | -v, --verbose Toggle for displaying verbose output of iofogctl 21 | ``` 22 | 23 | ### SEE ALSO 24 | 25 | * [iofogctl](iofogctl.md) - 26 | * [iofogctl rename agent](iofogctl_rename_agent.md) - Rename an Agent 27 | * [iofogctl rename application](iofogctl_rename_application.md) - Rename an Application 28 | * [iofogctl rename controller](iofogctl_rename_controller.md) - Rename a Controller 29 | * [iofogctl rename edge-resource](iofogctl_rename_edge-resource.md) - Rename an Edge Resource 30 | * [iofogctl rename microservice](iofogctl_rename_microservice.md) - Rename a Microservice 31 | * [iofogctl rename namespace](iofogctl_rename_namespace.md) - Rename a Namespace 32 | * [iofogctl rename route](iofogctl_rename_route.md) - Rename a Route 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename_agent.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename agent 2 | 3 | Rename an Agent 4 | 5 | ### Synopsis 6 | 7 | Rename an Agent 8 | 9 | ``` 10 | iofogctl rename agent NAME NEW_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rename agent NAME NEW_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | --detached Specify command is to run against detached resources 23 | -h, --help help for agent 24 | ``` 25 | 26 | ### Options inherited from parent commands 27 | 28 | ``` 29 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 30 | -n, --namespace string Namespace to execute respective command within (default "default") 31 | -v, --verbose Toggle for displaying verbose output of iofogctl 32 | ``` 33 | 34 | ### SEE ALSO 35 | 36 | * [iofogctl rename](iofogctl_rename.md) - Rename the iofog resources that are currently deployed 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename_application.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename application 2 | 3 | Rename an Application 4 | 5 | ### Synopsis 6 | 7 | Rename a Application 8 | 9 | ``` 10 | iofogctl rename application NAME NEW_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rename application NAME NEW_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for application 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl rename](iofogctl_rename.md) - Rename the iofog resources that are currently deployed 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename_controller.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename controller 2 | 3 | Rename a Controller 4 | 5 | ### Synopsis 6 | 7 | Rename a Controller 8 | 9 | ``` 10 | iofogctl rename controller NAME NEW_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rename controller NAME NEW_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for controller 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl rename](iofogctl_rename.md) - Rename the iofog resources that are currently deployed 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename_edge-resource.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename edge-resource 2 | 3 | Rename an Edge Resource 4 | 5 | ### Synopsis 6 | 7 | Rename an Edge Resource 8 | 9 | ``` 10 | iofogctl rename edge-resource NAME NEW_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rename edge-resource NAME NEW_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for edge-resource 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl rename](iofogctl_rename.md) - Rename the iofog resources that are currently deployed 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename_microservice.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename microservice 2 | 3 | Rename a Microservice 4 | 5 | ### Synopsis 6 | 7 | Rename a Microservice 8 | 9 | ``` 10 | iofogctl rename microservice NAME NEW_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rename microservice NAME NEW_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for microservice 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl rename](iofogctl_rename.md) - Rename the iofog resources that are currently deployed 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename_namespace.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename namespace 2 | 3 | Rename a Namespace 4 | 5 | ### Synopsis 6 | 7 | Rename a Namespace 8 | 9 | ``` 10 | iofogctl rename namespace NAME NEW_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rename namespace NAME NEW_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for namespace 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl rename](iofogctl_rename.md) - Rename the iofog resources that are currently deployed 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rename_route.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rename route 2 | 3 | Rename a Route 4 | 5 | ### Synopsis 6 | 7 | Rename a Route 8 | 9 | ``` 10 | iofogctl rename route NAME NEW_NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rename route NAME NEW_NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for route 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl rename](iofogctl_rename.md) - Rename the iofog resources that are currently deployed 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_rollback.md: -------------------------------------------------------------------------------- 1 | ## iofogctl rollback 2 | 3 | Rollback ioFog resources 4 | 5 | ### Synopsis 6 | 7 | Rollback ioFog resources to latest versions available. 8 | 9 | ``` 10 | iofogctl rollback RESOURCE NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl rollback agent NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for rollback 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl](iofogctl.md) - 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_start.md: -------------------------------------------------------------------------------- 1 | ## iofogctl start 2 | 3 | Starts a resource 4 | 5 | ### Synopsis 6 | 7 | Starts a resource 8 | 9 | ### Options 10 | 11 | ``` 12 | -h, --help help for start 13 | ``` 14 | 15 | ### Options inherited from parent commands 16 | 17 | ``` 18 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 19 | -n, --namespace string Namespace to execute respective command within (default "default") 20 | -v, --verbose Toggle for displaying verbose output of iofogctl 21 | ``` 22 | 23 | ### SEE ALSO 24 | 25 | * [iofogctl](iofogctl.md) - 26 | * [iofogctl start application](iofogctl_start_application.md) - Starts an application 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/md/iofogctl_start_application.md: -------------------------------------------------------------------------------- 1 | ## iofogctl start application 2 | 3 | Starts an application 4 | 5 | ### Synopsis 6 | 7 | Starts an application 8 | 9 | ``` 10 | iofogctl start application NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl start application NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for application 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl start](iofogctl_start.md) - Starts a resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_stop.md: -------------------------------------------------------------------------------- 1 | ## iofogctl stop 2 | 3 | Stops a resource 4 | 5 | ### Synopsis 6 | 7 | Stops a resource 8 | 9 | ### Options 10 | 11 | ``` 12 | -h, --help help for stop 13 | ``` 14 | 15 | ### Options inherited from parent commands 16 | 17 | ``` 18 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 19 | -n, --namespace string Namespace to execute respective command within (default "default") 20 | -v, --verbose Toggle for displaying verbose output of iofogctl 21 | ``` 22 | 23 | ### SEE ALSO 24 | 25 | * [iofogctl](iofogctl.md) - 26 | * [iofogctl stop application](iofogctl_stop_application.md) - Stop an application 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/md/iofogctl_stop_application.md: -------------------------------------------------------------------------------- 1 | ## iofogctl stop application 2 | 3 | Stop an application 4 | 5 | ### Synopsis 6 | 7 | Stop an application 8 | 9 | ``` 10 | iofogctl stop application NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl stop application NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for application 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl stop](iofogctl_stop.md) - Stops a resource 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_upgrade.md: -------------------------------------------------------------------------------- 1 | ## iofogctl upgrade 2 | 3 | Upgrade ioFog resources 4 | 5 | ### Synopsis 6 | 7 | Upgrade ioFog resources to latest versions available. 8 | 9 | ``` 10 | iofogctl upgrade RESOURCE NAME [flags] 11 | ``` 12 | 13 | ### Examples 14 | 15 | ``` 16 | iofogctl upgrade agent NAME 17 | ``` 18 | 19 | ### Options 20 | 21 | ``` 22 | -h, --help help for upgrade 23 | ``` 24 | 25 | ### Options inherited from parent commands 26 | 27 | ``` 28 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 29 | -n, --namespace string Namespace to execute respective command within (default "default") 30 | -v, --verbose Toggle for displaying verbose output of iofogctl 31 | ``` 32 | 33 | ### SEE ALSO 34 | 35 | * [iofogctl](iofogctl.md) - 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/md/iofogctl_version.md: -------------------------------------------------------------------------------- 1 | ## iofogctl version 2 | 3 | Get CLI application version 4 | 5 | ### Synopsis 6 | 7 | Get CLI application version 8 | 9 | ``` 10 | iofogctl version [flags] 11 | ``` 12 | 13 | ### Options 14 | 15 | ``` 16 | --ecn Get default package versions and images of all ECN components 17 | -h, --help help for version 18 | ``` 19 | 20 | ### Options inherited from parent commands 21 | 22 | ``` 23 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 24 | -n, --namespace string Namespace to execute respective command within (default "default") 25 | -v, --verbose Toggle for displaying verbose output of iofogctl 26 | ``` 27 | 28 | ### SEE ALSO 29 | 30 | * [iofogctl](iofogctl.md) - 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/md/iofogctl_view.md: -------------------------------------------------------------------------------- 1 | ## iofogctl view 2 | 3 | Open ECN Viewer 4 | 5 | ### Synopsis 6 | 7 | Open ECN Viewer 8 | 9 | ``` 10 | iofogctl view [flags] 11 | ``` 12 | 13 | ### Options 14 | 15 | ``` 16 | -h, --help help for view 17 | ``` 18 | 19 | ### Options inherited from parent commands 20 | 21 | ``` 22 | --debug Toggle for displaying verbose output of API clients (HTTP and SSH) 23 | -n, --namespace string Namespace to execute respective command within (default "default") 24 | -v, --verbose Toggle for displaying verbose output of iofogctl 25 | ``` 26 | 27 | ### SEE ALSO 28 | 29 | * [iofogctl](iofogctl.md) - 30 | 31 | 32 | -------------------------------------------------------------------------------- /gitHooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git commit" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message if 6 | # it wants to stop the commit. 7 | # 8 | 9 | set -e 10 | 11 | echo "Pre commit:" 12 | echo "Building..." 13 | make lint 14 | make build 15 | echo "Generating docs..." 16 | ./bin/iofogctl documentation md -o ./docs/ 17 | echo "Patching docs..." 18 | find ./docs/md -type f | xargs sed -i '' 's/.*Auto generated.*//g' 19 | find ./docs/md -type f | xargs sed -E -i '' 's/(command within \(default).*/\1 "default")/g' 20 | echo "Adding docs to the commit..." 21 | git add ./docs/ 22 | -------------------------------------------------------------------------------- /internal/cmd/attach.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newAttachCommand() *cobra.Command { 21 | cmd := &cobra.Command{ 22 | Use: "attach", 23 | Example: `attach`, 24 | Short: "Attach one ioFog resource to another", 25 | Long: `Attach one ioFog resource to another.`, 26 | } 27 | 28 | // Add subcommands 29 | cmd.AddCommand( 30 | newAttachAgentCommand(), 31 | newAttachEdgeResourceCommand(), 32 | ) 33 | 34 | return cmd 35 | } 36 | -------------------------------------------------------------------------------- /internal/cmd/attach_agent.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | attach "github.com/eclipse-iofog/iofogctl/v3/internal/attach/agent" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newAttachAgentCommand() *cobra.Command { 23 | opt := attach.Options{} 24 | cmd := &cobra.Command{ 25 | Use: "agent NAME", 26 | Short: "Attach an Agent to an existing Namespace", 27 | Long: `Attach a detached Agent to an existing Namespace. 28 | 29 | The Agent will be provisioned with the Controller within the Namespace.`, 30 | Example: `iofogctl attach agent NAME`, 31 | Args: cobra.ExactArgs(1), 32 | Run: func(cmd *cobra.Command, args []string) { 33 | // Get name and namespace of agent 34 | opt.Name = args[0] 35 | var err error 36 | opt.Namespace, err = cmd.Flags().GetString("namespace") 37 | util.Check(err) 38 | 39 | // Run the command 40 | exe := attach.NewExecutor(&opt) 41 | err = exe.Execute() 42 | util.Check(err) 43 | 44 | util.PrintSuccess("Successfully attached Agent " + opt.Name + " to namespace " + opt.Namespace) 45 | }, 46 | } 47 | 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /internal/cmd/create.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newCreateCommand() *cobra.Command { 21 | cmd := &cobra.Command{ 22 | Use: "create", 23 | Short: "Create a resource", 24 | Long: `Create a component of an Edge Compute Network.`, 25 | } 26 | 27 | // Add subcommands 28 | cmd.AddCommand( 29 | newCreateNamespaceCommand(), 30 | ) 31 | return cmd 32 | } 33 | -------------------------------------------------------------------------------- /internal/cmd/create_namespace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | create "github.com/eclipse-iofog/iofogctl/v3/internal/create/namespace" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newCreateNamespaceCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "namespace NAME", 25 | Short: "Create a Namespace", 26 | Long: `Create a Namespace. 27 | 28 | A Namespace contains all components of an Edge Compute Network. 29 | 30 | A single instance of iofogctl can be used to manage any number of Edge Compute Networks.`, 31 | Example: `iofogctl create namespace NAME`, 32 | Args: cobra.ExactArgs(1), 33 | Run: func(cmd *cobra.Command, args []string) { 34 | // Get name and namespace of agent 35 | name := args[0] 36 | 37 | // Run the command 38 | err := create.Execute(name) 39 | util.Check(err) 40 | 41 | util.PrintSuccess("Successfully created namespace " + name) 42 | }, 43 | } 44 | 45 | return cmd 46 | } 47 | -------------------------------------------------------------------------------- /internal/cmd/delete_application.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/application" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteApplicationCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "application NAME", 25 | Short: "Delete an application", 26 | Long: `Delete an application and all its components`, 27 | Example: `iofogctl delete application NAME`, 28 | Args: cobra.MinimumNArgs(1), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get microservice name 31 | name := args[0] 32 | namespace, err := cmd.Flags().GetString("namespace") 33 | util.Check(err) 34 | 35 | // Execute command 36 | err = delete.Execute(namespace, name) 37 | util.Check(err) 38 | 39 | util.PrintSuccess("Successfully deleted " + namespace + "/" + name) 40 | }, 41 | } 42 | 43 | return cmd 44 | } 45 | -------------------------------------------------------------------------------- /internal/cmd/delete_catalog_item.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/catalogitem" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteCatalogItemCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "catalogitem NAME", 25 | Short: "Delete a Catalog item", 26 | Long: `Delete a Catalog item from the Controller.`, 27 | Example: `iofogctl delete catalogitem NAME`, 28 | Args: cobra.ExactArgs(1), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and namespace 31 | name := args[0] 32 | namespace, err := cmd.Flags().GetString("namespace") 33 | util.Check(err) 34 | 35 | // Get an executor for the command 36 | exe, err := delete.NewExecutor(namespace, name) 37 | util.Check(err) 38 | err = exe.Execute() 39 | util.Check(err) 40 | 41 | util.PrintSuccess("Successfully deleted catalog item " + name) 42 | }, 43 | } 44 | 45 | return cmd 46 | } 47 | -------------------------------------------------------------------------------- /internal/cmd/delete_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/controller" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteControllerCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "controller NAME", 25 | Short: "Delete a Controller", 26 | Long: `Delete a Controller.`, 27 | Example: `iofogctl delete controller NAME`, 28 | Args: cobra.ExactArgs(1), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and namespace of controller 31 | name := args[0] 32 | namespace, err := cmd.Flags().GetString("namespace") 33 | util.Check(err) 34 | 35 | // Get an executor for the command 36 | exe, err := delete.NewExecutor(namespace, name) 37 | util.Check(err) 38 | err = exe.Execute() 39 | util.Check(err) 40 | 41 | util.PrintSuccess("Successfully deleted " + namespace + "/" + name) 42 | }, 43 | } 44 | 45 | return cmd 46 | } 47 | -------------------------------------------------------------------------------- /internal/cmd/delete_microservice.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/microservice" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteMicroserviceCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "microservice NAME", 25 | Short: "Delete a Microservice", 26 | Long: `Delete a Microservice`, 27 | Example: `iofogctl delete microservice NAME`, 28 | Args: cobra.ExactArgs(1), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and namespace 31 | name := args[0] 32 | namespace, err := cmd.Flags().GetString("namespace") 33 | util.Check(err) 34 | 35 | // Get an executor for the command 36 | exe, err := delete.NewExecutor(namespace, name) 37 | util.Check(err) 38 | err = exe.Execute() 39 | util.Check(err) 40 | 41 | util.PrintSuccess("Successfully deleted microservice " + name) 42 | }, 43 | } 44 | 45 | return cmd 46 | } 47 | -------------------------------------------------------------------------------- /internal/cmd/delete_namespace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/namespace" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteNamespaceCommand() *cobra.Command { 23 | force := false 24 | cmd := &cobra.Command{ 25 | Use: "namespace NAME", 26 | Short: "Delete a Namespace", 27 | Long: `Delete a Namespace. 28 | 29 | The Namespace must be empty. 30 | 31 | If you would like to delete all resources in the Namespace, use the --force flag.`, 32 | Example: `iofogctl delete namespace NAME`, 33 | Args: cobra.MinimumNArgs(1), 34 | Run: func(cmd *cobra.Command, args []string) { 35 | // Get microservice name 36 | name := args[0] 37 | 38 | // Execute command 39 | err := delete.Execute(name, force) 40 | util.Check(err) 41 | 42 | util.PrintSuccess("Successfully deleted Namespace " + name) 43 | }, 44 | } 45 | 46 | cmd.Flags().BoolVar(&force, "force", false, "Force deletion of all resources within the Namespace") 47 | 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /internal/cmd/delete_registry.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/registry" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteRegistryCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "registry ID", 25 | Short: "Delete a Registry", 26 | Long: `Delete a Registry from the Controller.`, 27 | Example: `iofogctl delete registry ID`, 28 | Args: cobra.ExactArgs(1), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and namespace 31 | id := args[0] 32 | namespace, err := cmd.Flags().GetString("namespace") 33 | util.Check(err) 34 | 35 | // Get an executor for the command 36 | exe, err := delete.NewExecutor(namespace, id) 37 | util.Check(err) 38 | err = exe.Execute() 39 | util.Check(err) 40 | 41 | util.PrintSuccess("Successfully deleted registry " + id) 42 | }, 43 | } 44 | 45 | return cmd 46 | } 47 | -------------------------------------------------------------------------------- /internal/cmd/delete_route.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/route" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteRouteCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "route NAME", 25 | Short: "Delete a Route", 26 | Long: `Delete a Route. 27 | 28 | The corresponding Microservices will no longer be able to reach each other using ioMessages.`, 29 | Example: `iofogctl delete route NAME`, 30 | Args: cobra.ExactArgs(1), 31 | Run: func(cmd *cobra.Command, args []string) { 32 | // Get name and namespace of route 33 | name := args[0] 34 | namespace, err := cmd.Flags().GetString("namespace") 35 | util.Check(err) 36 | 37 | // Run the command 38 | exe := delete.NewExecutor(namespace, name) 39 | err = exe.Execute() 40 | util.Check(err) 41 | 42 | util.PrintSuccess("Successfully deleted " + namespace + "/" + name) 43 | }, 44 | } 45 | 46 | return cmd 47 | } 48 | -------------------------------------------------------------------------------- /internal/cmd/delete_template.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/template" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteApplicationTemplateCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "application-template NAME", 25 | Short: "Delete an application-template", 26 | Long: `Delete an application-template`, 27 | Example: `iofogctl delete application-template NAME`, 28 | Args: cobra.MinimumNArgs(1), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get microservice name 31 | name := args[0] 32 | namespace, err := cmd.Flags().GetString("namespace") 33 | util.Check(err) 34 | 35 | // Execute command 36 | err = delete.Execute(namespace, name) 37 | util.Check(err) 38 | 39 | util.PrintSuccess("Successfully deleted " + namespace + "/" + name) 40 | }, 41 | } 42 | 43 | return cmd 44 | } 45 | -------------------------------------------------------------------------------- /internal/cmd/delete_volume.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | delete "github.com/eclipse-iofog/iofogctl/v3/internal/delete/volume" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDeleteVolumeCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "volume NAME", 25 | Short: "Delete an Volume", 26 | Long: `Delete an Volume. 27 | 28 | The Volume will be deleted from the Agents that it is stored on.`, 29 | Example: `iofogctl delete volume NAME`, 30 | Args: cobra.ExactArgs(1), 31 | Run: func(cmd *cobra.Command, args []string) { 32 | // Get name and namespace of volume 33 | name := args[0] 34 | namespace, err := cmd.Flags().GetString("namespace") 35 | util.Check(err) 36 | 37 | // Run the command 38 | exe, err := delete.NewExecutor(namespace, name) 39 | util.Check(err) 40 | err = exe.Execute() 41 | util.Check(err) 42 | 43 | util.PrintSuccess("Successfully deleted " + namespace + "/" + name) 44 | }, 45 | } 46 | 47 | return cmd 48 | } 49 | -------------------------------------------------------------------------------- /internal/cmd/describe.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newDescribeCommand() *cobra.Command { 21 | // Values accepted in resource type argument 22 | filename := "" 23 | cmd := &cobra.Command{ 24 | Use: "describe", 25 | Short: "Get detailed information of an existing resources", 26 | Long: `Get detailed information of an existing resources. 27 | 28 | Most resources require a working Controller in the Namespace in order to be described.`, 29 | } 30 | 31 | // Add subcommands 32 | cmd.AddCommand( 33 | newDescribeControlPlaneCommand(), 34 | newDescribeControllerCommand(), 35 | newDescribeNamespaceCommand(), 36 | newDescribeAgentCommand(), 37 | newDescribeRegistryCommand(), 38 | newDescribeAgentConfigCommand(), 39 | newDescribeMicroserviceCommand(), 40 | newDescribeApplicationCommand(), 41 | newDescribeApplicationTemplateCommand(), 42 | newDescribeVolumeCommand(), 43 | newDescribeRouteCommand(), 44 | newDescribeEdgeResourceCommand(), 45 | ) 46 | 47 | // Register Flags 48 | cmd.Flags().StringVarP(&filename, "output-file", "o", "", "YAML output file") 49 | 50 | return cmd 51 | } 52 | -------------------------------------------------------------------------------- /internal/cmd/describe_route.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/describe" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDescribeRouteCommand() *cobra.Command { 23 | opt := describe.Options{ 24 | Resource: "route", 25 | } 26 | 27 | cmd := &cobra.Command{ 28 | Use: "route NAME", 29 | Short: "Get detailed information about a Route", 30 | Long: `Get detailed information about a Route.`, 31 | Example: `iofogctl describe route NAME`, 32 | Args: cobra.ExactArgs(1), 33 | Run: func(cmd *cobra.Command, args []string) { 34 | // Get resource type and name 35 | var err error 36 | opt.Name = args[0] 37 | opt.Namespace, err = cmd.Flags().GetString("namespace") 38 | util.Check(err) 39 | 40 | // Get executor for describe command 41 | exe, err := describe.NewExecutor(&opt) 42 | util.Check(err) 43 | 44 | // Execute the command 45 | err = exe.Execute() 46 | util.Check(err) 47 | }, 48 | } 49 | cmd.Flags().StringVarP(&opt.Filename, "output-file", "o", "", "YAML output file") 50 | 51 | return cmd 52 | } 53 | -------------------------------------------------------------------------------- /internal/cmd/describe_volume.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/describe" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDescribeVolumeCommand() *cobra.Command { 23 | opt := describe.Options{ 24 | Resource: "volume", 25 | } 26 | 27 | cmd := &cobra.Command{ 28 | Use: "volume NAME", 29 | Short: "Get detailed information about a Volume", 30 | Long: `Get detailed information about a Volume.`, 31 | Example: `iofogctl describe volume NAME`, 32 | Args: cobra.ExactArgs(1), 33 | Run: func(cmd *cobra.Command, args []string) { 34 | // Get resource type and name 35 | var err error 36 | opt.Name = args[0] 37 | opt.Namespace, err = cmd.Flags().GetString("namespace") 38 | util.Check(err) 39 | 40 | // Get executor for describe command 41 | exe, err := describe.NewExecutor(&opt) 42 | util.Check(err) 43 | 44 | // Execute the command 45 | err = exe.Execute() 46 | util.Check(err) 47 | }, 48 | } 49 | cmd.Flags().StringVarP(&opt.Filename, "output-file", "o", "", "YAML output file") 50 | 51 | return cmd 52 | } 53 | -------------------------------------------------------------------------------- /internal/cmd/detach.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newDetachCommand() *cobra.Command { 21 | cmd := &cobra.Command{ 22 | Use: "detach", 23 | Example: `detach`, 24 | Short: "Detach one ioFog resource from another", 25 | Long: `Detach one ioFog resource from another.`, 26 | } 27 | 28 | // Add subcommands 29 | cmd.AddCommand( 30 | newDetachAgentCommand(), 31 | newDetachEdgeResourceCommand(), 32 | ) 33 | 34 | return cmd 35 | } 36 | -------------------------------------------------------------------------------- /internal/cmd/disconnect.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/disconnect" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newDisconnectCommand() *cobra.Command { 23 | // Instantiate options 24 | opt := &disconnect.Options{} 25 | 26 | // Instantiate command 27 | cmd := &cobra.Command{ 28 | Use: "disconnect", 29 | Short: "Disconnect from an ioFog cluster", 30 | Long: `Disconnect from an ioFog cluster. 31 | 32 | This will remove all client-side information for this Namespace. The Namespace will itself be deleted. 33 | Use the connect command to reconnect after a disconnect. 34 | If you would like to uninstall the Control Plane and/or Agents, use the delete command instead.`, 35 | Example: `iofogctl disconnect -n NAMESPACE`, 36 | Run: func(cmd *cobra.Command, args []string) { 37 | var err error 38 | opt.Namespace, err = cmd.Flags().GetString("namespace") 39 | util.Check(err) 40 | 41 | // Execute the get command 42 | err = disconnect.Execute(opt) 43 | util.Check(err) 44 | }, 45 | } 46 | 47 | return cmd 48 | } 49 | -------------------------------------------------------------------------------- /internal/cmd/logs.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/logs" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newLogsCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "logs RESOURCE NAME", 25 | Short: "Get log contents of deployed resource", 26 | Long: `Get log contents of deployed resource`, 27 | Example: `iofogctl logs controller NAME 28 | agent NAME 29 | microservice NAME`, 30 | Args: cobra.ExactValidArgs(2), 31 | Run: func(cmd *cobra.Command, args []string) { 32 | // Get Resource type and name 33 | resource := args[0] 34 | name := args[1] 35 | namespace, err := cmd.Flags().GetString("namespace") 36 | util.Check(err) 37 | 38 | // Instantiate logs executor 39 | exe, err := logs.NewExecutor(resource, namespace, name) 40 | util.Check(err) 41 | 42 | // Run the logs command 43 | err = exe.Execute() 44 | util.Check(err) 45 | }, 46 | } 47 | 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /internal/cmd/move.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newMoveCommand() *cobra.Command { 21 | cmd := &cobra.Command{ 22 | Use: "move", 23 | Short: "Move an existing resources inside the current Namespace", 24 | Long: `Move an existing resources inside the current Namespace`, 25 | } 26 | 27 | cmd.AddCommand( 28 | newMoveMicroserviceCommand(), 29 | newMoveAgentCommand(), 30 | ) 31 | 32 | return cmd 33 | } 34 | -------------------------------------------------------------------------------- /internal/cmd/move_microservice.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | move "github.com/eclipse-iofog/iofogctl/v3/internal/move/microservice" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newMoveMicroserviceCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "microservice NAME AGENT_NAME", 25 | Short: "Move a Microservice to another Agent in the same Namespace", 26 | Long: `Move a Microservice to another Agent in the same Namespace`, 27 | Example: `iofogctl move microservice NAME AGENT_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and namespace 31 | name := args[0] 32 | agent := args[1] 33 | namespace, err := cmd.Flags().GetString("namespace") 34 | util.Check(err) 35 | 36 | // Get an executor for the command 37 | err = move.Execute(namespace, name, agent) 38 | util.Check(err) 39 | 40 | util.PrintSuccess(getMoveSuccessMessage("Microservice", name, "Agent", agent)) 41 | }, 42 | } 43 | 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /internal/cmd/pkg.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | ) 20 | 21 | var pkg struct { 22 | flagDescDetached string 23 | flagDescYaml string 24 | succRename string 25 | succMove string 26 | } 27 | 28 | func init() { 29 | pkg.flagDescDetached = "Specify command is to run against detached resources" 30 | pkg.flagDescYaml = "YAML file containing specifications for ioFog resources to deploy" 31 | pkg.succRename = "Successfully renamed %s %s to %s" 32 | pkg.succMove = "Successfully moved %s %s to %s %s" 33 | } 34 | 35 | func getRenameSuccessMessage(resource, oldName, newName string) string { 36 | return fmt.Sprintf(pkg.succRename, strings.Title(strings.ToLower(resource)), oldName, newName) 37 | } 38 | 39 | func getMoveSuccessMessage(resource, name, otherResource, otherName string) string { 40 | return fmt.Sprintf(pkg.succRename, resource, name, otherResource, otherName) 41 | } 42 | -------------------------------------------------------------------------------- /internal/cmd/prune.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newDockerPruneCommand() *cobra.Command { 21 | cmd := &cobra.Command{ 22 | Use: "prune", 23 | Short: "prune ioFog resources", 24 | Long: `prune ioFog resources`, 25 | } 26 | 27 | // Add subcommands 28 | cmd.AddCommand( 29 | newPruneAgentCommand(), 30 | ) 31 | 32 | return cmd 33 | } 34 | -------------------------------------------------------------------------------- /internal/cmd/prune_agent.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | prune "github.com/eclipse-iofog/iofogctl/v3/internal/prune/agent" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newPruneAgentCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "agent NAME", 25 | Short: "Remove all dangling images from Agent", 26 | Long: `Remove all the images which are not used by existing containers on the specified Agent`, 27 | Example: `iofogctl prune agent NAME`, 28 | Args: cobra.ExactArgs(1), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and namespace of agent 31 | name := args[0] 32 | namespace, err := cmd.Flags().GetString("namespace") 33 | util.Check(err) 34 | useDetached, err := cmd.Flags().GetBool("detached") 35 | util.Check(err) 36 | 37 | // Run the command 38 | exe := prune.NewExecutor(namespace, name, useDetached) 39 | err = exe.Execute() 40 | util.Check(err) 41 | 42 | util.PrintSuccess("Successfully pruned " + name) 43 | }, 44 | } 45 | 46 | cmd.Flags().Bool("detached", false, pkg.flagDescDetached) 47 | 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /internal/cmd/rename.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newRenameCommand() *cobra.Command { 21 | // Instantiate command 22 | cmd := &cobra.Command{ 23 | Use: "rename", 24 | Short: "Rename the iofog resources that are currently deployed", 25 | Long: `Rename the iofog resources that are currently deployed`, 26 | } 27 | 28 | // Add subcommands 29 | cmd.AddCommand( 30 | newRenameNamespaceCommand(), 31 | newRenameControllerCommand(), 32 | newRenameAgentCommand(), 33 | newRenameApplicationCommand(), 34 | newRenameMicroserviceCommand(), 35 | newRenameRouteCommand(), 36 | newRenameEdgeResourceCommand(), 37 | ) 38 | 39 | return cmd 40 | } 41 | -------------------------------------------------------------------------------- /internal/cmd/rename_agent.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/agent" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newRenameAgentCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "agent NAME NEW_NAME", 25 | Short: "Rename an Agent", 26 | Long: `Rename an Agent`, 27 | Example: `iofogctl rename agent NAME NEW_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and the new name of agent 31 | name := args[0] 32 | newName := args[1] 33 | namespace, err := cmd.Flags().GetString("namespace") 34 | util.Check(err) 35 | useDetached, err := cmd.Flags().GetBool("detached") 36 | util.Check(err) 37 | 38 | // Get an executor for the command 39 | err = rename.Execute(namespace, name, newName, useDetached) 40 | util.Check(err) 41 | 42 | util.PrintSuccess(getRenameSuccessMessage("Agent", name, newName)) 43 | }, 44 | } 45 | 46 | cmd.Flags().Bool("detached", false, pkg.flagDescDetached) 47 | 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /internal/cmd/rename_application.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/application" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newRenameApplicationCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "application NAME NEW_NAME", 25 | Short: "Rename an Application", 26 | Long: `Rename a Application`, 27 | Example: `iofogctl rename application NAME NEW_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and the new name of the application 31 | name := args[0] 32 | newName := args[1] 33 | namespace, err := cmd.Flags().GetString("namespace") 34 | util.Check(err) 35 | 36 | // Get an executor for the command 37 | err = rename.Execute(namespace, name, newName) 38 | util.Check(err) 39 | 40 | util.PrintSuccess(getRenameSuccessMessage("Application", name, newName)) 41 | }, 42 | } 43 | 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /internal/cmd/rename_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/controller" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newRenameControllerCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "controller NAME NEW_NAME", 25 | Short: "Rename a Controller", 26 | Long: `Rename a Controller`, 27 | Example: `iofogctl rename controller NAME NEW_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and the new name of Controller 31 | name := args[0] 32 | newName := args[1] 33 | namespace, err := cmd.Flags().GetString("namespace") 34 | util.Check(err) 35 | 36 | // Get an executor for the command 37 | err = rename.Execute(namespace, name, newName) 38 | util.Check(err) 39 | 40 | util.PrintSuccess(getRenameSuccessMessage("Controller", name, newName)) 41 | }, 42 | } 43 | 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /internal/cmd/rename_edge_resource.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/edgeresource" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newRenameEdgeResourceCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "edge-resource NAME NEW_NAME", 25 | Short: "Rename an Edge Resource", 26 | Long: `Rename an Edge Resource`, 27 | Example: `iofogctl rename edge-resource NAME NEW_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and new name of the edgeResource 31 | name := args[0] 32 | newName := args[1] 33 | namespace, err := cmd.Flags().GetString("namespace") 34 | util.Check(err) 35 | 36 | // Get an executor for the command 37 | err = rename.Execute(namespace, name, newName) 38 | util.Check(err) 39 | 40 | util.PrintSuccess(getRenameSuccessMessage("Edge Resource", name, newName)) 41 | }, 42 | } 43 | 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /internal/cmd/rename_microservice.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/microservice" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newRenameMicroserviceCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "microservice NAME NEW_NAME", 25 | Short: "Rename a Microservice", 26 | Long: `Rename a Microservice`, 27 | Example: `iofogctl rename microservice NAME NEW_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and new name of the microservice 31 | name := args[0] 32 | newName := args[1] 33 | namespace, err := cmd.Flags().GetString("namespace") 34 | util.Check(err) 35 | 36 | // Get an executor for the command 37 | err = rename.Execute(namespace, name, newName) 38 | util.Check(err) 39 | 40 | util.PrintSuccess(getRenameSuccessMessage("Microservice", name, newName)) 41 | }, 42 | } 43 | 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /internal/cmd/rename_namespace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/namespace" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newRenameNamespaceCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "namespace NAME NEW_NAME", 25 | Short: "Rename a Namespace", 26 | Long: `Rename a Namespace`, 27 | Example: `iofogctl rename namespace NAME NEW_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and new name of the namespace 31 | name := args[0] 32 | newName := args[1] 33 | 34 | // Get an executor for the command 35 | err := rename.Execute(name, newName) 36 | util.Check(err) 37 | 38 | util.PrintSuccess(getRenameSuccessMessage("Namespace", name, newName)) 39 | }, 40 | } 41 | 42 | return cmd 43 | } 44 | -------------------------------------------------------------------------------- /internal/cmd/rename_route.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/route" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newRenameRouteCommand() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "route NAME NEW_NAME", 25 | Short: "Rename a Route", 26 | Long: `Rename a Route`, 27 | Example: `iofogctl rename route NAME NEW_NAME`, 28 | Args: cobra.ExactArgs(2), 29 | Run: func(cmd *cobra.Command, args []string) { 30 | // Get name and new name of the route 31 | name := args[0] 32 | newName := args[1] 33 | namespace, err := cmd.Flags().GetString("namespace") 34 | util.Check(err) 35 | 36 | // Get an executor for the command 37 | err = rename.Execute(namespace, name, newName) 38 | util.Check(err) 39 | 40 | util.PrintSuccess(getRenameSuccessMessage("Route", name, newName)) 41 | }, 42 | } 43 | 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /internal/cmd/start.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newStartCommand() *cobra.Command { 21 | cmd := &cobra.Command{ 22 | Use: "start", 23 | Short: "Starts a resource", 24 | Long: "Starts a resource", 25 | } 26 | 27 | // Add subcommands 28 | cmd.AddCommand( 29 | newStartApplicationCommand(), 30 | ) 31 | return cmd 32 | } 33 | -------------------------------------------------------------------------------- /internal/cmd/start_application.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | startapplication "github.com/eclipse-iofog/iofogctl/v3/internal/start" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newStartApplicationCommand() *cobra.Command { 23 | opt := startapplication.Options{} 24 | cmd := &cobra.Command{ 25 | Use: "application NAME", 26 | Short: "Starts an application", 27 | Long: "Starts an application", 28 | Example: `iofogctl start application NAME`, 29 | Args: cobra.ExactValidArgs(1), 30 | Run: func(cmd *cobra.Command, args []string) { 31 | var err error 32 | if len(args) == 0 { 33 | util.Check(util.NewInputError("Must specify an application to start")) 34 | } 35 | opt.Name = args[0] 36 | opt.Namespace, err = cmd.Flags().GetString("namespace") 37 | util.Check(err) 38 | 39 | exe := startapplication.NewExecutor(opt) 40 | 41 | // Execute the command 42 | err = exe.Execute() 43 | util.Check(err) 44 | 45 | util.PrintSuccess("Successfully started Application " + opt.Name) 46 | }, 47 | } 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /internal/cmd/stop.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "github.com/spf13/cobra" 18 | ) 19 | 20 | func newStopCommand() *cobra.Command { 21 | cmd := &cobra.Command{ 22 | Use: "stop", 23 | Short: "Stops a resource", 24 | Long: "Stops a resource", 25 | } 26 | 27 | // Add subcommands 28 | cmd.AddCommand( 29 | newStopApplicationCommand(), 30 | ) 31 | return cmd 32 | } 33 | -------------------------------------------------------------------------------- /internal/cmd/stop_application.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | stopapplication "github.com/eclipse-iofog/iofogctl/v3/internal/stop" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | func newStopApplicationCommand() *cobra.Command { 23 | opt := stopapplication.Options{} 24 | cmd := &cobra.Command{ 25 | Use: "application NAME", 26 | Short: "Stop an application", 27 | Long: "Stop an application", 28 | Example: `iofogctl stop application NAME`, 29 | Args: cobra.ExactValidArgs(1), 30 | Run: func(cmd *cobra.Command, args []string) { 31 | var err error 32 | if len(args) == 0 { 33 | util.Check(util.NewInputError("Must specify an application to start")) 34 | } 35 | opt.Name = args[0] 36 | opt.Namespace, err = cmd.Flags().GetString("namespace") 37 | util.Check(err) 38 | 39 | exe := stopapplication.NewExecutor(opt) 40 | 41 | // Execute the command 42 | err = exe.Execute() 43 | util.Check(err) 44 | 45 | util.PrintSuccess("Successfully stopped Application " + opt.Name) 46 | }, 47 | } 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /internal/configure/default_namespace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package configure 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | type defaultNamespaceExecutor struct { 22 | name string 23 | } 24 | 25 | func newDefaultNamespaceExecutor(opt *Options) *defaultNamespaceExecutor { 26 | return &defaultNamespaceExecutor{ 27 | name: opt.Name, 28 | } 29 | } 30 | 31 | func (exe *defaultNamespaceExecutor) GetName() string { 32 | return exe.name 33 | } 34 | 35 | func (exe *defaultNamespaceExecutor) Execute() error { 36 | if exe.name == "" { 37 | return util.NewInputError("Must specify Namespace") 38 | } 39 | return config.SetDefaultNamespace(exe.name) 40 | } 41 | -------------------------------------------------------------------------------- /internal/connect/controlplane/connect.go: -------------------------------------------------------------------------------- 1 | package connectcontrolplane 2 | 3 | import ( 4 | "github.com/eclipse-iofog/iofog-go-sdk/v3/pkg/client" 5 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 6 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 7 | ) 8 | 9 | func Connect(ctrlPlane rsc.ControlPlane, endpoint string, ns *rsc.Namespace) error { 10 | // Connect to Controller 11 | baseURL, err := util.GetBaseURL(endpoint) 12 | if err != nil { 13 | return err 14 | } 15 | ctrl, err := client.NewAndLogin(client.Options{BaseURL: baseURL}, ctrlPlane.GetUser().Email, ctrlPlane.GetUser().GetRawPassword()) 16 | if err != nil { 17 | return err 18 | } 19 | 20 | // Get Agents 21 | listAgentsResponse, err := ctrl.ListAgents(client.ListAgentsRequest{}) 22 | if err != nil { 23 | return err 24 | } 25 | 26 | // Update Agents config 27 | for idx := range listAgentsResponse.Agents { 28 | agent := &listAgentsResponse.Agents[idx] 29 | agentConfig := rsc.RemoteAgent{ 30 | Name: agent.Name, 31 | UUID: agent.UUID, 32 | Host: agent.IPAddressExternal, 33 | } 34 | if err := ns.AddAgent(&agentConfig); err != nil { 35 | return err 36 | } 37 | } 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /internal/create/namespace/namespace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package createnamespace 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | func Execute(name string) error { 22 | if err := util.IsLowerAlphanumeric("Namespace", name); err != nil { 23 | return err 24 | } 25 | // Update configuration 26 | err := config.AddNamespace(name, util.NowUTC()) 27 | if err != nil { 28 | return err 29 | } 30 | 31 | return config.Flush() 32 | } 33 | -------------------------------------------------------------------------------- /internal/delete/agent/remote.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deleteagent 15 | 16 | import ( 17 | "fmt" 18 | 19 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/iofog/install" 21 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 22 | ) 23 | 24 | func (exe executor) deleteRemoteAgent(agent *rsc.RemoteAgent) error { 25 | // Stop and remove the Agent process on remote server 26 | if agent.ValidateSSH() != nil { 27 | util.PrintNotify("Could not stop daemon for Agent " + agent.Name + ". SSH details missing from local cofiguration. Use configure command to add SSH details.") 28 | } else { 29 | sshAgent, err := install.NewRemoteAgent(agent.SSH.User, 30 | agent.Host, 31 | agent.SSH.Port, 32 | agent.SSH.KeyFile, 33 | agent.Name, 34 | agent.UUID) 35 | if err != nil { 36 | return err 37 | } 38 | if err := sshAgent.Uninstall(); err != nil { 39 | util.PrintNotify(fmt.Sprintf("Failed to stop daemon on Agent %s. %s", agent.Name, err.Error())) 40 | } 41 | } 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /internal/delete/application/execute.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deleteapplication 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 18 | ) 19 | 20 | func Execute(namespace, name string) error { 21 | // Get executor 22 | exe, _ := NewExecutor(namespace, name) 23 | 24 | // Execute deletion 25 | if err := exe.Execute(); err != nil { 26 | return err 27 | } 28 | 29 | // Leave this here as a note on general practice with Execute functions 30 | return config.Flush() 31 | } 32 | -------------------------------------------------------------------------------- /internal/delete/application/legacy.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deleteapplication 15 | 16 | func (exe *Executor) initLegacy() (err error) { 17 | flow, err := exe.client.GetFlowByName(exe.name) 18 | if err != nil { 19 | return 20 | } 21 | exe.flow = flow 22 | return 23 | } 24 | 25 | func (exe *Executor) deleteLegacy() (err error) { 26 | // Init remote resources 27 | if err = exe.initLegacy(); err != nil { 28 | return 29 | } 30 | 31 | // Delete flow 32 | if err = exe.client.DeleteFlow(exe.flow.ID); err != nil { 33 | return 34 | } 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /internal/delete/catalogitem/catalog_item.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deletecatalogitem 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 18 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 19 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 20 | ) 21 | 22 | type Executor struct { 23 | namespace string 24 | name string 25 | } 26 | 27 | func NewExecutor(namespace, name string) (execute.Executor, error) { 28 | exe := &Executor{ 29 | namespace: namespace, 30 | name: name, 31 | } 32 | 33 | return exe, nil 34 | } 35 | 36 | // GetName returns application name 37 | func (exe *Executor) GetName() string { 38 | return exe.name 39 | } 40 | 41 | // Execute deletes application by deleting its associated flow 42 | func (exe *Executor) Execute() error { 43 | util.SpinStart("Deleting Catalog item") 44 | // Init remote resources 45 | clt, err := clientutil.NewControllerClient(exe.namespace) 46 | if err != nil { 47 | return err 48 | } 49 | 50 | item, err := clt.GetCatalogItemByName(exe.name) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | return clt.DeleteCatalogItem(item.ID) 56 | } 57 | -------------------------------------------------------------------------------- /internal/delete/controller/execute.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deletecontroller 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | func Execute(namespace, name string) error { 22 | util.SpinStart("Deleting Controller") 23 | 24 | // Get executor 25 | exe, err := NewExecutor(namespace, name) 26 | if err != nil { 27 | return err 28 | } 29 | 30 | // Execute deletion 31 | if err := exe.Execute(); err != nil { 32 | return err 33 | } 34 | 35 | return config.Flush() 36 | } 37 | -------------------------------------------------------------------------------- /internal/delete/controlplane/factory.go: -------------------------------------------------------------------------------- 1 | package deletecontrolplane 2 | 3 | import ( 4 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 5 | deletek8scontrolplane "github.com/eclipse-iofog/iofogctl/v3/internal/delete/controlplane/k8s" 6 | deletelocalcontrolplane "github.com/eclipse-iofog/iofogctl/v3/internal/delete/controlplane/local" 7 | deleteremotecontrolplane "github.com/eclipse-iofog/iofogctl/v3/internal/delete/controlplane/remote" 8 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 9 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 10 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 11 | ) 12 | 13 | func NewExecutor(namespace string) (execute.Executor, error) { 14 | ns, err := config.GetNamespace(namespace) 15 | if err != nil { 16 | return nil, err 17 | } 18 | baseControlPlane, err := ns.GetControlPlane() 19 | if err != nil { 20 | return nil, err 21 | } 22 | switch baseControlPlane.(type) { 23 | case *rsc.KubernetesControlPlane: 24 | return deletek8scontrolplane.NewExecutor(namespace) 25 | case *rsc.RemoteControlPlane: 26 | return deleteremotecontrolplane.NewExecutor(namespace) 27 | case *rsc.LocalControlPlane: 28 | return deletelocalcontrolplane.NewExecutor(namespace) 29 | } 30 | return nil, util.NewError("Could not convert Control Plane to dynamic type") 31 | } 32 | -------------------------------------------------------------------------------- /internal/delete/edgeresource/factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deleteedgeresource 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 20 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 21 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 22 | ) 23 | 24 | type executor struct { 25 | namespace string 26 | name string 27 | version string 28 | } 29 | 30 | func (exe executor) GetName() string { 31 | return fmt.Sprintf("%s/%s", exe.name, exe.version) 32 | } 33 | 34 | func (exe executor) Execute() (err error) { 35 | if _, err = config.GetNamespace(exe.namespace); err != nil { 36 | return 37 | } 38 | 39 | // Connect to Controller 40 | clt, err := clientutil.NewControllerClient(exe.namespace) 41 | if err != nil { 42 | return 43 | } 44 | 45 | if err = clt.DeleteEdgeResource(exe.name, exe.version); err != nil { 46 | return 47 | } 48 | return 49 | } 50 | 51 | func NewExecutor(namespace, name, version string) (exe execute.Executor) { 52 | return executor{ 53 | namespace: namespace, 54 | name: name, 55 | version: version, 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /internal/delete/registry/registry.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deleteregistry 15 | 16 | import ( 17 | "strconv" 18 | 19 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 20 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 21 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 22 | ) 23 | 24 | type Executor struct { 25 | namespace string 26 | id int 27 | } 28 | 29 | func NewExecutor(namespace, name string) (execute.Executor, error) { 30 | id, err := strconv.Atoi(name) 31 | if err != nil { 32 | return nil, err 33 | } 34 | exe := &Executor{ 35 | namespace: namespace, 36 | id: id, 37 | } 38 | 39 | return exe, nil 40 | } 41 | 42 | // GetName returns application name 43 | func (exe *Executor) GetName() string { 44 | return strconv.Itoa(exe.id) 45 | } 46 | 47 | // Execute deletes application by deleting its associated flow 48 | func (exe *Executor) Execute() error { 49 | util.SpinStart("Deleting Registry") 50 | // Init remote resources 51 | clt, err := clientutil.NewControllerClient(exe.namespace) 52 | if err != nil { 53 | return err 54 | } 55 | 56 | return clt.DeleteRegistry(exe.id) 57 | } 58 | -------------------------------------------------------------------------------- /internal/delete/route/factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deleteroute 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 18 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 19 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 20 | ) 21 | 22 | type executor struct { 23 | namespace string 24 | name string 25 | } 26 | 27 | func (exe executor) GetName() string { 28 | return "deleting Route " + exe.name 29 | } 30 | 31 | func (exe executor) Execute() (err error) { 32 | if _, err = config.GetNamespace(exe.namespace); err != nil { 33 | return 34 | } 35 | 36 | // Connect to Controller 37 | clt, err := clientutil.NewControllerClient(exe.namespace) 38 | if err != nil { 39 | return 40 | } 41 | 42 | appName, routeName, err := clientutil.ParseFQName(exe.name, "Route") 43 | if err != nil { 44 | return err 45 | } 46 | 47 | if err = clt.DeleteRoute(appName, routeName); err != nil { 48 | return 49 | } 50 | return 51 | } 52 | 53 | func NewExecutor(namespace, name string) (exe execute.Executor) { 54 | return executor{ 55 | namespace: namespace, 56 | name: name, 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /internal/delete/volume/local.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deletevolume 15 | 16 | import ( 17 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 18 | ) 19 | 20 | func deleteLocal(agent *rsc.LocalAgent, volume *rsc.Volume) error { 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /internal/delete/volume/remote.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package deletevolume 15 | 16 | import ( 17 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | func deleteRemote(agent *rsc.RemoteAgent, volume *rsc.Volume) error { 22 | // Check SSH details 23 | if err := agent.ValidateSSH(); err != nil { 24 | return err 25 | } 26 | // Check agent is not local 27 | if util.IsLocalHost(agent.Host) { 28 | return util.NewError("Volume deletion is not supported for local Agents") 29 | } 30 | // Connect 31 | ssh, err := util.NewSecureShellClient(agent.SSH.User, agent.Host, agent.SSH.KeyFile) 32 | if err != nil { 33 | return err 34 | } 35 | if err := ssh.Connect(); err != nil { 36 | return err 37 | } 38 | // Delete 39 | if _, err := ssh.Run("sudo -S rm -rf " + util.AddTrailingSlash(volume.Destination) + "*"); err != nil { 40 | return err 41 | } 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /internal/describe/application_legacy.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package describe 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofog-go-sdk/v3/pkg/client" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | func (exe *applicationExecutor) initLegacy() (err error) { 22 | exe.flow, err = exe.client.GetFlowByName(exe.name) 23 | if err != nil { 24 | return 25 | } 26 | msvcListResponse, err := exe.client.GetMicroservicesPerFlow(exe.flow.ID) 27 | if err != nil { 28 | return 29 | } 30 | 31 | // Filter system microservices 32 | for idx := range msvcListResponse.Microservices { 33 | msvc := &msvcListResponse.Microservices[idx] 34 | if util.IsSystemMsvc(msvc) { 35 | continue 36 | } 37 | exe.msvcs = append(exe.msvcs, msvc) 38 | } 39 | exe.msvcPerID = make(map[string]*client.MicroserviceInfo) 40 | for i := 0; i < len(exe.msvcs); i++ { 41 | exe.msvcPerID[exe.msvcs[i].UUID] = exe.msvcs[i] 42 | } 43 | return 44 | } 45 | -------------------------------------------------------------------------------- /internal/describe/namespace.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package describe 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | type namespaceExecutor struct { 22 | name string 23 | filename string 24 | } 25 | 26 | func newNamespaceExecutor(name, filename string) *namespaceExecutor { 27 | n := &namespaceExecutor{} 28 | n.name = name 29 | n.filename = filename 30 | return n 31 | } 32 | 33 | func (exe *namespaceExecutor) GetName() string { 34 | return exe.name 35 | } 36 | 37 | func (exe *namespaceExecutor) Execute() error { 38 | namespace, err := config.GetNamespace(exe.name) 39 | if err != nil { 40 | return err 41 | } 42 | if exe.filename == "" { 43 | if err := util.Print(namespace); err != nil { 44 | return err 45 | } 46 | } else { 47 | if err := util.FPrint(namespace, exe.filename); err != nil { 48 | return err 49 | } 50 | } 51 | return nil 52 | } 53 | -------------------------------------------------------------------------------- /internal/detach/agent/local.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package detachagent 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/eclipse-iofog/iofogctl/v3/pkg/iofog/install" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 21 | ) 22 | 23 | func (exe executor) localDeprovision() error { 24 | containerClient, err := install.NewLocalContainerClient() 25 | if err != nil { 26 | util.PrintNotify(fmt.Sprintf("Could not deprovision local iofog-agent container. Error: %s\n", err.Error())) 27 | } else if _, err = containerClient.ExecuteCmd(install.GetLocalContainerName("agent", false), []string{ 28 | "sudo", 29 | "iofog-agent", 30 | "deprovision", 31 | }); err != nil { 32 | util.PrintNotify(fmt.Sprintf("Could not deprovision local iofog-agent container. Error: %s\n", err.Error())) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /internal/detach/agent/remote.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package detachagent 15 | 16 | import ( 17 | "fmt" 18 | 19 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/iofog/install" 21 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 22 | ) 23 | 24 | func (exe executor) remoteDeprovision(agent *rsc.RemoteAgent) error { 25 | if agent.ValidateSSH() != nil { 26 | util.PrintNotify("Could not deprovision daemon for Agent " + agent.Name + ". SSH details missing from local configuration. Use configure command to add SSH details.") 27 | } else { 28 | sshAgent, err := install.NewRemoteAgent( 29 | agent.SSH.User, 30 | agent.Host, 31 | agent.SSH.Port, 32 | agent.SSH.KeyFile, 33 | agent.Name, 34 | agent.UUID) 35 | if err != nil { 36 | return err 37 | } 38 | if err := sshAgent.Deprovision(); err != nil { 39 | util.PrintNotify(fmt.Sprintf("Failed to deprovision daemon on Agent %s. %s", agent.Name, err.Error())) 40 | } 41 | } 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /internal/disconnect/disconnect.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package disconnect 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | type Options struct { 22 | Namespace string 23 | } 24 | 25 | func Execute(opt *Options) error { 26 | // Check Namespace exists 27 | if _, err := config.GetNamespace(opt.Namespace); err != nil { 28 | if util.IsNotFoundError(err) { 29 | // Not found, disconnection is idempotent 30 | return nil 31 | } 32 | // Error was not 'not found' 33 | return err 34 | } 35 | 36 | if err := config.DeleteNamespace(opt.Namespace); err != nil { 37 | return err 38 | } 39 | return config.Flush() 40 | } 41 | -------------------------------------------------------------------------------- /internal/execute/executor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package execute 15 | 16 | type Executor interface { 17 | Execute() error 18 | GetName() string 19 | } 20 | 21 | type ProvisioningExecutor interface { 22 | ProvisionAgent() (string, error) 23 | } 24 | -------------------------------------------------------------------------------- /internal/get/applications_legacy.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package get 15 | 16 | import "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 17 | 18 | func (exe *applicationExecutor) initLegacy() (err error) { 19 | flows, err := exe.client.GetAllFlows() 20 | if err != nil { 21 | return 22 | } 23 | exe.flows = flows.Flows 24 | for _, flow := range exe.flows { 25 | listMsvcs, err := exe.client.GetMicroservicesPerFlow(flow.ID) 26 | if err != nil { 27 | return err 28 | } 29 | 30 | // Filter System microservices 31 | for idx := range listMsvcs.Microservices { 32 | msvc := &listMsvcs.Microservices[idx] 33 | if util.IsSystemMsvc(msvc) { 34 | continue 35 | } 36 | exe.msvcsPerApplication[flow.ID] = append(exe.msvcsPerApplication[flow.ID], msvc) 37 | } 38 | } 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /internal/get/print.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package get 15 | 16 | import ( 17 | "fmt" 18 | "os" 19 | "text/tabwriter" 20 | ) 21 | 22 | func print(table [][]string) error { 23 | minWidth := 16 24 | tabWidth := 8 25 | padding := 1 26 | writer := tabwriter.NewWriter(os.Stdout, minWidth, tabWidth, padding, '\t', 0) 27 | defer writer.Flush() 28 | 29 | for _, row := range table { 30 | for _, col := range row { 31 | _, err := fmt.Fprintf(writer, "%s\t", col) 32 | if err != nil { 33 | return err 34 | } 35 | } 36 | _, err := fmt.Fprintf(writer, "\n") 37 | if err != nil { 38 | return err 39 | } 40 | } 41 | _, err := fmt.Fprintf(writer, "\n") 42 | if err != nil { 43 | return err 44 | } 45 | 46 | return nil 47 | } 48 | 49 | func printNamespace(namespace string) { 50 | fmt.Printf("NAMESPACE\n%s\n\n", namespace) 51 | } 52 | -------------------------------------------------------------------------------- /internal/get/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package get 15 | 16 | import ( 17 | "regexp" 18 | 19 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 20 | ) 21 | 22 | func getAddressAndPort(endpoint, defaultPort string) (addr, port string) { 23 | // Remove prefix 24 | regex := regexp.MustCompile("https?://") 25 | addr = regex.ReplaceAllString(endpoint, "") 26 | 27 | // Get port from address 28 | port = util.AfterLast(addr, ":") 29 | if port == "" { 30 | port = defaultPort 31 | } 32 | 33 | // Remove port from address 34 | addr = util.Before(addr, ":") 35 | 36 | return 37 | } 38 | -------------------------------------------------------------------------------- /internal/logs/k8s_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package logs 15 | 16 | import ( 17 | "fmt" 18 | 19 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 21 | ) 22 | 23 | type kubernetesControllerExecutor struct { 24 | controlPlane *rsc.KubernetesControlPlane 25 | namespace string 26 | name string 27 | } 28 | 29 | func newKubernetesControllerExecutor(controlPlane *rsc.KubernetesControlPlane, namespace, name string) *kubernetesControllerExecutor { 30 | return &kubernetesControllerExecutor{ 31 | controlPlane: controlPlane, 32 | namespace: namespace, 33 | name: name, 34 | } 35 | } 36 | 37 | func (exe *kubernetesControllerExecutor) GetName() string { 38 | return exe.name 39 | } 40 | 41 | func (exe *kubernetesControllerExecutor) Execute() error { 42 | if err := exe.controlPlane.ValidateKubeConfig(); err != nil { 43 | return err 44 | } 45 | out, err := util.Exec("KUBECONFIG="+exe.controlPlane.KubeConfig, "kubectl", "logs", "-l", "name=controller", "-n", exe.namespace) 46 | if err != nil { 47 | return err 48 | } 49 | fmt.Print(out.String()) 50 | 51 | return nil 52 | } 53 | -------------------------------------------------------------------------------- /internal/logs/local_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package logs 15 | 16 | import ( 17 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/iofog/install" 19 | ) 20 | 21 | type localControllerExecutor struct { 22 | controlPlane *rsc.LocalControlPlane 23 | namespace string 24 | name string 25 | } 26 | 27 | func newLocalControllerExecutor(controlPlane *rsc.LocalControlPlane, namespace, name string) *localControllerExecutor { 28 | return &localControllerExecutor{ 29 | controlPlane: controlPlane, 30 | namespace: namespace, 31 | name: name, 32 | } 33 | } 34 | 35 | func (exe *localControllerExecutor) GetName() string { 36 | return exe.name 37 | } 38 | 39 | func (exe *localControllerExecutor) Execute() error { 40 | lc, err := install.NewLocalContainerClient() 41 | if err != nil { 42 | return err 43 | } 44 | containerName := install.GetLocalContainerName("controller", false) 45 | stdout, stderr, err := lc.GetLogsByName(containerName) 46 | if err != nil { 47 | return err 48 | } 49 | 50 | printContainerLogs(stdout, stderr) 51 | 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /internal/logs/utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package logs 15 | 16 | import ( 17 | "os" 18 | ) 19 | 20 | func printContainerLogs(stdout, stderr string) { 21 | os.Stdout.WriteString(stdout) 22 | os.Stderr.WriteString(stderr) 23 | } 24 | -------------------------------------------------------------------------------- /internal/prune/agent/local.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package pruneagent 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/eclipse-iofog/iofogctl/v3/pkg/iofog/install" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 21 | ) 22 | 23 | func (exe executor) localAgentPrune() error { 24 | containerClient, err := install.NewLocalContainerClient() 25 | if err != nil { 26 | return err 27 | } 28 | if _, err = containerClient.ExecuteCmd(install.GetLocalContainerName("agent", false), []string{ 29 | "sudo", 30 | "iofog-agent", 31 | "prune", 32 | }); err != nil { 33 | return util.NewInternalError(fmt.Sprintf("Could not prune local agent. Error: %s\n", err.Error())) 34 | } 35 | 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /internal/rename/application/executor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package application 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/eclipse-iofog/iofog-go-sdk/v3/pkg/client" 20 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 21 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 22 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 23 | ) 24 | 25 | func Execute(namespace, name, newName string) error { 26 | if err := util.IsLowerAlphanumeric("Application", newName); err != nil { 27 | return err 28 | } 29 | util.SpinStart(fmt.Sprintf("Renaming Application %s", name)) 30 | 31 | // Init remote resources 32 | clt, err := clientutil.NewControllerClient(namespace) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | flow, err := clt.GetFlowByName(name) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | flow.Name = newName 43 | _, err = clt.UpdateFlow(&client.FlowUpdateRequest{ 44 | ID: flow.ID, 45 | Name: &newName, 46 | }) 47 | if err != nil { 48 | return err 49 | } 50 | config.Flush() 51 | return nil 52 | } 53 | -------------------------------------------------------------------------------- /internal/rename/controller/executor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package controller 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 21 | ) 22 | 23 | func Execute(namespace, name, newName string) error { 24 | ns, err := config.GetNamespace(namespace) 25 | if err != nil { 26 | return err 27 | } 28 | // Check that Controller exists in current namespace 29 | controlPlane, err := ns.GetControlPlane() 30 | if err != nil { 31 | return err 32 | } 33 | 34 | // Get the Controller to rename 35 | controller, err := controlPlane.GetController(name) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | // Check new name is valid 41 | if err := util.IsLowerAlphanumeric("Controller", newName); err != nil { 42 | return err 43 | } 44 | 45 | // Perform the rename 46 | util.SpinStart(fmt.Sprintf("Renaming Controller %s", name)) 47 | controller.SetName(newName) 48 | ns.SetControlPlane(controlPlane) 49 | 50 | return config.Flush() 51 | } 52 | -------------------------------------------------------------------------------- /internal/rename/namespace/executor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package namespace 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/eclipse-iofog/iofogctl/v3/internal/config" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 21 | ) 22 | 23 | func Execute(name, newName string) error { 24 | if name == "" || name == "default" { 25 | return util.NewError("Cannot rename default or nonexistant namespaces") 26 | } 27 | if err := util.IsLowerAlphanumeric("Namespace", newName); err != nil { 28 | return err 29 | } 30 | 31 | util.SpinStart(fmt.Sprintf("Renaming Namespace %s", name)) 32 | 33 | if err := config.RenameNamespace(name, newName); err != nil { 34 | return err 35 | } 36 | return config.Flush() 37 | } 38 | -------------------------------------------------------------------------------- /internal/rename/route/executor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package route 15 | 16 | import ( 17 | "fmt" 18 | 19 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 20 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 21 | ) 22 | 23 | func Execute(namespace, name, newName string) error { 24 | // Init remote resources 25 | clt, err := clientutil.NewControllerClient(namespace) 26 | if err != nil { 27 | return err 28 | } 29 | 30 | appName, routeName, err := clientutil.ParseFQName(name, "Route") 31 | if err != nil { 32 | return err 33 | } 34 | 35 | route, err := clt.GetRoute(appName, routeName) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | if err := util.IsLowerAlphanumeric("Route", newName); err != nil { 41 | return err 42 | } 43 | util.SpinStart(fmt.Sprintf("Renaming route %s", name)) 44 | route.Name = newName 45 | // Temporary fix 46 | route.SourceMicroserviceUUID = "" 47 | route.DestMicroserviceUUID = "" 48 | 49 | if err := clt.PatchRoute(appName, routeName, &route); err != nil { 50 | return err 51 | } 52 | 53 | return err 54 | } 55 | -------------------------------------------------------------------------------- /internal/resource/agent.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package resource 15 | 16 | type Agent interface { 17 | GetName() string 18 | GetUUID() string 19 | GetHost() string 20 | GetCreatedTime() string 21 | GetConfig() *AgentConfiguration 22 | GetControllerEndpoint() string 23 | SetName(string) 24 | SetUUID(string) 25 | SetHost(string) 26 | SetCreatedTime(string) 27 | SetConfig(*AgentConfiguration) 28 | Sanitize() error 29 | Clone() Agent 30 | } 31 | -------------------------------------------------------------------------------- /internal/resource/controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package resource 15 | 16 | type Controller interface { 17 | GetName() string 18 | GetEndpoint() string 19 | GetCreatedTime() string 20 | SetName(string) 21 | Sanitize() error 22 | Clone() Controller 23 | } 24 | -------------------------------------------------------------------------------- /internal/resource/controlplane.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package resource 15 | 16 | type ControlPlane interface { 17 | GetUser() IofogUser 18 | GetControllers() []Controller 19 | GetController(string) (Controller, error) 20 | GetEndpoint() (string, error) 21 | UpdateController(Controller) error 22 | AddController(Controller) error 23 | DeleteController(string) error 24 | Sanitize() error 25 | Clone() ControlPlane 26 | } 27 | -------------------------------------------------------------------------------- /internal/resource/errors.go: -------------------------------------------------------------------------------- 1 | package resource 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type NoControlPlaneError struct { 9 | namespace string 10 | msg string 11 | } 12 | 13 | func NewNoControlPlaneError(namespace string) NoControlPlaneError { 14 | return NoControlPlaneError{ 15 | namespace: namespace, 16 | msg: "does not contain a Control Plane", 17 | } 18 | } 19 | 20 | func (err NoControlPlaneError) Error() string { 21 | return fmt.Sprintf("Namespace %s %s", err.namespace, err.msg) 22 | } 23 | 24 | func IsNoControlPlaneError(err error) bool { 25 | return strings.Contains(err.Error(), NewNoControlPlaneError("").msg) 26 | } 27 | 28 | type NoSSHConfigError struct { 29 | message string 30 | } 31 | 32 | func NewNoSSHConfigError(resource string) *NoSSHConfigError { 33 | message := fmt.Sprintf("Cannot perform command because SSH details for this %s are not available. Use the configure command to add required details.", resource) 34 | 35 | return &NoSSHConfigError{ 36 | message: message, 37 | } 38 | } 39 | 40 | func (err *NoSSHConfigError) Error() string { 41 | return err.message 42 | } 43 | 44 | type NoKubeConfigError struct { 45 | message string 46 | } 47 | 48 | func NewNoKubeConfigError(resource string) *NoKubeConfigError { 49 | message := fmt.Sprintf("Cannot perform command because Kube config for this %s is not available. Use the configure command to add required details.", resource) 50 | 51 | return &NoKubeConfigError{ 52 | message: message, 53 | } 54 | } 55 | 56 | func (err *NoKubeConfigError) Error() string { 57 | return err.message 58 | } 59 | -------------------------------------------------------------------------------- /internal/resource/k8s_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package resource 15 | 16 | type KubernetesController struct { 17 | PodName string `yaml:"podName"` 18 | Endpoint string `yaml:"endpoint"` 19 | Created string `yaml:"created,omitempty"` 20 | Status string `yaml:"status,omitempty"` 21 | } 22 | 23 | func (ctrl *KubernetesController) GetName() string { 24 | return ctrl.PodName 25 | } 26 | 27 | func (ctrl *KubernetesController) GetEndpoint() string { 28 | return ctrl.Endpoint 29 | } 30 | 31 | func (ctrl *KubernetesController) GetCreatedTime() string { 32 | return ctrl.Created 33 | } 34 | 35 | func (ctrl *KubernetesController) SetName(name string) { 36 | ctrl.PodName = name 37 | } 38 | 39 | func (ctrl *KubernetesController) Sanitize() error { 40 | return nil 41 | } 42 | 43 | func (ctrl *KubernetesController) Clone() Controller { 44 | return &KubernetesController{ 45 | PodName: ctrl.PodName, 46 | Endpoint: ctrl.Endpoint, 47 | Created: ctrl.Created, 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /internal/resource/local_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package resource 15 | 16 | type LocalController struct { 17 | Name string `yaml:"name"` 18 | Endpoint string `yaml:"endpoint"` 19 | Container Container `yaml:"container"` 20 | Created string `yaml:"created,omitempty"` 21 | } 22 | 23 | func (ctrl *LocalController) GetName() string { 24 | return ctrl.Name 25 | } 26 | 27 | func (ctrl *LocalController) GetEndpoint() string { 28 | return ctrl.Endpoint 29 | } 30 | 31 | func (ctrl *LocalController) GetCreatedTime() string { 32 | return ctrl.Created 33 | } 34 | 35 | func (ctrl *LocalController) SetName(name string) { 36 | ctrl.Name = name 37 | } 38 | 39 | func (ctrl *LocalController) Sanitize() error { 40 | if ctrl.Name == "" { 41 | ctrl.Name = "local" 42 | } 43 | return nil 44 | } 45 | 46 | func (ctrl *LocalController) Clone() Controller { 47 | return &LocalController{ 48 | Name: ctrl.Name, 49 | Endpoint: ctrl.Endpoint, 50 | Container: ctrl.Container, 51 | Created: ctrl.Created, 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /internal/resource/namespace_test.go: -------------------------------------------------------------------------------- 1 | package resource 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestAgents(t *testing.T) { 8 | ns := Namespace{} 9 | agents := []Agent{ 10 | &LocalAgent{ 11 | Name: "local", 12 | }, 13 | &RemoteAgent{ 14 | Name: "remote", 15 | Host: "123.123.123.123", 16 | SSH: SSH{ 17 | User: "serge", 18 | KeyFile: "~/.ssh/id_rsa", 19 | Port: 0, 20 | }, 21 | }, 22 | } 23 | // Add 24 | for idx := range agents { 25 | if err := ns.AddAgent(agents[idx]); err != nil { 26 | t.Errorf("Failed to create Agent: " + err.Error()) 27 | } 28 | } 29 | if len(ns.GetAgents()) != 2 { 30 | t.Errorf("Failed to get Agents, count: %d", len(ns.GetAgents())) 31 | } 32 | // Delete 33 | if err := ns.DeleteAgent("local"); err != nil { 34 | t.Errorf("Failed to delete Agent: %s", err.Error()) 35 | } 36 | if len(ns.GetAgents()) != 1 { 37 | t.Errorf("Failed to get Agents, count: %d", len(ns.GetAgents())) 38 | } 39 | if err := ns.DeleteAgent("remote"); err != nil { 40 | t.Errorf("Failed to delete Agent: %s", err.Error()) 41 | } 42 | if len(ns.GetAgents()) != 0 { 43 | t.Errorf("Failed to get Agents, count: %d", len(ns.GetAgents())) 44 | } 45 | // Update 46 | for idx := 0; idx < len(agents)*2; idx++ { 47 | modIdx := idx % len(agents) 48 | if err := ns.UpdateAgent(agents[modIdx]); err != nil { 49 | t.Errorf("Failed to update Agent: " + err.Error()) 50 | } 51 | } 52 | if len(ns.GetAgents()) != 2 { 53 | t.Errorf("Failed to get Agents, count: %d", len(ns.GetAgents())) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /internal/resource/user.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package resource 15 | 16 | import ( 17 | "encoding/base64" 18 | ) 19 | 20 | // IofogUser contains information about users registered against a controller 21 | type IofogUser struct { 22 | Name string `yaml:"name,omitempty"` 23 | Surname string `yaml:"surname,omitempty"` 24 | Email string `yaml:"email,omitempty"` 25 | Password string `yaml:"password,omitempty"` 26 | } 27 | 28 | func (user *IofogUser) EncodePassword() { 29 | user.Password = encodeBase64(user.Password) 30 | } 31 | 32 | func (user IofogUser) GetRawPassword() string { 33 | buf, err := base64.StdEncoding.DecodeString(user.Password) 34 | if err != nil { 35 | return user.Password 36 | } 37 | return string(buf) 38 | } 39 | 40 | func encodeBase64(raw string) string { 41 | return base64.StdEncoding.EncodeToString([]byte(raw)) 42 | } 43 | -------------------------------------------------------------------------------- /internal/rollback/factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package rollback 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | type Options struct { 22 | ResourceType string 23 | Namespace string 24 | Name string 25 | } 26 | 27 | func NewExecutor(opt Options) (execute.Executor, error) { 28 | switch opt.ResourceType { 29 | case "agent": 30 | return newAgentExecutor(opt), nil 31 | default: 32 | return nil, util.NewInputError("Unsupported resource: " + opt.ResourceType) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /internal/start/application.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package startapplication 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 18 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 19 | ) 20 | 21 | type Options struct { 22 | Namespace string 23 | Name string 24 | } 25 | 26 | type executor struct { 27 | namespace string 28 | name string 29 | } 30 | 31 | func NewExecutor(opt Options) (exe execute.Executor) { 32 | return &executor{ 33 | name: opt.Name, 34 | namespace: opt.Namespace, 35 | } 36 | } 37 | 38 | func (exe *executor) GetName() string { 39 | return exe.name 40 | } 41 | 42 | func (exe *executor) Execute() (err error) { 43 | clt, err := clientutil.NewControllerClient(exe.namespace) 44 | if err != nil { 45 | return err 46 | } 47 | 48 | flow, err := clt.GetFlowByName(exe.name) 49 | if err != nil { 50 | return err 51 | } 52 | 53 | _, err = clt.StartFlow(flow.ID) 54 | 55 | return 56 | } 57 | -------------------------------------------------------------------------------- /internal/stop/application.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package stopapplication 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 18 | clientutil "github.com/eclipse-iofog/iofogctl/v3/internal/util/client" 19 | ) 20 | 21 | type Options struct { 22 | Namespace string 23 | Name string 24 | } 25 | 26 | type executor struct { 27 | namespace string 28 | name string 29 | } 30 | 31 | func NewExecutor(opt Options) (exe execute.Executor) { 32 | return &executor{ 33 | name: opt.Name, 34 | namespace: opt.Namespace, 35 | } 36 | } 37 | 38 | func (exe *executor) GetName() string { 39 | return exe.name 40 | } 41 | 42 | func (exe *executor) Execute() (err error) { 43 | clt, err := clientutil.NewControllerClient(exe.namespace) 44 | if err != nil { 45 | return err 46 | } 47 | 48 | flow, err := clt.GetFlowByName(exe.name) 49 | if err != nil { 50 | return err 51 | } 52 | 53 | _, err = clt.StopFlow(flow.ID) 54 | 55 | return 56 | } 57 | -------------------------------------------------------------------------------- /internal/upgrade/factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package upgrade 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofogctl/v3/internal/execute" 18 | "github.com/eclipse-iofog/iofogctl/v3/pkg/util" 19 | ) 20 | 21 | type Options struct { 22 | ResourceType string 23 | Namespace string 24 | Name string 25 | } 26 | 27 | func NewExecutor(opt Options) (execute.Executor, error) { 28 | switch opt.ResourceType { 29 | case "agent": 30 | return newAgentExecutor(opt), nil 31 | default: 32 | return nil, util.NewInputError("Unsupported resource: " + opt.ResourceType) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /internal/util/misc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | rsc "github.com/eclipse-iofog/iofogctl/v3/internal/resource" 18 | ) 19 | 20 | func IsSystemAgent(agentConfig *rsc.AgentConfiguration) bool { 21 | return agentConfig != nil && agentConfig.IsSystem != nil && *agentConfig.IsSystem 22 | } 23 | 24 | func MakeIntPtr(value int) *int { 25 | return &value 26 | } 27 | 28 | func MakeStrPtr(value string) *string { 29 | return &value 30 | } 31 | 32 | func MakeBoolPtr(value bool) *bool { 33 | return &value 34 | } 35 | -------------------------------------------------------------------------------- /iofogctl-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-iofog/iofogctl/af1acc6cf0459e357fee4d6e4ef9354c12c4c8ad/iofogctl-logo.png -------------------------------------------------------------------------------- /pipeline/local.yaml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - job: Local 3 | pool: 4 | vmImage: 'Ubuntu-20.04' 5 | steps: 6 | - template: steps/init-gcloud-steps.yaml 7 | - script: | 8 | gcloud --quiet auth configure-docker 9 | docker pull $(controller_image) 10 | docker pull $(agent_image) 11 | displayName: 'Pull develop gcr docker image' 12 | - task: DownloadBuildArtifacts@0 13 | displayName: 'Download Build Artifacts' 14 | inputs: 15 | artifactName: iofogctl 16 | downloadPath: $(System.DefaultWorkingDirectory) 17 | - script: | 18 | sudo cp iofogctl/build_linux_linux_amd64/iofogctl /usr/local/bin/ 19 | sudo chmod 0755 /usr/local/bin/iofogctl 20 | - bash: | 21 | sudo apt-get install -y jq 22 | displayName: 'Install jq' 23 | - template: steps/postinstall.yaml 24 | - template: steps/configure-remote-tests.yaml 25 | - template: steps/install-test-deps.yaml 26 | - script: | 27 | test/run.bash smoke 28 | displayName: 'Run Smoke Tests' 29 | - script: | 30 | set -o pipefail 31 | test/run.bash local | tee test/conf/results-local.tap 32 | displayName: 'Run Functional Tests' 33 | - script: | 34 | tap-junit -i test/conf/results-local.tap -o test/conf -s Local -n results-local.xml || true 35 | displayName: 'Convert test output from TAP to JUnit' 36 | condition: succeededOrFailed() 37 | - template: steps/functional-post-test.yaml 38 | - script: | 39 | docker system prune -af 40 | condition: always() 41 | displayName: 'Clean local docker' -------------------------------------------------------------------------------- /pipeline/steps/functional-clean-vm.yaml: -------------------------------------------------------------------------------- 1 | parameters: 2 | id: '' 3 | agent_count: 0 4 | controller_count: 0 5 | 6 | steps: 7 | - bash: | 8 | id=${{ parameters.id }} 9 | agent_count=${{ parameters.agent_count }} 10 | controller_count=${{ parameters.controller_count }} 11 | jobs=0 12 | for idx in $(seq 1 $agent_count); do 13 | gcloud compute --project=$(gcp.project.name) instances delete iofogctl-ci-$id-$idx --zone=$(gcp.vm.zone) --delete-disks=all -q & 14 | ((jobs++)) 15 | done 16 | if [ $controller_count -gt 0 ]; then 17 | idx=$((agent_count+1)) 18 | gcloud compute --project=$(gcp.project.name) instances delete iofogctl-ci-$id-$idx --zone=$(gcp.vm.zone) --delete-disks=all -q & 19 | ((jobs++)) 20 | fi 21 | for job in $(seq 1 $jobs); do 22 | wait %$job 23 | done 24 | displayName: 'Teardown VMs' 25 | condition: always() -------------------------------------------------------------------------------- /pipeline/steps/functional-post-test.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | # Publish Test Results 3 | # Publish test results to Azure Pipelines 4 | - task: PublishTestResults@2 5 | condition: succeededOrFailed() 6 | inputs: 7 | testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest 8 | testResultsFiles: 'results-*.xml' 9 | searchFolder: './test/conf' # Optional 10 | #mergeTestResults: false # Optional 11 | #failTaskOnFailedTests: false # Optional 12 | #testRunTitle: # Optional 13 | #buildPlatform: # Optional 14 | #buildConfiguration: # Optional 15 | #publishRunAttachments: true # Optional 16 | displayName: 'Publish test results' 17 | -------------------------------------------------------------------------------- /pipeline/steps/init-gcloud-steps.yaml: -------------------------------------------------------------------------------- 1 | parameters: 2 | windows: 'false' 3 | 4 | steps: 5 | - task: DownloadSecureFile@1 6 | displayName: 'Download secure file' 7 | inputs: 8 | secureFile: 'azure-gcp.json' 9 | - bash: | 10 | keyFilePath="$(Agent.TempDirectory)/azure-gcp.json" 11 | if [[ ${{ parameters.windows }} == "true" ]]; then 12 | keyFilePath=$(wslpath "${keyFilePath}") 13 | fi 14 | if [[ -z $(which gcloud) ]]; then 15 | CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" 16 | echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list 17 | curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - 18 | sudo apt-get update && sudo apt-get install -y google-cloud-sdk 19 | fi 20 | gcloud --quiet auth activate-service-account --key-file="${keyFilePath}" 21 | gcloud --quiet config set project $(gcp.project.name) 22 | displayName: 'set up gcloud' -------------------------------------------------------------------------------- /pipeline/steps/init-ssh.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: InstallSSHKey@0 3 | inputs: 4 | knownHostsEntry: $(ssh.github.knownhost) 5 | sshPublicKey: $(ssh.user.pub) 6 | sshKeySecureFile: id_rsa 7 | - task: DownloadSecureFile@1 8 | displayName: 'Download SSH keys to' 9 | inputs: 10 | secureFile: 'id_rsa' -------------------------------------------------------------------------------- /pipeline/steps/install-test-deps.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - bash: | 3 | git clone https://github.com/bats-core/bats-core.git && cd bats-core && git checkout tags/v1.1.0 && sudo ./install.sh /usr/local 4 | sudo npm i -g tap-junit 5 | displayName: 'Install Test Deps' -------------------------------------------------------------------------------- /pipeline/steps/postinstall.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - script: | 3 | which iofogctl 4 | iofogctl version 5 | displayName: 'Verify Install' -------------------------------------------------------------------------------- /pipeline/steps/prebuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - script: | 3 | set -e 4 | mkdir -p '$(GOBIN)' 5 | mkdir -p '$(GOPATH)/pkg' 6 | echo '##vso[task.prependpath]$(GOBIN)' 7 | echo '##vso[task.prependpath]$(GOROOT)/bin' 8 | displayName: 'Set up the Go workspace' 9 | - task: GoTool@0 10 | inputs: 11 | version: '1.17.9' 12 | goPath: $(GOPATH) 13 | goBin: $(GOBIN) 14 | displayName: 'Install Golang' 15 | - script: | 16 | set -e 17 | script/check_fmt.sh 18 | displayName: 'Check Source Format' 19 | - script: | 20 | set -e 21 | PIPELINE=1 script/bootstrap.sh 22 | displayName: 'Bootstrap' 23 | - script: | 24 | set -e 25 | make test 26 | displayName: 'Run Unit Tests' -------------------------------------------------------------------------------- /pipeline/steps/publish-deps.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: UseRubyVersion@0 3 | inputs: 4 | versionSpec: '2.7' 5 | addToPath: true 6 | displayName: 'Install Ruby' 7 | - task: DownloadSecureFile@1 8 | inputs: 9 | secureFile: 'package_cloud' 10 | displayName: 'Download package cloud token file' 11 | - script: | 12 | gem install fpm 13 | fpm -h 14 | gem install package_cloud 15 | package_cloud -h 16 | echo "config file..." 17 | echo $(Agent.TempDirectory)/package_cloud 18 | displayName: 'Install package_cloud cli and fpm' -------------------------------------------------------------------------------- /pipeline/steps/vanilla.yaml: -------------------------------------------------------------------------------- 1 | parameters: 2 | id: '' 3 | distro: '' 4 | repo: '' 5 | agent_count: 1 6 | controller_count: 1 7 | 8 | steps: 9 | - task: DownloadBuildArtifacts@0 10 | displayName: 'Download Build Artifacts' 11 | inputs: 12 | artifactName: iofogctl 13 | downloadPath: $(System.DefaultWorkingDirectory) 14 | - script: | 15 | sudo cp iofogctl/build_linux_linux_amd64/iofogctl /usr/local/bin/ 16 | sudo chmod 0755 /usr/local/bin/iofogctl 17 | - template: postinstall.yaml 18 | - template: init-ssh.yaml 19 | - template: init-vms.yaml 20 | parameters: 21 | id: ${{ parameters.id }} 22 | distro: ${{ parameters.distro }} 23 | repo: ${{ parameters.repo }} 24 | agent_count: ${{ parameters.agent_count }} 25 | controller_count: ${{ parameters.controller_count }} 26 | - template: configure-remote-tests.yaml 27 | - template: install-test-deps.yaml 28 | - script: | 29 | test/run.bash smoke 30 | displayName: 'Run Smoke Tests' 31 | - script: | 32 | set -o pipefail 33 | test/run.bash vanilla | tee test/conf/results-vanilla.tap 34 | displayName: 'Run Functional Tests' 35 | - script: | 36 | tap-junit -i test/conf/results-vanilla.tap -o test/conf -s Vanilla -n results-vanilla.xml || true 37 | displayName: 'Convert test output from TAP to JUnit' 38 | condition: succeededOrFailed() 39 | - template: functional-post-test.yaml 40 | - template: functional-clean-vm.yaml 41 | parameters: 42 | id: ${{ parameters.id }} 43 | agent_count: ${{ parameters.agent_count }} 44 | controller_count: ${{ parameters.controller_count }} 45 | -------------------------------------------------------------------------------- /pipeline/steps/version.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - script: | 3 | . version.sh 4 | VERS=$MAJOR.$MINOR.$PATCH$SUFFIX 5 | echo "$VERS" 6 | if [[ $(ref) == refs/tags* ]]; then 7 | TAG=$(echo $(ref) | sed "s|refs/tags/v||g") 8 | if [[ $TAG != $VERS ]]; then 9 | echo 'Version file does not match git tag' 10 | exit 1 11 | fi 12 | fi 13 | echo "##vso[task.setvariable variable=version]$VERS" 14 | echo "Version: $VERS" 15 | displayName: 'Set version variable' -------------------------------------------------------------------------------- /pipeline/vanilla.yaml: -------------------------------------------------------------------------------- 1 | parameters: 2 | job_name: '' 3 | id: '' 4 | distro: '' 5 | repo: '' 6 | agent_count: 1 7 | controller_count: 1 8 | 9 | jobs: 10 | - job: ${{ parameters.job_name }} 11 | pool: 12 | vmImage: 'Ubuntu-20.04' 13 | steps: 14 | - template: steps/vanilla.yaml 15 | parameters: 16 | id: $(jobuuid) 17 | distro: ${{ parameters.distro }} 18 | repo: ${{ parameters.repo }} 19 | agent_count: 2 20 | controller_count: 1 -------------------------------------------------------------------------------- /pkg/iofog/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package iofog 15 | 16 | import "github.com/eclipse-iofog/iofog-go-sdk/v3/pkg/client" 17 | 18 | // String and numeric values of TCP ports used accross ioFog 19 | const ( 20 | ControllerPort = client.ControllerPort 21 | ControllerPortString = client.ControllerPortString 22 | 23 | ControllerHostECNViewerPort = 8008 24 | ControllerHostECNViewerPortString = "8008" 25 | 26 | DefaultHTTPPort = 80 27 | DefaultHTTPPortString = "80" 28 | 29 | ConnectorPort = 8080 30 | ConnectorPortString = "8080" 31 | 32 | VanillaRouterAgentName string = client.DefaultRouterName 33 | ) 34 | -------------------------------------------------------------------------------- /pkg/iofog/install/pkg.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package install 15 | 16 | var pkg struct { 17 | scriptPrereq string 18 | scriptInit string 19 | scriptInstallDeps string 20 | scriptInstallJava string 21 | scriptInstallDocker string 22 | scriptInstallIofog string 23 | scriptUninstallIofog string 24 | iofogDir string 25 | agentDir string 26 | } 27 | 28 | func init() { 29 | pkg.scriptPrereq = "check_prereqs.sh" 30 | pkg.scriptInit = "init.sh" 31 | pkg.scriptInstallDeps = "install_deps.sh" 32 | pkg.scriptInstallJava = "install_java.sh" 33 | pkg.scriptInstallDocker = "install_docker.sh" 34 | pkg.scriptInstallIofog = "install_iofog.sh" 35 | pkg.scriptUninstallIofog = "uninstall_iofog.sh" 36 | pkg.iofogDir = "/etc/iofog" 37 | pkg.agentDir = "/etc/iofog/agent" 38 | } 39 | -------------------------------------------------------------------------------- /pkg/iofog/install/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package install 15 | 16 | type IofogUser struct { 17 | Name string 18 | Surname string 19 | Email string 20 | Password string 21 | } 22 | 23 | type Database struct { 24 | Provider string 25 | Host string 26 | Port int 27 | User string 28 | Password string 29 | DatabaseName string 30 | } 31 | 32 | type Pod struct { 33 | Name string 34 | Status string 35 | } 36 | 37 | type ControllerConfig struct { 38 | User IofogUser 39 | Replicas int32 40 | Database Database 41 | PidBaseDir string 42 | EcnViewerPort int 43 | } 44 | -------------------------------------------------------------------------------- /pkg/iofog/install/verbosity.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package install 15 | 16 | import ( 17 | "fmt" 18 | ) 19 | 20 | // Toggle HTTP output 21 | var isVerbose bool 22 | 23 | func IsVerbose() bool { 24 | return isVerbose 25 | } 26 | 27 | func SetVerbosity(verbose bool) { 28 | isVerbose = verbose 29 | } 30 | 31 | func Verbose(msg string) { 32 | if isVerbose { 33 | fmt.Println(msg) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pkg/util/assets.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "fmt" 18 | "sync" 19 | 20 | rice "github.com/GeertJohan/go.rice" 21 | ) 22 | 23 | var assets *rice.Box 24 | 25 | var once sync.Once 26 | 27 | func GetStaticFile(filename string) (string, error) { 28 | var err error 29 | once.Do(func() { 30 | assets, err = rice.FindBox("../../assets") 31 | }) 32 | if err != nil { 33 | msg := "could not initialize assets: %s" 34 | err = fmt.Errorf(msg, err.Error()) 35 | return "", err 36 | } 37 | fileContent, err := assets.String(filename) 38 | if err != nil { 39 | msg := "could not load static file %s: %s" 40 | err = fmt.Errorf(msg, filename, err.Error()) 41 | return "", err 42 | } 43 | return fileContent, nil 44 | } 45 | -------------------------------------------------------------------------------- /pkg/util/debug.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | var debug bool = false 17 | 18 | func SetDebug(value bool) { 19 | debug = value 20 | } 21 | 22 | func IsDebug() bool { 23 | return debug 24 | } 25 | -------------------------------------------------------------------------------- /pkg/util/exec.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "bytes" 18 | "os" 19 | "os/exec" 20 | ) 21 | 22 | // Exec command 23 | func Exec(env, cmdName string, args ...string) (stdout bytes.Buffer, err error) { 24 | // Instantiate command object 25 | cmd := exec.Command(cmdName, args...) 26 | 27 | // Instantiate output objects 28 | var stderr bytes.Buffer 29 | cmd.Stdout = &stdout 30 | cmd.Stderr = &stderr 31 | 32 | // Set env vars 33 | cmd.Env = os.Environ() 34 | cmd.Env = append(cmd.Env, env) 35 | 36 | // Run command 37 | err = cmd.Run() 38 | if err != nil { 39 | err = NewInternalError(stderr.String()) 40 | return 41 | } 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /pkg/util/get_controller_endpoint.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "net/url" 18 | "strings" 19 | 20 | "github.com/eclipse-iofog/iofog-go-sdk/v3/pkg/client" 21 | ) 22 | 23 | func GetControllerEndpoint(host string) (endpoint string, err error) { 24 | // Generate controller endpoint 25 | u, err := url.Parse(host) 26 | if err != nil || u.Host == "" { 27 | if !strings.Contains(host, ":") { 28 | host = host + ":" + client.ControllerPortString 29 | } 30 | 31 | u, err = url.Parse("//" + host) // Try to see if controllerEndpoint is an IP, in which case it needs to be pefixed by // 32 | if err != nil { 33 | return "", err 34 | } 35 | } 36 | if u.Scheme == "" { 37 | u.Scheme = "http" 38 | } 39 | return u.String(), nil 40 | } 41 | -------------------------------------------------------------------------------- /pkg/util/get_controller_endpoint_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Red Hat, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | package util 14 | 15 | import ( 16 | "testing" 17 | ) 18 | 19 | func TestGetControllerEndpoint(t *testing.T) { 20 | 21 | for _, entry := range []struct { 22 | input string 23 | output string 24 | }{ 25 | { 26 | "foo-bar", "http://foo-bar:51121", 27 | }, 28 | { 29 | "https://foo-bar", "https://foo-bar", 30 | }, 31 | { 32 | "http://foo-bar", "http://foo-bar", 33 | }, 34 | { 35 | "foo-bar:1234", "http://foo-bar:1234", 36 | }, 37 | { 38 | "1.2.3.4", "http://1.2.3.4:51121", 39 | }, 40 | } { 41 | 42 | if result, err := GetControllerEndpoint(entry.input); result != entry.output { 43 | if err != nil { 44 | t.Errorf("Failed for input %v, when it should not", entry.input) 45 | } else { 46 | t.Errorf("Wrong result - expected: %v, actual: %v, for input: %v", entry.output, result, entry.input) 47 | } 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /pkg/util/is_local.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "regexp" 18 | ) 19 | 20 | func IsLocalHost(host string) bool { 21 | r := regexp.MustCompile(`^(http(s){0,1}:\/\/){0,1}(localhost|0\.0\.0\.0|127\.0\.0\.1)(:[0-9]+){0,1}`) 22 | return r.MatchString(host) 23 | } 24 | -------------------------------------------------------------------------------- /pkg/util/is_system_msvc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "github.com/eclipse-iofog/iofog-go-sdk/v3/pkg/client" 18 | ) 19 | 20 | const LastSystemCatalogItemID int = 3 21 | 22 | func IsSystemMsvc(msvc *client.MicroserviceInfo) bool { 23 | // 3 is hard coded. TODO: Find a way to maintain this ID from Controller. 24 | // Catalog item 1, 2, 3 are SYSTEM microservices, and are not inspectable by the user 25 | return msvc.CatalogItemID != 0 && msvc.CatalogItemID <= LastSystemCatalogItemID 26 | } 27 | -------------------------------------------------------------------------------- /pkg/util/rand.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "math/rand" 18 | "time" 19 | ) 20 | 21 | func init() { 22 | rand.Seed(time.Now().UTC().UnixNano()) 23 | } 24 | 25 | func RandomString(size int, chars string) string { 26 | buf := make([]byte, size) 27 | for idx := range buf { 28 | buf[idx] = chars[rand.Intn(len(chars))] 29 | } 30 | return string(buf) 31 | } 32 | 33 | const AlphaNum = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 34 | const Alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 35 | const AlphaLower = "abcdefghijklmnopqrstuvwxyz" 36 | -------------------------------------------------------------------------------- /pkg/util/spinner.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "github.com/briandowns/spinner" 8 | ) 9 | 10 | var ( 11 | quiet bool 12 | spin *spinner.Spinner // There is only one spinner, output overlaps with multiple concurrent spinners 13 | currentMessage string 14 | isRunning bool 15 | ) 16 | 17 | func init() { 18 | // Note: don't set the colour here, it will display the spinner when you don't want it to 19 | spin = spinner.New(spinner.CharSets[14], 100*time.Millisecond) 20 | } 21 | 22 | func SpinEnable(isEnabled bool) { 23 | quiet = !isEnabled 24 | } 25 | 26 | func SpinStart(msg string) { 27 | isRunning = true 28 | currentMessage = msg 29 | if quiet { 30 | fmt.Println(msg) 31 | return 32 | } 33 | _ = spin.Color("red") 34 | spin.Stop() 35 | spin.Suffix = " " + msg 36 | spin.Start() 37 | } 38 | 39 | func SpinPause() bool { 40 | wasRunning := isRunning 41 | SpinStop() 42 | return wasRunning 43 | } 44 | 45 | func SpinUnpause() { 46 | SpinStart(currentMessage) 47 | } 48 | 49 | func SpinStop() { 50 | isRunning = false 51 | if quiet { 52 | return 53 | } 54 | spin.Stop() 55 | } 56 | -------------------------------------------------------------------------------- /pkg/util/url.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "fmt" 18 | "net/url" 19 | ) 20 | 21 | func GetBaseURL(controllerEndpoint string) (*url.URL, error) { 22 | u, err := url.Parse(controllerEndpoint) 23 | if err != nil || u.Host == "" { 24 | // Try to see if controllerEndpoint is an IP, in which case it needs to be pefixed by // 25 | u, err = url.Parse("//" + controllerEndpoint) 26 | if err != nil { 27 | return nil, fmt.Errorf("failed to parse Controller URL (%s): %s", controllerEndpoint, err.Error()) 28 | } 29 | } 30 | 31 | // Default protocol 32 | if u.Scheme == "" { 33 | u.Scheme = "http" 34 | } 35 | 36 | // Default path 37 | if u.Path == "" { 38 | u.Path = "api/v3" 39 | } 40 | u.RawQuery = "" 41 | u.Fragment = "" 42 | 43 | return u, nil 44 | } 45 | -------------------------------------------------------------------------------- /pkg/util/yaml.go: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | package util 15 | 16 | import ( 17 | "io" 18 | "io/ioutil" 19 | "os" 20 | 21 | "gopkg.in/yaml.v2" 22 | ) 23 | 24 | func UnmarshalYAML(filename string, object interface{}) error { 25 | yamlFile, err := ioutil.ReadFile(filename) 26 | if err != nil { 27 | return err 28 | } 29 | err = yaml.UnmarshalStrict(yamlFile, object) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | return nil 35 | } 36 | 37 | func printYAML(writer io.Writer, obj interface{}) error { 38 | marshal, err := yaml.Marshal(&obj) 39 | if err != nil { 40 | return err 41 | } 42 | _, err = writer.Write(marshal) 43 | if err != nil { 44 | return err 45 | } 46 | return nil 47 | } 48 | 49 | func FPrint(obj interface{}, filename string) error { 50 | f, err := os.Create(filename) 51 | defer Log(f.Close) 52 | if err != nil { 53 | return err 54 | } 55 | err = printYAML(f, obj) 56 | if err != nil { 57 | return err 58 | } 59 | return nil 60 | } 61 | 62 | func Print(obj interface{}) error { 63 | err := printYAML(os.Stdout, obj) 64 | if err != nil { 65 | return err 66 | } 67 | return nil 68 | } 69 | -------------------------------------------------------------------------------- /script/bump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Bump project version 4 | if [ -z "$1" ]; then 5 | echo "Provide a version argument e.g. 1.2.3-beta" 6 | fi 7 | if [ ! -f "version" ]; then 8 | echo "File node found: $(pwd)/version" 9 | exit 1 10 | fi 11 | 12 | # Extract version numbers and suffix 13 | major=$1 14 | minor=$2 15 | patch=$3 16 | suffix=$4 17 | version=$1.$2.$3$4 18 | 19 | # Update version file 20 | sed -i.bkp "s/MAJOR=.*/MAJOR=$major/g" "version" 21 | sed -i.bkp "s/MINOR=.*/MINOR=$minor/g" "version" 22 | sed -i.bkp "s/PATCH=.*/PATCH=$patch/g" "version" 23 | sed -i.bkp "s/SUFFIX=.*/SUFFIX=$suffix/g" "version" 24 | rm "version.bkp" 25 | 26 | # Update Makefile 27 | sed -i.bkp -E "s/(.*iofog-go-sdk\/v2@).*/\1v$version/g" Makefile 28 | sed -i.bkp -E "s/(.*iofog-operator\/v2@).*/\1v$version/g" Makefile 29 | sed -i.bkp -E "s/(.*-X.*Tag=).*/\1$version/g" Makefile 30 | sed -i.bkp -E "s/(.*-X.*Version=).*/\1$version/g" Makefile 31 | sed -i.bkp -E "s/(.*-X.*repo=).*/\1iofog/g" Makefile 32 | rm Makefile.bkp 33 | 34 | # Update pipeline 35 | for file in azure-pipelines.yaml test/env.sh; do 36 | sed -i.bkp -E "s/(gcr\.io\/focal-freedom.*:).*/\1$version'/g" $file 37 | sed -i.bkp -E "s/(_version: ).*/\1'$version'/g" $file 38 | sed -i.bkp -E "s/(_VERSION=').*/\1$version'/g" $file 39 | rm $file.bkp 40 | done 41 | 42 | # Pull modules 43 | make modules 44 | -------------------------------------------------------------------------------- /script/check_fmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Import our helper functions 4 | . script/utils.sh 5 | 6 | prettyTitle "Checking src file formatting" 7 | 8 | FMT_FILES=$(gofmt -s -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./client/*")) 9 | 10 | if [ -z "$FMT_FILES" ]; then 11 | echoInfo "Files are formatted correctly. Thanks!" 12 | exit 0 13 | else 14 | echoError "Bad '${USER}'! Files are not formatted correctly:" 15 | echoInfo "$FMT_FILES" 16 | exit 1 17 | fi -------------------------------------------------------------------------------- /test/bats/smoke.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . test/func/include.bash 4 | 5 | @test "Help" { 6 | iofogctl --help 7 | } 8 | 9 | @test "Help w/o Flag" { 10 | iofogctl help 11 | } 12 | 13 | @test "Create Help" { 14 | iofogctl create --help 15 | } 16 | 17 | @test "Delete Help" { 18 | iofogctl delete --help 19 | } 20 | 21 | @test "Deploy Help" { 22 | iofogctl deploy --help 23 | } 24 | 25 | @test "Describe Help" { 26 | iofogctl describe --help 27 | } 28 | 29 | @test "Connect Help" { 30 | iofogctl connect --help 31 | } 32 | 33 | @test "Disconnect Help" { 34 | iofogctl disconnect --help 35 | } 36 | 37 | @test "Legacy Help" { 38 | iofogctl legacy --help 39 | } 40 | 41 | @test "Logs Help" { 42 | iofogctl logs --help 43 | } 44 | 45 | @test "Get Help" { 46 | iofogctl get --help 47 | } 48 | 49 | @test "Version" { 50 | iofogctl version 51 | } 52 | 53 | @test "Get All" { 54 | iofogctl get all 55 | } 56 | 57 | @test "Get Namespaces" { 58 | iofogctl get namespaces 59 | } 60 | 61 | @test "Get Controllers" { 62 | iofogctl get controllers 63 | } 64 | 65 | @test "Get Agents" { 66 | iofogctl get agents 67 | } 68 | 69 | @test "Get Microservices" { 70 | iofogctl get microservices 71 | } 72 | 73 | @test "Get Applications" { 74 | iofogctl get applications 75 | } 76 | 77 | @test "Create Namespace" { 78 | iofogctl create namespace smoketestsnamespace1234 79 | } 80 | 81 | @test "Set Default Namespace" { 82 | iofogctl configure current-namespace smoketestsnamespace1234 83 | iofogctl get all 84 | } 85 | 86 | @test "Delete Namespace" { 87 | iofogctl delete namespace smoketestsnamespace1234 88 | iofogctl get all 89 | iofogctl get namespaces 90 | } -------------------------------------------------------------------------------- /test/clean.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . test/conf/env.sh 4 | 5 | echo "Cleaning namespace $NAMESPACE" 6 | 7 | kubectl delete ns "$NAMESPACE" 8 | iofogctl disconnect -n "$NAMESPACE" -v 9 | 10 | exit 0 11 | -------------------------------------------------------------------------------- /test/conf/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | env.sh 6 | -------------------------------------------------------------------------------- /test/func/alias.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function kctl(){ 4 | KUBECONFIG="$TEST_KUBE_CONFIG" kubectl $@ 5 | # For local run use this 6 | # kubectl $@ 7 | } 8 | 9 | function print(){ 10 | echo "# $@ " >&3 11 | } 12 | 13 | function log(){ 14 | echo "$@" >> "/tmp/bats_$BATS_TEST_NAME" 15 | } 16 | 17 | function startTest(){ 18 | local FILE="/tmp/bats.test" 19 | if [ -f $FILE ]; then 20 | skip 21 | fi 22 | echo 'start' > $FILE 23 | } 24 | 25 | function stopTest(){ 26 | local FILE="/tmp/bats.test" 27 | if [ -f $FILE ]; then 28 | rm $FILE 29 | fi 30 | } -------------------------------------------------------------------------------- /test/func/include.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . test/func/vars.bash 4 | . test/func/init.bash 5 | . test/func/check.bash 6 | . test/func/wait.bash 7 | . test/func/alias.bash 8 | . test/func/test.bash 9 | . test/func/run.bash 10 | -------------------------------------------------------------------------------- /test/func/run.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # These functions are designed to be used with the bats `run` command 4 | 5 | function curlMsvc(){ 6 | PUBLIC_ENDPOINT="$1" 7 | curl -s --max-time 120 ${PUBLIC_ENDPOINT}/api/raw 8 | } 9 | 10 | function jqMsvcArray(){ 11 | ARR="$1" 12 | echo "$ARR" | jq '. | length' 13 | } 14 | 15 | function findMsvcState(){ 16 | NS="$1" 17 | MS="$2" 18 | STATE="$3" 19 | iofogctl -n $NS get microservices | grep $MS | grep $STATE 20 | } 21 | 22 | function runNoExecutors(){ 23 | echo '' > test/conf/nothing.yaml 24 | iofogctl deploy -f test/conf/nothing.yaml -n "$NS" 25 | } 26 | 27 | function runWrongNamespace(){ 28 | echo "--- 29 | apiVersion: iofog.org/v3 30 | kind: LocalControlPlane 31 | metadata: 32 | namespace: wrong 33 | spec: 34 | iofogUser: 35 | name: Testing 36 | surname: Functional 37 | email: user@domain.com 38 | password: S5gYVgLEZV 39 | controller: 40 | name: func-test" > test/conf/wrong-ns.yaml 41 | iofogctl deploy -f test/conf/wrong-ns.yaml -n "$NS" 42 | } -------------------------------------------------------------------------------- /test/func/vars.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | NAME="func-test" 4 | APPLICATION_NAME="func-app" 5 | MICROSERVICE_NAME="func-msvc" 6 | MSVC1_NAME="func-app-server" 7 | MSVC2_NAME="func-app-ui" 8 | VOL_SRC="/tmp/iofogctl_tests" 9 | WIN_VOL_SRC="C:/tests" 10 | VOL_DEST="/tmp/iofog" 11 | VOL_CONT_DEST="/data" 12 | VOL_NAME="volume-data" 13 | USER_PW="S5gYVgLEZV" 14 | USER_PW_B64="UzVnWVZnTEVaVg==" 15 | USER_EMAIL="user@domain.com" 16 | ROUTE_NAME="route-1" 17 | EDGE_RESOURCE_NAME="smart-door" 18 | EDGE_RESOURCE_VERSION="v1.0.0" 19 | EDGE_RESOURCE_DESC="Very smart door" 20 | EDGE_RESOURCE_PROTOCOL="https" 21 | APP_TEMPLATE_NAME="app-tpl-1" 22 | APP_TEMPLATE_DESC="This is an application template to test with" 23 | APP_TEMPLATE_KEY="agent-name" 24 | APP_TEMPLATE_KEY_DESC="Name of Agent to deploy Microservices to" 25 | APP_TEMPLATE_DEF_VAL="func-test-0" 26 | VOL_INVALID_DEST="/img/iofog" 27 | VOL_CONT_INVALID_DEST="/img/data" 28 | MSVC3_NAME="func-app-server-1" 29 | MSVC4_NAME="func-app-ui-1" 30 | MSVC5_NAME="func-heart-rate-ui" -------------------------------------------------------------------------------- /test/run.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Export variables 6 | CONF=test/conf/env.sh 7 | if [ -f "$CONF" ]; then 8 | . "$CONF" 9 | fi 10 | 11 | function preprocess() { 12 | TO_LOAD=$((cat $1 | grep "# LOAD: ") || (echo -n "")) 13 | if [[ -z $TO_LOAD ]]; then 14 | return 0 15 | fi 16 | while IFS= read -r GREP_LINE; do 17 | grep -B 999999 "${GREP_LINE}" $1 > ${1}_temp 18 | local FILE_TO_LOAD=$(echo $GREP_LINE | awk '{print $3}') 19 | preprocess $FILE_TO_LOAD 20 | echo "" >> ${1}_temp 21 | cat $FILE_TO_LOAD >> ${1}_temp 22 | echo "" >> ${1}_temp 23 | grep -A 999999 "${GREP_LINE}" $1 >> ${1}_temp 24 | mv ${1}_temp $1 25 | done <<< "$TO_LOAD" 26 | } 27 | 28 | # Run tests 29 | for TEST in "$@"; do 30 | TEST_FILE="/tmp/tmp.bats" 31 | cp "test/bats/$TEST.bats" $TEST_FILE 32 | preprocess $TEST_FILE 33 | bats $TEST_FILE 34 | done -------------------------------------------------------------------------------- /version.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | 3 | LATEST_TAG=$(git for-each-ref refs/tags --sort=-taggerdate --format='%(refname)' | tail -n1 | sed "s|refs/tags/||") 4 | MAJOR=$(echo "$LATEST_TAG" | tr -d "v" | sed "s|-.*||" | sed -E "s|(.)\..\..|\1|g") 5 | MINOR=$(echo "$LATEST_TAG" | tr -d "v" | sed "s|-.*||" | sed -E "s|.\.(.)\..|\1|g") 6 | PATCH=$(echo "$LATEST_TAG" | tr -d "v" | sed "s|-.*||" | sed -E "s|.\..\.(.)|\1|g") 7 | SUFFIX_TAG=$(echo "$LATEST_TAG" | sed "s|v$MAJOR\.$MINOR\.$PATCH||") 8 | SUFFIX_DEV="-dev" 9 | SUFFIX="$([ -z "$(git tag --points-at HEAD)" ] && echo "$SUFFIX_DEV" || echo "$SUFFIX_TAG")" 10 | echo $SUFFIX 11 | echo $SUFFIX_TAG 12 | --------------------------------------------------------------------------------