diff --git a/.github/workflows/_reusable_build_package.yml b/.github/workflows/_reusable_build_package.yml index 83b9a1d6..a84c814b 100644 --- a/.github/workflows/_reusable_build_package.yml +++ b/.github/workflows/_reusable_build_package.yml @@ -149,7 +149,7 @@ jobs: echo path="$PACKAGE_NAME" >> $GITHUB_OUTPUT - name: Set simple otc-bin outputs - id: otc-bin + id: bin if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} env: OTC_BIN: >- @@ -157,14 +157,20 @@ jobs: steps.cmake-linux.outputs.otc-bin || steps.cmake-other.outputs.otc-bin }} + OTC_CONFIG_BIN: >- + ${{ + steps.cmake-linux.outputs.otc-config-bin || + steps.cmake-other.outputs.otc-config-bin + }} run: > - echo path="$OTC_BIN" >> $GITHUB_OUTPUT + echo otelcol_sumo_path="$OTC_BIN" >> $GITHUB_OUTPUT && + echo otelcol_config_path="$OTC_CONFIG_BIN" >> $GITHUB_OUTPUT # Download the artifacts required to build the package target. If # inputs.workflow_id is empty then this will be skipped and CMake will # attempt to fetch the artifacts from a GitHub Release matching # otc_version and otc_sumo_version. - - name: Download artifacts from sumologic-otel-collector + - name: Download otelcol-sumo artifact from sumologic-otel-collector uses: dawidd6/action-download-artifact@v3.1.4 if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} with: @@ -173,7 +179,20 @@ jobs: run_id: ${{ inputs.workflow_id }} workflow: dev_builds.yml workflow_conclusion: success - name: ${{ steps.otc-bin.outputs.path }} + name: ${{ steps.bin.outputs.otelcol_sumo_path }} + path: ./build/gh-artifacts + if_no_artifact_found: fail + + - name: Download otelcol-config artifact from sumologic-otel-collector + uses: dawidd6/action-download-artifact@v3.1.4 + if: inputs.workflow_id != '' + with: + github_token: ${{ secrets.gh_artifacts_token }} + repo: SumoLogic/sumologic-otel-collector + run_id: ${{ inputs.workflow_id }} + workflow: dev_builds.yml + workflow_conclusion: success + name: ${{ steps.bin.outputs.otelcol_config_path }} path: ./build/gh-artifacts if_no_artifact_found: fail diff --git a/Dockerfile b/Dockerfile index 20342b4e..0d75e448 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:3.17 -MAINTAINER Sumo Logic +LABEL org.opencontainers.image.authors="Sumo Logic " RUN apk add --no-cache \ cmake \ diff --git a/assets/productbuild/uninstall.sh b/assets/productbuild/uninstall.sh index 6f915a2e..2ddc16ba 100755 --- a/assets/productbuild/uninstall.sh +++ b/assets/productbuild/uninstall.sh @@ -43,6 +43,7 @@ collector_files=( "/etc/otelcol-sumo/sumologic.yaml" "/etc/otelcol-sumo/conf.d" "/etc/otelcol-sumo" + "/usr/local/bin/otelcol-config" "/usr/local/bin/otelcol-sumo" "/var/lib/otelcol-sumo/file_storage" "/var/lib/otelcol-sumo" diff --git a/ci/verify_installer.sh b/ci/verify_installer.sh index 5c774afa..117c8cc3 100755 --- a/ci/verify_installer.sh +++ b/ci/verify_installer.sh @@ -52,6 +52,7 @@ expected_collector_files=( "Library/Application Support/otelcol-sumo" "Library/Application Support/otelcol-sumo/uninstall.sh" "Library/LaunchDaemons/com.sumologic.otelcol-sumo.plist" + "usr/local/bin/otelcol-config" "usr/local/bin/otelcol-sumo" "var/lib/otelcol-sumo" "var/lib/otelcol-sumo/file_storage" diff --git a/components/otelcol-sumo.cmake b/components/otelcol-sumo.cmake index 71add6be..8a547494 100644 --- a/components/otelcol-sumo.cmake +++ b/components/otelcol-sumo.cmake @@ -10,6 +10,7 @@ macro(default_otc_linux_install) install_otc_common_yaml() install_otc_token_env() install_otc_binary() + install_otc_config_binary() endmacro() macro(default_otc_darwin_install) @@ -24,6 +25,7 @@ macro(default_otc_darwin_install) install_otc_common_yaml() install_otc_darwin_hostmetrics_yaml() install_otc_binary() + install_otc_config_binary() install_otc_uninstall_script() endmacro() @@ -188,6 +190,26 @@ macro(install_otc_binary) ) endmacro() +# e.g. /usr/local/bin/otelcol-config +macro(install_otc_config_binary) + require_variables( + "OTC_BIN_DIR" + "OTC_CONFIG_BINARY" + "SOURCE_OTC_CONFIG_BINARY_PATH" + ) + + install( + FILES "${SOURCE_OTC_CONFIG_BINARY_PATH}" + DESTINATION "${OTC_BIN_DIR}" + PERMISSIONS + OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + RENAME "${OTC_CONFIG_BINARY}" + COMPONENT otelcol-sumo + ) +endmacro() + # e.g. /Libary/Application Support/otelcol-sumo/uninstall.sh macro(install_otc_uninstall_script) require_variables( diff --git a/packages.cmake b/packages.cmake index 1994dc5a..24736cee 100644 --- a/packages.cmake +++ b/packages.cmake @@ -5,7 +5,9 @@ macro(build_cpack_config) "CPACK_PACKAGE_FILE_NAME" "PACKAGE_FILE_EXTENSION" "OTC_BINARY" + "OTC_CONFIG_BINARY" "SOURCE_OTC_BINARY" + "SOURCE_OTC_CONFIG_BINARY" ) # Set a GitHub output with a name matching ${target_name}-pkg and a value @@ -26,6 +28,7 @@ macro(build_cpack_config) require_variables( "GH_ARTIFACTS_DIR" "GH_OUTPUT_OTC_BIN" + "GH_OUTPUT_OTC_CONFIG_BIN" ) file(MAKE_DIRECTORY "${GH_ARTIFACTS_DIR}") @@ -36,6 +39,7 @@ macro(build_cpack_config) WORLD_WRITE WORLD_READ WORLD_EXECUTE ) set_github_output("otc-bin" "${GH_OUTPUT_OTC_BIN}") + set_github_output("otc-config-bin" "${GH_OUTPUT_OTC_CONFIG_BIN}") else() message(FATAL_ERROR "Unsupported value for OTC_ARTIFACTS_SOURCE environment variable: $ENV{OTC_ARTIFACTS_SOURCE}" @@ -56,6 +60,21 @@ macro(build_cpack_config) VERBATIM ) endif() + + # Create a target, if the target does not yet exist, for copying the + # otelcol-config binary from the gh-actions directory to the artifacts + # directory + if(TARGET "${SOURCE_OTC_CONFIG_BINARY}") + message(STATUS "Target already exists: ${SOURCE_OTC_CONFIG_BINARY}") + else() + message(STATUS "Creating target: ${SOURCE_OTC_CONFIG_BINARY}") + file(MAKE_DIRECTORY "${SOURCE_OTC_CONFIG_BINARY_DIR}") + add_custom_target("${SOURCE_OTC_CONFIG_BINARY}" + ALL + COMMAND ${CMAKE_COMMAND} -E copy ${GH_ARTIFACT_OTC_CONFIG_BINARY_PATH} ${SOURCE_OTC_CONFIG_BINARY_PATH} + VERBATIM + ) + endif() else() # Create a target for downloading the otelcol-sumo binary from GitHub # Releases if the target does not exist yet @@ -71,6 +90,21 @@ macro(build_cpack_config) "${SOURCE_OTC_BINARY_DIR}" ) endif() + + # Create a target for downloading the otelcol-config binary from GitHub + # Releases if the target does not exist yet + if(TARGET "${SOURCE_OTC_CONFIG_BINARY}") + message(STATUS "Target already exists: ${SOURCE_OTC_CONFIG_BINARY}") + else() + message(STATUS "Creating target: ${SOURCE_OTC_CONFIG_BINARY}") + require_variables("OTC_GIT_TAG") + create_otelcol_sumo_target( + "${SOURCE_OTC_CONFIG_BINARY}" + "${OTC_CONFIG_BINARY}" + "${OTC_GIT_TAG}" + "${SOURCE_OTC_CONFIG_BINARY_DIR}" + ) + endif() endif() # Build CPackConfig diff --git a/settings/otc.cmake b/settings/otc.cmake index 8f54c730..e997fb44 100644 --- a/settings/otc.cmake +++ b/settings/otc.cmake @@ -21,6 +21,7 @@ macro(set_otc_settings) # File names set(OTC_BINARY "otelcol-sumo") + set(OTC_CONFIG_BINARY "otelcol-config") set(OTC_SUMOLOGIC_CONFIG "sumologic.yaml") set(OTC_SYSTEMD_CONFIG "otelcol-sumo.service") @@ -47,20 +48,29 @@ macro(set_otc_settings) # File names set(SOURCE_OTC_BINARY "otelcol-sumo-${OTC_VERSION}-sumo-${OTC_SUMO_VERSION}") + set(SOURCE_OTC_CONFIG_BINARY "otelcol-config-${OTC_VERSION}-sumo-${OTC_SUMO_VERSION}") set(GH_OUTPUT_OTC_BIN "otelcol-sumo") + set(GH_OUTPUT_OTC_CONFIG_BIN "otelcol-config") if(fips) set(SOURCE_OTC_BINARY "${SOURCE_OTC_BINARY}-fips") + set(SOURCE_OTC_CONFIG_BINARY "${SOURCE_OTC_CONFIG_BINARY}-fips") set(GH_OUTPUT_OTC_BIN "${GH_OUTPUT_OTC_BIN}-fips") + set(GH_OUTPUT_OTC_CONFIG_BIN "${GH_OUTPUT_OTC_CONFIG_BIN}-fips") endif() set(SOURCE_OTC_BINARY "${SOURCE_OTC_BINARY}-${goos}_${goarch}") + set(SOURCE_OTC_CONFIG_BINARY "${SOURCE_OTC_CONFIG_BINARY}-${goos}_${goarch}") set(GH_OUTPUT_OTC_BIN "${GH_OUTPUT_OTC_BIN}-${goos}_${goarch}") + set(GH_OUTPUT_OTC_CONFIG_BIN "${GH_OUTPUT_OTC_CONFIG_BIN}-${goos}_${goarch}") # Directories set(SOURCE_OTC_BINARY_DIR "${ARTIFACTS_DIR}/${SOURCE_OTC_BINARY}") + set(SOURCE_OTC_CONFIG_BINARY_DIR "${ARTIFACTS_DIR}/${SOURCE_OTC_CONFIG_BINARY}") # File paths set(SOURCE_OTC_BINARY_PATH "${SOURCE_OTC_BINARY_DIR}/${OTC_BINARY}") + set(SOURCE_OTC_CONFIG_BINARY_PATH "${SOURCE_OTC_CONFIG_BINARY_DIR}/${OTC_CONFIG_BINARY}") set(GH_ARTIFACT_OTC_BINARY_PATH "${GH_ARTIFACTS_DIR}/${GH_OUTPUT_OTC_BIN}") + set(GH_ARTIFACT_OTC_CONFIG_BINARY_PATH "${GH_ARTIFACTS_DIR}/${GH_OUTPUT_OTC_CONFIG_BIN}") set(ACL_LOG_FILE_PATHS "/var/log") ## @@ -93,5 +103,6 @@ macro(set_otc_settings) # OTC packages. set(target_dependencies "${SOURCE_OTC_BINARY}" + "${SOURCE_OTC_CONFIG_BINARY}" ) endmacro()