├── changelog ├── v0.2.9 │ ├── readme.yaml │ ├── clidoc1.yaml │ └── cli_docs.yaml ├── v0.10.26 │ └── remove-log.yaml ├── v0.21.4 │ ├── testspace.yaml │ └── errgroup.yaml ├── v0.9.16 │ └── roles.yaml ├── v0.20.1 │ ├── update-kind.yaml │ └── windows-build.yaml ├── v0.9.17 │ └── args.yaml ├── v0.22.2 │ └── gitbot-add-pprof.yaml ├── v0.9.12 │ ├── helm_docs.yaml │ └── expect-proto-with-message.yaml ├── v0.9.13 │ └── helm_docs.yaml ├── v0.20.4 │ └── add-benchmarking-util.yaml ├── v0.10.24 │ └── refresh-cache.yaml ├── v0.16.6 │ ├── add-github-action.yaml │ ├── add-noop-cloudbuild.yaml │ └── add-wasm-tags.yaml ├── v0.8.11 │ ├── deprecate.yaml │ └── xerrors.yaml ├── v0.10.3 │ └── debug-cmd.yaml ├── v0.4.1 │ ├── install-utils.yaml │ └── descriptive-errors.yaml ├── v0.9.11 │ └── test-appsv1-deployment.yaml ├── v0.10.17 │ ├── add-warn.yaml │ └── logging.yaml ├── v0.27.3 │ └── expose-morechangelogstuff.yaml ├── v0.6.0 │ ├── lock-release-fix.yaml │ ├── upload-retry.yaml │ └── clusterlock-heartbeat.yaml ├── v0.7.4 │ ├── remove-bitbucket.yaml │ └── listing-cached-values.yaml ├── v0.28.4 │ └── fixing-cache-issue.yaml ├── v0.9.20 │ └── expect-test-util.yaml ├── v0.9.3 │ └── incorrect-interface.yaml ├── v0.10.4 │ └── log-request-builder.yaml ├── v0.21.18 │ └── benchmarking-tools.yaml ├── v0.10.2 │ └── fix-perm-tester.yaml ├── v0.22.1 │ ├── typo.yaml │ └── nil-notes-error.yaml ├── v0.7.19 │ └── namespace-utils.yaml ├── v0.11.8 │ └── extract-function.yaml ├── v0.16.1 │ ├── http-echo-pin.yaml │ └── stop-prerelease-brew-prs.yaml ├── v0.8.20 │ └── fix-sort.yaml ├── v0.8.23 │ ├── allow_custom_poll_time_curl.yaml │ └── debugutils-additions.yaml ├── v0.10.19 │ └── fix-slack.yaml ├── v0.10.21 │ └── teardown-ns-for-client.yaml ├── v0.13.1 │ └── fix-comments-on-exported-functions.yaml ├── v0.25.3 │ └── cli-doc-tmpl.yaml ├── v0.3.0 │ └── go-mod.yaml ├── v0.10.0 │ ├── health-checks.yaml │ └── namespace-override-fix.yaml ├── v0.10.5 │ └── gencert.yaml ├── v0.21.15 │ └── add-string-utils.yaml ├── v0.8.18 │ └── update_formula.yaml ├── v0.10.20 │ ├── fix-testrunner-race.yaml │ └── add-rc.yaml ├── v0.10.6 │ └── pr-tag.yaml ├── v0.11.5 │ └── dry-stats.yaml ├── v0.2.15 │ └── fix-docs-cli-push.yaml ├── v0.21.19 │ └── deprecate-exponentioal-backoff.yaml ├── v0.28.5 │ └── update-gh-issue-writer.yaml ├── v0.8.16 │ └── pod-termination.yaml ├── v0.8.5 │ └── tar-util-fix.yaml ├── v0.9.10 │ └── package-management.yaml ├── v0.9.9 │ └── fix-issues.yaml ├── v0.10.15 │ └── add-gateway-enterprise-install-constant.yaml ├── v0.21.23 │ └── avoid-empty-gh-issue.yaml ├── v0.21.24 │ └── bump-cloudbuild-api.yaml ├── v0.21.8 │ └── fix-docs-gen-ratelimit-issue.yaml ├── v0.27.2 │ ├── enable-pre-release-scan.yaml │ └── expose-morechangelogstuff.yaml ├── v0.9.14 │ └── bot-build.yaml ├── v0.17.0 │ └── bump-k8s-1.18.x.yaml ├── v0.2.14 │ └── use-new-func-in-cli.yaml ├── v0.21.21 │ └── security-scan-cli-fix.yaml ├── v0.21.28 │ └── fix-grpcutils.yaml ├── v0.5.0 │ ├── clusterlock.yaml │ ├── clarify-pr-message.yaml │ └── remove-changelog-refactor.yaml ├── v0.8.22 │ ├── debugutils.yaml │ ├── fixlogline.yaml │ └── github-client-maybe-token.yaml ├── v0.8.24 │ ├── botutils.yaml │ ├── changelog-reader.yaml │ ├── mount-util.yaml │ └── changelog-validator.yaml ├── v0.9.2 │ └── tcp-echo.yaml ├── v0.10.12 │ └── fix-logging.yaml ├── v0.10.14 │ └── support-glooctl-enterprise-subcommand.yaml ├── v0.20.0 │ └── no-k8s.yaml ├── v0.20.2 │ └── grpc-utils.yaml ├── v0.3.1 │ └── crd-wait.yaml ├── v0.5.1 │ └── cluster-lock-timeout.yaml ├── v0.7.13 │ └── cache-installed.yaml ├── v0.8.3 │ └── fix-testrunner.yaml ├── v0.8.6 │ └── retrieve-archive.yaml ├── v0.8.9 │ └── manifest-test.yaml ├── v0.9.15 │ └── wait-for-jobs.yaml ├── v0.9.6 │ └── crd_teardown.yaml ├── v0.9.7 │ ├── issues.yaml │ └── gcloudutils.yaml ├── v0.10.13 │ └── fix.yaml ├── v0.2.16 │ └── start-dependency-changelog.yaml ├── v0.7.0 │ ├── installutils.yaml │ ├── testutils-revamp.yaml │ ├── finish-installer-port.yaml │ └── uninstall-gloo-namespace.yaml ├── v0.9.19 │ ├── install.yaml │ └── nomad-install.yaml ├── v0.11.2 │ └── hash-compare.yaml ├── v0.28.0 │ └── go-124.yaml ├── v0.7.1 │ └── contextutils.yaml ├── v0.7.10 │ └── cliutils.yaml ├── v0.7.12 │ └── supergloo-version.yaml ├── v0.7.17 │ └── version-check-update.yaml ├── v0.8.17 │ └── curl-util.yaml ├── v0.8.2 │ └── mount-tar.yaml ├── v0.8.21 │ └── envutils.yaml ├── v0.9.18 │ └── install.yaml ├── v0.9.8 │ └── fix-issues.yaml ├── v0.10.11 │ ├── fix-log.yaml │ └── git-mv.yaml ├── v0.10.27 │ └── logrus.yaml ├── v0.11.6 │ └── must-hash.yaml ├── v0.18.1 │ └── cliutils-port-forward.yaml ├── v0.21.26 │ └── bump-crypto-dep.yaml ├── v0.7.16 │ └── repo-init-changlog-v0.yaml ├── v0.8.1 │ └── http-echo-test-pod.yaml ├── v0.8.19 │ └── manifests-from-resource.yaml ├── v0.11.1 │ ├── safe-hash.yaml │ └── release-versioning.yaml ├── v0.19.0 │ └── fix-grpc-health.yaml ├── v0.10.10 │ └── fix.yaml ├── v0.13.4 │ └── helminstall-output-formatting.yaml ├── v0.16.2 │ └── sni-curl.yaml ├── v0.16.4 │ └── fix-sha256-regex.yaml ├── v0.21.20 │ └── trivy-scan-generalization.yaml ├── v0.7.5 │ └── retry-kubeinstaller-opts.yaml ├── v0.9.21 │ └── manifest-utils-error-msg.yaml ├── v0.10.18 │ └── clidoc-config.yaml ├── v0.10.9 │ └── crd-manifest-utils.yaml ├── v0.15.1 │ └── fix-helminstall-interface.yaml ├── v0.22.4 │ └── require-label.yaml ├── v0.8.4 │ └── test-helper-interface.yaml ├── v0.10.25 │ └── manifest-filter.yaml ├── v0.11.3 │ └── settings-file.yaml ├── v0.13.2 │ ├── git-describe-always.yaml │ └── network-util.yaml ├── v0.14.0 │ └── helm_kubecontext.yaml ├── v0.14.1 │ └── fix-github-500-retry-logic.yaml ├── v0.20.5 │ ├── add-log-level-changing-via-env-var.yaml │ └── fix-homebrew-formula-regex.yaml ├── v0.21.22 │ └── avoid-empty-gh-issue.yaml ├── v0.7.6 │ ├── readable-timestamps.yaml │ └── fix-cache-access.yaml ├── v0.10.23 │ └── changelog-validation.yaml ├── v0.16.0 │ └── helminstall-memory-kubeconfig.yaml ├── v0.6.3 │ └── quiet-curl.yaml ├── v0.9.5 │ └── sanitize_name_v2.yaml ├── v0.10.1 │ └── permissions-check.yaml ├── v0.13.3 │ ├── grpc-logging.yaml │ └── helminstall.yaml ├── v0.7.21 │ └── fixes.yaml ├── v0.9.4 │ └── kube_api_version.yaml ├── v0.2.12 │ └── fix-copy-on-initial-push.yaml ├── v0.21.5 │ └── log-level-fix.yaml ├── v0.21.7 │ └── changelog-refactor.yaml ├── v0.8.0 │ ├── proto-assertion-util.yaml │ └── migrate-solo-kit.yaml ├── v0.10.16 │ └── changelog-docs-from-dir.yaml ├── v0.15.2 │ └── fix-label-to-unlabeled-version-validation.yaml ├── v0.8.13 │ └── proto-unmarshal-allow-unknown.yaml ├── v0.16.3 │ └── fix-formula-updater.yaml ├── v0.21.9 │ └── fix-docs-gen-ratelimit-issue.yaml ├── v0.20.3 │ └── add-benchmarking-util.yaml ├── v0.25.2 │ └── terminating-is-not-ready.yaml ├── v0.6.1 │ └── fix-regression-in-release-upload.yaml ├── v0.6.2 │ ├── lock-deletion-resilience.yaml │ └── changelog-resolves-issue.yaml ├── v0.8.15 │ └── config-utils.yaml ├── v0.8.7 │ └── expect-configmap-with-yaml-data.yaml ├── v0.11.4 │ └── fix-file-validation.yaml ├── v0.2.13 │ └── find-latest-including-prerelease.yaml ├── v0.21.27 │ ├── fix-stats-logging-npe.yaml │ └── trivy-github-issue-per-minor.yaml ├── v0.15.0 │ └── helm-install-fix.yaml ├── v0.21.0 │ └── fix-homebrew-formula-regex.yaml ├── v0.21.3 │ └── fix-fail-handler.yaml ├── v0.24.2 │ ├── gomock-ignore.yaml │ └── fix-test-utils-double-import.yaml ├── v0.27.0 │ ├── fix-extra-issues-bug.yaml │ └── remove-sarif-scanning.yaml ├── v0.10.7 │ └── improve-toml-parsing.yaml ├── v0.11.7 │ └── generate-changelog.yaml ├── v0.13.0 │ └── errors-improvement.yaml ├── v0.24.1 │ ├── remove-actions-cache.yaml │ ├── github-actions-deprecations.yaml │ └── new-benchmark-util.yaml ├── v0.10.8 │ └── more-version-info.yaml ├── v0.10.22 │ └── helm-upgrade.yaml ├── v0.21.13 │ └── security-scan-create-github-issue.yaml ├── v0.2.11 │ └── fix-sha-to-match-shasum.yaml ├── v0.24.0 │ └── ginkgo-v2.yaml ├── v0.4.0 │ └── install-utils.yaml ├── v0.22.3 │ └── configurable-changelog-dir.yaml ├── v0.27.1 │ └── fix-alpine-labeling.yaml ├── v0.28.6 │ └── go-1-24-6.yaml ├── v0.7.15 │ └── customize-install-order.yaml ├── v0.7.8 │ └── package-manager-update.yaml ├── v0.14.2 │ └── healthcheck-interceptor.yaml ├── v0.21.10 │ └── fix-docs-gen-ratelimit-issue.yaml ├── v0.21.14 │ └── security-scan-create-github-issue.yaml ├── v0.23.0 │ └── cvectl.yaml ├── v0.7.11 │ └── package-manager-update.yaml ├── v0.25.1 │ └── 13898-formatting-missing-images.yaml ├── v0.2.8 │ └── 1.yaml ├── v0.8.14 │ └── fix-kube-caching.yaml ├── v0.24.3 │ └── helm-scanning.yaml ├── v0.24.5 │ └── log-to-file.yaml ├── v0.22.0 │ └── improve-scan-perf.yaml ├── v0.9.1 │ └── config-env.yaml ├── v0.8.12 │ └── termination-log.yaml ├── v0.21.16 │ └── trivy-retries.yaml ├── v0.21.25 │ └── bump-crypto-dep.yaml ├── v0.18.0 │ └── bump-github-library.yaml ├── v0.21.12 │ └── security-scan-create-github-issue.yaml ├── v0.7.2 │ └── add-utils.yaml ├── v0.7.3 │ └── listing-cached-values.yaml ├── v0.7.18 │ └── manifest-test-utils.yaml ├── v0.21.1 │ └── fix-homebrew-formula-regex.yaml ├── v0.7.9 │ └── package-manager-update.yaml ├── v0.21.11 │ └── security-scan-create-github-issue.yaml ├── v0.8.10 │ └── set-log-level.yaml ├── v0.16.5 │ └── stats-log-level.yaml ├── v0.29.0 │ └── bump-go.yaml ├── v0.21.2 │ └── add-custom-order-tag-label.yaml ├── v0.7.20 │ └── fixes.yaml ├── v0.12.0 │ └── version.yaml ├── v0.8.8 │ └── updates.yaml ├── v0.10.28 │ └── version-increase-for-v1.yaml ├── v0.2.10 │ └── release-asset-cli.yaml ├── v0.11.0 │ └── helm-3.yaml ├── v0.21.17 │ └── add-split-output-logging.yaml ├── v0.21.6 │ └── bump-deps.yaml ├── v0.27.4 │ └── k8s-1.32-bump-related.yaml ├── v0.24.7 │ └── mapstructure-utils.yaml ├── v0.7.7 │ └── github-manifest.yaml ├── v0.9.0 │ └── config-env.yaml ├── v0.24.6 │ └── bumps-to-support-k8s-1.27.yaml ├── v0.25.0 │ └── 13501-report-missing-images-in-scan.yaml ├── v0.24.8 │ └── bump-k8s-128.yaml └── v0.7.14 │ └── clicore.yaml ├── healthchecker ├── interface.go ├── healthchecker_suite_test.go └── interceptor_test.go ├── cloudbuild.yaml ├── generate.go ├── testutils ├── fail_handler_default.go ├── runners │ └── ports.go ├── testutils_suite_test.go ├── logs.go ├── goimpl │ ├── goimpl_suite_test.go │ ├── curl_test.go │ └── curl.go ├── make.go ├── skip.go ├── get_current_file_test.go ├── random.go ├── get_current_file.go ├── port │ └── port.go ├── README.md ├── fail_handler.go ├── errors_test.go ├── assertions.go ├── fail_handler_unix.go ├── exec │ └── cmd.go ├── errors.go └── kubernetes_test.go ├── docker ├── save.go ├── docker_suite_test.go ├── exec.go ├── pull.go └── docker_test.go ├── securityscanutils ├── contants.go ├── cli │ ├── exampleVersionImageConstraints.txt │ └── main.go ├── issuewriter │ ├── issue_writer.go │ ├── noop_writer.go │ └── local_writer.go ├── securityscanutils_suite_test.go ├── README.md ├── trivy_templates.go └── commands │ └── utils.go ├── clicore ├── constants │ └── constants.go ├── internal │ └── clibufferpool │ │ └── resource.go ├── clicore_suite_test.go ├── mocker.go └── README.md ├── versionutils ├── dep │ └── types.go ├── kubeapi │ ├── kubeapi_suite_test.go │ ├── list.go │ └── list_test.go ├── versionutils_suite_test.go └── cli.go ├── ci ├── tools.go └── check-code-format.sh ├── fileutils ├── text.go ├── fileutils_suite_test.go ├── messages.go └── messages_test.go ├── grpcutils ├── grpc_suite_test.go ├── test.proto └── reset_connection_backoff.go ├── test └── checks │ ├── checks_suite_test.go │ └── checks_test.go ├── cliutils ├── common_suite_test.go ├── options.go ├── flags.go └── cli_helpers.go ├── vfsutils ├── vfs_suite_test.go ├── vfs_test.go └── mount_test.go ├── helmutils └── helm_suite_test.go ├── tarutils └── tarutils_suite_test.go ├── hashutils └── hashutils_suite_test.go ├── protoutils └── protoutil_suite_test.go ├── slackutils ├── slack_suite_test.go ├── http.go └── slack.go ├── contextutils ├── time.go └── errors_and_logging.go ├── botutils ├── consts.go ├── botconfig │ ├── botconfig_suite_test.go │ └── os_mock_test.go ├── README.md └── interface.go ├── gcloudutils ├── cloudbuild_suite_test.go ├── builders │ ├── builders_suite_test.go │ ├── mock.go │ └── gcloud_test.go ├── public.go ├── README.md ├── interface.go └── factory.go ├── githubutils ├── githubutils_suite_test.go └── README.md ├── pkgmgmtutils ├── internal │ ├── internal_suite_test.go │ └── remote_sha_getter.go ├── formula_updater_suite_test.go └── formula_updater_types │ └── opts.go ├── stringutils ├── stringutils_suite_test.go └── strings_test.go ├── surveyutils └── surveyutils_suite_test.go ├── loggingutils ├── loggingutils_suite_test.go ├── grpc.go └── grpc_test.go ├── changeloggenutils └── changelogdocutils_suite_test.go ├── changelogutils ├── cmd │ ├── Makefile │ └── main.go ├── changelogutils_suite_test.go ├── cli.go └── entrytype.go ├── .gitignore ├── randutils └── rand.go ├── errutils └── aggregate_errs.go ├── osutils ├── utils.go ├── client.go └── executils │ └── exec.go ├── README.md ├── clidoc └── README.md ├── stats ├── stats_suite_test.go ├── runtime.go └── README.md ├── mapstructureutils ├── mapdecoder_suite_test.go └── mapdecoder_test.go ├── maputils └── ordered_map_iterate.go ├── .githooks └── pre-commit ├── hack ├── increment_semver.sh └── make-changelog-entry.sh ├── envutils └── vars.go ├── .github └── workflows │ ├── codeformat.yaml │ └── pull_request.yaml ├── log └── log.go └── errgroup └── errgroup.go /changelog/v0.2.9/readme.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING -------------------------------------------------------------------------------- /changelog/v0.10.26/remove-log.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | -------------------------------------------------------------------------------- /changelog/v0.21.4/testspace.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Set up testspace -------------------------------------------------------------------------------- /changelog/v0.9.16/roles.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Support roles in test utils -------------------------------------------------------------------------------- /changelog/v0.20.1/update-kind.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Update kind setup action -------------------------------------------------------------------------------- /changelog/v0.20.1/windows-build.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Allow building on windows -------------------------------------------------------------------------------- /changelog/v0.9.17/args.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Allow adding args to test helper -------------------------------------------------------------------------------- /healthchecker/interface.go: -------------------------------------------------------------------------------- 1 | package healthchecker 2 | 3 | type HealthChecker interface { 4 | Fail() 5 | Ok() 6 | } 7 | -------------------------------------------------------------------------------- /changelog/v0.22.2/gitbot-add-pprof.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: added pprof to gitbot utils -------------------------------------------------------------------------------- /changelog/v0.9.12/helm_docs.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add utility to generate helm docs. -------------------------------------------------------------------------------- /changelog/v0.9.13/helm_docs.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add to copy files in push docs. -------------------------------------------------------------------------------- /cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker' 3 | args: ['version'] 4 | id: 'empty noop to pass CI' 5 | -------------------------------------------------------------------------------- /changelog/v0.20.4/add-benchmarking-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add Authority to GRPC Dial Opts -------------------------------------------------------------------------------- /changelog/v0.10.24/refresh-cache.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add a Refresh function to the cache object -------------------------------------------------------------------------------- /changelog/v0.16.6/add-github-action.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Replace cloudbuild with github action 4 | -------------------------------------------------------------------------------- /changelog/v0.8.11/deprecate.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add deprecated flag to a few more functions. 4 | -------------------------------------------------------------------------------- /changelog/v0.10.3/debug-cmd.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Make ConvertPodsToUnstructured function public 4 | -------------------------------------------------------------------------------- /changelog/v0.4.1/install-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Imported consolidated regression test helpers. 4 | -------------------------------------------------------------------------------- /changelog/v0.9.11/test-appsv1-deployment.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add apps/v1.Deployment to the test utils. -------------------------------------------------------------------------------- /changelog/v0.10.17/add-warn.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Added warning when notify called but nothing to notify. -------------------------------------------------------------------------------- /changelog/v0.27.3/expose-morechangelogstuff.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Make doc generation cleaner -------------------------------------------------------------------------------- /changelog/v0.4.1/descriptive-errors.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Created error comparison for better error handling. -------------------------------------------------------------------------------- /changelog/v0.6.0/lock-release-fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Only allow the person holding the lock to release it. -------------------------------------------------------------------------------- /changelog/v0.7.4/remove-bitbucket.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Remove bitbucket package causing go mod issue. 4 | -------------------------------------------------------------------------------- /changelog/v0.28.4/fixing-cache-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: "Bumping version step over some Go cache issues" 4 | -------------------------------------------------------------------------------- /changelog/v0.9.20/expect-test-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: add a generic Expect function to manifesttestutils 4 | -------------------------------------------------------------------------------- /changelog/v0.9.3/incorrect-interface.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add interface function to testrunner for checking output -------------------------------------------------------------------------------- /changelog/v0.10.4/log-request-builder.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Make LogRequestBuilder field of logCollector public 4 | -------------------------------------------------------------------------------- /changelog/v0.16.6/add-noop-cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add a noop step to cloudbuild so that builds pass CI 4 | 5 | -------------------------------------------------------------------------------- /changelog/v0.21.18/benchmarking-tools.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add a benchmarking helper that returns the time taken. 4 | -------------------------------------------------------------------------------- /changelog/v0.10.2/fix-perm-tester.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Export nested fields so permissions tests will actually work. 4 | -------------------------------------------------------------------------------- /changelog/v0.22.1/typo.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/490 4 | description: fixed typo in trivy logs -------------------------------------------------------------------------------- /changelog/v0.7.19/namespace-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add some utilities around creating and deleting namespaces. 4 | -------------------------------------------------------------------------------- /generate.go: -------------------------------------------------------------------------------- 1 | package go_utils 2 | 3 | //go:generate mockgen -package mock_afero -destination ./testutils/mocks/afero/mock_afero_file.go github.com/spf13/afero File 4 | -------------------------------------------------------------------------------- /testutils/fail_handler_default.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | var waitOnFail = func() {} 4 | 5 | var IsDebuggerPresent = func() bool { 6 | 7 | return false 8 | } 9 | -------------------------------------------------------------------------------- /changelog/v0.11.8/extract-function.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Expose logic to read validation settings in a public function. 4 | -------------------------------------------------------------------------------- /changelog/v0.16.1/http-echo-pin.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Use a content tag for http echo. pinning version is best practice. 4 | -------------------------------------------------------------------------------- /changelog/v0.8.20/fix-sort.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: fix manifest sorting 4 | issueLink: https://github.com/solo-io/go-utils/issues/198 5 | -------------------------------------------------------------------------------- /changelog/v0.8.23/allow_custom_poll_time_curl.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Allow customizing the polling time in CurlEventuallyShouldRespond -------------------------------------------------------------------------------- /changelog/v0.10.19/fix-slack.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix slack notification logic. 4 | issueLink: https://github.com/solo-io/go-utils/issues/315 -------------------------------------------------------------------------------- /changelog/v0.10.21/teardown-ns-for-client.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add new function for watching namespace teardown on a given client. -------------------------------------------------------------------------------- /changelog/v0.13.1/fix-comments-on-exported-functions.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Fix comments on exported version comparison functions. 4 | -------------------------------------------------------------------------------- /changelog/v0.25.3/cli-doc-tmpl.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: >- 4 | Revise CLI reference doc template to add a description metadata line. 5 | -------------------------------------------------------------------------------- /changelog/v0.3.0/go-mod.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Upgrade to go modules. 4 | issueLink: https://github.com/solo-io/go-utils/issues/56 -------------------------------------------------------------------------------- /changelog/v0.10.0/health-checks.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add grpc health check lib. 4 | issueLink: https://github.com/solo-io/go-utils/issues/275 -------------------------------------------------------------------------------- /changelog/v0.10.5/gencert.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: add util to generate certs 4 | issueLink: https://github.com/solo-io/go-utils/pull/287 5 | -------------------------------------------------------------------------------- /changelog/v0.21.15/add-string-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Add `MapStringSlice` and `StringSliceToHashSet` stringutil functions. -------------------------------------------------------------------------------- /changelog/v0.8.18/update_formula.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Updated commit string format 4 | issueLink: https://github.com/solo-io/gloo/issues/719 5 | -------------------------------------------------------------------------------- /changelog/v0.10.20/fix-testrunner-race.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix race in TestRunner 4 | issueLink: https://github.com/solo-io/go-utils/issues/320 5 | -------------------------------------------------------------------------------- /changelog/v0.10.6/pr-tag.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/289 4 | description: Support PR number tag on builds. -------------------------------------------------------------------------------- /changelog/v0.11.5/dry-stats.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/363 4 | description: DRY out stats server startup config 5 | -------------------------------------------------------------------------------- /changelog/v0.2.15/fix-docs-cli-push.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fixed bug in cli docs push logic. 4 | issueLink: https://github.com/solo-io/go-utils/issues/50 -------------------------------------------------------------------------------- /changelog/v0.21.19/deprecate-exponentioal-backoff.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Deprecate misspelled versions of exponential backoff functions. 4 | -------------------------------------------------------------------------------- /changelog/v0.28.5/update-gh-issue-writer.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: | 4 | Updated security scan GH issue writer to not purge existing labels. -------------------------------------------------------------------------------- /changelog/v0.8.16/pod-termination.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Change the behavior of LogFailureState so it doesn't create /dev/termination-log 4 | -------------------------------------------------------------------------------- /changelog/v0.8.23/debugutils-additions.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Fix up some capabilities of log fetcher based on requirements from debug-utils. 4 | -------------------------------------------------------------------------------- /changelog/v0.8.5/tar-util-fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: fix error in tarutils Tar function. 4 | issueLink: https://github.com/solo-io/go-utils/issues/167 -------------------------------------------------------------------------------- /changelog/v0.9.10/package-management.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Pull CLI binary SHA256 from GitHub Releases for more consistent package management. -------------------------------------------------------------------------------- /changelog/v0.9.9/fix-issues.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/241 4 | description: Fix set ref to use the correct logic. -------------------------------------------------------------------------------- /changelog/v0.10.15/add-gateway-enterprise-install-constant.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add gateway enterprise install command for glooctl test helper 4 | -------------------------------------------------------------------------------- /changelog/v0.21.23/avoid-empty-gh-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Allow for versions to match multiple constraints for cleaner image constraints files. -------------------------------------------------------------------------------- /changelog/v0.21.24/bump-cloudbuild-api.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | dependencyOwner: golang 4 | dependencyRepo: google.golang.org/api 5 | dependencyTag: v0.42.0 -------------------------------------------------------------------------------- /changelog/v0.21.8/fix-docs-gen-ratelimit-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Adds option to changelog generator to provide cached github repository releases. -------------------------------------------------------------------------------- /changelog/v0.27.2/enable-pre-release-scan.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Enable security scans for pre-releases if --enable-pre-release=true. 5 | -------------------------------------------------------------------------------- /changelog/v0.9.14/bot-build.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add utilities for builder bots. 4 | issueLink: https://github.com/solo-io/go-utils/issues/252 5 | -------------------------------------------------------------------------------- /docker/save.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | // Save saves image to dest, as in `docker save` 4 | func Save(image, dest string) error { 5 | return Command("save", "-o", dest, image).Run() 6 | } 7 | -------------------------------------------------------------------------------- /changelog/v0.10.17/logging.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Reduce verbosity of log messages in bot libraries. 4 | issueLink: https://github.com/solo-io/go-utils/issues/312 -------------------------------------------------------------------------------- /changelog/v0.17.0/bump-k8s-1.18.x.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Upgrade kube libraries to v1.18.x 4 | issueLink: https://github.com/solo-io/go-utils/issues/420 5 | -------------------------------------------------------------------------------- /changelog/v0.2.14/use-new-func-in-cli.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: CLI to render changelog now uses correct method to find latest release including prereleases. -------------------------------------------------------------------------------- /changelog/v0.21.21/security-scan-cli-fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Fix gen-security-scan-md command of new security scan CLI to properly infer image names. -------------------------------------------------------------------------------- /changelog/v0.21.28/fix-grpcutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/486 4 | description: Add option to set timeout in grpcutils. 5 | -------------------------------------------------------------------------------- /changelog/v0.5.0/clusterlock.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Create a basic lock for test-clusters. 4 | issueLink: https://github.com/solo-io/supergloo/issues/236 -------------------------------------------------------------------------------- /changelog/v0.8.22/debugutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add resource/log gathering capability. 4 | issueLink: https://github.com/solo-io/go-utils/issues/202 5 | -------------------------------------------------------------------------------- /changelog/v0.8.24/botutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Adds some basic utilities for writing bots. 4 | issueLink: https://github.com/solo-io/go-utils/issues/215 -------------------------------------------------------------------------------- /changelog/v0.9.2/tcp-echo.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: tco-echo pod for testing tcp connections. 4 | issueLink: https://github.com/solo-io/go-utils/issues/227 5 | -------------------------------------------------------------------------------- /changelog/v0.10.12/fix-logging.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/302 4 | description: Fix log messages to avoid nil value issues. 5 | -------------------------------------------------------------------------------- /changelog/v0.10.14/support-glooctl-enterprise-subcommand.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add gateway enterprise install subcommand support for glooctl test helper 4 | -------------------------------------------------------------------------------- /changelog/v0.20.0/no-k8s.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: >- 4 | Move all k8s code out of here. 5 | issueLink: https://github.com/solo-io/go-utils/issues/426 -------------------------------------------------------------------------------- /changelog/v0.20.2/grpc-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add `grpcutils` for creating gRPC connections. 4 | issueLink: https://github.com/solo-io/go-utils/issues/431 -------------------------------------------------------------------------------- /changelog/v0.3.1/crd-wait.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add util method to wait for crds to become active. 4 | issueLink: https://github.com/solo-io/go-utils/issues/59 -------------------------------------------------------------------------------- /changelog/v0.5.1/cluster-lock-timeout.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add a tiemout to the cluster lock. 4 | issueLink: https://github.com/solo-io/go-utils/issues/72 -------------------------------------------------------------------------------- /changelog/v0.6.0/upload-retry.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Retry uploading assets to github if there's an error. 4 | issueLink: https://github.com/solo-io/go-utils/issues/76 -------------------------------------------------------------------------------- /changelog/v0.7.13/cache-installed.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Only cache flattened, installed resources. 4 | issueLink: https://github.com/solo-io/go-utils/issues/138 5 | -------------------------------------------------------------------------------- /changelog/v0.8.3/fix-testrunner.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix testrunner pod regression from last release. 4 | issueLink: https://github.com/solo-io/go-utils/issues/161 -------------------------------------------------------------------------------- /changelog/v0.8.6/retrieve-archive.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add retrieve archive utility. 4 | issueLink: https://github.com/solo-io/go-utils/issues/169 5 | 6 | -------------------------------------------------------------------------------- /changelog/v0.8.9/manifest-test.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add support for testing crds in manifest tester. 4 | issueLink: https://github.com/solo-io/go-utils/issues/178 -------------------------------------------------------------------------------- /changelog/v0.9.15/wait-for-jobs.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Wait for jobs to complete in the kube installer. 4 | issueLink: https://github.com/solo-io/go-utils/issues/254 -------------------------------------------------------------------------------- /changelog/v0.9.6/crd_teardown.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Helper for cleaning up CRDs after tests. 4 | issueLink: https://github.com/solo-io/go-utils/issues/234 5 | -------------------------------------------------------------------------------- /changelog/v0.9.7/issues.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/237 4 | description: Support issues webhook events for git bots. 5 | -------------------------------------------------------------------------------- /changelog/v0.10.13/fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Use correct repo when getting sha for a tag in repo client. 4 | issueLink: https://github.com/solo-io/go-utils/issues/304 5 | -------------------------------------------------------------------------------- /changelog/v0.2.16/start-dependency-changelog.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Begin work on dependency changelogs. 4 | issueLink: https://github.com/solo-io/go-utils/issues/48 -------------------------------------------------------------------------------- /changelog/v0.7.0/installutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Start bringing in installutils from supergloo. 4 | issueLink: https://github.com/solo-io/go-utils/issues/100 -------------------------------------------------------------------------------- /changelog/v0.9.19/install.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Extend cluster locker to support Consul clusters 4 | issueLink: https://github.com/solo-io/go-utils/issues/261 5 | -------------------------------------------------------------------------------- /changelog/v0.11.2/hash-compare.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/359 4 | description: Add a hash compare helper function, and some testing 5 | -------------------------------------------------------------------------------- /changelog/v0.2.9/clidoc1.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Moves common documentation generation to a shared lib 4 | issueLink: https://github.com/solo-io/go-utils/issues/35 5 | -------------------------------------------------------------------------------- /changelog/v0.28.0/go-124.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: "Update Go to 1.24" 4 | issueLink: https://github.com/solo-io/solo-projects/issues/7609 5 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.7.0/testutils-revamp.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Moves testutils from gloo into go-utils. 4 | issueLink: https://github.com/solo-io/go-utils/issues/95 5 | -------------------------------------------------------------------------------- /changelog/v0.7.1/contextutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Enable adding arbitrary logging meta in context logger 4 | issueLink: https://github.com/solo-io/go-utils/issues/105 5 | -------------------------------------------------------------------------------- /changelog/v0.7.10/cliutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Added some utility functions to cliutils. 5 | issueLink: https://github.com/solo-io/go-utils/issues/130 6 | -------------------------------------------------------------------------------- /changelog/v0.7.12/supergloo-version.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add supergloo repo to versionutils 4 | issueLink: https://github.com/solo-io/go-utils/issues/136 5 | 6 | -------------------------------------------------------------------------------- /changelog/v0.7.17/version-check-update.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Changelog validation now allows v0.0.1 releases. 4 | issueLink: https://github.com/solo-io/go-utils/issues/142 5 | -------------------------------------------------------------------------------- /changelog/v0.8.17/curl-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add a simple go function that functions like curl. 4 | issueLink: https://github.com/solo-io/glooshot/issues/16 5 | -------------------------------------------------------------------------------- /changelog/v0.8.2/mount-tar.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Added utility for mounting generic compressed tar via URL. 4 | issueLink: https://github.com/solo-io/go-utils/issues/159 -------------------------------------------------------------------------------- /changelog/v0.8.21/envutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Port useful env utils for writing grpc api servers. 4 | issueLink: https://github.com/solo-io/go-utils/issues/206 5 | -------------------------------------------------------------------------------- /changelog/v0.9.18/install.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Wait for default service account before deploying testrunner. 4 | issueLink: https://github.com/solo-io/go-utils/issues/259 5 | -------------------------------------------------------------------------------- /changelog/v0.9.7/gcloudutils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/205 4 | description: Adds utilities for writing gcloud subscribers. 5 | -------------------------------------------------------------------------------- /changelog/v0.9.8/fix-issues.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/239 4 | description: Register Issues in the list of webhook events that are handled. -------------------------------------------------------------------------------- /securityscanutils/contants.go: -------------------------------------------------------------------------------- 1 | package securityscanutils 2 | 3 | const ( 4 | GithubRepositoryOwner = "solo-io" 5 | QuayRepository = "quay.io/solo-io" 6 | OutputScanDirectory = "_output/scans" 7 | ) 8 | -------------------------------------------------------------------------------- /testutils/runners/ports.go: -------------------------------------------------------------------------------- 1 | package runners 2 | 3 | import "github.com/onsi/ginkgo/v2" 4 | 5 | func AllocateParallelPort(basePort int) int { 6 | return basePort + (ginkgo.GinkgoParallelNode()-1)*20 7 | } 8 | -------------------------------------------------------------------------------- /changelog/v0.10.11/fix-log.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/301 4 | description: Invalid data was being logged, causing the bot handler to crash. 5 | -------------------------------------------------------------------------------- /changelog/v0.10.11/git-mv.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add utilites to help move and inspect files in a repo. 4 | issueLink: https://github.com/solo-io/go-utils/issues/298 5 | -------------------------------------------------------------------------------- /changelog/v0.10.27/logrus.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Change how logrus dependency is handled to aovid downstream problems. 4 | issueLink: https://github.com/solo-io/go-utils/issues/340 -------------------------------------------------------------------------------- /changelog/v0.11.6/must-hash.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/367 4 | description: Add MustHash function to more easily interact with SafeHashers 5 | -------------------------------------------------------------------------------- /changelog/v0.18.1/cliutils-port-forward.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: >- 4 | Move the PortForwardGet into cliutils so that other repositories with other CLIs can use it. 5 | -------------------------------------------------------------------------------- /changelog/v0.21.26/bump-crypto-dep.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/478 4 | description: Only create scans for the latest patches in a version -------------------------------------------------------------------------------- /changelog/v0.7.0/finish-installer-port.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Finished porting over installer from Supergloo. 4 | issueLink: https://github.com/solo-io/go-utils/issues/103 -------------------------------------------------------------------------------- /changelog/v0.7.16/repo-init-changlog-v0.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Changelog validation now allows v0.0.1 releases. 4 | issueLink: https://github.com/solo-io/go-utils/issues/142 5 | 6 | -------------------------------------------------------------------------------- /changelog/v0.8.1/http-echo-test-pod.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add test pod which can output all request metadata. 4 | issueLink: https://github.com/solo-io/go-utils/issues/157 -------------------------------------------------------------------------------- /changelog/v0.8.11/xerrors.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add xerrors support to go-utils for error comparison. 4 | issueLink: https://github.com/solo-io/go-utils/issues/184 5 | 6 | 7 | -------------------------------------------------------------------------------- /changelog/v0.8.19/manifests-from-resource.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add util function to convert resources to manifest 4 | issueLink: https://github.com/solo-io/go-utils/196 5 | -------------------------------------------------------------------------------- /changelog/v0.8.22/fixlogline.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: simplify logline in installation that has been seen to panic 4 | issueLink: https://github.com/solo-io/go-utils/issues/209 -------------------------------------------------------------------------------- /changelog/v0.8.24/changelog-reader.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Provides a better abstraction for reading changelogs. 4 | issueLink: https://github.com/solo-io/go-utils/issues/220 -------------------------------------------------------------------------------- /changelog/v0.9.19/nomad-install.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: make kubeinstaller more robust for creating resources 4 | issueLink: https://github.com/solo-io/go-utils/pull/263 5 | -------------------------------------------------------------------------------- /changelog/v0.11.1/safe-hash.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/356 4 | description: Create a new safe hash function, which match generated hash functions. -------------------------------------------------------------------------------- /changelog/v0.19.0/fix-grpc-health.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: >- 4 | Fixes an issue with gRPC health checking 5 | issueLink: https://github.com/solo-io/go-utils/issues/425 -------------------------------------------------------------------------------- /changelog/v0.8.24/mount-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add utilities for working with lazily mounted github repos. 4 | issueLink: https://github.com/solo-io/go-utils/issues/213 5 | -------------------------------------------------------------------------------- /changelog/v0.10.10/fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add builder tag and other utilities to simplify writing build bots. 4 | issueLink: https://github.com/solo-io/go-utils/issues/297 5 | -------------------------------------------------------------------------------- /changelog/v0.13.4/helminstall-output-formatting.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add library for performing Helm 3 installs. 4 | issueLink: https://github.com/solo-io/go-utils/issues/385 5 | -------------------------------------------------------------------------------- /changelog/v0.16.2/sni-curl.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | issueLink: https://github.com/solo-io/go-utils/issues/410 4 | description: Add the ability to specify SNI and self-signed client cert. 5 | 6 | 7 | -------------------------------------------------------------------------------- /changelog/v0.16.4/fix-sha256-regex.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix the regex used to find sha256 checksum release assets from Github. 4 | issueLink: https://github.com/solo-io/gloo/issues/3178 5 | -------------------------------------------------------------------------------- /changelog/v0.21.20/trivy-scan-generalization.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Add generalized CLI to security scan utils. 4 | issueLink: https://github.com/solo-io/go-utils/issues/467 5 | -------------------------------------------------------------------------------- /changelog/v0.7.5/retry-kubeinstaller-opts.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Expose configurable retry options on kube installer 4 | issueLink: https://github.com/solo-io/go-utils/issues/117 5 | -------------------------------------------------------------------------------- /changelog/v0.9.21/manifest-utils-error-msg.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add contextual info to manifestutils error messages. 4 | issueLink: https://github.com/solo-io/go-utils/issues/272 5 | -------------------------------------------------------------------------------- /changelog/v0.10.18/clidoc-config.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add configurable output directory to cli docs generation utility. 4 | issueLink: https://github.com/solo-io/go-utils/issues/317 5 | -------------------------------------------------------------------------------- /changelog/v0.10.9/crd-manifest-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Return more info about a dependency version retrieved from a .toml file. 4 | issueLink: https://github.com/solo-io/go-utils/issues/294 -------------------------------------------------------------------------------- /changelog/v0.15.1/fix-helminstall-interface.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix some types that were too aggressivley moved into internal 4 | issueLink: https://github.com/solo-io/go-utils/issues/399 5 | -------------------------------------------------------------------------------- /changelog/v0.22.4/require-label.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add require label to changelog validation to ensure we have valid version 4 | issueLink: https://github.com/solo-io/go-utils/issues/503 5 | -------------------------------------------------------------------------------- /changelog/v0.6.0/clusterlock-heartbeat.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: create heartbeat for cluster lock to allow for quicker recovery 4 | issueLink: https://github.com/solo-io/go-utils/issues/77 -------------------------------------------------------------------------------- /changelog/v0.8.4/test-helper-interface.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Add interface to testrunner to avoid accessing underlying functionality. 4 | issueLink: https://github.com/solo-io/go-utils/issues/161 -------------------------------------------------------------------------------- /changelog/v0.10.25/manifest-filter.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Allow selecting which helm manifest resources you'd like to test against 4 | issueLink: https://github.com/solo-io/go-utils/issues/337 5 | -------------------------------------------------------------------------------- /changelog/v0.11.3/settings-file.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Changelog validator looks at a settings file to determine behavior. 4 | issueLink: https://github.com/solo-io/go-utils/issues/357 5 | -------------------------------------------------------------------------------- /changelog/v0.13.2/git-describe-always.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Prefer `git describe` with the `--always` flag in case repo has no prior tags. 4 | issueLink: https://github.com/solo-io/go-utils/issues/381 -------------------------------------------------------------------------------- /changelog/v0.14.0/helm_kubecontext.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Allow passing in Helm kube context and config during installation. 4 | issueLink: https://github.com/solo-io/go-utils/issues/392 5 | -------------------------------------------------------------------------------- /changelog/v0.14.1/fix-github-500-retry-logic.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix github release asset upload logic to handle github 500 errors 4 | issueLink: https://github.com/solo-io/go-utils/issues/394 5 | -------------------------------------------------------------------------------- /changelog/v0.20.5/add-log-level-changing-via-env-var.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add ability to set log level from an environment variable 4 | issueLink: https://github.com/solo-io/gloo/issues/4090 -------------------------------------------------------------------------------- /changelog/v0.21.22/avoid-empty-gh-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/solo-projects/issues/2739 4 | description: Do not create empty Github issues on trivy scans with no vulnerabilities -------------------------------------------------------------------------------- /changelog/v0.21.4/errgroup.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Implement error group which does not squelch errors. 4 | issueLink: https://github.com/solo-io/gloo-mesh/issues/1468 5 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.5.0/clarify-pr-message.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Use more specific project name in docs PRs, if repo is configured with changelogs. 4 | issueLink: https://github.com/solo-io/go-utils/issues/39 -------------------------------------------------------------------------------- /changelog/v0.7.6/readable-timestamps.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Update logger returned from contextutils to record readable timestamps. 4 | issueLink: https://github.com/solo-io/go-utils/issues/115 -------------------------------------------------------------------------------- /changelog/v0.10.23/changelog-validation.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Changelog validation now works even when a repo releases from multiple branches. 4 | issueLink: https://github.com/solo-io/go-utils/issues/331 -------------------------------------------------------------------------------- /changelog/v0.16.0/helminstall-memory-kubeconfig.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Allow passing in in-memory kubeconfigs to Helm installer. 4 | issueLink: https://github.com/solo-io/go-utils/issues/406 5 | -------------------------------------------------------------------------------- /changelog/v0.6.3/quiet-curl.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add options to curl wrapper for toggling -v and -s flags for verbosity specification. 4 | issueLink: https://github.com/solo-io/go-utils/issues/91 5 | -------------------------------------------------------------------------------- /changelog/v0.9.12/expect-proto-with-message.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Allow for passing of optional description to ExpectEqualProtoMessages. 4 | issueLink: https://github.com/solo-io/go-utils/issues/249 -------------------------------------------------------------------------------- /changelog/v0.9.5/sanitize_name_v2.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Remove quotes from strings for compatibility with Kubernetes' naming convention. 4 | issueLink: https://github.com/solo-io/go-utils/issues/232 5 | -------------------------------------------------------------------------------- /changelog/v0.10.1/permissions-check.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add manifest test function for getting permissions granted to k8s service accounts. 4 | issueLink: https://github.com/solo-io/go-utils/issues/277 -------------------------------------------------------------------------------- /changelog/v0.13.3/grpc-logging.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Added WithExistingLogger and LoggerInterceptor that can be used as a grpc interceptor. 4 | issueLink: https://github.com/solo-io/go-utils/issues/387 -------------------------------------------------------------------------------- /changelog/v0.5.0/remove-changelog-refactor.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Remove remnants of changelog refactor that wasn't done on master. 4 | issueLink: https://github.com/solo-io/go-utils/issues/55 5 | -------------------------------------------------------------------------------- /changelog/v0.7.0/uninstall-gloo-namespace.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: The test Gloo wrapper now calls `glooctl uninstall` with the `--delete-namespace` flag. 4 | issueLink: https://github.com/solo-io/go-utils/issues/90 -------------------------------------------------------------------------------- /changelog/v0.7.21/fixes.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Install cache now tracks resources even if they fail to become ready for created and deleted resources. 4 | issueLink: https://github.com/solo-io/go-utils/issues/152 -------------------------------------------------------------------------------- /changelog/v0.7.4/listing-cached-values.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | Ensure that subresources are deleted by the kube installer on delete 5 | issueLink: https://github.com/solo-io/go-utils/issues/113 6 | -------------------------------------------------------------------------------- /changelog/v0.7.6/fix-cache-access.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: List resources should access the cached resources via the cache API, which properly locks. 4 | issueLink: https://github.com/solo-io/go-utils/issues/119 -------------------------------------------------------------------------------- /changelog/v0.8.22/github-client-maybe-token.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add github client getter that just logs a warning when no token is found. 4 | issueLink: https://github.com/solo-io/go-utils/issues/168 -------------------------------------------------------------------------------- /changelog/v0.9.4/kube_api_version.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add and implement ApiVersion interface for reasoning about kubernetes api versions. 4 | issueLink: https://github.com/solo-io/go-utils/issues/230 -------------------------------------------------------------------------------- /clicore/constants/constants.go: -------------------------------------------------------------------------------- 1 | package constants 2 | 3 | // CliLoggerKey is the key passed through zap logs that indicates that its value should be written to the console, 4 | // in addition to the full log file. 5 | const CliLoggerKey = "cli" 6 | -------------------------------------------------------------------------------- /changelog/v0.13.2/network-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Added network utility to get IP address of service, used across Gloo and Service Mesh Hub. 4 | issueLink: https://github.com/solo-io/go-utils/issues/383 -------------------------------------------------------------------------------- /changelog/v0.2.12/fix-copy-on-initial-push.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: No longer create unwanted nested directory when pushing solo-kit docs for the first time. 4 | issueLink: https://github.com/solo-io/go-utils/issues/43 -------------------------------------------------------------------------------- /changelog/v0.21.5/log-level-fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix setting of stat server log level when using the LOG_LEVEL environment variable 4 | resolvesIssue: false 5 | issueLink: https://github.com/solo-io/gloo/issues/4648 -------------------------------------------------------------------------------- /changelog/v0.21.7/changelog-refactor.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Adds changelog tooling to go-utils to be used across repos. 5 | issueLink: https://github.com/solo-io/gloo/issues/4653 6 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.8.0/proto-assertion-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Simplify proto equivalence checks and provide enhanced error message on failure. 4 | issueLink: https://github.com/solo-io/go-utils/issues/148 5 | -------------------------------------------------------------------------------- /versionutils/dep/types.go: -------------------------------------------------------------------------------- 1 | package dep 2 | 3 | type VersionType int 4 | 5 | const ( 6 | Revision VersionType = iota 7 | Version 8 | Branch 9 | ) 10 | 11 | type VersionInfo struct { 12 | Version string 13 | Type VersionType 14 | } 15 | -------------------------------------------------------------------------------- /changelog/v0.10.16/changelog-docs-from-dir.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Utility for generating changelog summary documentation from a changelog directory. 4 | issueLink: https://github.com/solo-io/go-utils/issues/309 5 | -------------------------------------------------------------------------------- /changelog/v0.15.2/fix-label-to-unlabeled-version-validation.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix label to unlabeled version validation (e.g., 1.1.0-beta1 -> 1.1.0) 4 | issueLink: https://github.com/solo-io/go-utils/issues/401 5 | -------------------------------------------------------------------------------- /changelog/v0.8.13/proto-unmarshal-allow-unknown.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add proto unmarshal function that allows unknown fields rather than fail on them. 4 | issueLink: https://github.com/solo-io/go-utils/issues/188 -------------------------------------------------------------------------------- /changelog/v0.8.24/changelog-validator.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Added changelog validator interface, deprecating the old changelog validation utilities. 4 | issueLink: https://github.com/solo-io/go-utils/issues/221 -------------------------------------------------------------------------------- /changelog/v0.13.3/helminstall.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Do not output post install message if installation error occurred. Separate install output with newlines. 4 | issueLink: https://github.com/solo-io/go-utils/issues/389 5 | -------------------------------------------------------------------------------- /changelog/v0.16.3/fix-formula-updater.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fix the tag names looked up by the formula updater utility, and document the related naming in-code. 4 | issueLink: https://github.com/solo-io/gloo/issues/3178 5 | -------------------------------------------------------------------------------- /changelog/v0.21.9/fix-docs-gen-ratelimit-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/gloo/issues/4974 4 | resolvesIssue: false 5 | description: Start querying github paginated API at page 1, rather than page 0. -------------------------------------------------------------------------------- /changelog/v0.8.0/migrate-solo-kit.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Finishes moving utils into go-utils. Renames logger to log to keep parity with solo-kit. 4 | issueLink: https://github.com/solo-io/go-utils/issues/155 5 | -------------------------------------------------------------------------------- /ci/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | // This package imports things required by build scripts, to force `go mod` to see them as dependencies 5 | package tools 6 | 7 | import ( 8 | _ "golang.org/x/tools/cmd/goimports" 9 | ) 10 | -------------------------------------------------------------------------------- /changelog/v0.20.3/add-benchmarking-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add benchmarking util for testing user time spent in tests. 4 | issueLink: https://github.com/solo-io/ext-auth-service/issues/160 5 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.25.2/terminating-is-not-ready.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/529 4 | resolvesIssue: true 5 | description: >- 6 | Revise kubectl tool to not report `Terminating` pods as `Running`. 7 | -------------------------------------------------------------------------------- /changelog/v0.6.1/fix-regression-in-release-upload.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fixes a regression introduced in v0.6.0 where uploading github release assets would always fail. 4 | issueLink: https://github.com/solo-io/go-utils/issues/81 -------------------------------------------------------------------------------- /changelog/v0.6.2/lock-deletion-resilience.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fixes a bug where locks will fail if the lock present in the cluster is deleted while trying to acquire. 4 | issueLink: https://github.com/solo-io/go-utils/issues/83 -------------------------------------------------------------------------------- /changelog/v0.8.15/config-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Added utils for interacting with config maps and structs, pulled upstream from the service mesh hub. 4 | issueLink: https://github.com/solo-io/go-utils/issues/192 5 | -------------------------------------------------------------------------------- /changelog/v0.8.7/expect-configmap-with-yaml-data.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add ExpectConfigMapWithYamlData to handle assertions on configmaps with yaml Data values. 4 | issueLink: https://github.com/solo-io/go-utils/issues/171 -------------------------------------------------------------------------------- /clicore/internal/clibufferpool/resource.go: -------------------------------------------------------------------------------- 1 | package clibufferpool 2 | 3 | import "go.uber.org/zap/buffer" 4 | 5 | var ( 6 | _pool = buffer.NewPool() 7 | // Get retrieves a buffer from the pool, creating one if necessary. 8 | Get = _pool.Get 9 | ) 10 | -------------------------------------------------------------------------------- /changelog/v0.11.4/fix-file-validation.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/357 4 | description: Changelog validator now ignores validation.yaml when validating that exactly one changelog file was added. 5 | -------------------------------------------------------------------------------- /changelog/v0.2.13/find-latest-including-prerelease.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fixes the behavior where changelog verification would fail if the latest release was a prerelease. 4 | issueLink: https://github.com/solo-io/go-utils/issues/45 -------------------------------------------------------------------------------- /changelog/v0.20.5/fix-homebrew-formula-regex.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Fix homebrew formula to update homebrew-core with stable gloo release 4 | issueLink: https://github.com/solo-io/gloo/issues/4047 5 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.21.27/fix-stats-logging-npe.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/gloo/issues/6449 4 | resolvesIssue: false 5 | description: Ensure that the handler for the /logging endpoint of the stats server is never nil. -------------------------------------------------------------------------------- /changelog/v0.22.1/nil-notes-error.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | issueLink: https://github.com/solo-io/go-utils/issues/496 4 | description: Return an error when we are unable to retrieve ChangelogNotes for a release 5 | resolvesIssue: false -------------------------------------------------------------------------------- /fileutils/text.go: -------------------------------------------------------------------------------- 1 | package fileutils 2 | 3 | import "os" 4 | 5 | func ReadFileString(filename string) (string, error) { 6 | contents, err := os.ReadFile(filename) 7 | if err != nil { 8 | return "", err 9 | } 10 | return string(contents), nil 11 | } 12 | -------------------------------------------------------------------------------- /changelog/v0.15.0/helm-install-fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: Clean up the helminstall package, as well as fix a confusing message when the namespace exists already. 4 | issueLink: https://github.com/solo-io/go-utils/issues/399 5 | -------------------------------------------------------------------------------- /changelog/v0.21.0/fix-homebrew-formula-regex.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | issueLink: https://github.com/solo-io/gloo/issues/2549 4 | resolvesIssue: false 5 | description: Allow injecting an initial serving status to the grpc health checker 6 | -------------------------------------------------------------------------------- /changelog/v0.21.3/fix-fail-handler.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | Fix the `RegisterCommonFailHandlers` function so that our custom fail handlers report correct line numbers on failures. 5 | issueLink: https://github.com/solo-io/go-utils/issues/443 -------------------------------------------------------------------------------- /changelog/v0.24.2/gomock-ignore.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Add intermediate files that gomock sometimes generates to .gitignore 5 | issueLink: https://github.com/solo-io/solo-projects/issues/4810 6 | resolvesIssue: false 7 | -------------------------------------------------------------------------------- /changelog/v0.27.0/fix-extra-issues-bug.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | Fix a bug that caused issues to be written for releases without vulnerabilities when running security scans 5 | issueLink: https://github.com/solo-io/go-utils/issues/532 -------------------------------------------------------------------------------- /changelog/v0.10.7/improve-toml-parsing.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/291 4 | description: Consider all possible version fields (version, branch, revision) when retrieving a dependency version from a .toml file. -------------------------------------------------------------------------------- /changelog/v0.11.7/generate-changelog.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/369 4 | description: Support generating the changelog, used by Gloo and GlooE, now that validation.yaml can exist in the changelog directory. 5 | -------------------------------------------------------------------------------- /changelog/v0.13.0/errors-improvement.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | issueLink: https://github.com/solo-io/go-utils/issues/378 4 | description: Remove our existing errors utils in favor of a new, readable gomega expectation using github.com/rotisserie/eris 5 | -------------------------------------------------------------------------------- /changelog/v0.24.1/remove-actions-cache.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | issueLink: https://github.com/solo-io/solo-projects/issues/4708 4 | resolvesIssue: false 5 | description: Removed actions/cache as this is made redundant by actions/setup-go@v4. 6 | -------------------------------------------------------------------------------- /changelog/v0.10.0/namespace-override-fix.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: 'Add option to respect manifest namespace on installer. Breaks the ReconcileResources API of the KubeInstaller' 4 | issueLink: https://github.com/solo-io/go-utils/pull/266 5 | -------------------------------------------------------------------------------- /changelog/v0.10.8/more-version-info.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Return more info about a dependency version retrieved from a .toml file. 4 | - type: NON_USER_FACING 5 | description: Return more complete info about the current HEAD of a git repository. -------------------------------------------------------------------------------- /docker/docker_suite_test.go: -------------------------------------------------------------------------------- 1 | package docker_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestDocker(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Docker Suite") 13 | } 14 | -------------------------------------------------------------------------------- /grpcutils/grpc_suite_test.go: -------------------------------------------------------------------------------- 1 | package grpcutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestGrpc(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Grpc Suite") 13 | } 14 | -------------------------------------------------------------------------------- /test/checks/checks_suite_test.go: -------------------------------------------------------------------------------- 1 | package checks 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestChecks(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Checks Suite") 13 | } 14 | -------------------------------------------------------------------------------- /cliutils/common_suite_test.go: -------------------------------------------------------------------------------- 1 | package cliutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestCommon(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Common Suite") 13 | } 14 | -------------------------------------------------------------------------------- /vfsutils/vfs_suite_test.go: -------------------------------------------------------------------------------- 1 | package vfsutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestVfsutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Vfsutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /changelog/v0.10.22/helm-upgrade.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Changelog now supports HELM and UPGRADE entry types, to help establish stronger conventions around communicating important release notes. 4 | issueLink: https://github.com/solo-io/go-utils/issues/332 -------------------------------------------------------------------------------- /changelog/v0.21.13/security-scan-create-github-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/gloo/issues/5048 4 | resolvesIssue: false 5 | description: > 6 | Fixes security scanning bug that renames issue from 1.6.13 -> 1.6.1 or 1.6.24-> 1.6.2 -------------------------------------------------------------------------------- /changelog/v0.24.1/github-actions-deprecations.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | issueLink: https://github.com/solo-io/solo-projects/issues/4708 4 | resolvesIssue: false 5 | description: Updated various github actions due to deprecated methods, images, or libraries. 6 | -------------------------------------------------------------------------------- /grpcutils/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package grpc.test; 4 | 5 | option go_package = "./test_api"; 6 | 7 | service TestService { 8 | rpc Invoke (Request) returns (Response) { 9 | } 10 | } 11 | 12 | message Request { 13 | } 14 | 15 | message Response { 16 | } 17 | -------------------------------------------------------------------------------- /helmutils/helm_suite_test.go: -------------------------------------------------------------------------------- 1 | package helmutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestHealthchecker(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Helm Suite") 13 | } 14 | -------------------------------------------------------------------------------- /tarutils/tarutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package tarutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestTarutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Tarutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /testutils/testutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestTestutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Testutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /changelog/v0.2.11/fix-sha-to-match-shasum.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Fixes the sha upload in `UploadReleaseAssetsCli` to upload a checksum for `foo` that matches the output of `shasum -a 256 foo > foo.sha256`. 4 | issueLink: https://github.com/solo-io/go-utils/issues/41 -------------------------------------------------------------------------------- /changelog/v0.24.0/ginkgo-v2.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | issueLink: https://github.com/solo-io/gloo/issues/7222 4 | resolvesIssue: false 5 | description: > 6 | Upgrade Ginkgo from v1 to v2, using https://onsi.github.io/ginkgo/MIGRATING_TO_V2 as a helpful guide. -------------------------------------------------------------------------------- /changelog/v0.4.0/install-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: Figured out the go-mod-cache. 4 | - type: BREAKING_CHANGE 5 | description: Move install utils into this repo and start cleanup. 6 | issueLink: https://github.com/solo-io/go-utils/issues/61 7 | -------------------------------------------------------------------------------- /fileutils/fileutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package fileutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestFileutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Fileutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /hashutils/hashutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package hashutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestHashutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Hashutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /protoutils/protoutil_suite_test.go: -------------------------------------------------------------------------------- 1 | package protoutils 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestProtoutil(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Protoutil Suite") 13 | } 14 | -------------------------------------------------------------------------------- /slackutils/slack_suite_test.go: -------------------------------------------------------------------------------- 1 | package slackutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestSlackutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Slackutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /changelog/v0.22.3/configurable-changelog-dir.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: added ability to validate changelogs in a subdirectory by specifying `activeSubdirectory` in "validation.yaml". This should enable users to have less sprawling changelog directorys as time progresses. -------------------------------------------------------------------------------- /changelog/v0.24.2/fix-test-utils-double-import.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | Fix issue where testutils was importing two different versions of the `ginkgo` and `errors` packages. 5 | issueLink: https://github.com/solo-io/gloo/issues/8164 6 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.27.1/fix-alpine-labeling.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | Fix a bug that results in duplicate versions in the output of the changeloggenutils GenerateJSON function when the label is "alpine" 5 | issueLink: https://github.com/solo-io/go-utils/issues/537 6 | -------------------------------------------------------------------------------- /changelog/v0.28.6/go-1-24-6.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | dependencyOwner: golang 4 | dependencyRepo: go 5 | dependencyTag: v1.24.6 6 | description: "Update Go to 1.24.6" 7 | issueLink: https://github.com/solo-io/solo-projects/issues/8512 8 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.7.15/customize-install-order.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Add MutatingWebhookConfiguration to the install order list. Required by our custom installer as some deployments 5 | may require a preexisting MutatingWebhookConfiguration 6 | 7 | -------------------------------------------------------------------------------- /contextutils/time.go: -------------------------------------------------------------------------------- 1 | package contextutils 2 | 3 | import ( 4 | "context" 5 | "time" 6 | ) 7 | 8 | func Sleep(ctx context.Context, amount time.Duration) error { 9 | select { 10 | case <-time.After(amount): 11 | return nil 12 | case <-ctx.Done(): 13 | return ctx.Err() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /versionutils/kubeapi/kubeapi_suite_test.go: -------------------------------------------------------------------------------- 1 | package kubeapi_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestKubeApi(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Kube Api Suite") 13 | } 14 | -------------------------------------------------------------------------------- /botutils/consts.go: -------------------------------------------------------------------------------- 1 | package botutils 2 | 3 | const ( 4 | PrType = "pull_request" 5 | PrReviewType = "pull_request_review" 6 | IssueCommentType = "issue_comment" 7 | CommitCommentType = "commit_comment" 8 | ReleaseType = "release" 9 | IssuesType = "issues" 10 | ) 11 | -------------------------------------------------------------------------------- /changelog/v0.27.2/expose-morechangelogstuff.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Midterm update post gloo donation. 5 | Eventually github tests should rely on this repo and not another repo 6 | This also forced a trivy upgrade to the same style used else where -------------------------------------------------------------------------------- /changelog/v0.7.8/package-manager-update.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | The utilities in `pkgmgmtutils/` now support updating homebrew and gofish style formulas as part of a release 5 | process. 6 | issueLink: https://github.com/solo-io/gloo/issues/520 7 | -------------------------------------------------------------------------------- /gcloudutils/cloudbuild_suite_test.go: -------------------------------------------------------------------------------- 1 | package gcloudutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestCloudbuild(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Cloudbuild Suite") 13 | } 14 | -------------------------------------------------------------------------------- /githubutils/githubutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package githubutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestGithubutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Githubutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /pkgmgmtutils/internal/internal_suite_test.go: -------------------------------------------------------------------------------- 1 | package internal_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestInternal(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Internal Suite") 13 | } 14 | -------------------------------------------------------------------------------- /stringutils/stringutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package stringutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestSurveyutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Stringutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /surveyutils/surveyutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package surveyutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestSurveyutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Surveyutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /changelog/v0.14.2/healthcheck-interceptor.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Add a health check interceptor to send a "x-envoy-immediate-health-check-fail" header 5 | to envoy. 6 | issueLink: https://github.com/solo-io/gloo/issues/2489 7 | resolvesIssue: false 8 | -------------------------------------------------------------------------------- /changelog/v0.21.10/fix-docs-gen-ratelimit-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/gloo/issues/5048 4 | resolvesIssue: true 5 | description: Adds securityscanutils package to go-utils, adding utility methods to security scan image releases from repositories. -------------------------------------------------------------------------------- /changelog/v0.21.14/security-scan-create-github-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/gloo/issues/5048 4 | resolvesIssue: false 5 | description: > 6 | Fixes issue where security scanning will fail and error when scanning releases that failed mid-release. -------------------------------------------------------------------------------- /loggingutils/loggingutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package loggingutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestLoggingutils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Loggingutils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /changelog/v0.23.0/cvectl.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | issueLink: https://github.com/solo-io/go-utils/issues/469 4 | resolvesIssue: false 5 | description: > 6 | Add scan-version command to CVE CLI which allows for easier scans of a single version (tag) 7 | of multiple images. -------------------------------------------------------------------------------- /healthchecker/healthchecker_suite_test.go: -------------------------------------------------------------------------------- 1 | package healthchecker_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestHealthchecker(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Healthchecker Suite") 13 | } 14 | -------------------------------------------------------------------------------- /pkgmgmtutils/formula_updater_suite_test.go: -------------------------------------------------------------------------------- 1 | package pkgmgmtutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestFormulaUpdater(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "FormulaUpdater Suite") 13 | } 14 | -------------------------------------------------------------------------------- /changelog/v0.7.11/package-manager-update.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | Added parameter to help more finely narrow down to just the sha256 files in the build path that 5 | pkgmgmtutils.UpdateFormulas really need. 6 | issueLink: https://github.com/solo-io/go-utils/issues/132 7 | 8 | -------------------------------------------------------------------------------- /changelog/v0.16.1/stop-prerelease-brew-prs.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Stop opening PRs to homebrew-core for non-stable versions, which is disallowed per https://docs.brew.sh/Acceptable-Formulae#stable-versions. 4 | issueLink: https://github.com/solo-io/gloo/issues/3178 5 | resolvesIssue: false 6 | -------------------------------------------------------------------------------- /changelog/v0.25.1/13898-formatting-missing-images.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/13898 4 | description: > 5 | Fix missing newline in scanner output Markdown. 6 | Explicitly report "No Vulnerabilities Found" in Markdown for images when applicable. -------------------------------------------------------------------------------- /testutils/logs.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "github.com/fgrosse/zaptest" 5 | "github.com/solo-io/go-utils/contextutils" 6 | 7 | . "github.com/onsi/ginkgo/v2" 8 | ) 9 | 10 | func SetupLog() { 11 | logger := zaptest.LoggerWriter(GinkgoWriter) 12 | contextutils.SetFallbackLogger(logger.Sugar()) 13 | } 14 | -------------------------------------------------------------------------------- /changelog/v0.2.8/1.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Markdown generation now always ends in two new lines. 4 | issueLink: https://github.com/solo-io/go-utils/issues/30 5 | - type: NEW_FEATURE 6 | description: Changelog now enabled for this repo. 7 | issueLink: https://github.com/solo-io/go-utils/issues/31 -------------------------------------------------------------------------------- /changelog/v0.8.14/fix-kube-caching.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: At the start of reconcile, reset Kube client so it's discovery cache is updated to reflect any newly-created CRDs (i.e. from a background Job) since it was last refreshed. 4 | issueLink: https://github.com/solo-io/sm-marketplace/issues/452 5 | -------------------------------------------------------------------------------- /changeloggenutils/changelogdocutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package changelogdocutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestChangelogDocUtils(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "ChangelogDocUtils Suite") 13 | } 14 | -------------------------------------------------------------------------------- /changelogutils/cmd/Makefile: -------------------------------------------------------------------------------- 1 | 2 | README.md: 3 | echo "This is a sample of the output from the changelog generation script.\n" > $@ 4 | echo "To update this file, run: \`cd changelogutils/cmd && make README.md -B && cd -\`\n" >> $@ 5 | echo "---" >> $@ 6 | cd ../.. && go run changelogutils/cmd/main.go >> changelogutils/cmd/README.md 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dep 2 | vendor 3 | 4 | # intellij 5 | .idea 6 | 7 | # vscode 8 | .vscode 9 | 10 | # mac files 11 | .DS_Store 12 | 13 | # junit 14 | junit.xml 15 | 16 | _output 17 | 18 | test-report.json 19 | junit*.xml 20 | *cov 21 | 22 | *.test 23 | 24 | # ignore intermediate files that gomock sometimes generates 25 | **/gomock_reflect* -------------------------------------------------------------------------------- /changelog/v0.6.2/changelog-resolves-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Changelog entries now support an optional `resolvesIssue` boolean field, defaulting to `true`, to specify if the issue referenced in `issueLink` should be resolved when the PR merges. 4 | issueLink: https://github.com/solo-io/go-utils/issues/88 -------------------------------------------------------------------------------- /securityscanutils/cli/exampleVersionImageConstraints.txt: -------------------------------------------------------------------------------- 1 | # comments are skipped, as are empty lines 2 | # format 3 | constraint-a , image1, image2, image3 4 | constraint-b , image2, image3, image4 5 | #valid example for GME 6 | # >=0.0.0,enterprise-networking,enterprise-agent,istiod-agent,gloo-mesh-apiserver,gloo-mesh-ui,gloo-mesh-envoy,rbac-webhook -------------------------------------------------------------------------------- /changelog/v0.24.3/helm-scanning.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Ability to scan Helm charts for issues related to formatting. Use the `helmutils.FindHelmChartWhiteSpaces()` with it's host of options, to use this functionality. 5 | issueLink: https://github.com/solo-io/gloo/issues/8268 6 | resolvesIssue: false 7 | -------------------------------------------------------------------------------- /changelog/v0.24.5/log-to-file.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Add ability to log to a file by setting the LOG_TO_FILE_LOCATION environment variable. This is needed to support AWS Fargate, which can not collect logs from STDOUT. 5 | issueLink: https://github.com/solo-io/gloo/issues/7299 6 | resolvesIssue: false 7 | -------------------------------------------------------------------------------- /changelog/v0.22.0/improve-scan-perf.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | issueLink: https://github.com/solo-io/go-utils/issues/490 4 | description: > 5 | Greatly reduced trivy scan time by detecting exit codes to prevent duplicate runs and backoff delays. In the 6 | process some originally public functions were made private. 7 | -------------------------------------------------------------------------------- /gcloudutils/builders/builders_suite_test.go: -------------------------------------------------------------------------------- 1 | package builders 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | var ( 11 | T *testing.T 12 | ) 13 | 14 | func TestBuilders(t *testing.T) { 15 | T = t 16 | RegisterFailHandler(Fail) 17 | RunSpecs(t, "Builders Suite") 18 | } 19 | -------------------------------------------------------------------------------- /changelog/v0.16.6/add-wasm-tags.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Expand on allowed tags. Now tags like v1.2.3-foo, v1.2.3-foo-bar-baz, 5 | and v1.2.3-foo-bar1 are allowed. Any labelVersion numbers must be 6 | trailing, so v1.2.3-foo1-bar is still not allowed for example. 7 | issueLink: https://github.com/solo-io/go-utils/issues/416 8 | -------------------------------------------------------------------------------- /changelog/v0.9.1/config-env.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Provide a utility function (for tests) to get the absolute path of the directory 5 | containing the caller's file. 6 | issueLink: https://github.com/solo-io/go-utils/issues/223 7 | - type: NON_USER_FACING 8 | description: Enable verbose flag for glooctl installs -------------------------------------------------------------------------------- /securityscanutils/cli/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "log" 6 | 7 | "github.com/solo-io/go-utils/securityscanutils/commands" 8 | ) 9 | 10 | func main() { 11 | ctx := context.Background() 12 | 13 | cmd := commands.RootCommand(ctx) 14 | if err := cmd.Execute(); err != nil { 15 | log.Fatalf("unable to run: %v\n", err) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /changelog/v0.8.12/termination-log.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add termination error function for kube containers. 4 | issueLink: https://github.com/solo-io/go-utils/issues/185 5 | - type: FIX 6 | description: Shorten error message around changelog files. 7 | issueLink: https://github.com/solo-io/solobot/issues/100 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /testutils/goimpl/goimpl_suite_test.go: -------------------------------------------------------------------------------- 1 | package goimpl 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/solo-io/go-utils/testutils" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | ) 10 | 11 | func TestGoImpl(t *testing.T) { 12 | testutils.RegisterPreFailHandler(testutils.PrintTrimmedStack) 13 | testutils.RegisterCommonFailHandlers() 14 | RunSpecs(t, "Go Impl Suite") 15 | } 16 | -------------------------------------------------------------------------------- /changelog/v0.21.16/trivy-retries.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Support retries in Trivy scan. 5 | This is an attempt to handle cases where a network connection failure causes 6 | a Trivy scan to fail. Since the SecurityScan executes as a bulk job, we want 7 | to ensure that transient failures do not cause the entire job to fail. -------------------------------------------------------------------------------- /changelog/v0.21.25/bump-crypto-dep.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | dependencyOwner: golang 4 | dependencyRepo: golang.org/x/crypto 5 | dependencyTag: v0.0.0-20220315160706-3147a52a75dd 6 | - type: DEPENDENCY_BUMP 7 | description: Bumped the go version for go.mod 8 | dependencyOwner: golang 9 | dependencyRepo: go 10 | dependencyTag: v1.18 -------------------------------------------------------------------------------- /changelog/v0.18.0/bump-github-library.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | dependencyOwner: palantir 4 | dependencyRepo: go-githubapp 5 | dependencyTag: v0.5.0 6 | - type: BREAKING_CHANGE 7 | description: >- 8 | Use new github API throughout the project. 9 | issueLink: https://github.com/solo-io/build-bot/issues/73 10 | resolvesIssue: false 11 | -------------------------------------------------------------------------------- /changelog/v0.21.12/security-scan-create-github-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/gloo/issues/5048 4 | resolvesIssue: false 5 | description: > 6 | Change image vulnerability github issue creation behavior such that only one issue is created per version, where 7 | each of the images' vulnerabilities are reported in that one issue. -------------------------------------------------------------------------------- /changelog/v0.7.2/add-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Added a `SanitizeName` function to `kubeutils`. 4 | issueLink: https://github.com/solo-io/go-utils/issues/108 5 | - type: FIX 6 | description: Remove reference to docs in shared `versionutils` function to get `TAGGED_VERSION` from the environment. 7 | issueLink: https://github.com/solo-io/go-utils/issues/99 -------------------------------------------------------------------------------- /changelog/v0.7.3/listing-cached-values.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Allow listing from the cache all the unique values for a particular label key. This enables discovering label 5 | key/value pairs that should be purged because the CRD that led to the creation of that resource was deleted. 6 | issueLink: https://github.com/solo-io/go-utils/issues/110 7 | -------------------------------------------------------------------------------- /changelog/v0.11.1/release-versioning.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/353 4 | description: Allow skipping strict version incrementing logic when validating changelogs. 5 | - type: NEW_FEATURE 6 | issueLink: https://github.com/solo-io/go-utils/issues/352 7 | description: Allow rc-style workflows for any minor version, not just 1.0.0. -------------------------------------------------------------------------------- /changelog/v0.7.18/manifest-test-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Distribute a library for testing installation manifests generated from Helm charts. 4 | issueLink: https://github.com/solo-io/go-utils/issues/146 5 | - type: NON_USER_FACING 6 | description: Some readme cleanup. 7 | issueLink: https://github.com/solo-io/go-utils/issues/64 8 | resolvesIssue: false 9 | -------------------------------------------------------------------------------- /testutils/make.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "fmt" 5 | "os/exec" 6 | "strings" 7 | 8 | . "github.com/onsi/gomega" 9 | ) 10 | 11 | func MustMake(dir, args string) { 12 | make := exec.Command("make", strings.Split(args, " ")...) 13 | make.Dir = dir 14 | out, err := make.CombinedOutput() 15 | if err != nil { 16 | fmt.Print(string(out)) 17 | } 18 | Expect(err).NotTo(HaveOccurred()) 19 | } 20 | -------------------------------------------------------------------------------- /testutils/skip.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/solo-io/go-utils/log" 7 | ) 8 | 9 | func AreTestsDisabled() bool { 10 | if os.Getenv("RUN_KUBE2E_TESTS") != "1" { 11 | log.Warnf("This test requires a running kubernetes cluster and is disabled by default. " + 12 | "To enable, set RUN_KUBE2E_TESTS=1 in your env.") 13 | return true 14 | } 15 | return false 16 | } 17 | -------------------------------------------------------------------------------- /changelog/v0.21.1/fix-homebrew-formula-regex.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Adds a method will get the latest release by Semantic Versioning from a github repo. 5 | Other methods, such as FindLatestReleaseTag and FindLatestReleaseTagIncudingPrerelease only find latest releases by chronological order, which may not be appropriate if a backport v1.6.x was released after a v1.7.0-betax. 6 | -------------------------------------------------------------------------------- /changelog/v0.7.9/package-manager-update.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | Added a FormulaOptions.FormulaName field to allow the FormulaOptions.Name field to be a descriptive name, and 5 | FormulaOptions.FormulaName to be used to reference the proper formula name as needed in branch and commit name 6 | conventions for external PRs. 7 | issueLink: https://github.com/solo-io/go-utils/issues/128 8 | -------------------------------------------------------------------------------- /randutils/rand.go: -------------------------------------------------------------------------------- 1 | package randutils 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | ) 7 | 8 | func init() { 9 | rand.Seed(time.Now().UnixNano()) 10 | } 11 | 12 | var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz1234567890") 13 | 14 | func RandString(length int) string { 15 | b := make([]rune, length) 16 | for i := range b { 17 | b[i] = letterRunes[rand.Intn(len(letterRunes))] 18 | } 19 | return string(b) 20 | } 21 | -------------------------------------------------------------------------------- /testutils/get_current_file_test.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | ) 7 | 8 | var _ = Describe("GetCurrentFileDirectory", func() { 9 | It("works", func() { 10 | f, err := GetCurrentFile() 11 | Expect(err).NotTo(HaveOccurred()) 12 | Expect(f).To(HaveSuffix("testutils/get_current_file_test.go")) 13 | Expect(f).To(HavePrefix("/")) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /testutils/random.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | ) 7 | 8 | func init() { 9 | rand.Seed(time.Now().UnixNano()) 10 | } 11 | 12 | var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz1234567890") 13 | 14 | func RandString(length int) string { 15 | b := make([]rune, length) 16 | for i := range b { 17 | b[i] = letterRunes[rand.Intn(len(letterRunes))] 18 | } 19 | return string(b) 20 | } 21 | -------------------------------------------------------------------------------- /changelog/v0.21.11/security-scan-create-github-issue.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/gloo/issues/5048 4 | resolvesIssue: false 5 | description: > 6 | Adds option to Security Scanner to create github issues for each image that a vulnerability is found in. 7 | If an issue already exists for that image, it will update the issue with the most recent vulnerability scan results. -------------------------------------------------------------------------------- /changelog/v0.8.10/set-log-level.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Added new functions around Toml management to support checking overrides or constraints. 4 | issueLink: https://github.com/solo-io/go-utils/issues/180 5 | - type: NEW_FEATURE 6 | description: You can now set the log level dynamically on loggers constructed via contextutils. 7 | issueLink: https://github.com/solo-io/go-utils/issues/164 8 | -------------------------------------------------------------------------------- /ci/check-code-format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | 5 | make format-code 6 | if [[ $? -ne 0 ]]; then 7 | echo "Code formatting failed" 8 | exit 1; 9 | fi 10 | if [[ $(git status --porcelain | wc -l) -ne 0 ]]; then 11 | echo "Error: Generating code produced a non-empty diff" 12 | echo "Try running 'make install-go-tools format-code -B' then re-pushing." 13 | git status --porcelain 14 | git diff | cat 15 | exit 1; 16 | fi -------------------------------------------------------------------------------- /changelog/v0.16.5/stats-log-level.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Add a new `LogLevel` startup option to inject the `zap.AtomicLevel` into the stats server. This way clients can 5 | build their own logger and use the stats server to change its log level at runtime, instead of having to rely on 6 | the logger built internally by the server. 7 | issueLink: https://github.com/solo-io/go-utils/issues/413 8 | -------------------------------------------------------------------------------- /versionutils/kubeapi/list.go: -------------------------------------------------------------------------------- 1 | package kubeapi 2 | 3 | // VersionList implements sort.Interface for a list of Kubernetes API version tags. 4 | type VersionList []Version 5 | 6 | func (list VersionList) Len() int { 7 | return len(list) 8 | } 9 | 10 | func (list VersionList) Less(i, j int) bool { 11 | return list[i].LessThan(list[j]) 12 | } 13 | 14 | func (list VersionList) Swap(i, j int) { 15 | list[i], list[j] = list[j], list[i] 16 | } 17 | -------------------------------------------------------------------------------- /changelog/v0.29.0/bump-go.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | dependencyOwner: golang 4 | dependencyRepo: go 5 | dependencyTag: v1.25.5 6 | issueLink: https://github.com/solo-io/solo-projects/issues/8681 7 | resolvesIssue: false 8 | - type: BREAKING_CHANGE 9 | description: "Update Go to 1.25.5" 10 | issueLink: https://github.com/solo-io/solo-projects/issues/8681 11 | resolvesIssue: false 12 | 13 | -------------------------------------------------------------------------------- /clicore/clicore_suite_test.go: -------------------------------------------------------------------------------- 1 | package clicore 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | "github.com/solo-io/go-utils/testutils" 9 | ) 10 | 11 | func TestCliCore(t *testing.T) { 12 | testutils.RegisterPreFailHandler(testutils.PrintTrimmedStack) 13 | testutils.RegisterCommonFailHandlers() 14 | RegisterFailHandler(Fail) 15 | testutils.SetupLog() 16 | RunSpecs(t, "Clicore Suite") 17 | } 18 | -------------------------------------------------------------------------------- /versionutils/versionutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package versionutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/solo-io/go-utils/testutils" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestVersionUtils(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | testutils.RegisterPreFailHandler(testutils.PrintTrimmedStack) 15 | testutils.RegisterCommonFailHandlers() 16 | RunSpecs(t, "Versionutils Suite") 17 | } 18 | -------------------------------------------------------------------------------- /gcloudutils/public.go: -------------------------------------------------------------------------------- 1 | package gcloudutils 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | func IsPublic(ctx context.Context, projectId, repoName string) bool { 8 | // TODO: should this be in the app config? 9 | if projectId == "solo-public" { 10 | return true 11 | } 12 | // Support our testing efforts :) can be removed once 13 | // we figure out a better plan for live bot canary 14 | if repoName == "testrepo" { 15 | return true 16 | } 17 | return false 18 | } 19 | -------------------------------------------------------------------------------- /gcloudutils/README.md: -------------------------------------------------------------------------------- 1 | This project contains some utilities for GCloud, most importantly a library for building google cloud subscriber 2 | plugins for Solobot CI builds. 3 | 4 | To build a new cloud subscriber, simply do: 5 | 6 | ``` 7 | subscriber, err := NewSolobotCloudSubscriber(ctx context.Context) 8 | if err != nil { 9 | // handle 10 | } 11 | subscriber.RegisterHandler(myCustomHandler) 12 | if err := subscriber.Run(); err != nil { 13 | // handle 14 | } 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /testutils/get_current_file.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "path/filepath" 5 | "runtime" 6 | 7 | "github.com/rotisserie/eris" 8 | ) 9 | 10 | // returns the absolute path to the file the caller 11 | // intended to provide a way to find test files 12 | func GetCurrentFile() (string, error) { 13 | _, callerFile, _, ok := runtime.Caller(1) 14 | if !ok { 15 | return "", eris.New("failed to get runtime.Caller") 16 | } 17 | return filepath.Abs(callerFile) 18 | } 19 | -------------------------------------------------------------------------------- /changelog/v0.21.2/add-custom-order-tag-label.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Adds `labelOrder` to changelogValidator. If `labelOrder` exists, then changelogValidator 5 | will now use the order specified in this array to tie-break tags with same versions but different labels. 6 | e.g. if e.g. labelOrder = [ beta, alpha, predev ], then 1.7.0-beta11 > 1.7.0-alpha5 > 1.7.0-predev9. 7 | issueLink: https://github.com/solo-io/go-utils/issues/441 -------------------------------------------------------------------------------- /changelog/v0.7.20/fixes.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: Install cache now tracks resources even if they fail to become ready. 4 | issueLink: https://github.com/solo-io/go-utils/issues/152 5 | - type: NON_USER_FACING 6 | description: The `testutils.MustMake` utility now prints make output if the command fails. 7 | - type: NEW_FEATURE 8 | description: Allow customizing pull policy when testing containers. 9 | issueLink: https://github.com/solo-io/go-utils/issues/151 -------------------------------------------------------------------------------- /errutils/aggregate_errs.go: -------------------------------------------------------------------------------- 1 | package errutils 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/pkg/errors" 7 | ) 8 | 9 | func AggregateErrs(ctx context.Context, dest chan error, src <-chan error, srcInfo string) { 10 | for { 11 | select { 12 | case err, ok := <-src: 13 | if !ok { 14 | return 15 | } 16 | select { 17 | case <-ctx.Done(): 18 | return 19 | case dest <- errors.Wrapf(err, srcInfo): 20 | } 21 | case <-ctx.Done(): 22 | return 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /botutils/botconfig/botconfig_suite_test.go: -------------------------------------------------------------------------------- 1 | package botconfig_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/solo-io/go-utils/testutils" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestBotconfig(t *testing.T) { 13 | test = t 14 | RegisterFailHandler(Fail) 15 | testutils.RegisterPreFailHandler(testutils.PrintTrimmedStack) 16 | testutils.RegisterCommonFailHandlers() 17 | RunSpecs(t, "Botconfig Suite") 18 | } 19 | 20 | var test *testing.T 21 | -------------------------------------------------------------------------------- /gcloudutils/interface.go: -------------------------------------------------------------------------------- 1 | package gcloudutils 2 | 3 | import ( 4 | "context" 5 | 6 | "google.golang.org/api/cloudbuild/v1" 7 | ) 8 | 9 | type CloudBuildRegistry struct { 10 | eventHandlers []CloudBuildEventHandler 11 | } 12 | 13 | func (r *CloudBuildRegistry) AddEventHandler(handler CloudBuildEventHandler) { 14 | r.eventHandlers = append(r.eventHandlers, handler) 15 | } 16 | 17 | type CloudBuildEventHandler interface { 18 | CloudBuild(ctx context.Context, build *cloudbuild.Build) error 19 | } 20 | -------------------------------------------------------------------------------- /osutils/utils.go: -------------------------------------------------------------------------------- 1 | package osutils 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | var ( 9 | MissingEnvVarError = func(envVar string) error { 10 | return fmt.Errorf("Missing %s environment variable", envVar) 11 | } 12 | ) 13 | 14 | /* 15 | * 16 | 17 | Returns error if the environment variable is empty 18 | */ 19 | func GetEnvE(envVar string) (string, error) { 20 | env := os.Getenv(envVar) 21 | if env == "" { 22 | return "", MissingEnvVarError(envVar) 23 | } 24 | return env, nil 25 | } 26 | -------------------------------------------------------------------------------- /changelog/v0.12.0/version.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | issueLink: https://github.com/solo-io/go-utils/issues/376 4 | description: Remove `ReleaseCandidate` in lieu of more general uses of labels on versions, so versions like `1.3.0-beta1` are valid. 5 | - type: NEW_FEATURE 6 | issueLink: https://github.com/solo-io/go-utils/issues/376 7 | description: Added `allowedLabels` as an option to `validation.yaml` for changelogs, to enforce the label used is allowed during changelog validation. -------------------------------------------------------------------------------- /changelog/v0.8.8/updates.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: Add support for overrides in toml parser. 4 | issueLink: https://github.com/solo-io/go-utils/issues/175 5 | - type: NEW_FEATURE 6 | description: Add support for secrets to manifesttestutils. 7 | issueLink: https://github.com/solo-io/go-utils/issues/174 8 | - type: FIX 9 | description: Reduce logging in get_cluster_resources to DEBUG level. 10 | issueLink: https://github.com/solo-io/go-utils/issues/165 -------------------------------------------------------------------------------- /versionutils/cli.go: -------------------------------------------------------------------------------- 1 | package versionutils 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func GetReleaseVersionOrExitGracefully() *Version { 9 | tag, present := os.LookupEnv("TAGGED_VERSION") 10 | if !present || tag == "" { 11 | fmt.Printf("TAGGED_VERSION not found in environment.\n") 12 | os.Exit(0) 13 | } 14 | version, err := ParseVersion(tag) 15 | if err != nil { 16 | fmt.Printf("TAGGED_VERSION %s is not a valid semver version.\n", tag) 17 | os.Exit(0) 18 | } 19 | return version 20 | } 21 | -------------------------------------------------------------------------------- /changelog/v0.24.1/new-benchmark-util.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/511 4 | description: > 5 | Added the `Measure` function to the `benchmarking` test utility package. 6 | The new function measures the portion of time a given test function spent in user mode, 7 | in kernel mode, and on both of them combined. The other functions in the same package have been deprecated 8 | and will be removed when other repositories will stop depending on them. 9 | -------------------------------------------------------------------------------- /osutils/client.go: -------------------------------------------------------------------------------- 1 | package osutils 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | ) 7 | 8 | type OsClient interface { 9 | Getenv(key string) string 10 | ReadFile(path string) ([]byte, error) 11 | } 12 | 13 | type osClient struct { 14 | } 15 | 16 | func (*osClient) Getenv(key string) string { 17 | return os.Getenv(key) 18 | } 19 | 20 | func (*osClient) ReadFile(path string) ([]byte, error) { 21 | return ioutil.ReadFile(path) 22 | } 23 | 24 | func NewOsClient() OsClient { 25 | return &osClient{} 26 | } 27 | -------------------------------------------------------------------------------- /testutils/port/port.go: -------------------------------------------------------------------------------- 1 | package port 2 | 3 | import ( 4 | "sync/atomic" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | ) 8 | 9 | var MaxTests = 1000 10 | 11 | type TestPort struct { 12 | port *uint32 13 | } 14 | 15 | // Helps you get a free port with ginkgo tests. 16 | func NewTestPort(initial uint32) TestPort { 17 | return TestPort{ 18 | port: &initial, 19 | } 20 | } 21 | 22 | func (t TestPort) NextPort() uint32 { 23 | return atomic.AddUint32(t.port, 1) + uint32(GinkgoParallelProcess()*MaxTests) 24 | } 25 | -------------------------------------------------------------------------------- /changelogutils/changelogutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package changelogutils_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/solo-io/go-utils/testutils" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestChangelogUtils(t *testing.T) { 13 | test = t 14 | RegisterFailHandler(Fail) 15 | testutils.RegisterPreFailHandler(testutils.PrintTrimmedStack) 16 | testutils.RegisterCommonFailHandlers() 17 | RunSpecs(t, "ChangelogUtils Suite") 18 | } 19 | 20 | var test *testing.T 21 | -------------------------------------------------------------------------------- /osutils/executils/exec.go: -------------------------------------------------------------------------------- 1 | package executils 2 | 3 | import ( 4 | "os/exec" 5 | "syscall" 6 | ) 7 | 8 | // Runs cmd.CombinedOutput and returns the status code of the run 9 | func CombinedOutputWithStatus(cmd *exec.Cmd) ([]byte, int, error) { 10 | out, err := cmd.CombinedOutput() 11 | if err != nil { 12 | if exitErr, ok := err.(*exec.ExitError); ok { 13 | if status, ok := exitErr.Sys().(syscall.WaitStatus); ok { 14 | return out, status.ExitStatus(), err 15 | } 16 | } 17 | } 18 | return out, 0, err 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # go-utils 2 | 3 | This repo contains common utilities for go projects. 4 | 5 | ## Contents 6 | 7 | There are a number of useful Go libraries in this repo, including: 8 | 9 | - `versionutils`: utilities for parsing and comparing versions and tags, and resolving semver rules. 10 | - `changelogutils`: utilities for defining and enforcing rules about changelogs. 11 | - `contextutils`: utilities for logging based on context. 12 | - `manifesttestutils`: utilities for testing helm charts and installation manifests. 13 | -------------------------------------------------------------------------------- /loggingutils/grpc.go: -------------------------------------------------------------------------------- 1 | package loggingutils 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/solo-io/go-utils/contextutils" 7 | "go.uber.org/zap" 8 | "google.golang.org/grpc" 9 | ) 10 | 11 | func GrpcUnaryServerLoggerInterceptor(logger *zap.SugaredLogger) grpc.UnaryServerInterceptor { 12 | return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { 13 | ctx = contextutils.WithExistingLogger(ctx, logger) 14 | return handler(ctx, req) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testutils/goimpl/curl_test.go: -------------------------------------------------------------------------------- 1 | package goimpl 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | ) 7 | 8 | var _ = Describe("Curl", func() { 9 | 10 | It("should query a url", func() { 11 | soloResp, err := Curl("https://www.solo.io") 12 | Expect(err).NotTo(HaveOccurred()) 13 | Expect(len(soloResp)).To(BeNumerically(">", 0)) 14 | }) 15 | 16 | It("should error on invalid url", func() { 17 | _, err := Curl("invalid://www.solo.io") 18 | Expect(err).To(HaveOccurred()) 19 | }) 20 | 21 | }) 22 | -------------------------------------------------------------------------------- /changelog/v0.10.20/add-rc.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/go-utils/issues/323 4 | description: > 5 | Update versionutils to support a 4th digit, release candidate, on versions. Update the regex to optionally match on vX.X.X-rcX. 6 | Relax changelog incrementing validation to always allow incrementing to an rc release. Allow incrementing from 1.0.0-rc1 to 1.0.0 7 | by using `releaseStableApi`. In the future, we can generalize this flag to support migrating to any non-rc release. 8 | -------------------------------------------------------------------------------- /changelog/v0.10.28/version-increase-for-v1.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | description: > 4 | When verifying changelog entries after the v1.0.0 release, the version utils currently require a minor version bump 5 | for any non-breaking change. We need to update the logic to ensure that if a changelog entry is of type 6 | `BREAKING_CHANGE` we must bump the major version, if it is of type `NEW_FEATURE` we must bump the minor version, 7 | and else we have to bump the patch version. 8 | issueLink: https://github.com/solo-io/go-utils/issues/345 -------------------------------------------------------------------------------- /changelog/v0.2.10/release-asset-cli.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: A utility CLI has been added for uploading release artifacts to github, to replace the old shell script. See the [readme](https://github.com/solo-io/go-utils/tree/master/githubutils) for more information. 4 | issueLink: https://github.com/solo-io/go-utils/issues/38 5 | - type: FIX 6 | description: PushDocsCli no longer errors on the initial push when the destination directory doesn't exist. 7 | issueLink: https://github.com/solo-io/go-utils/issues/40 -------------------------------------------------------------------------------- /changelog/v0.27.0/remove-sarif-scanning.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: BREAKING_CHANGE 3 | description: > 4 | Remove unused code related to generating sarif security scans and uploading them to Github which relied on a dependency 5 | with a known CVE 6 | issueLink: https://github.com/solo-io/go-utils/issues/534 7 | - type: NON_USER_FACING 8 | description: > 9 | Update repo client tests that had gotten slow due to the number of releases since the last update and in one case 10 | which had broken due to a deleted release -------------------------------------------------------------------------------- /changelog/v0.11.0/helm-3.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | dependencyOwner: helm 4 | dependencyRepo: helm 5 | dependencyTag: v3.0.0 6 | description: Update Helm to version 3.0.0 7 | issueLink: https://github.com/solo-io/gloo/issues/1732 8 | resolvesIssue: false 9 | - type: BREAKING_CHANGE 10 | description: Helm has been updated to version 3.0.0, which has resulted in some changed type signatures on exported functions 11 | issueLink: https://github.com/solo-io/gloo/issues/1732 12 | resolvesIssue: false 13 | -------------------------------------------------------------------------------- /changelog/v0.21.17/add-split-output-logging.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/gloo/issues/5048 4 | resolvesIssue: false 5 | description: > 6 | When the SPLIT_LOG_OUTPUT environment variable is specified, a global logger is created with the following characteristics: 7 | debug/info/warning are written to stdout, error/fatal/panic are written to stderr 8 | Configuration is otherwise identical to the default logger 9 | When SPLIT_LOG_OUTPUT is unspecified, logging configuration is unchanged -------------------------------------------------------------------------------- /securityscanutils/issuewriter/issue_writer.go: -------------------------------------------------------------------------------- 1 | package issuewriter 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/google/go-github/v32/github" 7 | ) 8 | 9 | // IssueWriter writes the generated contents of a scan to a location, either a file on the local filesystem 10 | // or a GitHub issue. 11 | type IssueWriter interface { 12 | // Write writes `contents`, the results of a scan of the images in `release`, to a location 13 | // designated by the implementation. 14 | Write(ctx context.Context, release *github.RepositoryRelease, contents string) error 15 | } 16 | -------------------------------------------------------------------------------- /securityscanutils/issuewriter/noop_writer.go: -------------------------------------------------------------------------------- 1 | package issuewriter 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/google/go-github/v32/github" 7 | ) 8 | 9 | // NoopWriter provides a no-op implementation of the IssueWriter interface, used when the 10 | // specified scan action is `none`. 11 | type NoopWriter struct{} 12 | 13 | var _ IssueWriter = &NoopWriter{} 14 | 15 | func NewNoopWriter() IssueWriter { 16 | return &NoopWriter{} 17 | } 18 | 19 | func (n *NoopWriter) Write(_ context.Context, _ *github.RepositoryRelease, _ string) error { 20 | return nil 21 | } 22 | -------------------------------------------------------------------------------- /changelog/v0.2.9/cli_docs.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: The docs push utility now supports automated CLI docs. 4 | issueLink: https://github.com/solo-io/go-utils/issues/33 5 | - type: NEW_FEATURE 6 | description: The docs can support API or CLI docs that are not in the root of the repo. 7 | issueLink: https://github.com/solo-io/go-utils/issues/33 8 | - type: NEW_FEATURE 9 | description: The docs CLI library now includes the full CLI, so projects can execute docs push in 1 line. 10 | issueLink: https://github.com/solo-io/go-utils/issues/33 -------------------------------------------------------------------------------- /changelog/v0.21.6/bump-deps.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | dependencyOwner: golang 4 | dependencyRepo: crypto 5 | dependencyTag: v0.0.0-20210513164829-c07d793c2f9a 6 | - type: DEPENDENCY_BUMP 7 | dependencyOwner: palantir 8 | dependencyRepo: go-baseapp 9 | dependencyTag: v0.2.3 10 | - type: DEPENDENCY_BUMP 11 | dependencyOwner: spf13 12 | dependencyRepo: cobra 13 | dependencyTag: v1.1.3 14 | - type: FIX 15 | description: Use the form3tech-oss fork of jwt-go to fix CVE. 16 | issueLink: https://github.com/solo-io/gloo/issues/4722 17 | resolvesIssue: false -------------------------------------------------------------------------------- /changelog/v0.27.4/k8s-1.32-bump-related.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Bump dependencies to match k8s-utils changes for Kubernetes 1.32 5 | issueLink: https://github.com/solo-io/solo-projects/issues/7788 6 | resolvesIssue: false 7 | - type: DEPENDENCY_BUMP 8 | dependencyOwner: google 9 | dependencyRepo: protobuf 10 | dependencyTag: v1.35.1 11 | - type: DEPENDENCY_BUMP 12 | dependencyOwner: onsi 13 | dependencyRepo: gomega 14 | dependencyTag: v1.35.1 15 | - type: DEPENDENCY_BUMP 16 | dependencyOwner: go.uber.org 17 | dependencyRepo: zap 18 | dependencyTag: v1.27.0 -------------------------------------------------------------------------------- /changelog/v0.24.7/mapstructure-utils.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Normalizes and decodes map interfaces that can have (deeply nested) numbers of type json.Number 5 | by setting those to either to int64 or float64. 6 | 7 | Usually you don't need to normalize a map[string]interface{}, that you are decoding into a struct with mapstructure 8 | Unless, you will use it with `structpb.NewValue()` which doesn't handle that type and throws an invalid type error. 9 | 10 | issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/12608 11 | resolvesIssue: false 12 | -------------------------------------------------------------------------------- /clidoc/README.md: -------------------------------------------------------------------------------- 1 | # Generate standard Solo.io documentation from Cobra CLIs 2 | 3 | - Takes the entry point to a Cobra CLI (the root `*cobra.CMD`) and produces files formatted for Solo's online documentation 4 | 5 | ## Example usage 6 | - from Squash: 7 | ```go 8 | package main 9 | 10 | import ( 11 | "log" 12 | 13 | "github.com/solo-io/go-utils/clidoc" 14 | 15 | "github.com/solo-io/squash/pkg/squashctl" 16 | "github.com/solo-io/squash/pkg/version" 17 | ) 18 | 19 | func main() { 20 | app, err := squashctl.App(version.Version) 21 | if err != nil { 22 | log.Fatal(err) 23 | } 24 | clidoc.MustGenerateCliDocs(app) 25 | } 26 | ``` 27 | -------------------------------------------------------------------------------- /stats/stats_suite_test.go: -------------------------------------------------------------------------------- 1 | package stats_test 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/solo-io/go-utils/stats" 8 | 9 | . "github.com/onsi/ginkgo/v2" 10 | . "github.com/onsi/gomega" 11 | ) 12 | 13 | func TestStats(t *testing.T) { 14 | RegisterFailHandler(Fail) 15 | RunSpecs(t, "Stats Suite") 16 | } 17 | 18 | var _ = BeforeSuite(func() { 19 | // The stats server only starts if appropriate environment variable is set 20 | err := os.Setenv(stats.DefaultEnvVar, stats.DefaultEnabledValue) 21 | Expect(err).NotTo(HaveOccurred()) 22 | }) 23 | 24 | var _ = AfterSuite(func() { 25 | err := os.Unsetenv(stats.DefaultEnvVar) 26 | Expect(err).NotTo(HaveOccurred()) 27 | }) 28 | -------------------------------------------------------------------------------- /changelog/v0.7.7/github-manifest.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | The utilities in `installutils/helmchart` now support loading a helm chart and rendering manifests from a 5 | directory in a github repository. There is also a utility for batch loading charts from a github directory, 6 | for example to batch load several hundred charts from `https://github.com/helm/charts/tree/master/stable`. 7 | issueLink: https://github.com/solo-io/go-utils/issues/121 8 | - type: NEW_FEATURE 9 | description: There is now a new utility package called `fsutils` to support common file-system operations. 10 | issueLink: https://github.com/solo-io/go-utils/issues/122 -------------------------------------------------------------------------------- /vfsutils/vfs_test.go: -------------------------------------------------------------------------------- 1 | package vfsutils_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | "github.com/solo-io/go-utils/vfsutils" 7 | "github.com/spf13/afero" 8 | ) 9 | 10 | var _ = Describe("vfsutils", func() { 11 | Context("MountTar", func() { 12 | It("works", func() { 13 | fs := afero.NewMemMapFs() 14 | dir, err := vfsutils.MountTar(fs, "https://github.com/XiaoMi/naftis/releases/download/0.1.4-rc6/manifest.tar.gz") 15 | Expect(err).NotTo(HaveOccurred()) 16 | Expect(dir).NotTo(BeEquivalentTo("")) 17 | files, err := afero.ReadDir(fs, dir) 18 | Expect(err).NotTo(HaveOccurred()) 19 | Expect(len(files)).To(BeEquivalentTo(3)) 20 | }) 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /mapstructureutils/mapdecoder_suite_test.go: -------------------------------------------------------------------------------- 1 | package mapdecoder_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "go.uber.org/zap" 7 | 8 | "github.com/fgrosse/zaptest" 9 | "github.com/solo-io/go-utils/contextutils" 10 | 11 | . "github.com/onsi/ginkgo/v2" 12 | "github.com/onsi/ginkgo/v2/reporters" 13 | . "github.com/onsi/gomega" 14 | ) 15 | 16 | func TestMapDecoderServer(t *testing.T) { 17 | zaptest.Level = zap.InfoLevel 18 | logger := zaptest.LoggerWriter(GinkgoWriter) 19 | 20 | contextutils.SetFallbackLogger(logger.Sugar()) 21 | 22 | RegisterFailHandler(Fail) 23 | junitReporter := reporters.NewJUnitReporter("junit.xml") 24 | RunSpecsWithDefaultAndCustomReporters(t, "Map Decoder Suite", []Reporter{junitReporter}) 25 | } 26 | -------------------------------------------------------------------------------- /changelog/v0.9.0/config-env.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Support customizing bot config with WEBHOOK_SECRET, INTEGRATION_ID, and PRIVATE_KEY_FILE environment 5 | variables, to better support use cases around deploying to kubernetes from a git repo without checking in 6 | unencrypted secrets. 7 | issueLink: https://github.com/solo-io/go-utils/issues/223 8 | - type: BREAKING_CHANGE 9 | description: > 10 | Removes ApplicationConfig (containing slack notifications and installation id) from the bot config 11 | struct. This should only affect consumers of the new bot utilities (changelog-bot, approval-bot). 12 | issueLink: https://github.com/solo-io/go-utils/issues/223 -------------------------------------------------------------------------------- /securityscanutils/securityscanutils_suite_test.go: -------------------------------------------------------------------------------- 1 | package securityscanutils 2 | 3 | import ( 4 | "os/exec" 5 | "testing" 6 | 7 | "github.com/solo-io/go-utils/contextutils" 8 | "go.uber.org/zap/zapcore" 9 | 10 | . "github.com/onsi/ginkgo/v2" 11 | . "github.com/onsi/gomega" 12 | ) 13 | 14 | func TestSecurityScanUtil(t *testing.T) { 15 | RegisterFailHandler(Fail) 16 | RunSpecs(t, "SecurityScanUtils Suite") 17 | } 18 | 19 | var _ = BeforeSuite(func() { 20 | // This test suite requires that Trivy is installed and present in the PATH 21 | contextutils.SetLogLevel(zapcore.DebugLevel) 22 | 23 | path, err := exec.LookPath("trivy") 24 | ExpectWithOffset(1, err).NotTo(HaveOccurred()) 25 | ExpectWithOffset(1, path).NotTo(BeEmpty()) 26 | }) 27 | -------------------------------------------------------------------------------- /changelog/v0.24.6/bumps-to-support-k8s-1.27.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NON_USER_FACING 3 | description: > 4 | Bump dependencies to support Kubernetes 1.27 5 | issueLink: https://github.com/solo-io/gloo/issues/8214 6 | resolvesIssue: false 7 | - type: DEPENDENCY_BUMP 8 | dependencyOwner: onsi 9 | dependencyRepo: ginkgo/v2 10 | dependencyTag: v2.9.5 11 | - type: DEPENDENCY_BUMP 12 | dependencyOwner: onsi 13 | dependencyRepo: gomega 14 | dependencyTag: v1.27.7 15 | - type: DEPENDENCY_BUMP 16 | dependencyOwner: go.uber.org 17 | dependencyRepo: zap 18 | dependencyTag: v1.24.0 19 | - type: DEPENDENCY_BUMP 20 | dependencyOwner: sirupsen 21 | dependencyRepo: logrus 22 | dependencyTag: v1.9.0 -------------------------------------------------------------------------------- /maputils/ordered_map_iterate.go: -------------------------------------------------------------------------------- 1 | package maputils 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | // thank you R.P. 8 | // TODO(ilackarms): find a better way to solve generics than interface{} 9 | // consider using go-utils to generate 10 | func OrderedMapIterator(m map[string]interface{}, onKey func(key string, value interface{})) { 11 | var list []struct { 12 | key string 13 | value interface{} 14 | } 15 | for k, v := range m { 16 | list = append(list, struct { 17 | key string 18 | value interface{} 19 | }{ 20 | key: k, 21 | value: v, 22 | }) 23 | } 24 | sort.SliceStable(list, func(i, j int) bool { 25 | return list[i].key < list[j].key 26 | }) 27 | for _, el := range list { 28 | onKey(el.key, el.value) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /loggingutils/grpc_test.go: -------------------------------------------------------------------------------- 1 | package loggingutils_test 2 | 3 | import ( 4 | "context" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | "go.uber.org/zap" 9 | 10 | "github.com/solo-io/go-utils/contextutils" 11 | . "github.com/solo-io/go-utils/loggingutils" 12 | ) 13 | 14 | var _ = Describe("Grpc", func() { 15 | 16 | It("should inject log to context", func() { 17 | var logger zap.SugaredLogger 18 | var receivedLogger *zap.SugaredLogger 19 | 20 | f := GrpcUnaryServerLoggerInterceptor(&logger) 21 | f(context.Background(), "foo", nil, func(ctx context.Context, req interface{}) (interface{}, error) { 22 | receivedLogger = contextutils.LoggerFrom(ctx) 23 | return nil, nil 24 | }) 25 | Expect(receivedLogger).To(Equal(&logger)) 26 | }) 27 | 28 | }) 29 | -------------------------------------------------------------------------------- /changelog/v0.25.0/13501-report-missing-images-in-scan.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/13499 4 | description: > 5 | Scanner includes an optional Additional Context section on reported vulnerabilities. 6 | resolvesIssue: false 7 | - type: BREAKING_CHANGE 8 | issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/13499 9 | description: > 10 | Create `IssueWriter` interface with implementations as `NoopWriter`, `GithubIssueWriter`, and `LocalIssueWriter`. 11 | resolvesIssue: false 12 | - type: FIX 13 | issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/13501 14 | description: > 15 | Scanner continues to scan remaining images if one image cannot be found. 16 | -------------------------------------------------------------------------------- /changelogutils/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "os" 6 | 7 | "github.com/solo-io/go-utils/changelogutils" 8 | "github.com/solo-io/go-utils/log" 9 | ) 10 | 11 | // This is a reference script, showing how to call the generation script. 12 | // See the README.md file for an example of the output 13 | func main() { 14 | ctx := context.Background() 15 | repoRootPath := "." 16 | owner := "solo-io" 17 | repo := "go-utils" 18 | changelogDirPath := "changelog" 19 | 20 | // consider writing to stdout to enhance makefile/io readability `go run cmd/main.go > changelogSummary.md` 21 | w := os.Stdout 22 | err := changelogutils.GenerateChangelogFromLocalDirectory(ctx, repoRootPath, owner, repo, changelogDirPath, w) 23 | if err != nil { 24 | log.Fatalf("unable to run: %v", err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testutils/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Fail Handlers 3 | 4 | ## PrintTrimmedStack 5 | 6 | The `PrintTrimmedStack` fail handler simplifies error tracking in ginkgo tests by printing a condensed stack trace upon failure. Printout excludes well-known overhead files so you can more easily sight the failing line. This eliminates the need to count stack offset via `ExpectWithOffset`. You can just use `Expect`. 7 | 8 | 9 | ### Usage 10 | 11 | To use, register `PrintTrimmedStack` as a prefail handler with `RegisterPreFailHandler` in your `ginkgo` suite: 12 | 13 | ```go 14 | func TestCliCore(t *testing.T) { 15 | 16 | testutils.RegisterPreFailHandler( 17 | func() { 18 | testutils.PrintTrimmedStack() 19 | }) 20 | testutils.RegisterCommonFailHandlers() 21 | RegisterFailHandler(Fail) 22 | testutils.SetupLog() 23 | RunSpecs(t, "Clicore Suite") 24 | } 25 | ``` -------------------------------------------------------------------------------- /changelogutils/cli.go: -------------------------------------------------------------------------------- 1 | package changelogutils 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/solo-io/go-utils/githubutils" 7 | "github.com/spf13/afero" 8 | ) 9 | 10 | func GetChangelogMarkdownForPR(owner, repo string) (string, error) { 11 | client, err := githubutils.GetClient(context.Background()) 12 | if err != nil { 13 | return "", err 14 | } 15 | fs := afero.NewOsFs() 16 | latestTag, err := githubutils.FindLatestReleaseTagIncudingPrerelease(context.Background(), client, owner, repo) 17 | if err != nil { 18 | return "", err 19 | } 20 | proposedTag, err := GetProposedTag(fs, latestTag, "") 21 | if err != nil { 22 | return "", err 23 | } 24 | changelog, err := ComputeChangelogForNonRelease(fs, latestTag, proposedTag, "") 25 | if err != nil { 26 | return "", err 27 | } 28 | return GenerateChangelogMarkdown(changelog), nil 29 | } 30 | -------------------------------------------------------------------------------- /fileutils/messages.go: -------------------------------------------------------------------------------- 1 | package fileutils 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/ghodss/yaml" 7 | "github.com/gogo/protobuf/proto" 8 | "github.com/rotisserie/eris" 9 | "github.com/solo-io/go-utils/protoutils" 10 | ) 11 | 12 | func WriteToFile(filename string, pb proto.Message) error { 13 | jsn, err := protoutils.MarshalBytes(pb) 14 | if err != nil { 15 | return err 16 | } 17 | data, err := yaml.JSONToYAML(jsn) 18 | if err != nil { 19 | return err 20 | } 21 | return os.WriteFile(filename, data, 0644) 22 | } 23 | 24 | func ReadFileInto(filename string, v proto.Message) error { 25 | data, err := os.ReadFile(filename) 26 | if err != nil { 27 | return eris.Errorf("error reading file: %v", err) 28 | } 29 | jsn, err := yaml.YAMLToJSON(data) 30 | if err != nil { 31 | return err 32 | } 33 | return protoutils.UnmarshalBytes(jsn, v) 34 | } 35 | -------------------------------------------------------------------------------- /changelog/v0.21.27/trivy-github-issue-per-minor.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: FIX 3 | issueLink: https://github.com/solo-io/go-utils/issues/469 4 | resolvesIssue: false 5 | description: > 6 | Ensure the SecurityScanner scans all images for a set of minor versions. 7 | Previously, the scanner would only scan the latest patch release, which would cause docs which depend 8 | on these scans (as Gloo Edge does) to show empty scans. 9 | - type: FIX 10 | issueLink: https://github.com/solo-io/go-utils/issues/478 11 | resolvesIssue: true 12 | description: > 13 | Expose a new option 'CreateGithubIssueForLatestPatchVersion', which when enabled, will ensure that the 14 | SecurityScanner only creates Github issues to track the latest patch version as opposed to creating 15 | an issue for every version (which it has historically done) -------------------------------------------------------------------------------- /botutils/README.md: -------------------------------------------------------------------------------- 1 | # Botutils 2 | 3 | This package contains utilities for writing simple git bot applications. 4 | 5 | ## Implementing hooks 6 | 7 | Write a plugin that implements one or more of the handler interfaces defined in `interface.go`. 8 | 9 | ## Implementing a server 10 | 11 | Create an instance of SimpleGitBot: 12 | 13 | ```go 14 | func Run(ctx context.Context) error { 15 | staticCfg := botutils.StaticBotConfig{BotName: BotName, Version: version.Version} 16 | bot := botutils.NewSimpleGitBot(staticCfg) 17 | return bot.Start(context.TODO(), plugins...) 18 | } 19 | ``` 20 | 21 | ## Deploying the bot 22 | 23 | The bot needs to be deployed with a config that can be deserialized into the `botconfig.Config` struct. By default, 24 | this should be available at `/etc/solo-github-app/config.yml`, but can be mounted to a custom location 25 | by setting the `BOT_CONFIG` environment variable. -------------------------------------------------------------------------------- /clicore/mocker.go: -------------------------------------------------------------------------------- 1 | package clicore 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | type MockWriteSyncer struct { 8 | inputs []string 9 | syncCount uint 10 | inputCount uint 11 | } 12 | 13 | func (m *MockWriteSyncer) Write(in []byte) (int, error) { 14 | m.inputCount++ 15 | m.inputs = append(m.inputs, string(in)) 16 | return len(in), nil 17 | } 18 | func (m *MockWriteSyncer) Sync() error { 19 | m.syncCount++ 20 | return nil 21 | } 22 | func (m *MockWriteSyncer) Summarize() (string, uint, uint) { 23 | return strings.Join(m.inputs, ""), m.inputCount, m.syncCount 24 | } 25 | 26 | type MockTargets struct { 27 | Stdout *MockWriteSyncer 28 | Stderr *MockWriteSyncer 29 | FileLog *MockWriteSyncer 30 | } 31 | 32 | func NewMockTargets() MockTargets { 33 | return MockTargets{ 34 | Stdout: &MockWriteSyncer{}, 35 | Stderr: &MockWriteSyncer{}, 36 | FileLog: &MockWriteSyncer{}, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /testutils/fail_handler.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "fmt" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | var preFails []func() 11 | 12 | func RegisterPreFailHandler(prefail func()) { 13 | preFails = append(preFails, prefail) 14 | } 15 | 16 | func RegisterCommonFailHandlers() { 17 | RegisterPreFailHandler(waitOnFail) 18 | RegisterFailHandler(failHandler) 19 | } 20 | 21 | func failHandler(message string, callerSkip ...int) { 22 | fmt.Println("Fail handler msg", message) 23 | 24 | for _, preFail := range preFails { 25 | preFail() 26 | } 27 | 28 | // Account for this extra function in the call stack. 29 | // Without this all failure messages will show the incorrect line number! 30 | var shiftedCallerSkip []int 31 | for _, i := range callerSkip { 32 | shiftedCallerSkip = append(shiftedCallerSkip, i+1) 33 | } 34 | 35 | Fail(message, shiftedCallerSkip...) 36 | } 37 | -------------------------------------------------------------------------------- /cliutils/options.go: -------------------------------------------------------------------------------- 1 | package cliutils 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | type Options interface { 11 | Initialize() 12 | } 13 | 14 | type OptionsFunc = func(*cobra.Command) 15 | type CmdFunc = func(Options, ...OptionsFunc) *cobra.Command 16 | 17 | func ApplyOptions(cmd *cobra.Command, funcs []OptionsFunc) { 18 | for _, v := range funcs { 19 | v(cmd) 20 | } 21 | } 22 | 23 | func ReplaceCmd(parent *cobra.Command, new *cobra.Command) error { 24 | parentCmds := parent.Commands() 25 | for _, old := range parentCmds { 26 | if old.Use == new.Use { 27 | parent.RemoveCommand(old) 28 | parent.AddCommand(new) 29 | return nil 30 | } 31 | } 32 | return fmt.Errorf("did not find child command to replace") 33 | } 34 | 35 | func MustReplaceCmd(parent *cobra.Command, new *cobra.Command) { 36 | if err := ReplaceCmd(parent, new); err != nil { 37 | log.Fatal(err) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /changelog/v0.24.8/bump-k8s-128.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: DEPENDENCY_BUMP 3 | description: Bumped the go version for go.mod 4 | dependencyOwner: golang 5 | dependencyRepo: go 6 | dependencyTag: v1.19 7 | - type: NON_USER_FACING 8 | description: > 9 | Bump dependencies to support Kubernetes 1.28 10 | issueLink: https://github.com/solo-io/gloo/issues/8515 11 | resolvesIssue: false 12 | - type: DEPENDENCY_BUMP 13 | dependencyOwner: onsi 14 | dependencyRepo: ginkgo/v2 15 | dependencyTag: v2.11.0 16 | - type: DEPENDENCY_BUMP 17 | dependencyOwner: onsi 18 | dependencyRepo: gomega 19 | dependencyTag: v1.27.10 20 | - type: DEPENDENCY_BUMP 21 | dependencyOwner: sirupsen 22 | dependencyRepo: logrus 23 | dependencyTag: v1.9.3 24 | - type: DEPENDENCY_BUMP 25 | dependencyOwner: go.uber.org 26 | dependencyRepo: zap 27 | dependencyTag: v1.25.0 28 | - type: NON_USER_FACING 29 | description: > 30 | Modify repo_client tests so that they do not hit the GH rate limit 31 | -------------------------------------------------------------------------------- /slackutils/http.go: -------------------------------------------------------------------------------- 1 | package slackutils 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "net/http" 8 | 9 | "github.com/solo-io/go-utils/contextutils" 10 | "go.uber.org/zap" 11 | ) 12 | 13 | type HttpClient interface { 14 | PostJsonContent(ctx context.Context, message, url string) 15 | } 16 | 17 | type DefaultHttpClient struct{} 18 | 19 | func (*DefaultHttpClient) PostJsonContent(ctx context.Context, message, url string) { 20 | type Payload struct { 21 | Text string `json:"text"` 22 | } 23 | 24 | data := Payload{ 25 | Text: message, 26 | } 27 | payloadBytes, err := json.Marshal(data) 28 | if err != nil { 29 | contextutils.LoggerFrom(ctx).Errorw("Notifying slack failed", zap.Error(err)) 30 | return 31 | } 32 | body := bytes.NewReader(payloadBytes) 33 | 34 | req, err := http.Post(url, "application/json", body) 35 | defer req.Body.Close() 36 | if err != nil { 37 | contextutils.LoggerFrom(ctx).Errorw("Notifying slack failed", zap.Error(err)) 38 | return 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2012 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | 6 | # git gofmt pre-commit hook 7 | # 8 | # To use, store as .git/hooks/pre-commit inside your repository and make sure 9 | # it has execute permissions. 10 | # 11 | # This script does not handle file names that contain spaces. 12 | 13 | gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$') 14 | [ -z "$gofiles" ] && exit 0 15 | 16 | unformatted=$(gofmt -l $gofiles) 17 | badimports=$(goimports -l $gofiles) 18 | [ -z "$unformatted" ] && [ -z "$badimports" ] && exit 0 19 | 20 | # Some files are not gofmt'd or goimport'd. Print message and fail. 21 | 22 | echo >&2 "Go files must be formatted with gofmt and goimport. Please run:" 23 | for fn in $unformatted; do 24 | echo >&2 " gofmt -w $PWD/$fn" 25 | done 26 | for fn in $badimports; do 27 | echo >&2 " goimports -w $PWD/$fn" 28 | done 29 | 30 | exit 1 31 | -------------------------------------------------------------------------------- /testutils/goimpl/curl.go: -------------------------------------------------------------------------------- 1 | package goimpl 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "net/http" 7 | ) 8 | 9 | // Curl provides some of the functionality you would expect from the curl command. 10 | // This saves you from having to call the curl binary in environments where that binary is not available. 11 | func Curl(url string) (string, error) { 12 | body := bytes.NewReader([]byte(url)) 13 | req, err := http.NewRequest("GET", url, body) 14 | if err != nil { 15 | return "", err 16 | } 17 | 18 | return ExecuteRequest(req) 19 | } 20 | 21 | // ExecuteRequest provides some of the functionality you would expect from the curl command. 22 | // This saves you from having to call the curl binary in environments where that binary is not available. 23 | func ExecuteRequest(request *http.Request) (string, error) { 24 | resp, err := http.DefaultClient.Do(request) 25 | if err != nil { 26 | return "", err 27 | } 28 | p := new(bytes.Buffer) 29 | _, err = io.Copy(p, resp.Body) 30 | defer resp.Body.Close() 31 | 32 | return p.String(), nil 33 | } 34 | -------------------------------------------------------------------------------- /versionutils/kubeapi/list_test.go: -------------------------------------------------------------------------------- 1 | package kubeapi_test 2 | 3 | import ( 4 | "math/rand" 5 | "sort" 6 | "time" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | "github.com/solo-io/go-utils/versionutils/kubeapi" 11 | ) 12 | 13 | var _ = Describe("VersionList", func() { 14 | Describe("sort", func() { 15 | It("works", func() { 16 | orderedVersions := []string{"v1alpha1", "v1beta1", "v1beta2", "v1", "v2beta1", "v2beta2", "v4", "v5alpha2", "v5beta1"} 17 | 18 | subject := make(kubeapi.VersionList, 0, len(orderedVersions)) 19 | for _, v := range orderedVersions { 20 | parsedVersion, err := kubeapi.ParseVersion(v) 21 | Expect(err).NotTo(HaveOccurred()) 22 | subject = append(subject, parsedVersion) 23 | } 24 | rand.Seed(time.Now().UnixNano()) 25 | rand.Shuffle(subject.Len(), subject.Swap) 26 | 27 | sort.Slice(subject, subject.Less) 28 | 29 | for i, apiVersion := range subject { 30 | Expect(apiVersion.String()).To(Equal(orderedVersions[i])) 31 | } 32 | }) 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /pkgmgmtutils/internal/remote_sha_getter.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "net/http" 7 | "strings" 8 | 9 | "github.com/rotisserie/eris" 10 | "github.com/solo-io/go-utils/pkgmgmtutils/formula_updater_types" 11 | ) 12 | 13 | var ErrNoShaDataFound = eris.New("pkgmgmtutils: no data in SHA256 file") 14 | 15 | func NewRemoteShaGetter() formula_updater_types.RemoteShaGetter { 16 | return &remoteShaGetter{} 17 | } 18 | 19 | type remoteShaGetter struct{} 20 | 21 | func (*remoteShaGetter) GetShaFromUrl(url string) (sha string, err error) { 22 | resp, err := http.Get(url) 23 | if err != nil { 24 | return "", err 25 | } 26 | defer resp.Body.Close() 27 | 28 | b, err := ioutil.ReadAll(resp.Body) 29 | if err != nil { 30 | return "", err 31 | } 32 | 33 | if !(len(b) > 0) { 34 | return "", ErrNoShaDataFound 35 | } 36 | 37 | s := strings.Fields(string(b)) 38 | if len(s) != 2 { 39 | return "", fmt.Errorf("pkgmgmtutils: Sha256 file %s is not in expected format", url) 40 | } 41 | 42 | return s[0], nil 43 | } 44 | -------------------------------------------------------------------------------- /hack/increment_semver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Increment a version string using Semantic Versioning (SemVer) terminology. 4 | 5 | # Parse command line options. 6 | 7 | # Taken from https://github.com/fmahnke/shell-semver 8 | 9 | while getopts ":Mmp" Option 10 | do 11 | case $Option in 12 | M ) major=true;; 13 | m ) minor=true;; 14 | p ) patch=true;; 15 | esac 16 | done 17 | 18 | shift $(($OPTIND - 1)) 19 | 20 | version=$1 21 | 22 | # Build array from version string. 23 | 24 | a=( ${version//./ } ) 25 | 26 | # If version string is missing or has the wrong number of members, show usage message. 27 | 28 | if [ ${#a[@]} -ne 3 ] 29 | then 30 | echo "usage: $(basename $0) [-Mmp] major.minor.patch" 31 | exit 1 32 | fi 33 | 34 | # Increment version numbers as requested. 35 | 36 | if [ ! -z $major ] 37 | then 38 | ((a[0]++)) 39 | a[1]=0 40 | a[2]=0 41 | fi 42 | 43 | if [ ! -z $minor ] 44 | then 45 | ((a[1]++)) 46 | a[2]=0 47 | fi 48 | 49 | if [ ! -z $patch ] 50 | then 51 | ((a[2]++)) 52 | fi 53 | 54 | echo "${a[0]}.${a[1]}.${a[2]}" -------------------------------------------------------------------------------- /docker/exec.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "os/exec" 7 | ) 8 | 9 | func Command(args ...string) *containerCmd { 10 | return &containerCmd{ 11 | args: args, 12 | stderr: os.Stderr, 13 | stdout: os.Stdout, 14 | } 15 | } 16 | 17 | // containerCmd implements exec.Cmd for docker containers 18 | type containerCmd struct { 19 | nameOrID string // the container name or ID 20 | args []string 21 | env []string 22 | stdin io.Reader 23 | stdout io.Writer 24 | stderr io.Writer 25 | } 26 | 27 | func (c *containerCmd) Run() error { 28 | var args []string 29 | 30 | // set env 31 | for _, env := range c.env { 32 | args = append(args, "-e", env) 33 | } 34 | args = append( 35 | args, 36 | // finally, with the caller args 37 | c.args..., 38 | ) 39 | 40 | cmd := exec.Command("docker", args...) 41 | if c.stdin != nil { 42 | cmd.Stdin = c.stdin 43 | } 44 | if c.stderr != nil { 45 | cmd.Stderr = c.stderr 46 | } 47 | if c.stdout != nil { 48 | cmd.Stdout = c.stdout 49 | } 50 | return cmd.Run() 51 | } 52 | -------------------------------------------------------------------------------- /stats/runtime.go: -------------------------------------------------------------------------------- 1 | package stats 2 | 3 | import ( 4 | "context" 5 | "runtime" 6 | "time" 7 | 8 | "go.opencensus.io/stats" 9 | "go.opencensus.io/stats/view" 10 | ) 11 | 12 | var ( 13 | MNumGoRoutines = stats.Int64("runtime/goroutines", "The number of goroutines", "1") 14 | 15 | GoroutinesNumView = &view.View{ 16 | Name: "runtime/goroutines", 17 | Measure: MNumGoRoutines, 18 | Description: "The number of goroutines", 19 | Aggregation: view.Sum(), 20 | } 21 | ) 22 | 23 | func init() { 24 | view.Register(GoroutinesNumView) 25 | } 26 | 27 | func RunGoroutineStat() { 28 | RunCancellableGoroutineStat(context.Background()) 29 | } 30 | 31 | func RunCancellableGoroutineStat(ctx context.Context) { 32 | numgoroutines := int64(0) 33 | for { 34 | select { 35 | default: 36 | time.Sleep(time.Second) 37 | newnumgoroutines := int64(runtime.NumGoroutine()) 38 | diff := newnumgoroutines - numgoroutines 39 | numgoroutines = newnumgoroutines 40 | if diff != 0 { 41 | stats.Record(context.TODO(), MNumGoRoutines.M(diff)) 42 | } 43 | case <-ctx.Done(): 44 | return 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /testutils/errors_test.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | "github.com/rotisserie/eris" 7 | ) 8 | 9 | var _ = Describe("eris errors", func() { 10 | var ( 11 | baseError = eris.New("base error") 12 | wrapperError1 = eris.Wrap(baseError, "wrapper 1") 13 | wrapperError2 = eris.Wrap(wrapperError1, "wrapper 2") 14 | ) 15 | 16 | It("can compare underlying error values", func() { 17 | Expect(baseError).To(HaveInErrorChain(baseError), "Identity should work") 18 | Expect(wrapperError1).To(HaveInErrorChain(baseError), "Chaining should work") 19 | Expect(wrapperError2).To(HaveInErrorChain(baseError), "Chaining should work at any depth") 20 | Expect(wrapperError2).To(HaveInErrorChain(wrapperError1), "Chaining should pick up intermediate errors") 21 | Expect(wrapperError2).NotTo(HaveInErrorChain(eris.New("dummy error")), "Should not pick up errors that are not in the chain") 22 | Expect(wrapperError2).NotTo(HaveInErrorChain(nil), "nil as the expected error should not blow up") 23 | Expect(nil).NotTo(HaveInErrorChain(baseError), "nil as the actual error should not blow up") 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /vfsutils/mount_test.go: -------------------------------------------------------------------------------- 1 | package vfsutils_test 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/solo-io/go-utils/githubutils" 7 | "github.com/solo-io/go-utils/vfsutils" 8 | 9 | . "github.com/onsi/ginkgo/v2" 10 | . "github.com/onsi/gomega" 11 | ) 12 | 13 | var _ = Describe("mounted repo utils", func() { 14 | 15 | const ( 16 | owner = "solo-io" 17 | repo = "testrepo" 18 | sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a" 19 | ) 20 | 21 | var ( 22 | ctx = context.Background() 23 | mountedRepo vfsutils.MountedRepo 24 | ) 25 | 26 | BeforeEach(func() { 27 | client, err := githubutils.GetClient(ctx) 28 | Expect(err).NotTo(HaveOccurred()) 29 | mountedRepo = vfsutils.NewLazilyMountedRepo(client, owner, repo, sha) 30 | }) 31 | 32 | It("can get contents", func() { 33 | contents, err := mountedRepo.GetFileContents(ctx, "tmp.txt") 34 | Expect(err).NotTo(HaveOccurred()) 35 | Expect(string(contents)).To(ContainSubstring("another")) 36 | }) 37 | 38 | It("can list files", func() { 39 | files, err := mountedRepo.ListFiles(ctx, "namespace") 40 | Expect(err).NotTo(HaveOccurred()) 41 | Expect(len(files)).To(Equal(1)) 42 | }) 43 | 44 | }) 45 | -------------------------------------------------------------------------------- /fileutils/messages_test.go: -------------------------------------------------------------------------------- 1 | package fileutils_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | 7 | "io/ioutil" 8 | "os" 9 | 10 | "github.com/gogo/protobuf/types" 11 | . "github.com/solo-io/go-utils/fileutils" 12 | ) 13 | 14 | var _ = Describe("Messages", func() { 15 | var filename string 16 | BeforeEach(func() { 17 | f, err := ioutil.TempFile("", "messages_test") 18 | Expect(err).NotTo(HaveOccurred()) 19 | filename = f.Name() 20 | }) 21 | AfterEach(func() { 22 | os.RemoveAll(filename) 23 | }) 24 | It("Writes and reads proto messages into files", func() { 25 | input := &types.Struct{ 26 | Fields: map[string]*types.Value{ 27 | "foo": { 28 | Kind: &types.Value_StringValue{StringValue: "bar"}, 29 | }, 30 | }, 31 | } 32 | err := WriteToFile(filename, input) 33 | Expect(err).NotTo(HaveOccurred()) 34 | 35 | b, err := ioutil.ReadFile(filename) 36 | Expect(err).NotTo(HaveOccurred()) 37 | 38 | Expect(string(b)).To(Equal("foo: bar\n")) 39 | 40 | var output types.Struct 41 | err = ReadFileInto(filename, &output) 42 | Expect(err).NotTo(HaveOccurred()) 43 | Expect(output).To(Equal(*input)) 44 | }) 45 | }) 46 | -------------------------------------------------------------------------------- /botutils/interface.go: -------------------------------------------------------------------------------- 1 | package botutils 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/google/go-github/v32/github" 7 | ) 8 | 9 | type Plugin interface { 10 | } 11 | 12 | type PullRequestHandler interface { 13 | Plugin 14 | HandlePREvent(ctx context.Context, client *github.Client, event *github.PullRequestEvent) error 15 | } 16 | 17 | type PullRequestReviewHandler interface { 18 | Plugin 19 | HandlePullRequestReviewEvent(ctx context.Context, client *github.Client, event *github.PullRequestReviewEvent) error 20 | } 21 | 22 | type IssueCommentHandler interface { 23 | Plugin 24 | HandleIssueCommentEvent(ctx context.Context, client *github.Client, event *github.IssueCommentEvent) error 25 | } 26 | 27 | type CommitCommentHandler interface { 28 | Plugin 29 | HandleCommitCommentEvent(ctx context.Context, client *github.Client, event *github.CommitCommentEvent) error 30 | } 31 | 32 | type ReleaseHandler interface { 33 | Plugin 34 | HandleReleaseEvent(ctx context.Context, client *github.Client, event *github.ReleaseEvent) error 35 | } 36 | 37 | type IssuesHandler interface { 38 | Plugin 39 | HandleIssuesEvent(ctx context.Context, client *github.Client, event *github.IssuesEvent) error 40 | } 41 | -------------------------------------------------------------------------------- /changelog/v0.7.14/clicore.yaml: -------------------------------------------------------------------------------- 1 | changelog: 2 | - type: NEW_FEATURE 3 | description: > 4 | Introduce a utility for managing zap logs from a CLI tool. The new `clicore` 5 | library provides a means of sending human-friendly log messages to the console 6 | while capturing full json-formatted logs to a file. Library includes a pair of 7 | `Run` methods for siplified execution of the "main" file and simplified output 8 | validation during integration tests. 9 | issueLink: https://github.com/solo-io/go-utils/issues/135 10 | - type: NEW_FEATURE 11 | description: Simplified way to call cobra commands from test environments. 12 | issueLink: https://github.com/solo-io/go-utils/issues/124 13 | - type: NEW_FEATURE 14 | description: > 15 | The `PrintTrimmedStack` fail handler simplifies error tracking in ginkgo tests 16 | by printing a condensed stack trace upon failure. Printout excludes well-known 17 | overhead files so you can more easily sight the failing line. This eliminates 18 | the need to count stack offset via `ExpectWithOffset`. You can just use 19 | `Expect`. 20 | issueLink: https://github.com/solo-io/go-utils/issues/131 21 | 22 | -------------------------------------------------------------------------------- /test/checks/checks_test.go: -------------------------------------------------------------------------------- 1 | package checks 2 | 3 | import ( 4 | "io/ioutil" 5 | "os/exec" 6 | "strings" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | "golang.org/x/mod/modfile" 11 | ) 12 | 13 | var _ = Describe("Checks", func() { 14 | 15 | It("should used forked klog instead of klog", func() { 16 | // regular klog writes to disk, so make sure we used a forked version that doesn't write to 17 | // disk, which is a problem with hardened containers with root only file systems. 18 | 19 | gomod, err := exec.Command("go", "env", "GOMOD").CombinedOutput() 20 | Expect(err).NotTo(HaveOccurred()) 21 | gomodfile := strings.TrimSpace(string(gomod)) 22 | data, err := ioutil.ReadFile(gomodfile) 23 | Expect(err).NotTo(HaveOccurred()) 24 | 25 | modFile, err := modfile.Parse(gomodfile, data, nil) 26 | Expect(err).NotTo(HaveOccurred()) 27 | 28 | for _, dep := range modFile.Require { 29 | // let's not depend on these in go utils, as go utils is used in a lot of places 30 | // and we want to keep it lean 31 | Expect(dep.Mod.Path).NotTo(HavePrefix("k8s.io/")) 32 | Expect(dep.Mod.Path).NotTo(HavePrefix("sigs.k8s.io/controller-runtime/")) 33 | } 34 | 35 | }) 36 | 37 | }) 38 | -------------------------------------------------------------------------------- /stringutils/strings_test.go: -------------------------------------------------------------------------------- 1 | package stringutils_test 2 | 3 | import ( 4 | "strings" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | "github.com/solo-io/go-utils/stringutils" 9 | ) 10 | 11 | var _ = Describe("stringutils", func() { 12 | Context("MapStringSlice", func() { 13 | var ( 14 | stringSlice []string 15 | ) 16 | 17 | BeforeEach(func() { 18 | stringSlice = []string{"a", "b", "c", "d", "e"} 19 | }) 20 | 21 | It("works", func() { 22 | transformedSlice := stringutils.MapStringSlice(stringSlice, strings.ToUpper) 23 | Expect(transformedSlice).To(Equal([]string{"A", "B", "C", "D", "E"})) 24 | Expect(stringSlice).To(Equal([]string{"a", "b", "c", "d", "e"})) 25 | }) 26 | }) 27 | 28 | Context("StringSliceToHashSet", func() { 29 | var ( 30 | stringSlice []string 31 | ) 32 | 33 | BeforeEach(func() { 34 | stringSlice = []string{"a", "b", "c", "d", "e", "e"} 35 | }) 36 | 37 | It("Works", func() { 38 | hashSet := stringutils.StringSliceToHashSet(stringSlice) 39 | for _, s := range stringSlice { 40 | Expect(hashSet).To(HaveKeyWithValue(s, true)) 41 | } 42 | Expect(stringSlice).To(Equal([]string{"a", "b", "c", "d", "e", "e"})) 43 | }) 44 | }) 45 | }) 46 | -------------------------------------------------------------------------------- /testutils/assertions.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "github.com/gogo/protobuf/proto" 5 | . "github.com/onsi/gomega" 6 | ) 7 | 8 | // ExpectEqualProtoMessages provides richer error messages than struct comparison by leveraging the String() method that all 9 | // proto Messages provide. On error, Gomega's string comparison utility prints a few characters of the text immediately 10 | // surrounding the first discrepancy. 11 | // 12 | // Variadic optionalDescription argument is passed on to fmt.Sprintf() and is used to annotate failure messages. 13 | // 14 | // Example of the output: 15 | // 16 | // optionalDescription is rendered here: template string with values foo and bar 17 | // Expected 18 | // : "...-1010" vers..." 19 | // to equal | 20 | // : "...-10101" ver..." 21 | func ExpectEqualProtoMessages(a, b proto.Message, optionalDescription ...interface{}) { 22 | if proto.Equal(a, b) { 23 | return 24 | } 25 | // One shortcoming is that you only get +/- 5 chars of context 26 | // per: https://github.com/onsi/gomega/blob/master/format/format.go#L146 27 | // TODO(mitchdraft) gomega pr to modify charactersAroundMismatchToInclude (if not merged will make a util) 28 | Expect(a.String()).To(Equal(b.String()), optionalDescription...) 29 | } 30 | -------------------------------------------------------------------------------- /pkgmgmtutils/formula_updater_types/opts.go: -------------------------------------------------------------------------------- 1 | package formula_updater_types 2 | 3 | type FormulaOptions struct { 4 | Name string // Descriptive name to be used for logging and general identification 5 | FormulaName string // proper formula name without file extension 6 | Path string // repo relative path with file extension 7 | RepoOwner string // repo owner for Formula change 8 | RepoName string // repo name for Formula change 9 | PRRepoOwner string // optional, empty means use RepoOwner 10 | PRRepoName string // optional, empty means use RepoName 11 | PRBranch string // optional, default to master 12 | PRDescription string 13 | PRCommitName string 14 | PRCommitEmail string 15 | VersionRegex string 16 | VersionShaRegex string 17 | DarwinShaRegex string 18 | LinuxShaRegex string 19 | WindowsShaRegex string 20 | 21 | // If true, open a PR even if this version is something other than a stable version. For example, "x.y.z-beta1" 22 | // Note that per https://docs.brew.sh/Acceptable-Formulae#stable-versions, this is not allowed for homebrew-core 23 | PublishUnstableVersion bool 24 | DryRun bool 25 | } 26 | 27 | type FormulaStatus struct { 28 | Name string 29 | Updated bool 30 | Err error 31 | } 32 | -------------------------------------------------------------------------------- /securityscanutils/issuewriter/local_writer.go: -------------------------------------------------------------------------------- 1 | package issuewriter 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | "path" 8 | 9 | "github.com/Masterminds/semver/v3" 10 | "github.com/google/go-github/v32/github" 11 | ) 12 | 13 | // LocalIssueWriter writes the scan results to a file on the local file system. 14 | type LocalIssueWriter struct { 15 | // The directory in which to create files 16 | outputDir string 17 | } 18 | 19 | var _ IssueWriter = &LocalIssueWriter{} 20 | 21 | func NewLocalIssueWriter(outputDir string) (IssueWriter, error) { 22 | // Set up the directory structure for local output 23 | err := os.MkdirAll(outputDir, os.ModePerm) 24 | if err != nil { 25 | return nil, err 26 | } 27 | return &LocalIssueWriter{ 28 | outputDir: outputDir, 29 | }, nil 30 | } 31 | 32 | func (l *LocalIssueWriter) Write(_ context.Context, release *github.RepositoryRelease, contents string) error { 33 | version, err := semver.NewVersion(release.GetTagName()) 34 | if err != nil { 35 | return err 36 | } 37 | filename := path.Join(l.outputDir, version.String()+".md") 38 | f, err := os.OpenFile(filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) 39 | if err != nil { 40 | return err 41 | } 42 | _, err = fmt.Fprintf(f, contents) 43 | if err != nil { 44 | return err 45 | } 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /envutils/vars.go: -------------------------------------------------------------------------------- 1 | package envutils 2 | 3 | import ( 4 | "context" 5 | "os" 6 | "strconv" 7 | 8 | "go.uber.org/zap" 9 | 10 | "github.com/solo-io/go-utils/contextutils" 11 | ) 12 | 13 | func MustGetPodNamespace(ctx context.Context) string { 14 | contextutils.LoggerFrom(ctx).Infow("Looking for install namespace in POD_NAMESPACE environment variable") 15 | namespace := os.Getenv("POD_NAMESPACE") 16 | if namespace == "" { 17 | contextutils.LoggerFrom(ctx).Fatalw("Could not determine namespace, must have non-empty POD_NAMESPACE in environment") 18 | } 19 | contextutils.LoggerFrom(ctx).Infow("Found install namespace", zap.String("installNamespace", namespace)) 20 | return namespace 21 | } 22 | 23 | func MustGetGrpcPort(ctx context.Context) int { 24 | contextutils.LoggerFrom(ctx).Infow("Looking for grpc port in GRPC_PORT environment variable") 25 | port := os.Getenv("GRPC_PORT") 26 | if port == "" { 27 | contextutils.LoggerFrom(ctx).Fatalw("Could not determine port, must have non-empty GRPC_PORT in environment") 28 | } 29 | p, err := strconv.Atoi(port) 30 | if err != nil { 31 | contextutils.LoggerFrom(ctx).Fatalw("Failed to parse grpc port", 32 | zap.Error(err), 33 | zap.String("port", port)) 34 | } 35 | contextutils.LoggerFrom(ctx).Infow("Found grpc port", zap.Int("grpcPort", p)) 36 | return p 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/codeformat.yaml: -------------------------------------------------------------------------------- 1 | name: pull_request 2 | on: pull_request 3 | jobs: 4 | codegen: 5 | name: Code format check 6 | runs-on: ubuntu-22.04 7 | steps: 8 | - name: Cancel Previous Actions 9 | uses: styfle/cancel-workflow-action@0.11.0 10 | with: 11 | access_token: ${{ github.token }} 12 | - name: Free disk space 13 | run: | 14 | echo "Before clearing disk space:" 15 | df -h 16 | 17 | # https://github.com/actions/virtual-environments/issues/709 18 | sudo apt-get clean 19 | 20 | # Clean up pre-installed tools 21 | # https://github.com/actions/virtual-environments/issues/1918 22 | sudo rm -rf /usr/share/dotnet 23 | sudo rm -rf /opt/ghc 24 | sudo rm -rf /usr/local/share/boost 25 | sudo rm -rf $AGENT_TOOLSDIRECTORY 26 | 27 | echo "After clearing disk space:" 28 | df -h 29 | - name: Check out code into the Go module directory 30 | uses: actions/checkout@v3 31 | with: 32 | fetch-depth: 0 33 | - name: Set up Go 34 | uses: actions/setup-go@v4 35 | with: 36 | go-version-file: "go.mod" 37 | id: go 38 | - name: Check code format 39 | run: | 40 | ./ci/check-code-format.sh 41 | -------------------------------------------------------------------------------- /securityscanutils/README.md: -------------------------------------------------------------------------------- 1 | ## Trivy Security Scanning 2 | 3 | Trivy is a security scanning tool which we use to scan our images for vulnerabilities. 4 | You can run a trivy scan identical to CI on your own command line by installing trivy and running 5 | ```shell 6 | trivy image --severity HIGH,CRITICAL quay.io/solo-io/: 7 | ``` 8 | 9 | ## Using securityscanutils 10 | Using the utils here is as easy as using the CLI defined in the cli subdirectory. The snippet 11 | below shows the output the said CLI's `help` command. 12 | 13 | The `GITHUB_TOKEN` environment variable must be set for security scanning to work. 14 | 15 | ```bash 16 | go-utils/securityscan % go run ./cli/main.go help 17 | 18 | CLI for identifying CVEs in images 19 | 20 | Usage: 21 | cvectl [command] 22 | 23 | Available Commands: 24 | format-results Pull down security scan files from gcloud bucket and generate docs markdown file 25 | help Help about any command 26 | scan-repo Run Trivy scans against images for the repo specified and upload scan results to a google cloud bucket 27 | scan-version Run Trivy scans against images for a single version 28 | 29 | Flags: 30 | -h, --help help for cvectl 31 | -v, --verbose Enable verbose logging 32 | 33 | Use "cvectl [command] --help" for more information about a command. 34 | ``` -------------------------------------------------------------------------------- /testutils/fail_handler_unix.go: -------------------------------------------------------------------------------- 1 | //go:build !windows 2 | // +build !windows 3 | 4 | package testutils 5 | 6 | import ( 7 | "fmt" 8 | "io/ioutil" 9 | "os" 10 | "os/signal" 11 | "runtime/debug" 12 | "strings" 13 | "syscall" 14 | ) 15 | 16 | func init() { 17 | 18 | waitOnFail = func() { 19 | 20 | if os.Getenv("WAIT_ON_FAIL") == "0" { 21 | return 22 | } 23 | 24 | if os.Getenv("WAIT_ON_FAIL") == "1" || IsDebuggerPresent() { 25 | // wait for sig usr1 26 | c := make(chan os.Signal, 1) 27 | signal.Notify(c, syscall.SIGUSR1) 28 | defer signal.Reset(syscall.SIGUSR1) 29 | fmt.Println("We are here:") 30 | debug.PrintStack() 31 | fmt.Printf("Waiting for human intervention. to continue, run 'kill -SIGUSR1 %d'\n", os.Getpid()) 32 | <-c 33 | } 34 | } 35 | 36 | IsDebuggerPresent = func() bool { 37 | f, err := ioutil.ReadFile("/proc/self/status") 38 | if err != nil { 39 | // no status so we don't know 40 | return false 41 | } 42 | status := string(f) 43 | if !strings.Contains(status, "TracerPid:") { 44 | // no tracer pid field, so we don't know 45 | return false 46 | } 47 | 48 | if strings.Contains(status, "TracerPid:\t0") { 49 | // no tracer pid - no debugger 50 | return false 51 | } 52 | // tracer pid is present and not zero - we have a debugger 53 | return true 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /securityscanutils/trivy_templates.go: -------------------------------------------------------------------------------- 1 | package securityscanutils 2 | 3 | import ( 4 | "io/ioutil" 5 | 6 | "github.com/rotisserie/eris" 7 | ) 8 | 9 | // Template for markdown docs 10 | const MarkdownTrivyTemplate = `{{- if . }} 11 | {{- range . }} 12 | {{- if (eq (len .Vulnerabilities) 0) }} 13 | 14 | No Vulnerabilities Found for {{.Target}} 15 | {{- else }} 16 | 17 | Vulnerabilities Listed for {{.Target}} 18 | 19 | Vulnerability ID|Package|Severity|Installed Version|Fixed Version|Reference 20 | ---|---|---|---|---|--- 21 | {{- range .Vulnerabilities }} 22 | {{ .VulnerabilityID }}|{{ .PkgName }}|{{ .Vulnerability.Severity }}|{{ .InstalledVersion }}|{{ .FixedVersion }}|{{ .PrimaryURL }} 23 | {{- end }} 24 | {{- end }} 25 | {{- end }} 26 | {{- else }} 27 | Trivy Returned Empty Report 28 | {{- end }}` 29 | 30 | // Create tempoarary file that contains the trivy template 31 | // Trivy CLI only accepts files as input for a template, so this is a workaround 32 | func GetTemplateFile(trivyTemplate string) (string, error) { 33 | f, err := ioutil.TempFile("", "") 34 | if err != nil { 35 | return "", eris.Wrap(err, "Unable to create temporary file to write template to") 36 | } 37 | _, err = f.Write([]byte(trivyTemplate)) 38 | if err != nil { 39 | return "", eris.Wrapf(err, "Unable to write template to file %s", f.Name()) 40 | } 41 | f.Close() 42 | return f.Name(), nil 43 | } 44 | -------------------------------------------------------------------------------- /log/log.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "regexp" 8 | "runtime" 9 | "time" 10 | 11 | "github.com/k0kubun/pp" 12 | ) 13 | 14 | var debugMode = os.Getenv("DEBUG") == "1" 15 | var DefaultOut io.Writer = os.Stdout 16 | 17 | func init() { 18 | if os.Getenv("DISABLE_COLOR") == "1" { 19 | pp.ColoringEnabled = false 20 | } 21 | } 22 | 23 | var rxp = regexp.MustCompile(".*/src/") 24 | 25 | func Sprintf(format string, a ...interface{}) string { 26 | return pp.Sprintf("%v\t"+format, append([]interface{}{line()}, a...)...) 27 | } 28 | 29 | func GreyPrintf(format string, a ...interface{}) { 30 | fmt.Fprintf(DefaultOut, "%v\t"+format+"\n", append([]interface{}{line()}, a...)...) 31 | } 32 | 33 | func Printf(format string, a ...interface{}) { 34 | fmt.Fprintln(DefaultOut, Sprintf(format, a...)) 35 | } 36 | 37 | func Warnf(format string, a ...interface{}) { 38 | fmt.Fprintln(DefaultOut, Sprintf("WARNING:\n"+format+"\n", a...)) 39 | } 40 | 41 | func Debugf(format string, a ...interface{}) { 42 | if debugMode { 43 | fmt.Fprintln(DefaultOut, Sprintf(format, a...)) 44 | } 45 | } 46 | 47 | func Fatalf(format string, a ...interface{}) { 48 | fmt.Fprintln(DefaultOut, Sprintf(format, a...)) 49 | os.Exit(1) 50 | } 51 | 52 | func line() string { 53 | _, file, line, _ := runtime.Caller(3) 54 | file = rxp.ReplaceAllString(file, "") 55 | return fmt.Sprintf("%v: %v:%v", time.Now().Format(time.RFC1123), file, line) 56 | } 57 | -------------------------------------------------------------------------------- /cliutils/flags.go: -------------------------------------------------------------------------------- 1 | package cliutils 2 | 3 | import ( 4 | errors "github.com/rotisserie/eris" 5 | "github.com/spf13/cobra" 6 | "github.com/spf13/pflag" 7 | ) 8 | 9 | type HideableFlag interface { 10 | MarkHidden(string) error 11 | } 12 | 13 | // MustMarkHidden panics if the call to MarkHidden() fails. 14 | func MustMarkHidden(flags HideableFlag, name string) { 15 | if err := flags.MarkHidden(name); err != nil { 16 | panic(err) 17 | } 18 | } 19 | 20 | // MustMarkFlagRequired panics if the call to MarkFlagRequired() fails. 21 | func MustMarkFlagRequired(flaggish interface{}, name string) { 22 | if err := MarkFlagRequired(flaggish, name); err != nil { 23 | panic(err) 24 | } 25 | } 26 | 27 | // MarkFlagRequired returns an error if the call to MarkFlagRequired() fails. 28 | func MarkFlagRequired(flaggish interface{}, name string) error { 29 | switch v := flaggish.(type) { 30 | case *cobra.Command: 31 | if err := v.MarkFlagRequired(name); err != nil { 32 | return err 33 | } 34 | case *pflag.FlagSet: 35 | if err := cobra.MarkFlagRequired(v, name); err != nil { 36 | return err 37 | } 38 | 39 | default: 40 | return errors.Errorf("Unknown flag type: %v", v) 41 | } 42 | return nil 43 | } 44 | 45 | // MustMarkPersistentFlagRequired panics if the call to MarkPersistentFlagRequired() fails. 46 | func MustMarkPersistentFlagRequired(cmd *cobra.Command, name string) { 47 | if err := cmd.MarkPersistentFlagRequired(name); err != nil { 48 | panic(err) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /testutils/exec/cmd.go: -------------------------------------------------------------------------------- 1 | package exec 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "io" 7 | "os" 8 | "os/exec" 9 | 10 | "github.com/onsi/ginkgo/v2" 11 | "github.com/pkg/errors" 12 | ) 13 | 14 | func RunCommand(workingDir string, verbose bool, args ...string) error { 15 | _, err := RunCommandOutput(workingDir, verbose, args...) 16 | return err 17 | } 18 | 19 | func RunCommandOutput(workingDir string, verbose bool, args ...string) (string, error) { 20 | return RunCommandInputOutput("", workingDir, verbose, args...) 21 | } 22 | 23 | func RunCommandInput(input, workingDir string, verbose bool, args ...string) error { 24 | _, err := RunCommandInputOutput(input, workingDir, verbose, args...) 25 | return err 26 | } 27 | 28 | func RunCommandInputOutput(input, workingDir string, verbose bool, args ...string) (string, error) { 29 | ctx, cancel := context.WithCancel(context.Background()) 30 | defer cancel() 31 | 32 | cmd := exec.CommandContext(ctx, args[0], args[1:]...) 33 | cmd.Dir = workingDir 34 | cmd.Env = os.Environ() 35 | if len(input) > 0 { 36 | cmd.Stdin = bytes.NewBuffer([]byte(input)) 37 | } 38 | buf := &bytes.Buffer{} 39 | var out io.Writer 40 | if verbose { 41 | out = io.MultiWriter(buf, ginkgo.GinkgoWriter) 42 | } else { 43 | out = buf 44 | } 45 | cmd.Stdout = out 46 | cmd.Stderr = out 47 | if err := cmd.Run(); err != nil { 48 | return "", errors.Wrapf(err, "%v failed: %s", cmd.Args, buf.String()) 49 | } 50 | 51 | return buf.String(), nil 52 | } 53 | -------------------------------------------------------------------------------- /gcloudutils/builders/mock.go: -------------------------------------------------------------------------------- 1 | package builders 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/google/go-github/v32/github" 7 | "github.com/solo-io/go-utils/githubutils" 8 | "google.golang.org/api/cloudbuild/v1" 9 | ) 10 | 11 | type mockBuilderContext struct { 12 | *sharedContext 13 | 14 | tag string 15 | sha string 16 | } 17 | 18 | func DefaultMockBuilderContext(ctx context.Context) (*mockBuilderContext, error) { 19 | client, err := githubutils.GetClient(ctx) 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | sharedContext := NewSharedContext("solo-public", 123, client, nil, "solo-io", "testrepo") 25 | return NewMockBuilderContext(sharedContext, "v0.1.9", "4fa0be07c7daaafcfb97ffe021fbfa8f51696622"), nil 26 | } 27 | 28 | func NewMockBuilderContext(sharedContext *sharedContext, tag string, sha string) *mockBuilderContext { 29 | return &mockBuilderContext{sharedContext: sharedContext, tag: tag, sha: sha} 30 | } 31 | 32 | func (ctx *mockBuilderContext) Tag() string { 33 | return ctx.tag 34 | } 35 | 36 | func (ctx *mockBuilderContext) Sha() string { 37 | return ctx.sha 38 | } 39 | 40 | func (ctx *mockBuilderContext) Client() *github.Client { 41 | return ctx.client 42 | } 43 | 44 | func (ctx *mockBuilderContext) Service() *cloudbuild.Service { 45 | panic("not supported by this interface") 46 | } 47 | 48 | func (ctx *mockBuilderContext) Owner() string { 49 | return ctx.owner 50 | } 51 | 52 | func (ctx *mockBuilderContext) Repo() string { 53 | return ctx.repo 54 | } 55 | -------------------------------------------------------------------------------- /hack/make-changelog-entry.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | REPO=solo-io/go-utils 6 | 7 | NAME=$1 8 | TYPE=$2 9 | DESCRIPTION=$3 10 | ISSUE=$4 11 | 12 | if [[ "$#" -lt 3 ]]; then 13 | echo "Create a new changelog entry" 14 | echo "Usage:" 15 | echo "$(basename "$0") FILENAME NEW_FEATURE|FIX|NON_USER_FACING DESCRIPTION [ISSUE]" 16 | exit 1 17 | fi 18 | 19 | get_latest_release() { 20 | curl --silent "https://api.github.com/repos/$REPO/releases/latest" | # Get latest release from GitHub api 21 | grep '"tag_name":' | # Get tag line 22 | sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value 23 | } 24 | 25 | write_changelog_issue() { 26 | cat > changelog/$1/$NAME.yaml < changelog/${VERSION}/$NAME.yaml < 0 { 38 | imageSet[trimVal] = nil 39 | } 40 | } 41 | imagesPerVersion[values[0]] = values[1:] 42 | } 43 | 44 | return imagesPerVersion, nil 45 | } 46 | -------------------------------------------------------------------------------- /stats/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Logs 3 | 4 | enable debug logs with 5 | ```shell 6 | curl -XPUT -d '{"level":"debug"}' -H"content-type: application/json" http://localhost:9091/logging 7 | ``` 8 | 9 | # zPages 10 | 11 | see them here: 12 | 13 | localhost:9091/zpages/tracez 14 | 15 | # Local Prometheus 16 | 17 | Start like so: 18 | ```shell 19 | cat < config.yaml 20 | global: 21 | scrape_interval: 15s # By default, scrape targets every 15 seconds. 22 | 23 | # A scrape configuration containing exactly one endpoint to scrape: 24 | scrape_configs: 25 | # The job name is added as a label 'job=' to any timeseries scraped from this config. 26 | - job_name: 'go-utils' 27 | 28 | # Override the global default and scrape targets from this job every 1 seconds. 29 | scrape_interval: 1s 30 | 31 | static_configs: 32 | - targets: ['localhost:9091'] 33 | EOF 34 | prometheus --config.file=./config.yaml 35 | ``` 36 | 37 | Prometheus will be available in `localhost:9090`. 38 | 39 | To see the rate of incoming snapshots, try this query: 40 | ``` 41 | rate(api_snap_emitter_snap_in[5m]) 42 | ``` 43 | 44 | # Profiling 45 | ## CPU tracing 46 | ``` 47 | $ curl http://localhost:9091/debug/pprof/trace?seconds=5 -o trace.out 48 | $ go tool trace trace.out 49 | ``` 50 | 51 | ## profiling 52 | ``` 53 | $ curl http://localhost:9091/debug/pprof/profile?seconds=5 -o pprof.out 54 | $ go tool pprof pprof.out 55 | (pprof) top 56 | (pprof) web 57 | ``` 58 | 59 | ## Stack traces 60 | See go routines: 61 | ``` 62 | $ curl http://localhost:9091/debug/pprof/goroutine?debug=2 63 | ``` -------------------------------------------------------------------------------- /docker/pull.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "github.com/pkg/errors" 8 | "github.com/solo-io/go-utils/contextutils" 9 | ) 10 | 11 | // PullIfNotPresent will pull an image if it is not present locally 12 | // retrying up to retries times 13 | // it returns true if it attempted to pull, and any errors from pulling 14 | func PullIfNotPresent(ctx context.Context, image string, retries int) (pulled bool, err error) { 15 | logger := contextutils.LoggerFrom(ctx) 16 | // if this did not return an error, then the image exists locally 17 | cmd := Command("inspect", "--type=image", image) 18 | if err := cmd.Run(); err == nil { 19 | logger.Infof("Image: %s present locally", image) 20 | return false, nil 21 | } 22 | // otherwise try to pull it 23 | return true, Pull(ctx, image, retries) 24 | } 25 | 26 | // Pull pulls an image, retrying up to retries times 27 | func Pull(ctx context.Context, image string, retries int) error { 28 | logger := contextutils.LoggerFrom(ctx) 29 | logger.Infof("Pulling image: %s ...", image) 30 | err := Command("pull", image).Run() 31 | // retry pulling up to retries times if necessary 32 | if err != nil { 33 | for i := 0; i < retries; i++ { 34 | time.Sleep(time.Second * time.Duration(i+1)) 35 | logger.Warnf(errors.Wrapf(err, "Trying again to pull image: %s ...", image).Error()) 36 | err = Command("pull", image).Run() 37 | if err == nil { 38 | break 39 | } 40 | } 41 | } 42 | if err != nil { 43 | logger.Warnf(errors.Wrapf(err, "Failed to pull image: %s", image).Error()) 44 | } 45 | return err 46 | } 47 | -------------------------------------------------------------------------------- /contextutils/errors_and_logging.go: -------------------------------------------------------------------------------- 1 | package contextutils 2 | 3 | import ( 4 | "context" 5 | 6 | "go.uber.org/zap" 7 | ) 8 | 9 | func SilenceLogger(ctx context.Context) context.Context { 10 | return withLogger(ctx, zap.NewNop().Sugar()) 11 | } 12 | 13 | func WithLogger(ctx context.Context, name string) context.Context { 14 | return withLogger(ctx, fromContext(ctx).Named(name)) 15 | } 16 | 17 | func WithLoggerValues(ctx context.Context, meta ...interface{}) context.Context { 18 | return withLogger(ctx, fromContext(ctx).With(meta...)) 19 | } 20 | 21 | func WithExistingLogger(ctx context.Context, logger *zap.SugaredLogger) context.Context { 22 | return withLogger(ctx, logger) 23 | } 24 | 25 | func LoggerFrom(ctx context.Context) *zap.SugaredLogger { 26 | return fromContext(ctx) 27 | } 28 | 29 | type ErrorHandler interface { 30 | HandleErr(error) 31 | } 32 | 33 | type ErrorLogger struct { 34 | ctx context.Context 35 | } 36 | 37 | func (h *ErrorLogger) HandleErr(err error) { 38 | if err == nil { 39 | return 40 | } 41 | fromContext(h.ctx).Errorf(err.Error()) 42 | } 43 | 44 | type errorHandlerKey struct{} 45 | 46 | func WithErrorHandler(ctx context.Context, errorHandler ErrorHandler) context.Context { 47 | return context.WithValue(ctx, errorHandlerKey{}, errorHandler) 48 | } 49 | 50 | func ErrorHandlerFrom(ctx context.Context) ErrorHandler { 51 | val := ctx.Value(errorHandlerKey{}) 52 | if val == nil { 53 | return &ErrorLogger{ 54 | ctx: ctx, 55 | } 56 | } 57 | errorHandler, ok := val.(ErrorHandler) 58 | if !ok { 59 | return &ErrorLogger{ 60 | ctx: ctx, 61 | } 62 | } 63 | return errorHandler 64 | } 65 | -------------------------------------------------------------------------------- /testutils/errors.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "fmt" 5 | 6 | gomegatypes "github.com/onsi/gomega/types" 7 | "github.com/rotisserie/eris" 8 | ) 9 | 10 | // Relies on eris (https://github.com/rotisserie/eris)'s concept of error identity, specifically: 11 | // 12 | // "eris.Is returns true if a particular error appears anywhere in the error chain... 13 | // eris.Is works simply by comparing error messages with each other. If an error contains a 14 | // particular message anywhere in its chain (e.g. "not found"), it's defined to be that error 15 | // type (i.e. eris.Is will return true)." 16 | // 17 | // Example usage: 18 | // Expect(wrapperError1).To(HaveInErrorChain(baseError), "Chaining should work") 19 | func HaveInErrorChain(err error) gomegatypes.GomegaMatcher { 20 | return &errorChainMatcher{expected: err} 21 | } 22 | 23 | type errorChainMatcher struct { 24 | expected error 25 | } 26 | 27 | func (e *errorChainMatcher) Match(actual interface{}) (success bool, err error) { 28 | if actual == nil { 29 | return false, nil 30 | } 31 | 32 | actualError, ok := actual.(error) 33 | if !ok { 34 | return false, eris.New("could not convert actual value to error type") 35 | } 36 | return eris.Is(actualError, e.expected), nil 37 | } 38 | 39 | func (e *errorChainMatcher) FailureMessage(actual interface{}) (message string) { 40 | return fmt.Sprintf("Received actual: %+v, but expected error %+v", actual, e.expected) 41 | } 42 | 43 | func (e *errorChainMatcher) NegatedFailureMessage(actual interface{}) (message string) { 44 | return fmt.Sprintf("Expected actual: %+v not to equal error +%v", actual, e.expected) 45 | } 46 | -------------------------------------------------------------------------------- /grpcutils/reset_connection_backoff.go: -------------------------------------------------------------------------------- 1 | package grpcutils 2 | 3 | import ( 4 | "context" 5 | 6 | "google.golang.org/grpc" 7 | "google.golang.org/grpc/codes" 8 | "google.golang.org/grpc/status" 9 | ) 10 | 11 | // WithResetConnectionBackoffUnary creates a Unary Interceptor which resets the underlying connection's retry backoff timer. 12 | // This allows grpc connections to quickly attempt to reconnect to a server e.g. after a server restart. 13 | func WithResetConnectionBackoffUnary() grpc.UnaryClientInterceptor { 14 | return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { 15 | err := invoker(ctx, method, req, reply, cc, opts...) 16 | if status.Code(err) == codes.Unavailable { 17 | cc.ResetConnectBackoff() 18 | err = invoker(ctx, method, req, reply, cc, opts...) 19 | } 20 | return err 21 | } 22 | } 23 | 24 | // WithResetConnectionBackoffStream creates a Stream Interceptor which resets the underlying connection's retry backoff timer. 25 | // This allows grpc connections to quickly attempt to reconnect to a server e.g. after a server restart. 26 | func WithResetConnectionBackoffStream() grpc.StreamClientInterceptor { 27 | return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { 28 | cs, err := streamer(ctx, desc, cc, method, opts...) 29 | if status.Code(err) == codes.Unavailable { 30 | cc.ResetConnectBackoff() 31 | cs, err = streamer(ctx, desc, cc, method, opts...) 32 | } 33 | return cs, err 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /mapstructureutils/mapdecoder_test.go: -------------------------------------------------------------------------------- 1 | package mapdecoder_test 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | . "github.com/solo-io/go-utils/mapstructureutils" 9 | "google.golang.org/protobuf/types/known/structpb" 10 | ) 11 | 12 | var _ = Describe("Normalize Map Decode", func() { 13 | DescribeTable("should correctly decode JSON numbers into int64 or float64", 14 | func(input map[string]interface{}, expectedResult map[string]interface{}) { 15 | result := make(map[string]interface{}) 16 | err := NormalizeMapDecode(input, &result) 17 | Expect(err).NotTo(HaveOccurred()) 18 | 19 | Expect(result).To(Equal(expectedResult)) 20 | value, err := structpb.NewValue(result) 21 | Expect(err).NotTo(HaveOccurred()) 22 | Expect(value).ToNot(BeNil()) 23 | }, 24 | Entry("deeply nested JSON number to int", 25 | map[string]interface{}{ 26 | "number": json.Number("10"), 27 | "float": float64(10.5), 28 | "nested": map[string]interface{}{ 29 | "number": json.Number("100"), 30 | "float": float64(100.5), 31 | "deeplyNested": map[string]interface{}{ 32 | "number": json.Number("1000"), 33 | "float": float64(100.5), 34 | }, 35 | }, 36 | }, 37 | map[string]interface{}{ 38 | "number": int64(10), 39 | "float": float64(10.5), 40 | "nested": map[string]interface{}{ 41 | "number": int64(100), 42 | "float": float64(100.5), 43 | "deeplyNested": map[string]interface{}{ 44 | "number": int64(1000), 45 | "float": float64(100.5), 46 | }, 47 | }, 48 | }, 49 | ), 50 | ) 51 | }) 52 | -------------------------------------------------------------------------------- /githubutils/README.md: -------------------------------------------------------------------------------- 1 | ## Uploading Release Assets to Github 2 | 3 | To upload release assets to Github, follow these steps (requires go-utils 0.2.10+). 4 | 5 | ### Create a Go script 6 | 7 | Create a script `upload_github_release_asset.go`, like this: 8 | 9 | ```go 10 | package main 11 | 12 | import ( 13 | "github.com/solo-io/go-utils/githubutils" 14 | ) 15 | 16 | func main() { 17 | assets := make([]githubutils.ReleaseAssetSpec, 2) 18 | assets[0] = githubutils.ReleaseAssetSpec{ 19 | Name: "hello", 20 | ParentPath: "_output", 21 | UploadSHA: true, 22 | } 23 | assets[1] = githubutils.ReleaseAssetSpec{ 24 | Name: "my-resource.yaml", 25 | ParentPath: "namespace", 26 | } 27 | spec := githubutils.UploadReleaseAssetSpec{ 28 | Owner: "solo-io", 29 | Repo: "testrepo", 30 | Assets: assets, 31 | SkipAlreadyExists: true, 32 | } 33 | githubutils.UploadReleaseAssetCli(&spec) 34 | } 35 | ``` 36 | 37 | ### Create a Make target 38 | 39 | ```bash 40 | #---------------------------------------------------------------------------------- 41 | # Github Assets 42 | #---------------------------------------------------------------------------------- 43 | 44 | .PHONY: upload-github-release-assets 45 | upload-github-release-assets: hello 46 | go run upload_github_release_assets.go 47 | ``` 48 | 49 | ### Update cloudbuild.yaml to call this target 50 | 51 | ```yaml 52 | steps: 53 | - name: 'gcr.io/solo-corp/go-mod-make:0.1.1' 54 | args: [..., 'upload-github-release-assets', ...] 55 | secretEnv: ['GITHUB_TOKEN'] 56 | env: 57 | - 'TAGGED_VERSION=$TAG_NAME' 58 | ``` 59 | 60 | Make sure `GITHUB_TOKEN` and `TAGGED_VERSION` are in the environment. 61 | 62 | ### Notes 63 | 64 | * On each asset, a flag `UploadSHA` can be set to true to upload a SHA256 hash file. 65 | * Set `SkipAlreadyExists=true` to not fail when trying to upload an asset that already exists. -------------------------------------------------------------------------------- /gcloudutils/factory.go: -------------------------------------------------------------------------------- 1 | package gcloudutils 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/solo-io/go-utils/contextutils" 7 | "go.uber.org/zap" 8 | "golang.org/x/sync/errgroup" 9 | ) 10 | 11 | type CloudBot struct { 12 | subscribers []*CloudSubscriber 13 | } 14 | 15 | func NewCloudBot(ctx context.Context, projectIds []string, subscriberId string, handlers ...CloudBuildEventHandler) (*CloudBot, error) { 16 | contextutils.LoggerFrom(ctx).Infow("Creating cloud bot", zap.String("subscriberId", subscriberId)) 17 | var subscribers []*CloudSubscriber 18 | for _, projectId := range projectIds { 19 | contextutils.LoggerFrom(ctx).Debugw("Adding cloud subscriber for project", 20 | zap.String("projectId", projectId), 21 | zap.String("subscriberId", subscriberId)) 22 | subscriber, err := NewCloudSubscriber(ctx, projectId, subscriberId) 23 | if err != nil { 24 | contextutils.LoggerFrom(ctx).Errorw("Error creating cloud subscriber", 25 | zap.Error(err), 26 | zap.String("projectId", projectId), 27 | zap.String("subscriberId", subscriberId)) 28 | return nil, err 29 | } 30 | subscribers = append(subscribers, subscriber) 31 | } 32 | for _, subscriber := range subscribers { 33 | for _, handler := range handlers { 34 | subscriber.RegisterHandler(handler) 35 | } 36 | } 37 | return &CloudBot{subscribers: subscribers}, nil 38 | } 39 | 40 | func (b *CloudBot) Run(ctx context.Context) error { 41 | eg := errgroup.Group{} 42 | for _, subscriber := range b.subscribers { 43 | sub := subscriber 44 | eg.Go(func() error { 45 | subLogger := contextutils.WithLoggerValues(ctx, "projectId", sub.GetProjectId()) 46 | err := sub.Run(subLogger) 47 | if err != nil { 48 | contextutils.LoggerFrom(subLogger).Errorw("Error running cloud subscriber", zap.Error(err)) 49 | } 50 | return err 51 | }) 52 | } 53 | return eg.Wait() 54 | } 55 | -------------------------------------------------------------------------------- /cliutils/cli_helpers.go: -------------------------------------------------------------------------------- 1 | package cliutils 2 | 3 | import ( 4 | "math/rand" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | const ( 10 | lcAlpha = "abcdefghijklmnopqrstuvwxyz" 11 | lcAlphaNumeric = "abcdefghijklmnopqrstuvwxyz0123456789" 12 | ) 13 | 14 | func init() { 15 | rand.Seed(time.Now().UnixNano()) 16 | } 17 | 18 | // RandStringBytes produces a random string of length n using the characters present in the basis string 19 | func RandStringBytes(n int, basis string) string { 20 | if basis == "" { 21 | return "" 22 | } 23 | b := make([]byte, n) 24 | for i := range b { 25 | b[i] = basis[rand.Intn(len(basis))] 26 | } 27 | return string(b) 28 | } 29 | 30 | // RandDNS1035 generates a random string of length n that meets the DNS-1035 standard used by Kubernetes names 31 | // 32 | // Typical kubernetes error message for invalid names: a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?') 33 | func RandKubeNameBytes(n int) string { 34 | if n < 1 { 35 | return "" 36 | } 37 | firstChar := RandStringBytes(1, lcAlpha) 38 | suffix := "" 39 | if n > 1 { 40 | suffix = RandStringBytes(n-1, lcAlphaNumeric) 41 | } 42 | return strings.Join([]string{firstChar, suffix}, "") 43 | } 44 | 45 | // Contains indicates if a string slice 'a' contains the string s 46 | func Contains(a []string, s string) bool { 47 | for _, n := range a { 48 | if s == n { 49 | return true 50 | } 51 | } 52 | return false 53 | } 54 | 55 | // Contains indicates if a string slice 'a' contains a string that encompases the string s 56 | func ContainsSubstring(a []string, substring string) bool { 57 | for _, n := range a { 58 | if strings.Contains(n, substring) { 59 | return true 60 | } 61 | } 62 | return false 63 | } 64 | -------------------------------------------------------------------------------- /testutils/kubernetes_test.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | . "github.com/onsi/ginkgo/v2" 8 | . "github.com/onsi/gomega" 9 | ) 10 | 11 | var _ = Describe("Kubernetes", func() { 12 | Context("WaitPodsRunning", func() { 13 | var ( 14 | ctx context.Context 15 | cancel context.CancelFunc 16 | ) 17 | BeforeEach(func() { 18 | kubectlExecutable = `echo` 19 | ctx, cancel = context.WithDeadline(context.Background(), time.Now().Add(time.Second)) 20 | }) 21 | AfterEach(func() { 22 | cancel() 23 | }) 24 | It("Reports running pods as running", func() { 25 | kubectlArgs = []string{`"\ 26 | NAMESPACE NAME READY STATUS RESTARTS AGE \ 27 | kube-system coredns-5dd5756b68-62pwz 1/1 Running 0 3d18h" #`} 28 | 29 | // The parameters here don't really matter since we're not actually calling kubectl. 30 | // We do need a label however to enter the loop that calls the command. 31 | Expect(WaitPodsRunning(ctx, time.Millisecond, "", "foo=bar")).ToNot(HaveOccurred()) 32 | }) 33 | It("Doesn't report terminating pods as running", func() { 34 | kubectlArgs = []string{`"\ 35 | NAMESPACE NAME READY STATUS RESTARTS AGE \ 36 | kube-system coredns-5dd5756b68-jlm7r 1/1 Terminating 0 3d18h \ 37 | kube-system coredns-5dd5756b68-62pwz 1/1 Running 0 3d18h" #`} 38 | 39 | // The parameters here don't really matter since we're not actually calling kubectl. 40 | // We do need a label however to enter the loop that calls the command. 41 | Expect(WaitPodsRunning(ctx, time.Millisecond, "", "foo=bar")).To(MatchError(ContainSubstring("timed out waiting"))) 42 | }) 43 | }) 44 | }) 45 | -------------------------------------------------------------------------------- /healthchecker/interceptor_test.go: -------------------------------------------------------------------------------- 1 | package healthchecker_test 2 | 3 | import ( 4 | "context" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | "github.com/solo-io/go-utils/healthchecker" 9 | "google.golang.org/grpc" 10 | "google.golang.org/grpc/metadata" 11 | ) 12 | 13 | var _ = Describe("grpc healthchecker interceptor", func() { 14 | It("should make the health check fail", func() { 15 | ctx, cancel := context.WithCancel(context.Background()) 16 | stream := &mockServerTransportStream{} 17 | requestCtx := grpc.NewContextWithServerTransportStream(context.Background(), stream) 18 | cancel() 19 | f := healthchecker.GrpcUnaryServerHealthCheckerInterceptor(ctx) 20 | f(requestCtx, "foo", nil, func(ctx context.Context, req interface{}) (interface{}, error) { 21 | return nil, nil 22 | }) 23 | expectedMd := metadata.MD{ 24 | "x-envoy-immediate-health-check-fail": []string{""}, 25 | } 26 | Expect(stream.header).To(Equal(expectedMd)) 27 | }) 28 | It("should not when context still alive", func() { 29 | stream := &mockServerTransportStream{} 30 | requestCtx := grpc.NewContextWithServerTransportStream(context.Background(), stream) 31 | f := healthchecker.GrpcUnaryServerHealthCheckerInterceptor(context.Background()) 32 | f(requestCtx, "foo", nil, func(ctx context.Context, req interface{}) (interface{}, error) { 33 | return nil, nil 34 | }) 35 | Expect(stream.header).To(BeNil()) 36 | }) 37 | 38 | }) 39 | 40 | type mockServerTransportStream struct { 41 | header metadata.MD 42 | } 43 | 44 | func (m *mockServerTransportStream) Method() string { 45 | return "" 46 | } 47 | 48 | func (m *mockServerTransportStream) SetHeader(md metadata.MD) error { 49 | return nil 50 | } 51 | 52 | func (m *mockServerTransportStream) SendHeader(md metadata.MD) error { 53 | m.header = md 54 | return nil 55 | } 56 | 57 | func (m *mockServerTransportStream) SetTrailer(md metadata.MD) error { 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /docker/docker_test.go: -------------------------------------------------------------------------------- 1 | package docker_test 2 | 3 | import ( 4 | "context" 5 | "io/ioutil" 6 | "os/exec" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | "github.com/solo-io/go-utils/docker" 11 | ) 12 | 13 | const ( 14 | validImage = "soloio/gloo:0.7.0" 15 | invalidImage = "soloio/gloo:0.1.0" 16 | ) 17 | 18 | var _ = BeforeSuite(func() { 19 | exec.Command("docker", "image", "rm", validImage).Run() 20 | }) 21 | 22 | var _ = Describe("Docker", func() { 23 | 24 | pullValidImage := func() { 25 | _, err := docker.PullIfNotPresent(context.Background(), validImage, 1) 26 | Expect(err).NotTo(HaveOccurred()) 27 | } 28 | 29 | pullInvalidImage := func() { 30 | _, err := docker.PullIfNotPresent(context.Background(), invalidImage, 1) 31 | Expect(err).To(HaveOccurred()) 32 | } 33 | 34 | Context("Pull", func() { 35 | It("can pull a valid container", func() { 36 | // caching in github actions leads to docker image being present from run to run and 37 | // failing the previous check. 38 | // previous: Expect(pullValidImage()).To(BeTrue()) 39 | // docker.PullIfNotPresent returns a boolean to represent whether or not it pulled the image 40 | // and the caching stops it from being pulled 41 | pullValidImage() 42 | }) 43 | 44 | It("cannot pull an invalid container", func() { 45 | pullInvalidImage() 46 | }) 47 | 48 | }) 49 | 50 | Context("Save", func() { 51 | It("can save a valid, present container", func() { 52 | pullValidImage() 53 | file, err := ioutil.TempFile("", "docker_test") 54 | Expect(err).NotTo(HaveOccurred()) 55 | err = docker.Save(validImage, file.Name()) 56 | Expect(err).NotTo(HaveOccurred()) 57 | }) 58 | 59 | It("cannot save an invalid container", func() { 60 | file, err := ioutil.TempFile("", "docker_test") 61 | Expect(err).NotTo(HaveOccurred()) 62 | err = docker.Save(invalidImage, file.Name()) 63 | Expect(err).To(HaveOccurred()) 64 | }) 65 | }) 66 | 67 | }) 68 | -------------------------------------------------------------------------------- /slackutils/slack.go: -------------------------------------------------------------------------------- 1 | package slackutils 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/solo-io/go-utils/contextutils" 7 | "go.uber.org/zap" 8 | ) 9 | 10 | var _ SlackClient = new(slackClient) 11 | 12 | type SlackNotifications struct { 13 | DefaultUrl string `yaml:"default_url" json:"defaultUrl"` 14 | RepoUrls map[string]string `yaml:"repo_urls" json:"repoUrls"` 15 | } 16 | 17 | type SlackClient interface { 18 | // Use repo-specific channel, if exists 19 | NotifyForRepo(ctx context.Context, repo, message string) 20 | // Use default channel 21 | Notify(ctx context.Context, message string) 22 | } 23 | 24 | func NewSlackClient(notifications *SlackNotifications) *slackClient { 25 | return NewSlackClientForHttpClient(&DefaultHttpClient{}, notifications) 26 | } 27 | 28 | func NewSlackClientForHttpClient(httpClient HttpClient, notifications *SlackNotifications) *slackClient { 29 | return &slackClient{ 30 | httpClient: httpClient, 31 | notifications: notifications, 32 | } 33 | } 34 | 35 | type slackClient struct { 36 | httpClient HttpClient 37 | notifications *SlackNotifications 38 | } 39 | 40 | func (s *slackClient) getSlackUrl(repo string) string { 41 | if s.notifications == nil { 42 | return "" 43 | } 44 | if repo == "" || s.notifications.RepoUrls == nil { 45 | return s.notifications.DefaultUrl 46 | } 47 | repoUrl, ok := s.notifications.RepoUrls[repo] 48 | if ok { 49 | return repoUrl 50 | } 51 | return s.notifications.DefaultUrl 52 | } 53 | 54 | func (s *slackClient) Notify(ctx context.Context, message string) { 55 | s.NotifyForRepo(ctx, "", message) 56 | } 57 | 58 | func (s *slackClient) NotifyForRepo(ctx context.Context, repo, message string) { 59 | slackUrl := s.getSlackUrl(repo) 60 | if slackUrl == "" { 61 | contextutils.LoggerFrom(ctx).Warnw("Requested notifying slack, but no URL", 62 | zap.String("repo", repo), 63 | zap.Any("notifications", s.notifications)) 64 | return 65 | } 66 | s.httpClient.PostJsonContent(ctx, message, slackUrl) 67 | } 68 | -------------------------------------------------------------------------------- /errgroup/errgroup.go: -------------------------------------------------------------------------------- 1 | // Package errgroup provides synchronization, error propagation, and Context 2 | // cancelation for groups of goroutines working on subtasks of a common task. 3 | // Based on golangorg/x/sync 4 | package errgroup 5 | 6 | import ( 7 | "context" 8 | "sync" 9 | 10 | "github.com/hashicorp/go-multierror" 11 | ) 12 | 13 | // A Group is a collection of goroutines working on subtasks that are part of 14 | // the same overall task. 15 | // 16 | // A zero Group is valid and does not cancel on error. 17 | type Group struct { 18 | cancel func() 19 | 20 | wg sync.WaitGroup 21 | 22 | errOnce sync.Once 23 | errs error // appended with each error 24 | errLock sync.RWMutex 25 | } 26 | 27 | // WithContext returns a new Group and an associated Context derived from ctx. 28 | // 29 | // The derived Context is canceled the first time a function passed to Go 30 | // returns a non-nil error or the first time Wait returns, whichever occurs 31 | // first. 32 | func WithContext(ctx context.Context) (*Group, context.Context) { 33 | ctx, cancel := context.WithCancel(ctx) 34 | return &Group{cancel: cancel}, ctx 35 | } 36 | 37 | // Wait blocks until all function calls from the Go method have returned, then 38 | // returns an error representing all errors encountered from any goroutines in the group. 39 | func (g *Group) Wait() error { 40 | g.wg.Wait() 41 | if g.cancel != nil { 42 | g.cancel() 43 | } 44 | g.errLock.RLock() 45 | err := g.errs 46 | g.errLock.RUnlock() 47 | return err 48 | } 49 | 50 | // Go calls the given function in a new goroutine. 51 | // 52 | // The first call to return a non-nil error cancels the group; its error will be 53 | // returned by Wait. 54 | func (g *Group) Go(f func() error) { 55 | g.wg.Add(1) 56 | 57 | go func() { 58 | defer g.wg.Done() 59 | 60 | if err := f(); err != nil { 61 | g.errLock.Lock() 62 | g.errs = multierror.Append(g.errs, err) 63 | g.errLock.Unlock() 64 | g.errOnce.Do(func() { 65 | if g.cancel != nil { 66 | g.cancel() 67 | } 68 | }) 69 | } 70 | }() 71 | } 72 | -------------------------------------------------------------------------------- /.github/workflows/pull_request.yaml: -------------------------------------------------------------------------------- 1 | name: pull_request 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'master' 7 | - 'main' 8 | pull_request: 9 | 10 | jobs: 11 | test: 12 | name: Tests 13 | runs-on: ubuntu-22.04 14 | steps: 15 | - name: Cancel Previous Runs 16 | uses: styfle/cancel-workflow-action@0.11.0 17 | with: 18 | access_token: ${{ github.token }} 19 | - uses: actions/checkout@v3 20 | with: 21 | fetch-depth: 0 22 | - name: Set up Python 23 | uses: actions/setup-python@v4 24 | with: 25 | python-version: 3.8 26 | - uses: google-github-actions/setup-gcloud@a48b55b3b0eeaf77b6e1384aab737fbefe2085ac 27 | with: 28 | version: '290.0.1' 29 | project_id: ${{ secrets.GCP_PROJECT_ID }} 30 | service_account_key: ${{ secrets.GCP_SA_KEY }} 31 | export_default_credentials: true 32 | name: Gcloud Login 33 | - name: Install Trivy (latest) 34 | run: | 35 | TRIVY_VERSION=$(curl --silent "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') 36 | echo Using Trivy v${TRIVY_VERSION} 37 | wget https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.deb 38 | sudo dpkg -i trivy_${TRIVY_VERSION}_Linux-64bit.deb 39 | - name: Set up Go 40 | uses: actions/setup-go@v4 41 | with: 42 | go-version-file: "go.mod" 43 | - name: Run tests 44 | env: 45 | GITHUB_TOKEN: ${{ secrets.CLOUDBUILD_GITHUB_TOKEN }} 46 | TEST_PKG: ./... # Run all tests 47 | run: make test 48 | - uses: testspace-com/setup-testspace@v1 49 | with: 50 | domain: solo-io.testspace.com 51 | if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/master' }} 52 | - name: Push result to Testspace server 53 | run: | 54 | testspace push --verbose "**/junit.xml" 55 | if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/master' }} 56 | -------------------------------------------------------------------------------- /clicore/README.md: -------------------------------------------------------------------------------- 1 | # CLI Core 2 | - A library for feature-rich, configurable, and cross-project consistent command line interfaces. 3 | 4 | ## Usage 5 | - To use clicore, just define a `CommandConfig` and call `config.Run()`. 6 | ### Example 7 | - Sample `main` package, importing your cli: 8 | ```go 9 | package main 10 | import ( 11 | "myrepo/pkg/mycli" 12 | ) 13 | func main() { 14 | mycli.MyCommandConfig.Run() 15 | } 16 | ``` 17 | 18 | - Sample package, defining your CLI library and exporting the `CommandConfig`: 19 | 20 | ```go 21 | package mycli 22 | 23 | import "github.com/solo-io/go-utils/clicore" 24 | 25 | var MyCommandConfig = clicore.CommandConfig{ 26 | Command: App, 27 | Version: version.Version, 28 | FileLogPathElements: FileLogPathElements, 29 | OutputModeEnvVar: OutputModeEnvVar, 30 | RootErrorMessage: ErrorMessagePreamble, 31 | LoggingContext: []interface{}{"version", version.Version}, 32 | } 33 | ``` 34 | 35 | ### How to write logs to the console and log file 36 | 37 | There are three helpers that you can use: 38 | 39 | ```go 40 | 41 | contextutils.CliLogInfow(ctx, "this info log goes to file and console") 42 | contextutils.CliLogWarnw(ctx, "this warn log goes to file and console") 43 | contextutils.CliLogErrorw(ctx, "this error log goes to file and console") 44 | ``` 45 | 46 | Key-value pairs are supported too: 47 | 48 | ```go 49 | contextutils.CliLogInfow(ctx, "this infow log should go to file and console", 50 | "extrakey1", "val1") 51 | ``` 52 | 53 | Which is equivalent to the longer form: 54 | 55 | ```go 56 | contextutils.LoggerFrom(ctx).Infow("message going to file only", 57 | zap.String("cli", "info that will go to the console and file", 58 | "extrakey1", "val1") 59 | ``` 60 | 61 | ## Usage in tests 62 | - `clicore` was designed to simplify CLI specification and testing. 63 | - To run `clicore` in test mode, call `cliOutput, err := cli.GlooshotConfig.RunForTest(args)`. 64 | - Output from the command (stdout, stderr, and any log files) can then be validated one by one. 65 | - **See the [test file](cli_test.go) for an example** 66 | 67 | -------------------------------------------------------------------------------- /changelogutils/entrytype.go: -------------------------------------------------------------------------------- 1 | package changelogutils 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type ChangelogEntryType int 9 | 10 | const ( 11 | BREAKING_CHANGE ChangelogEntryType = iota 12 | FIX 13 | NEW_FEATURE 14 | NON_USER_FACING 15 | DEPENDENCY_BUMP 16 | HELM 17 | UPGRADE 18 | ) 19 | 20 | var ( 21 | _ChangelogEntryTypeToValue = map[string]ChangelogEntryType{ 22 | "BREAKING_CHANGE": BREAKING_CHANGE, 23 | "FIX": FIX, 24 | "NEW_FEATURE": NEW_FEATURE, 25 | "NON_USER_FACING": NON_USER_FACING, 26 | "DEPENDENCY_BUMP": DEPENDENCY_BUMP, 27 | "HELM": HELM, 28 | "UPGRADE": UPGRADE, 29 | } 30 | 31 | _ChangelogEntryValueToType = map[ChangelogEntryType]string{ 32 | BREAKING_CHANGE: "BREAKING_CHANGE", 33 | FIX: "FIX", 34 | NEW_FEATURE: "NEW_FEATURE", 35 | NON_USER_FACING: "NON_USER_FACING", 36 | DEPENDENCY_BUMP: "DEPENDENCY_BUMP", 37 | HELM: "HELM", 38 | UPGRADE: "UPGRADE", 39 | } 40 | ) 41 | 42 | func (clt ChangelogEntryType) String() string { 43 | return [...]string{"BREAKING_CHANGE", "FIX", "NEW_FEATURE", "NON_USER_FACING", "DEPENDENCY_BUMP", "HELM", "UPGRADE"}[clt] 44 | } 45 | 46 | func (clt ChangelogEntryType) BreakingChange() bool { 47 | return clt == BREAKING_CHANGE 48 | } 49 | 50 | func (clt ChangelogEntryType) NewFeature() bool { 51 | return clt == NEW_FEATURE 52 | } 53 | 54 | func (clt ChangelogEntryType) MarshalJSON() ([]byte, error) { 55 | if s, ok := interface{}(clt).(fmt.Stringer); ok { 56 | return json.Marshal(s.String()) 57 | } 58 | s, ok := _ChangelogEntryValueToType[clt] 59 | if !ok { 60 | return nil, fmt.Errorf("invalid ChangelogEntry type: %d", clt) 61 | } 62 | return json.Marshal(s) 63 | } 64 | 65 | func (clt *ChangelogEntryType) UnmarshalJSON(data []byte) error { 66 | var s string 67 | if err := json.Unmarshal(data, &s); err != nil { 68 | return fmt.Errorf("ChangelogEntryType should be a string, got %s", data) 69 | } 70 | v, ok := _ChangelogEntryTypeToValue[s] 71 | if !ok { 72 | return fmt.Errorf("invalid ChangelogEntryType %q", s) 73 | } 74 | *clt = v 75 | return nil 76 | } 77 | -------------------------------------------------------------------------------- /botutils/botconfig/os_mock_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: github.com/solo-io/go-utils/osutils (interfaces: OsClient) 3 | 4 | // Package botconfig_test is a generated GoMock package. 5 | package botconfig_test 6 | 7 | import ( 8 | reflect "reflect" 9 | 10 | gomock "github.com/golang/mock/gomock" 11 | ) 12 | 13 | // MockOsClient is a mock of OsClient interface 14 | type MockOsClient struct { 15 | ctrl *gomock.Controller 16 | recorder *MockOsClientMockRecorder 17 | } 18 | 19 | // MockOsClientMockRecorder is the mock recorder for MockOsClient 20 | type MockOsClientMockRecorder struct { 21 | mock *MockOsClient 22 | } 23 | 24 | // NewMockOsClient creates a new mock instance 25 | func NewMockOsClient(ctrl *gomock.Controller) *MockOsClient { 26 | mock := &MockOsClient{ctrl: ctrl} 27 | mock.recorder = &MockOsClientMockRecorder{mock} 28 | return mock 29 | } 30 | 31 | // EXPECT returns an object that allows the caller to indicate expected use 32 | func (m *MockOsClient) EXPECT() *MockOsClientMockRecorder { 33 | return m.recorder 34 | } 35 | 36 | // Getenv mocks base method 37 | func (m *MockOsClient) Getenv(arg0 string) string { 38 | m.ctrl.T.Helper() 39 | ret := m.ctrl.Call(m, "Getenv", arg0) 40 | ret0, _ := ret[0].(string) 41 | return ret0 42 | } 43 | 44 | // Getenv indicates an expected call of Getenv 45 | func (mr *MockOsClientMockRecorder) Getenv(arg0 interface{}) *gomock.Call { 46 | mr.mock.ctrl.T.Helper() 47 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Getenv", reflect.TypeOf((*MockOsClient)(nil).Getenv), arg0) 48 | } 49 | 50 | // ReadFile mocks base method 51 | func (m *MockOsClient) ReadFile(arg0 string) ([]byte, error) { 52 | m.ctrl.T.Helper() 53 | ret := m.ctrl.Call(m, "ReadFile", arg0) 54 | ret0, _ := ret[0].([]byte) 55 | ret1, _ := ret[1].(error) 56 | return ret0, ret1 57 | } 58 | 59 | // ReadFile indicates an expected call of ReadFile 60 | func (mr *MockOsClientMockRecorder) ReadFile(arg0 interface{}) *gomock.Call { 61 | mr.mock.ctrl.T.Helper() 62 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadFile", reflect.TypeOf((*MockOsClient)(nil).ReadFile), arg0) 63 | } 64 | --------------------------------------------------------------------------------