Skip to content

Commit

Permalink
Merge pull request #106 from SumoLogic/ci/otelcol-config
Browse files Browse the repository at this point in the history
feat: add otelcol-config binary
  • Loading branch information
amdprophet authored Aug 22, 2024
2 parents b3c6844 + 4f60759 commit 430e64c
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 5 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/_reusable_build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,28 @@ 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: >-
${{
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/[email protected]
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }}
with:
Expand All @@ -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/[email protected]
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

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM alpine:3.17
MAINTAINER Sumo Logic <[email protected]>
LABEL org.opencontainers.image.authors="Sumo Logic <opensource-collection-team@sumologic.com>"

RUN apk add --no-cache \
cmake \
Expand Down
1 change: 1 addition & 0 deletions assets/productbuild/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions ci/verify_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions components/otelcol-sumo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down Expand Up @@ -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(
Expand Down
34 changes: 34 additions & 0 deletions packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}")
Expand All @@ -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}"
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions settings/otc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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")

##
Expand Down Expand Up @@ -93,5 +103,6 @@ macro(set_otc_settings)
# OTC packages.
set(target_dependencies
"${SOURCE_OTC_BINARY}"
"${SOURCE_OTC_CONFIG_BINARY}"
)
endmacro()

0 comments on commit 430e64c

Please sign in to comment.