Compare commits

...

751 Commits
v0.3.7 ... main

Author SHA1 Message Date
Alex Jones
2276b12b0f Update sister project link in README.md (#1621)
Signed-off-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
2026-02-26 19:05:48 +00:00
Alex Jones
fd5bba6ab3 chore: updated readme (#1620)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2026-02-25 13:52:00 +00:00
praveen0612
19a172e575 docs: align Go version with go.mod toolchain (#1609)
Signed-off-by: Praveen Kumar <kumarpraveen@adobe.com>
Co-authored-by: Praveen Kumar <kumarpraveen@adobe.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
2026-02-24 09:32:52 +00:00
github-actions[bot]
36de157e21 chore(main): release 0.4.30 (#1618)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-20 10:47:51 +00:00
Three Foxes (in a Trenchcoat)
458aa9deba fix: validate namespace before running custom analyzers (#1617)
* feat(serve): add short flag and env var for metrics port

Add short flag -m for --metrics-port to improve discoverability.
Add K8SGPT_METRICS_PORT environment variable support, consistent
with other K8SGPT_* environment variables.

This helps users who encounter port conflicts on the default
metrics port (8081) when running k8sgpt serve with --mcp or
other configurations.

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>

* fix: validate namespace before running custom analyzers

Custom analyzers previously ignored the --namespace flag entirely,
executing even when an invalid or misspelled namespace was provided.
This was inconsistent with built-in filter behavior, which respects
namespace scoping.

Add namespace existence validation in RunCustomAnalysis() before
executing custom analyzers. If a namespace is specified but does
not exist, an error is reported and custom analyzers are skipped.

Fixes #1601

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>

---------

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
2026-02-20 10:25:34 +00:00
github-actions[bot]
285c1353d5 chore(main): release 0.4.29 (#1614)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-20 09:06:18 +00:00
Three Foxes (in a Trenchcoat)
4f63e9737c feat(serve): add short flag and env var for metrics port (#1616)
Add short flag -m for --metrics-port to improve discoverability.
Add K8SGPT_METRICS_PORT environment variable support, consistent
with other K8SGPT_* environment variables.

This helps users who encounter port conflicts on the default
metrics port (8081) when running k8sgpt serve with --mcp or
other configurations.

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
2026-02-20 06:27:44 +00:00
renovate[bot]
a56e4788c3 fix(deps): update k8s.io/utils digest to b8788ab (#1572)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-18 14:00:10 +00:00
Three Foxes (in a Trenchcoat)
99911fbb3a fix: use proper JSON marshaling for customrest prompt to handle special characters (#1615)
This fixes issue #1556 where the customrest backend fails when error messages
contain quotes or other special characters.

The root cause was that fmt.Sprintf was used to construct JSON, which doesn't
escape special characters like quotes, newlines, or tabs. When Kubernetes error
messages contain image names with quotes (e.g., "nginx:1.a.b.c"), the resulting
JSON was malformed and failed to parse.

The fix uses json.Marshal to properly construct the JSON payload, which
automatically handles all special character escaping according to JSON spec.

Fixes #1556

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
2026-02-16 17:35:22 +00:00
Three Foxes (in a Trenchcoat)
abc46474e3 refactor: improve MCP server handlers with better error handling and pagination (#1613)
* refactor: improve MCP server handlers with better error handling and pagination

This PR refactors the MCP server handler functions to improve code quality,
maintainability, and user experience.

## Key Improvements

### 1. Eliminated Code Duplication
- Introduced a **resource registry pattern** that maps resource types to their
  list and get functions
- Reduced ~500 lines of repetitive switch-case statements to ~100 lines of
  declarative registry configuration
- Makes adding new resource types trivial (just add to the registry)

### 2. Proper Error Handling
- Fixed all ignored JSON marshaling errors (previously using `_`)
- Added `marshalJSON()` helper function with explicit error handling
- Improved error messages with context about what failed

### 3. Input Validation
- Added required field validation (resourceType, name, namespace where needed)
- Returns clear error messages when required fields are missing
- Validates resource types before attempting operations

### 4. Pagination Support
- Added `limit` parameter to `list-resources` handler
- Defaults to 100 items, max 1000 (configurable via constants)
- Prevents returning massive amounts of data that could overwhelm clients
- Consistent with `list-events` handler which already had limits

### 5. Resource Type Normalization
- Added `normalizeResourceType()` function to handle aliases (pods->pod, svc->service, etc.)
- Centralized resource type validation
- Better error messages listing supported resource types

### 6. Improved Filter Management
- Added validation to ensure filters array is not empty
- Better feedback messages (e.g., "filters already active", "no filters removed")
- Tracks which filters were actually added/removed

## Technical Details

**Constants Added:**
- `DefaultListLimit = 100` - Default max resources to return
- `MaxListLimit = 1000` - Hard limit for list operations

**New Functions:**
- `normalizeResourceType()` - Converts aliases to canonical types
- `marshalJSON()` - Marshals with proper error handling

**Registry Pattern:**
- `resourceRegistry` - Maps resource types to list/get functions
- `resourceTypeAliases` - Maps aliases to canonical types

## Backward Compatibility

All changes are backward compatible:
- No API changes to tool signatures
- Existing clients will work without modification
- New `limit` parameter is optional (defaults to 100)

## Testing

Tested with:
- All resource types (pods, deployments, services, nodes, etc.)
- Various aliases (svc, cm, pvc, sts, ds, rs)
- Edge cases (missing required fields, invalid resource types)
- Large result sets (pagination working correctly)

Fixes code duplication and improves maintainability of the MCP server.

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>

* fix: remove duplicate mcp_handlers_old.go file causing build failures

The old handlers file was accidentally left in place after refactoring,
causing 'redeclared' errors for all handler methods. This commit removes
the old file to resolve the build failures.

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>

---------

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
2026-02-15 11:24:31 +00:00
github-actions[bot]
1a8f1d47a4 chore(main): release 0.4.28 (#1591)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-15 11:11:48 +00:00
Three Foxes (in a Trenchcoat)
1f2ff98834 fix: align CI Go versions with go.mod to ensure consistency (#1611)
Fixes #1610

The CI workflows were using inconsistent Go versions (1.22, 1.23) that
didn't match go.mod (go 1.24.1, toolchain go1.24.11). This creates
confusion for contributors and risks version-specific issues.

Changes:
- test.yaml: GO_VERSION ~1.22 -> ~1.24
- build_container.yaml: GO_VERSION ~1.23 -> ~1.24
- release.yaml: go-version 1.22 -> ~1.24

This aligns with PR #1609 which updates CONTRIBUTING.md to reflect
go.mod's Go 1.24 requirement.

Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxes53235@gmail.com>
2026-02-15 11:04:03 +00:00
kk573
c80b2e2c34 fix: use MaxCompletionTokens instead of deprecated MaxTokens for OpenAI (#1604)
The OpenAI API deprecated 'max_tokens' parameter in favor of
'max_completion_tokens' for newer models (o1, gpt-4o, etc.).

This change fixes the error:
'Unsupported parameter: max_tokens is not supported with this model.
Use max_completion_tokens instead.'

Refs: https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_tokens

Signed-off-by: Evgenii Kuzakov <evgeniy.kuzakov@csssr.com>
Co-authored-by: Evgenii Kuzakov <evgeniy.kuzakov@csssr.com>
2026-01-27 17:46:51 +00:00
lif
867bce1907 feat: add Groq as LLM provider (#1600)
Add Groq as a new AI backend provider. Groq provides an OpenAI-compatible
API, so this implementation reuses the existing OpenAI client library
with Groq's API endpoint.

Closes #1269

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: majiayu000 <1835304752@qq.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 12:05:17 +00:00
Alex Jones
f5fb2a7e12 feat: multiple security fixes. Prometheus: v0.302.1 → v0.306.0 (#1597)
Kubernetes client-go: v0.32.2 → v0.32.3 (security patches)
gRPC Gateway: v2.25.1 → v2.26.3
Prometheus Sigv4: v0.1.1 → v0.2.0
OpenTelemetry: Multiple v1.34.0 → v1.36.0 updates
gRPC: v1.70.0 → v1.73.0
Docker SDK: v27.4.1 → v28.3.0
Cloud/Auth SDKs: Multiple security updates

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-12-22 13:56:02 +00:00
renovate[bot]
a303ffa21c chore(deps): update actions/setup-go digest to 40f1582 (#1593)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-22 08:37:11 +00:00
Alex Jones
21369c5c09 chore: util tests (#1594)
* chore: incremental test coverage

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: incremental test coverage

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixed some security stuff

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixing linting issues

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixing linting issues

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixing linting issues

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-12-22 08:24:18 +00:00
renovate[bot]
40ffcbec6b chore(deps): update actions/checkout digest to 93cb6ef (#1592)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-18 16:45:32 +00:00
renovate[bot]
7fe3bdbd95 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1550)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-18 16:08:12 +00:00
github-actions[bot]
e7b7a5db47 chore(main): release 0.4.27 (#1590)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-18 13:52:08 +00:00
Alex Jones
5480051230 feat: mcp v2 (#1589)
* feat: bringing in 9 new mcp capabilities

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: bringing in 9 new mcp capabilities

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixed linting issue

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-12-18 13:11:10 +00:00
github-actions[bot]
ee6f58443b chore(main): release 0.4.26 (#1584)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-16 08:31:09 +01:00
Alex Jones
f1d2e306f3 chore: missing filter arg on serve (#1583)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-10-16 08:27:39 +01:00
github-actions[bot]
83c5d67084 chore(main): release 0.4.25 (#1576)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-09-03 20:09:29 +01:00
Alex Jones
291e42dc4b feat: fix to broken inference (#1575)
Signed-off-by: Alex <alexsimonjones@gmail.com>
2025-09-03 20:08:44 +01:00
github-actions[bot]
8bbffed643 chore(main): release 0.4.24 (#1560)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-08-24 18:59:36 +01:00
Umesh Kaul
53345895de feat: update helm charts with mcp support and fix Google ADA issue (#1568)
* migrated to more actively maintained mcp golang lib and added AI explain support for mcp mode

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* added a makefile option to create local docker image for testing

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* fixed linter errors and made anonymize as an arg

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* added mcp support for helm chart and fixed google adk support issue

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

---------

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
2025-08-18 19:33:12 +01:00
Alex Jones
7e332761d8 feat: reintroduced inference code (#1548)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-08-18 19:32:11 +01:00
renovate[bot]
0239b2fe6e chore(deps): update docker/login-action digest to 184bdaa (#1559)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-17 20:17:52 +01:00
renovate[bot]
c5c9135900 chore(deps): update amannn/action-semantic-pull-request action to v6 (#1565)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-16 12:06:30 +01:00
renovate[bot]
5e86f4925c chore(deps): update goreleaser/goreleaser-action digest to e435ccd (#1569)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-15 14:07:28 +01:00
Bruno Andrade
0cf4cae07e feat: add ClusterServiceVersion, Subscription, InstallPlan, OperatorGroup, and CatalogSource analyzers (#1564)
Signed-off-by: Bruno Andrade <bruno.balint@gmail.com>
2025-08-13 17:39:12 +01:00
renovate[bot]
e385e77da9 chore(deps): update actions/checkout action to v5 (#1562)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-12 16:56:30 +01:00
Umesh Kaul
c47ae595fb fix: migrated to more actively maintained mcp golang lib and added AI explain (#1557)
* migrated to more actively maintained mcp golang lib and added AI explain support for mcp mode

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* added a makefile option to create local docker image for testing

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* fixed linter errors and made anonymize as an arg

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

---------

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-08-10 12:52:17 +01:00
github-actions[bot]
00c99dc934 chore(main): release 0.4.23 (#1549)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-08-10 07:48:03 +01:00
Jian Zhang
a821814125 feat: add ClusterCatalog and ClusterExtension analyzers (#1555)
Signed-off-by: Jian Zhang <jiazha@redhat.com>
2025-08-08 17:12:05 +01:00
renovate[bot]
50d5d78c06 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1537)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-20 20:27:15 +01:00
renovate[bot]
5b4224951e fix(deps): update module helm.sh/helm/v3 to v3.17.4 [security] (#1541)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-20 19:20:42 +01:00
Anders Swanson
290a4be210 feat: oci genai chat models (#1337)
Signed-off-by: Anders Swanson <anders.swanson@oracle.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-07-20 10:02:47 +01:00
github-actions[bot]
fe4608793d chore(main): release 0.4.22 (#1545)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-07-18 15:28:01 +01:00
Umesh Kaul
3a1187ad5a feat: add streamable-http support for MCP server (#1546)
* use mcp library to support streamable http and fix resourceResponse

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* added name and version for mcp server

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* added tests

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

* chore: fixed linter

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fixed linter issues in server_test.go

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>

---------

Signed-off-by: Umesh Kaul <umeshkaul@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
Co-authored-by: AlexsJones <alexsimonjones@gmail.com>
2025-07-18 15:14:54 +01:00
koichi
1819e6f410 feat: add APAC region Claude models support for Amazon Bedrock (#1543)
Signed-off-by: Koichi Shimada <jumpe1programming@gmail.com>
2025-07-14 11:24:03 +01:00
github-actions[bot]
392c79d0be chore(main): release 0.4.21 (#1536)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-27 11:55:09 +01:00
HarelMil
00c07999e2 feat: add latest and legacy stable models (#1539)
Signed-off-by: HarelMil <HarelMil@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-06-27 08:34:23 +01:00
Alex Jones
8002d94345 feat: support for claude4 && model names listed (#1540)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-06-27 08:24:38 +01:00
renovate[bot]
0c917fc601 chore(deps): update docker/setup-buildx-action digest to e468171 (#1527)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-24 14:47:12 +01:00
renovate[bot]
08f2855a4d fix(deps): update module gopkg.in/yaml.v2 to v3 (#1511)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-20 17:20:36 +01:00
github-actions[bot]
57d32720dc chore(main): release 0.4.20 (#1533)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-20 16:56:13 +01:00
Alex Jones
0f700f0cd3 chore: model name (#1535)
* feat: added cache purge

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: improved AWS creds errors

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: removed model name

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated tests

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-06-20 16:30:50 +01:00
Alex Jones
74fbde0053 feat: added cache purge (#1532)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-06-20 16:00:08 +01:00
github-actions[bot]
ff619481cc chore(main): release 0.4.19 (#1531)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-20 13:54:13 +01:00
Alex Jones
5636515db9 feat: fixed haiku (#1530)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-06-20 13:49:24 +01:00
github-actions[bot]
47f09ac686 chore(main): release 0.4.18 (#1510)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-20 13:28:54 +01:00
Alex Jones
be4fb1cc03 chore: model access (#1529)
* chore: improve the node analyzer reporting false positives

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: improving the bedrock model access message

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: improving the bedrock model access message

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: improving the bedrock model access message

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: repairing tests

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-06-20 13:27:49 +01:00
renovate[bot]
5947876e49 chore(deps): update softprops/action-gh-release digest to 72f2c25 (#1526)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-11 06:17:02 +01:00
renovate[bot]
7d4cb26713 fix(deps): update k8s.io/utils digest to 4c0f3b2 (#1523)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-10 19:04:24 +01:00
renovate[bot]
6b9f346bf6 chore(deps): update softprops/action-gh-release digest to d5382d3 (#1525)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-10 18:50:49 +01:00
renovate[bot]
42654e7f55 chore(deps): update codecov/codecov-action digest to 18283e0 (#1513)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-27 18:56:55 +01:00
renovate[bot]
7dfe8bef0f chore(deps): update docker/build-push-action digest to 2634353 (#1517)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-27 18:43:24 +01:00
renovate[bot]
dfcc5dc5a1 chore(deps): update docker/build-push-action digest to 1dc7386 (#1512)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-20 11:21:03 +01:00
renovate[bot]
d7cb19ad29 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1509)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-15 09:08:24 +01:00
github-actions[bot]
306b3c9997 chore(main): release 0.4.17 (#1499)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-14 20:57:55 +01:00
renovate[bot]
1e57b7774c chore(deps): update golangci/golangci-lint-action action to v8 (#1490)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-14 20:45:57 +01:00
renovate[bot]
d308c511fb fix(deps): update module gopkg.in/yaml.v2 to v3 (#1500)
* fix(deps): update module gopkg.in/yaml.v2 to v3

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: resolved conflict in deps

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-05-14 20:38:36 +01:00
Alex Jones
4faf77d91a chore: golangci lint (#1508)
* feat: added token for goreleaser

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: updated the bedrock supported regions

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updating golangci_lint

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-05-14 17:04:49 +01:00
rkarthikr
b2241c03c9 feat: adding fixes for Messages API issue 1391 (#1504)
Signed-off-by: rkarthikr <38294804+rkarthikr@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-05-14 14:33:54 +01:00
Kay Yan
0b7ddf5e3b feat: new job analyzer (#1506)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2025-05-14 09:22:05 +01:00
renovate[bot]
d0f03641ae fix(deps): update module gopkg.in/yaml.v2 to v3 (#1454)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-09 15:30:11 +01:00
renovate[bot]
e76bdb0c23 chore(deps): update actions/setup-go digest to d35c59a (#1495)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-09 13:17:19 +01:00
typeid
cae94e7b6d fix: panic in k8sgpt auth update (#1497)
Signed-off-by: Claudio Busse <cbusse@redhat.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-05-09 13:02:37 +01:00
typeid
7e375a30be fix: align documentation to reflect default analyzers properly (#1498)
Signed-off-by: Claudio Busse <cbusse@redhat.com>
2025-05-09 12:58:29 +01:00
github-actions[bot]
34ff645fa0 chore(main): release 0.4.16 (#1478)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-06 19:24:25 +01:00
Naveen Thangaraj
61b60d5768 feat: enhancement of deployment analyzer (#1406)
* Updated the deployment analyzer

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Enhanced the deployment analyzer

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

---------

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-05-06 16:30:16 +01:00
renovate[bot]
6a81d2c140 fix(deps): update k8s.io/utils digest to 0f33e8f (#1484)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-06 11:30:48 +01:00
rkarthikr
21bc76e5b7 feat: add support for Amazon Bedrock Inference Profiles (#1492)
Signed-off-by: rkarthikr <38294804+rkarthikr@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-05-06 11:18:40 +01:00
renovate[bot]
d5341f3c00 chore(deps): update golangci/golangci-lint-action digest to 9fae48a (#1489)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-06 09:23:12 +01:00
Alex Jones
752a16c407 feat: supported regions govcloud (#1483)
* feat: added token for goreleaser

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: updated the bedrock supported regions

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-05-01 09:01:25 +01:00
renovate[bot]
81da402d46 chore(deps): update docker/build-push-action digest to 14487ce (#1472)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-29 13:58:23 +01:00
github-actions[bot]
f2f25edef7 chore(main): release 0.4.15 (#1477)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-29 12:57:30 +01:00
Alex Jones
85935a46d8 feat: added token for goreleaser (#1476)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-29 12:49:44 +01:00
github-actions[bot]
a56e663169 chore(main): release 0.4.14 (#1470)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-29 09:26:48 +01:00
Alex Jones
e41ffd80d0 feat: add MCP support (#1471)
* feat: first mcp impl

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: update

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: wip

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: switcheed to stdio transport

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: readme

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: fix the linter 🤖

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: fix the linter 🤖

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat(mcp): implement MCP server and handler

- Implement MCP server and handler
- Add MCP server to serve
- Add MCP handler to handle MCP requests
- Add MCP server to serve
- Add MCP handler to handle MCP requests

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: consolidating code duplication

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: added http sse support

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: fixed broken tests

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated and fixed linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated and fixed linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated the linter issues

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-29 09:22:44 +01:00
ju187
f603948935 feat: using modelName will calling completion (#1469)
* using modelName will calling completion

Signed-off-by: Tony Chen <tony_chen@discovery.com>

* sign

Signed-off-by: Tony Chen <tony_chen@discovery.com>

---------

Signed-off-by: Tony Chen <tony_chen@discovery.com>
2025-04-24 09:15:17 +01:00
github-actions[bot]
67f5855695 chore(main): release 0.4.13 (#1465)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-22 11:28:20 +01:00
Antoine Deschênes
ebb0373f69 fix: reverse hpa ScalingLimited error condition (#1366)
* fix: reverse hpa ScalingLimited error condition

Signed-off-by: Antoine Deschênes <antoine.deschenes@linux.com>

* chore: removed break

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Antoine Deschênes <antoine.deschenes@linux.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-22 11:27:02 +01:00
Alex Jones
3b6ad06de1 feat: slack announce (#1466)
* chore: added slack integration on release

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: patched two go dep security warnings

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-22 10:49:52 +01:00
renovate[bot]
443469960a chore(deps): update softprops/action-gh-release digest to da05d55 (#1464)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-19 20:27:30 +01:00
github-actions[bot]
17863c24d5 chore(main): release 0.4.12 (#1460)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-17 20:57:10 +01:00
renovate[bot]
e588fc316d fix(deps): update module golang.org/x/net to v0.38.0 [security] (#1462)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-17 20:50:44 +01:00
Alex Jones
a128906136 feat: new analyzers (#1459)
* chore: rebased
chore: removed trivy

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: missing error

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: missing error

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: switching old sonnet to message API

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added three new analyzers

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.2 (#1400)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* docs: remove extra dollar sign in README.md (#1410)

Signed-off-by: Qian_Xiao <heyheyco@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* test: add tests for `k8sgpt/pkg/analyzer/events.go` (#913)

* test: add tests for events_test.go

Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>

* feat: fixed event tests

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* docs: add table of contents and cleanup (#1413)

Signed-off-by: hadi2f244 <m.h.azaddel@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: linter (#1414)

* chore: changing linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: changing linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: changing linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(deps): pin golangci/golangci-lint-action action to 1481404 (#1415)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(deps): update goreleaser/goreleaser-action digest to 9c156ee (#1411)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: prometheus UTF8Validation (#1404)

Signed-off-by: Kay Yan <kay.yan@daocloud.io>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix(deps): update module gopkg.in/yaml.v2 to v3 (#1363)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: added new AmazonBedrock model  (#1390)

* Update AI Bedrock region - Added mumbai region

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

* Update amazonbedrock.go

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

* Added new AI model to work for ap-south-1 region[that does not uses inference profile]

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

---------

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.3 (#1412)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(deps): update module github.com/docker/docker to v28 (#1376)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updating deps (#1422)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(deps): update docker/setup-buildx-action digest to b5ca514 (#1371)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.4 (#1421)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fix workflows (#1423)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.5 (#1424)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixing docker build push action (#1426)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated actor for login (#1430)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(deps): pin docker/build-push-action action to 471d1dc (#1428)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.6 (#1427)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixing build (#1431)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(deps): update actions/upload-artifact digest to ea165f8 (#1425)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.7 (#1432)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: removed krew release (#1434)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.8 (#1435)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixing (#1437)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(deps): pin dependencies (#1440)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.9 (#1439)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: pod analyzer catches errors when containers are in Terminated state (#1438)

Signed-off-by: Guoxun Wei <guwe@microsoft.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: add a naive support of bedrock inference profile (#1446)

* feat: add a naive support of bedrock inference profile

Signed-off-by: Tony Chen <tony_chen@discovery.com>

* feat: improving the tests

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Tony Chen <tony_chen@discovery.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix(deps): update module gopkg.in/yaml.v2 to v3 (#1417)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix(deps): update module helm.sh/helm/v3 to v3.17.3 [security] (#1448)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.10 (#1441)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: call bedrock with inference profile (#1449)

* call bedrock with inference profile

Signed-off-by: Tony Chen <tony_chen@discovery.com>

* add validation and test

Signed-off-by: Tony Chen <tony_chen@discovery.com>

* update test

Signed-off-by: Tony Chen <tony_chen@discovery.com>

---------

Signed-off-by: Tony Chen <tony_chen@discovery.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix(deps): update module gopkg.in/yaml.v2 to v3 (#1447)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* docs: fix the slack invite link (#1450)

Signed-off-by: Pengfei Ni <feiskyer@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: add verbose flag to enable detailed output (#1420)

* feat: add verbose flag to enable detailed output

Signed-off-by: Yicheng <36285652+zyc140345@users.noreply.github.com>

* test: add verbose output tests for analysis.go and root.go

Signed-off-by: Yicheng <36285652+zyc140345@users.noreply.github.com>

---------

Signed-off-by: Yicheng <36285652+zyc140345@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix(deps): update module gopkg.in/yaml.v2 to v3 (#1453)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: improved test coverage (#1455)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: config ai provider in query (#1457)

Signed-off-by: Guoxun Wei <guwe@microsoft.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore(main): release 0.4.11 (#1451)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixed test

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixed test

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
Signed-off-by: Qian_Xiao <heyheyco@gmail.com>
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: hadi2f244 <m.h.azaddel@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>
Signed-off-by: Guoxun Wei <guwe@microsoft.com>
Signed-off-by: Tony Chen <tony_chen@discovery.com>
Signed-off-by: Pengfei Ni <feiskyer@gmail.com>
Signed-off-by: Yicheng <36285652+zyc140345@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Qian_Xiao <heyheyco@gmail.com>
Co-authored-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Co-authored-by: Hadi Azaddel <m.h.azaddel@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Kay Yan <kay.yan@daocloud.io>
Co-authored-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>
Co-authored-by: gossion <guwe@microsoft.com>
Co-authored-by: ju187 <tony_chen@discovery.com>
Co-authored-by: Pengfei Ni <feiskyer@users.noreply.github.com>
Co-authored-by: Yicheng <36285652+zyc140345@users.noreply.github.com>
2025-04-15 13:43:38 +01:00
renovate[bot]
0553b984b7 chore(deps): update codecov/codecov-action digest to ad3126e (#1456)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-15 12:45:00 +01:00
github-actions[bot]
96d86d3eb0 chore(main): release 0.4.11 (#1451)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-15 11:24:06 +01:00
gossion
df17e3e728 fix: config ai provider in query (#1457)
Signed-off-by: Guoxun Wei <guwe@microsoft.com>
2025-04-15 11:11:40 +01:00
Alex Jones
80904e3063 feat: improved test coverage (#1455)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-14 14:15:26 +01:00
renovate[bot]
cf6f9289e1 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1453)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-14 13:50:15 +01:00
Yicheng
a79224e2bf feat: add verbose flag to enable detailed output (#1420)
* feat: add verbose flag to enable detailed output

Signed-off-by: Yicheng <36285652+zyc140345@users.noreply.github.com>

* test: add verbose output tests for analysis.go and root.go

Signed-off-by: Yicheng <36285652+zyc140345@users.noreply.github.com>

---------

Signed-off-by: Yicheng <36285652+zyc140345@users.noreply.github.com>
2025-04-14 13:06:24 +01:00
Pengfei Ni
9ce33469d8 docs: fix the slack invite link (#1450)
Signed-off-by: Pengfei Ni <feiskyer@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-14 11:48:35 +01:00
renovate[bot]
969fe99b33 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1447)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-11 09:53:59 +01:00
ju187
91d423b147 feat: call bedrock with inference profile (#1449)
* call bedrock with inference profile

Signed-off-by: Tony Chen <tony_chen@discovery.com>

* add validation and test

Signed-off-by: Tony Chen <tony_chen@discovery.com>

* update test

Signed-off-by: Tony Chen <tony_chen@discovery.com>

---------

Signed-off-by: Tony Chen <tony_chen@discovery.com>
2025-04-11 07:11:38 +01:00
github-actions[bot]
766b51cd3e chore(main): release 0.4.10 (#1441)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-10 21:45:59 +01:00
renovate[bot]
060a3b2a26 fix(deps): update module helm.sh/helm/v3 to v3.17.3 [security] (#1448)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-10 18:59:22 +01:00
renovate[bot]
ce4b3c2e7d fix(deps): update module gopkg.in/yaml.v2 to v3 (#1417)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-10 11:25:50 +01:00
ju187
78ffa5904a feat: add a naive support of bedrock inference profile (#1446)
* feat: add a naive support of bedrock inference profile

Signed-off-by: Tony Chen <tony_chen@discovery.com>

* feat: improving the tests

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Tony Chen <tony_chen@discovery.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-10 09:47:58 +01:00
gossion
dceda9a6a1 fix: pod analyzer catches errors when containers are in Terminated state (#1438)
Signed-off-by: Guoxun Wei <guwe@microsoft.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-08 10:49:53 +01:00
github-actions[bot]
e7783482ce chore(main): release 0.4.9 (#1439)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-08 09:17:34 +01:00
renovate[bot]
a5574ee49d chore(deps): pin dependencies (#1440)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-08 09:08:25 +01:00
Alex Jones
f68ff0efee chore: fixing (#1437)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-08 08:36:39 +01:00
github-actions[bot]
0c63044254 chore(main): release 0.4.8 (#1435)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-07 20:31:33 +01:00
Alex Jones
39ae2aa635 chore: removed krew release (#1434)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-07 20:28:36 +01:00
github-actions[bot]
05040da188 chore(main): release 0.4.7 (#1432)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-07 17:32:40 +01:00
renovate[bot]
9bffc7cff7 chore(deps): update actions/upload-artifact digest to ea165f8 (#1425)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-07 16:54:08 +01:00
Alex Jones
c5fe2c68d1 chore: fixing build (#1431)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-07 16:50:19 +01:00
github-actions[bot]
c1b267b818 chore(main): release 0.4.6 (#1427)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-07 15:22:49 +01:00
renovate[bot]
5086ccd659 chore(deps): pin docker/build-push-action action to 471d1dc (#1428)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-07 15:16:26 +01:00
Alex Jones
b6261026f8 chore: updated actor for login (#1430)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-07 15:07:49 +01:00
Alex Jones
1681aadac1 chore: fixing docker build push action (#1426)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-07 07:37:25 +01:00
github-actions[bot]
9874cef8bf chore(main): release 0.4.5 (#1424)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-07 06:51:58 +01:00
Alex Jones
3dbc9e1a20 chore: fix workflows (#1423)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-07 06:50:46 +01:00
github-actions[bot]
e0d66f43f7 chore(main): release 0.4.4 (#1421)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-06 20:41:54 +01:00
renovate[bot]
d4de5d9e3f chore(deps): update docker/setup-buildx-action digest to b5ca514 (#1371)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-06 20:34:35 +01:00
Alex Jones
5b7fb7e619 chore: updating deps (#1422)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-06 19:30:25 +01:00
renovate[bot]
68ddac0089 chore(deps): update module github.com/docker/docker to v28 (#1376)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-06 16:47:40 +01:00
github-actions[bot]
d1a29e4001 chore(main): release 0.4.3 (#1412)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-04 11:49:09 +01:00
Sakshi Singh
ad2c90a129 chore: added new AmazonBedrock model (#1390)
* Update AI Bedrock region - Added mumbai region

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

* Update amazonbedrock.go

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

* Added new AI model to work for ap-south-1 region[that does not uses inference profile]

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

---------

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-04-04 11:45:05 +01:00
renovate[bot]
e4861e9e2d fix(deps): update module gopkg.in/yaml.v2 to v3 (#1363)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-02 16:19:03 +01:00
Kay Yan
3c353b0e93 fix: prometheus UTF8Validation (#1404)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2025-04-02 16:07:32 +01:00
renovate[bot]
c823de12e6 chore(deps): update goreleaser/goreleaser-action digest to 9c156ee (#1411)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-01 07:34:51 +01:00
renovate[bot]
e231032e1b chore(deps): pin golangci/golangci-lint-action action to 1481404 (#1415)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-31 20:14:41 +01:00
Alex Jones
f0b18cfb1c chore: linter (#1414)
* chore: changing linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: changing linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: changing linter

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2025-03-31 19:17:55 +01:00
Hadi Azaddel
a31d07c802 docs: add table of contents and cleanup (#1413)
Signed-off-by: hadi2f244 <m.h.azaddel@gmail.com>
2025-03-31 19:04:59 +01:00
Eshaan Aggarwal
06d201ca5d test: add tests for k8sgpt/pkg/analyzer/events.go (#913)
* test: add tests for events_test.go

Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>

* feat: fixed event tests

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-03-31 14:33:02 +01:00
Qian_Xiao
a962741220 docs: remove extra dollar sign in README.md (#1410)
Signed-off-by: Qian_Xiao <heyheyco@gmail.com>
2025-03-31 14:09:41 +01:00
github-actions[bot]
a75ec50789 chore(main): release 0.4.2 (#1400)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-03-28 14:17:21 +00:00
Alex Jones
e5817f9e55 feat: old sonnet (#1408)
* chore: rebased
chore: removed trivy

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: missing error

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: missing error

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: switching old sonnet to message API

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-03-28 13:51:47 +00:00
renovate[bot]
f5eaf817f0 fix(deps): update k8s.io/utils digest to 1f6e0b7 (#1405)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-25 07:26:43 +00:00
renovate[bot]
eb381b8087 chore(deps): update actions/upload-artifact digest to ea165f8 (#1402)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-21 10:42:48 +00:00
Alex Jones
288ca862b3 chore: fix error (#1403)
* chore: rebased
chore: removed trivy

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: missing error

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* fix: missing error

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-03-19 21:05:53 +00:00
renovate[bot]
81d4aaf402 chore(deps): update actions/setup-go digest to 0aaccfd (#1401)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-19 15:39:46 +00:00
renovate[bot]
fdf8e7a95a chore(deps): update docker/login-action digest to 74a5d14 (#1397)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-17 19:17:47 +00:00
github-actions[bot]
5a48bae667 chore(main): release 0.4.1 (#1389)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-03-17 12:23:11 +00:00
popsiclexu
7540e0084e feat: add custom restful backend for complex scenarios (e.g, rag) (#1228)
* feat: add custom restful backend for complex scenarios (e.g, rag)

Signed-off-by: popsiclexu <zhenxuexu@gmail.com>

* chore: rebased
chore: removed trivy

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: resolved issues

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: popsiclexu <zhenxuexu@gmail.com>
Signed-off-by: popsiclexu <ZhenxueXu@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
Co-authored-by: popsiclexu <zhenxue.xu@mthreads.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-03-17 12:21:38 +00:00
renovate[bot]
eb7b36aa27 fix(deps): update module golang.org/x/net to v0.36.0 [security] (#1395)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-17 12:06:10 +00:00
renovate[bot]
d6d2e3bc42 chore(deps): update goreleaser/goreleaser-action digest to 90a3faa (#1308)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-11 21:20:04 +00:00
100daysofdevops
4e39cb65b3 fix(deps): update default model to gpt-4o for improved performance and cost efficiency (#1332)
* fix: update OpenAI API key generation URL to reflect new platform link

Updated the outdated URL 'https://beta.openai.com/account/api-keys' to the current OpenAI API key generation page 'https://platform.openai.com/account/api-keys'.

This resolves the issue where users were directed to an incorrect URL when generating an OpenAI API key.


Signed-off-by: 100daysofdevops <47483190+100daysofdevops@users.noreply.github.com>

* fix(deps):Add transition plan for GPT-3.5 Turbo to GPT-4o

- A comprehensive comparison of GPT-3.5 Turbo and GPT-4o models, focusing on performance and cost improvements.
- Documentation updates highlighting the planned deprecation of gpt-3.5-turbo-0301 on February 13, 2025.
- Clear migration guidelines for transitioning to GPT-4o or GPT-4o mini to ensure service continuity.

Signed-off-by: 100daysofdevops <47483190+100daysofdevops@users.noreply.github.com>

---------

Signed-off-by: 100daysofdevops <47483190+100daysofdevops@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-03-11 20:58:21 +00:00
renovate[bot]
db5e517dbb chore(deps): update softprops/action-gh-release digest to c95fe14 (#1359)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-11 20:52:28 +00:00
Cindy Tong
aa1e237ebb feat: add amazon bedrock nova pro and nova lite models (#1383)
* feat: add amazon bedrock nova pro and nova lite models

Signed-off-by: Cindy Tong <tongcindyy@gmail.com>

* fix nova responses

Signed-off-by: Cindy Tong <tongcindyy@gmail.com>

* remove printing of Nova Response

Signed-off-by: Cindy Tong <tongcindyy@gmail.com>

* remove comments

Signed-off-by: Cindy Tong <tongcindyy@gmail.com>

* chore: rebased
chore: removed trivy

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: adding inference profile labels as model names

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added some tests around completions and responses

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added model test

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: Cindy Tong <tongcindyy@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
Co-authored-by: AlexsJones <alexsimonjones@gmail.com>
2025-03-11 12:55:21 +00:00
renovate[bot]
f2fdfd8dca chore(deps): update actions/setup-go digest to f111f33 (#1364)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-07 12:07:47 +00:00
github-actions[bot]
e14c3dad55 chore(main): release 0.4.0 (#1382)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-03-07 11:15:27 +00:00
renovate[bot]
093975e50d chore(deps): update actions/upload-artifact digest to 4cec3d8 (#1378)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-06 15:02:06 +00:00
Sakshi Singh
4f4f4f13a0 chore: Adding region (#1388)
* Update AI Bedrock region - Added mumbai region

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

* Update amazonbedrock.go

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>

---------

Signed-off-by: Sakshi Singh <66963254+sakshirajput02@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-03-06 12:22:57 +00:00
renovate[bot]
2a6f48500c chore(deps): update codecov/codecov-action digest to 0565863 (#1387)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-06 12:19:13 +00:00
renovate[bot]
f2e3b9a8a7 chore(deps): update docker/build-push-action digest to 471d1dc (#1358)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-04 07:55:27 +00:00
Alex Jones
d1b2227ff9 feat!: Removal of Trivy (#1386)
* feat: removal of trivy integration

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: removal of trivy integration

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: removed trivy

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-03-04 07:33:14 +00:00
Alex Jones
1f953585c9 chore: remediating security issue (#1381)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-02-24 19:45:06 +00:00
Kay Yan
9dcb21e160 fix: [Bug] Filter PolicyReport ignores namespace flag (#1355)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2025-02-24 19:40:34 +00:00
github-actions[bot]
d956f32e1e chore(main): release 0.3.50 (#1379)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-02-24 11:05:33 +00:00
Alex Jones
7dadea2570 feat: rework to how bedrock data models are structured and accessed (#1369)
* feat: rework to how bedrock data models are structured and accessed

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: rework to how bedrock data models are structured and accessed

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2025-02-24 11:03:19 +00:00
github-actions[bot]
3b85f09348 chore(main): release 0.3.49 (#1345)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-02-20 12:02:20 +00:00
Justin Santa Barbara
06b8f78150 chore: fix typo in "completion" (#1362)
Signed-off-by: justinsb <justinsb@google.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-02-20 11:48:52 +00:00
Dirc
076ca2f148 docs: fix broken schema link in README.md (#1373)
Signed-off-by: Dirc <e.e.cornet@gmail.com>
2025-02-20 11:46:12 +00:00
renovate[bot]
fcc8563e4e fix(deps): update k8s.io/utils digest to 24370be (#1344)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-06 16:08:33 +00:00
renovate[bot]
5de4f7704a fix(deps): update module golang.org/x/net to v0.33.0 [security] (#1354)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-06 12:00:58 +00:00
Daniel Clark
83672fa768 fix: prevent npe by handling checking error in NewAnalysis call (#1365)
If there is an issue in creating the Analysis config when calling
analysis.NewAnalysis, then we want to check before assigning the context to a
potentially nil pointer.

Signed-off-by: Danny Clark <danielclark@google.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2025-01-31 14:26:35 +00:00
renovate[bot]
990d723909 chore(deps): update codecov/codecov-action digest to 13ce06b (#1342)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-25 17:06:09 +00:00
renovate[bot]
c506a4b441 chore(deps): update actions/upload-artifact digest to 65c4c4a (#1350)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-18 20:48:55 +00:00
renovate[bot]
2918556793 chore(deps): update docker/setup-buildx-action digest to 6524bf6 (#1349)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-18 20:21:46 +00:00
renovate[bot]
19abbef9a3 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1336)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-13 07:35:23 +00:00
renovate[bot]
939e0672aa chore(deps): update actions/setup-go digest to 3041bf5 (#1347)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-12 17:24:09 +00:00
renovate[bot]
8cd3b2985e fix(deps): update all non-major dependencies (#1335)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-10 09:41:16 +00:00
github-actions[bot]
1827c43696 chore(main): release 0.3.48 (#1341)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-12-04 14:07:11 +00:00
Alex Jones
1363219b1b feat: fixed missing cache params (#1340)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-12-04 10:30:57 +00:00
github-actions[bot]
c3f448693d chore(main): release 0.3.47 (#1320)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-12-02 16:45:20 +00:00
renovate[bot]
5514ebb53b fix(deps): update module gopkg.in/yaml.v2 to v3 (#1326)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-02 13:45:39 +00:00
renovate[bot]
c21ba86237 chore(deps): update docker/build-push-action digest to 48aba3b (#1333)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-02 13:08:07 +00:00
Alex Jones
d6d80ee860 feat: adds interplex as a caching provider (#1328)
* feat: adds interplex as a caching provider

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: refactored cache input to lower

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: refactored cache input to lower

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-12-02 12:58:08 +00:00
renovate[bot]
a841568a9c chore(deps): update all non-major dependencies (#1327)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-02 12:08:02 +00:00
renovate[bot]
4d7eb0f622 chore(deps): update codecov/codecov-action digest to 015f24e (#1325)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-26 13:56:01 +00:00
ju187
a12aa07b1a feat: add new AWS Bedrock model ids (#1330)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-11-25 07:37:39 +00:00
100daysofdevops
ec5e42b8f4 fix: update OpenAI API key generation URL to reflect new platform link (#1331)
Updated the outdated URL 'https://beta.openai.com/account/api-keys' to the current OpenAI API key generation page 'https://platform.openai.com/account/api-keys'.

This resolves the issue where users were directed to an incorrect URL when generating an OpenAI API key.

Signed-off-by: 100daysofdevops <47483190+100daysofdevops@users.noreply.github.com>
2024-11-25 07:32:11 +00:00
renovate[bot]
69c67bd1d9 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1321)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-17 19:59:22 +00:00
renovate[bot]
b3f60b2d20 fix(deps): update all non-major dependencies (#1323)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-17 16:41:15 +00:00
renovate[bot]
cb1e1ffede chore(deps): update codecov/codecov-action action to v5 (#1324)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-15 12:24:26 +00:00
renovate[bot]
f37d923918 chore(deps): update docker/build-push-action action to v6 (#1294)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-12 20:36:32 +00:00
Samir Tahir
a50375c960 fix: add maxTokens to serve mode (#1280)
Signed-off-by: samir-tahir <samirtahir91@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-11-12 20:16:29 +00:00
Alex Jones
da266b3c82 feat: dump (#1322)
* feat: reverting the cncf runners

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: creating a dump file for debugging

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: ran the linter

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: improved the function readme

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added k8sgpt version info

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added k8sgpt version info

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: added additional command

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-11-12 12:04:01 +00:00
renovate[bot]
896a53be83 chore(deps): update rajatjindal/krew-release-bot action to v0.0.47 (#1317)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-12 07:13:06 +00:00
renovate[bot]
2da057360b fix(deps): update module gopkg.in/yaml.v2 to v3 (#1303)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-11 06:09:39 +00:00
github-actions[bot]
69fd7c7696 chore(main): release 0.3.46 (#1316)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-10 21:00:49 +00:00
Alex Jones
ad86e7aa39 feat: reverting the cncf runners (#1319)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-11-10 20:54:16 +00:00
Alex Jones
1ae70e806e feat: updated runners to enterprise (#1318)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-11-10 20:26:43 +00:00
renovate[bot]
2ce8450e03 chore(deps): update actions/setup-go digest to 41dfa10 (#1284)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-10 17:13:38 +00:00
renovate[bot]
b6b3d0c856 chore(deps): update softprops/action-gh-release action to v2 (#1295)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-10 16:29:01 +00:00
Alex Jones
5f7d9de46a feat: switching to higher spec runners (#1312)
* feat: switching to higher spec runners

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: switched to runner groups

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: switched to runner groups

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: switched to runner groups

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-11-10 16:06:06 +00:00
Alex Jones
7dcdfc83d2 feat: testupdate (#1315)
* feat: updated server test function

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: fixed server test

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated go.sum

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added free disk space to release job

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-11-10 15:33:50 +00:00
github-actions[bot]
44f4f7437f chore(main): release 0.3.45 (#1314)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-10 09:25:48 +00:00
Alex Jones
783cd1cfc6 feat: free disk (#1313)
* chore: updated go.sum

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added free disk space to release job

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* feat: added free disk space to release job

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-11-10 09:11:54 +00:00
github-actions[bot]
62ba6d84a4 chore(main): release 0.3.44 (#1311)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-09 17:55:26 +00:00
Alex Jones
cc9b3ea657 feat: test revert runner on release job (#1310)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-11-09 17:44:56 +00:00
github-actions[bot]
8ad288152f chore(main): release 0.3.43 (#1301)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-11-09 16:05:58 +00:00
renovate[bot]
004d9efc55 fix(deps): update all non-major dependencies (#1307)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-09 15:10:05 +00:00
renovate[bot]
2f62c7b3e0 fix(deps): update k8s.io/utils digest to 6fe5fd8 (#1302)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-07 17:24:45 +00:00
renovate[bot]
a6b19a81b0 fix(deps): update all non-major dependencies (#1306)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-06 14:54:35 +00:00
renovate[bot]
32e8bc3253 chore(deps): update all non-major dependencies (#1304)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-05 19:56:29 +00:00
Alex Jones
5f01cc685f chore: updated to use CNCF runners (#1305)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-11-05 16:48:01 +00:00
renovate[bot]
c67add30c6 chore(deps): update dependency ubuntu to v24 (#1293)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-05 07:07:28 +00:00
renovate[bot]
2f759865b6 fix(deps): update module gopkg.in/yaml.v2 to v3 (#1296)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-04 12:52:27 +00:00
github-actions[bot]
9d68c47040 chore(main): release 0.3.42 (#1258)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-04 07:38:22 +00:00
renovate[bot]
14e0f19b12 fix(deps): update all non-major dependencies (#1291)
* fix(deps): update all non-major dependencies

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: fixed the topk type

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: AlexsJones <alexsimonjones@gmail.com>
2024-11-04 07:12:57 +00:00
renovate[bot]
c1a38c2b35 chore(deps): update codecov/codecov-action action to v4 (#1292)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 18:42:55 +00:00
Alex Jones
458fcfe8d3 chore: renovate.json (#1290)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-10-31 16:56:49 +00:00
renovate[bot]
173e4dc5ac chore(deps): update anchore/sbom-action action to v0.17.6 (#1285)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 16:14:53 +00:00
renovate[bot]
7a3fb3cf67 fix(deps): update module github.com/cohere-ai/cohere-go/v2 to v2.12.0 (#1276)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 15:16:05 +00:00
renovate[bot]
0cfecbdd87 chore(deps): update actions/checkout digest to 11bd719 (#1283)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 09:05:10 +00:00
renovate[bot]
161bc11294 chore(deps): update docker/setup-buildx-action digest to c47758b (#1213)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 08:42:10 +00:00
renovate[bot]
ad349ae263 fix(deps): update module github.com/google/generative-ai-go to v0.18.0 (#1278)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 08:34:03 +00:00
renovate[bot]
911d578bf0 chore(deps): update actions/upload-artifact digest to b4b15b8 (#1272)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 07:42:42 +00:00
Matthis
3eec9bbb05 feat: add stats option to analyze command for performance insights (#1237)
* feat: add stats option to analyze command for performance insights

Introduced a new feature to the analyze command that enables users to print detailed performance statistics of each analyzer. This enhancement aids in debugging and understanding the time taken by various components during analysis, providing valuable insights for performance optimization.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: enhance analysis command with statistics option

Refactored the analysis command to support an enhanced statistics option, enabling users to opt-in for detailed performance metrics of the analysis process. This change introduces a more flexible approach to handling statistics, allowing for a clearer separation between the analysis output and performance metrics, thereby improving the usability and insights provided to the user.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

---------

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-10-30 13:58:18 +00:00
Milap Jhumkhawala
87565a0bcc fix: [Bug] Make lint command is not working (#1282)
* fix: [Bug] Make lint command is not working

Signed-off-by: Milap Jhumkhawala <milap.jhumkhawala@gmail.com>

* forgot to sign commit

Signed-off-by: Milap Jhumkhawala <milap.jhumkhawala@gmail.com>

---------

Signed-off-by: Milap Jhumkhawala <milap.jhumkhawala@gmail.com>
2024-10-30 10:49:44 +00:00
renovate[bot]
c128bf7942 chore(deps): update anchore/sbom-action action to v0.17.4 (#1273)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-16 15:41:54 +01:00
renovate[bot]
c9b11b6eee fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/storage/azblob to v1.4.1 (#1275)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-15 07:07:41 +01:00
renovate[bot]
9f39abf89e fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go to v1.35.1-20240920204244-7a91c8620515.1 (#1274)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-14 12:55:19 +01:00
renovate[bot]
98237b6408 fix(deps): update module github.com/adrg/xdg to v0.5.0 (#1262)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-14 07:58:02 +01:00
renovate[bot]
4143e9fd52 fix(deps): update module cloud.google.com/go/storage to v1.44.0 (#1265)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-14 06:48:07 +01:00
renovate[bot]
72eb8159fb chore(deps): update actions/checkout digest to eef6144 (#1270)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-14 06:38:32 +01:00
renovate[bot]
36135857ac fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/azidentity to v1.8.0 (#1264)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-11 08:02:01 +01:00
renovate[bot]
9c1927b497 chore(deps): update module github.com/docker/docker to v27.3.1+incompatible (#1225)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-04 07:54:27 +01:00
renovate[bot]
0148a5b354 fix(deps): update module github.com/aws/aws-sdk-go to v1.55.5 (#1263)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-03 19:19:28 +01:00
renovate[bot]
037e745c6f fix(deps): update module github.com/aquasecurity/trivy-operator to v0.22.0 (#1034)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-03 19:05:04 +01:00
Naveen Thangaraj
d8fad956f4 feat: error from events for STS analyzer (#1256)
* error from events for sts analyzer

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Signedoff this commit

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

---------

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-10-03 18:33:50 +01:00
renovate[bot]
7785dd12a0 fix(deps): update k8s.io/utils digest to 49e7df5 (#1259)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-29 20:55:29 +01:00
renovate[bot]
04582d8516 chore(deps): update anchore/sbom-action action to v0.17.2 (#1248)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-27 07:45:54 +01:00
Yanwei Li
da0764d951 fix: add providerId to serve mode (#1260)
Signed-off-by: yanweili <yanweili@ibm.com>
Co-authored-by: yanweili <yanweili@ibm.com>
2024-09-27 07:32:58 +01:00
renovate[bot]
b62b7dbe3c chore(deps): update golang docker tag to v1.23 (#1254)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-25 09:13:45 +01:00
Guangya Liu
5ff6dc9be5 fix: rename watsonxai to ibmwatsonxai (#1234)
Signed-off-by: Guangya Liu <gyliu@ibm.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-09-24 21:58:01 +01:00
github-actions[bot]
f071b32aa8 chore(main): release 0.3.41 (#1217)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-09-23 06:33:03 +01:00
Alex Jones
53465d5c83 feat: adding a query mode for the schednex scheduler (#1257)
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-09-22 19:29:29 +01:00
renovate[bot]
1dfd139731 fix(deps): update module github.com/mittwald/go-helm-client to v0.12.13 (#1251)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-19 12:08:13 +01:00
Alex Jones
d9c81494b7 Update README.md (#1253)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-09-19 09:04:52 +01:00
renovate[bot]
e0e86ea60f chore(deps): update actions/upload-artifact digest to 5076954 (#1239)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-19 08:41:46 +01:00
renovate[bot]
8405778cb2 fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2 to v2.22.0-20240807134501-ea98c104104d.1 (#1186)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-18 20:18:03 +01:00
awsyshah
4f3ecf0083 feat: added support for A21 and Amazon Titan models via bedrock api (#1101)
* feat: added support for A21 and Amazon Titan models via bedrock api

Signed-off-by: Yomesh Shah <yomesh@gmail.com>

* fix: response type for diffrent models and use of constant for top_P

Signed-off-by: Yomesh Shah <yomesh@gmail.com>

* fix: constant for top_P as int vs string

Signed-off-by: Yomesh Shah <yomesh@gmail.com>

* feat: moved topP and maxTokens to config rather than being constants in the code

Signed-off-by: Yomesh Shah <yomesh@gmail.com>

---------

Signed-off-by: Yomesh Shah <yomesh@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-09-17 16:24:21 +01:00
renovate[bot]
d30563d8cd fix(deps): update k8s.io/utils digest to 702e33f (#1246)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-17 15:01:52 +01:00
Aris Boutselis
e02c0ddd2d fix: typo (#1244)
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-09-17 08:39:39 +01:00
renovate[bot]
025a069ff1 fix(deps): update module github.com/schollz/progressbar/v3 to v3.15.0 (#1227)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-16 11:43:11 +01:00
renovate[bot]
453d5c37dd chore(deps): update dependency go to v1.23.1 (#1176)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-16 07:09:27 +01:00
Dominik Augustin
be4ca86af0 fix: helm chart security context rendering if empty (#1235)
Signed-off-by: Dominik Augustin <botchk@users.noreply.github.com>
Co-authored-by: Dominik Augustin <botchk@users.noreply.github.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-09-09 07:58:05 +01:00
renovate[bot]
477ef155d3 chore(deps): update docker/login-action digest to 9780b0c (#1212)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-02 07:43:20 +01:00
michael12312
8edb053b3e fix: issue-1168, remove duplicate CVE (#1230) 2024-08-27 07:21:38 +02:00
Guangya Liu
644581f495 fix: disable adding multiple openai provider (#1191)
Signed-off-by: Guangya Liu <gyliu@ibm.com>
Co-authored-by: Matthis <matthish29@gmail.com>
2024-08-20 15:52:44 +02:00
Guangya Liu
d702209941 fix: enabled auth add support watsonx backend (#1190)
Signed-off-by: Guangya Liu <gyliu@ibm.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Matthis <matthish29@gmail.com>
2024-08-20 09:35:45 +02:00
renovate[bot]
7019d0b62f fix(deps): update module github.com/mittwald/go-helm-client to v0.12.12 (#1226)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-15 18:38:16 +01:00
renovate[bot]
f57381961f chore(deps): update anchore/sbom-action action to v0.17.1 (#1224)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-15 18:22:11 +01:00
Alex Jones
02fa109429 feat: refactoring to the new schema (#1219)
* feat: refactoring to the new schema

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated readme with grpc commands

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>

---------

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
Co-authored-by: Matthis <matthish29@gmail.com>
2024-08-15 14:42:55 +01:00
renovate[bot]
3148b5c61d fix(deps): update module github.com/docker/docker to v27.1.1+incompatible [security] (#1220)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-13 13:17:40 +01:00
Xuetao Song
a4e44d59e3 feat: add event failure handling in service analyzer (#1132)
Signed-off-by: magicsong <songxuetao@bytedance.com>

Co-authored-by: magicsong <songxuetao@bytedance.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-08-13 06:36:15 +01:00
renovate[bot]
24ebeaf3a7 chore(deps): update actions/checkout digest to 692973e (#1129)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-13 06:34:46 +01:00
Matthis
db26d24ac6 feat: add custom-analyzer cmd (#1207)
* feat: add custom analyzer management capability

Introduced the ability to manage custom analyzers in the K8sGPT application, enabling users to add, deploy, and configure custom analyzers from various sources. This enhancement supports extending the application's analytical capabilities by integrating external analysis tools, thus offering more flexibility and customization options to meet specific user needs.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: enhance custom analyzer management with removal functionality

Introduced the ability to remove custom analyzers, streamlining the management process and ensuring flexibility in custom analyzer configuration. This enhancement addresses the need for dynamic customization and maintenance of analyzer setups, facilitating easier updates and modifications to the analysis environment.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: add list command to customAnalyzer for displaying configured analyzers

Implemented a new list command within the customAnalyzer module to enable users to view all configured custom analyzers. This enhancement aims to improve usability by providing a straightforward method for users to inspect their custom analyzer configurations directly from the command line.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: add support for listing, adding, and removing custom analyzers

This update introduces commands to manage custom analyzers in the k8sgpt tool, enhancing flexibility and control over analyzer configurations without the need for direct installation or docker dependency.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: support private docker image authentication for custom analyzers

Added authentication support for pulling private Docker images when adding custom analyzers, enhancing security and access control.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: remove Docker custom analyzer installation

Removed the installation and deployment functionality for custom analyzers, streamlining the process of adding analyzers. This change focuses on simplifying the configuration by eliminating the need for specifying installation types, package URLs, and authentication details for Docker images. The goal is to enhance user experience by making the addition of custom analyzers more straightforward and less error-prone.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* fix: remove unused packageUrl

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: update add command description to reflect broader functionality

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: Add name validation for custom analyzer creation

To ensure the integrity and consistency of analyzer names, we introduced a validation step that checks the format of the name against a predefined regex pattern. This change aims to prevent the creation of analyzers with invalid names, enhancing the system's reliability and usability.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: refactor customAnalyzer package for consistent naming

Refactored the customAnalyzer package and its references to use consistent snake_case naming for improved code readability and alignment with Go naming conventions.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

---------

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
2024-08-10 22:05:11 +01:00
Bo Wong
b2b86826e5 docs: update "CLI Installation" section in README.md (#1126) (#1127)
Signed-off-by: Bo Wang <wangbob@uniontech.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-08-08 10:34:22 +01:00
R0CKSTAR
8e37369e5c fix: set logger for controller-runtime (#1211)
Signed-off-by: Xiaodong Ye <yeahdongcn@gmail.com>
2024-08-08 07:10:49 +01:00
renovate[bot]
2a8a9b4867 chore(deps): update actions/upload-artifact digest to 834a144 (#1214)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-07 09:49:06 +01:00
Kay Yan
b7e5394caa fix: segmentation violation during serve (#1215)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2024-08-07 09:47:09 +01:00
github-actions[bot]
ad117a530f chore(main): release 0.3.40 (#1202)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-08-04 21:30:21 +01:00
Alex Jones
16d57e5a55 feat: initial custom analysis server mode (#1205)
* chore: initial custom analysis

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: saving the missing stuff

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: removed redundant error handling

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: missing piece of the custom analysis response

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
2024-08-04 21:03:34 +01:00
renovate[bot]
3547c4808a fix(deps): update module github.com/schollz/progressbar/v3 to v3.14.5 (#1145)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-08-02 15:01:47 +01:00
renovate[bot]
407c855e14 chore(deps): update anchore/sbom-action action to v0.17.0 (#1197)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-02 14:42:24 +01:00
Yanwei Li
d43fd878ba fix: add default maxToken value of watsonxai backend (#1209)
Signed-off-by: yanweili <yanweili@ibm.com>
Co-authored-by: yanweili <yanweili@ibm.com>
2024-08-02 05:15:28 -04:00
Naveen Thangaraj
a068310731 feat: getting the error from status field for HPA analyzer (#1164)
* getting the error from status field for hpa analyzer

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Signed-off

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Updated the hpaAnalyzer_test.go

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Updated hpa_test.go

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Updated the hpa

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Updated the Conflicts

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Resolved all the conflicts

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

* Updated the test case

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>

---------

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Matthis <matthish29@gmail.com>
2024-07-22 09:25:38 +02:00
renovate[bot]
8949f5bac3 fix(deps): update module cloud.google.com/go/storage to v1.43.0 (#1198)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-21 18:20:27 +01:00
Matthis
f1b7b37fb8 feat: custom analysis paralelism (#1203) 2024-07-20 07:58:26 +02:00
Guangya Liu
391a3cd5ad fix: auth update throw out exception (#1193)
Signed-off-by: Guangya Liu <gyliu@ibm.com>
Co-authored-by: Matthis <matthish29@gmail.com>
2024-07-18 16:49:51 +01:00
github-actions[bot]
3c08118104 chore(main): release 0.3.39 (#1181)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-18 15:03:49 +01:00
JuHyung Son
eb3b81f176 feat: add label selector (#1201)
* feat: fix the custom-analysis printing (#1195)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* feat: add label selector

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* feat: add label selector on analyzers

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* chore(deps): pin goreleaser/goreleaser-action action to 286f3b1 (#1171)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.4.0-20240715142657-3785f0a44aae.2 (#1196)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* chore(deps): update actions/upload-artifact digest to 0b2256b (#1175)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* chore: update proto pkg version

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* chore: fix typo

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* feat: add label string to LabelSelector util func

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* feat: add test using 2 label selector

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: JuHyung-Son <sonju0427@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: JuHyung Son <sonju0427@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-18 14:31:41 +01:00
Ronald Petty
5176759bd0 feat: initial kyverno support (#1200)
* refresh fork

Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* let out, wasn't sure it was needed, but seems it might be in CI pipeline

Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* chore(deps): update docker/setup-buildx-action digest to 4fd8129 (#1173)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2 to v2.20.0-20240406062209-1cc152efbf5c.1 (#1147)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* chore(deps): update anchore/sbom-action action to v0.16.0 (#1146)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* fix(deps): update module google.golang.org/grpc to v1.64.1 [security] (#1178)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* fix(deps): update module github.com/mittwald/go-helm-client to v0.12.10 (#1177)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* feat: add custom http headers to openai related api backends (#1174)

* feat: add custom http headers to openai related api backends

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* ci: add custom headers test

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* add error handling

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore(deps): update docker/setup-buildx-action digest to 4fd8129 (#1173)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2 to v2.20.0-20240406062209-1cc152efbf5c.1 (#1147)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore(deps): update anchore/sbom-action action to v0.16.0 (#1146)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* Update README.md

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

---------

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* chore(main): release 0.3.38 (#1165)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* chore(deps): update anchore/sbom-action action to v0.16.1 (#1179)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* chore(deps): update actions/setup-go digest to 0a12ed9 (#1182)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* ci: release to krew index as kubectl-gpt (#1100)

Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* fix(deps): update k8s.io/utils digest to 18e509b (#1183)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* fix(deps): update module github.com/prometheus/prometheus to v0.53.1 (#1035)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* fix(deps): update module github.com/ibm/watsonx-go to v1.0.1 (#1187)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* feat: skip k3s node type EtcdIsVoter (#1167)

Signed-off-by: Kay Yan <kay.yan@daocloud.io>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* feat: fix the custom-analysis printing (#1195)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* chore(deps): pin goreleaser/goreleaser-action action to 286f3b1 (#1171)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.4.0-20240715142657-3785f0a44aae.2 (#1196)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* chore(deps): update actions/upload-artifact digest to 0b2256b (#1175)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* Update pkg/integration/kyverno/kyverno.go

lgtm

Co-authored-by: Alex Jones <alex@k8sgpt.ai>
Signed-off-by: Ronald Petty <ronald.petty@minimumdistance.com>
Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

* remove unused function

Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>

---------

Signed-off-by: Ronald Petty <ronald.petty@rx-m.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Ronald Petty <ronald.petty@minimumdistance.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Miguel Varela Ramos <miguel@cohere.ai>
Co-authored-by: Kay Yan <kay.yan@daocloud.io>
Co-authored-by: Alex Jones <alex@k8sgpt.ai>
2024-07-18 07:57:11 +01:00
renovate[bot]
4b13727ef5 chore(deps): update actions/upload-artifact digest to 0b2256b (#1175)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-15 19:09:43 +01:00
renovate[bot]
f9edbf34f3 fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.4.0-20240715142657-3785f0a44aae.2 (#1196)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-15 18:50:16 +01:00
renovate[bot]
1a00aafbb2 chore(deps): pin goreleaser/goreleaser-action action to 286f3b1 (#1171)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-15 14:12:06 +01:00
Alex Jones
b6dd2a1181 feat: fix the custom-analysis printing (#1195)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-07-15 12:02:16 +01:00
Kay Yan
4366ad97b8 feat: skip k3s node type EtcdIsVoter (#1167)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-07-12 16:17:45 +01:00
renovate[bot]
34b6de3404 fix(deps): update module github.com/ibm/watsonx-go to v1.0.1 (#1187)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-11 17:12:43 +01:00
renovate[bot]
de9ef85878 fix(deps): update module github.com/prometheus/prometheus to v0.53.1 (#1035)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-11 12:33:10 +01:00
renovate[bot]
0b906511d5 fix(deps): update k8s.io/utils digest to 18e509b (#1183)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-11 11:05:15 +01:00
Miguel Varela Ramos
4d76e9c5ae ci: release to krew index as kubectl-gpt (#1100)
Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-07-11 09:37:46 +01:00
renovate[bot]
593139cffb chore(deps): update actions/setup-go digest to 0a12ed9 (#1182)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-11 09:12:37 +01:00
renovate[bot]
3e9340925c chore(deps): update anchore/sbom-action action to v0.16.1 (#1179)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-11 06:07:49 +01:00
github-actions[bot]
f6ce47c3a9 chore(main): release 0.3.38 (#1165)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-10 10:15:14 +01:00
Aris Boutselis
02e754ed59 feat: add custom http headers to openai related api backends (#1174)
* feat: add custom http headers to openai related api backends

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* ci: add custom headers test

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* add error handling

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore(deps): update docker/setup-buildx-action digest to 4fd8129 (#1173)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2 to v2.20.0-20240406062209-1cc152efbf5c.1 (#1147)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore(deps): update anchore/sbom-action action to v0.16.0 (#1146)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* Update README.md

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

---------

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-07-10 09:59:08 +01:00
renovate[bot]
fef853966f fix(deps): update module github.com/mittwald/go-helm-client to v0.12.10 (#1177)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-10 09:54:48 +01:00
renovate[bot]
dd20dbc982 fix(deps): update module google.golang.org/grpc to v1.64.1 [security] (#1178)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-10 09:48:40 +01:00
renovate[bot]
dd66355797 chore(deps): update anchore/sbom-action action to v0.16.0 (#1146)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-07-08 07:41:28 +01:00
renovate[bot]
314f25ac8b fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2 to v2.20.0-20240406062209-1cc152efbf5c.1 (#1147)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-08 07:38:28 +01:00
renovate[bot]
d4abb33b3c chore(deps): update docker/setup-buildx-action digest to 4fd8129 (#1173)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-08 07:27:44 +01:00
renovate[bot]
27ac60aed2 chore(deps): update amannn/action-semantic-pull-request action to v5.5.3 (#1172)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-04 11:03:15 +01:00
renovate[bot]
0c0216096e chore(deps): update docker/build-push-action digest to ca052bb (#1140)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-03 21:23:15 +01:00
Kay Yan
b35dbd9b09 feat: add Ollama backend (#1065)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2024-07-03 21:16:06 +01:00
renovate[bot]
a075792119 fix(deps): update module github.com/spf13/cobra to v1.8.1 (#1161)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-01 10:31:27 +01:00
Jin Song Wang
ce63821beb feat: add watsonx ai provider (#1163)
Signed-off-by: JINSONG WANG <jswang@ibm.com>
2024-07-01 10:20:44 +01:00
Rui Chen
ab534d184f chore: update brew installation note (#1155)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-20 17:43:47 +01:00
github-actions[bot]
3f80bbaa1b chore(main): release 0.3.37 (#1159)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-17 20:47:21 +01:00
Alex Jones
9bace02a67 chore: updated the goreleaser action (#1160)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-06-17 20:40:28 +01:00
renovate[bot]
7b1b63322e chore(deps): update reviewdog/action-golangci-lint digest to 7708105 (#1157)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-17 20:36:35 +01:00
github-actions[bot]
f963e4e0f4 chore(main): release 0.3.36 (#1152)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-17 20:25:59 +01:00
Alex Jones
2382de4c6f chore: fixed the goreleaser file (#1158)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-06-17 20:09:24 +01:00
renovate[bot]
55ae7c3298 chore(deps): update goreleaser/goreleaser-action digest to 5742e2a (#1153)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-06-17 19:59:44 +01:00
Rui Chen
aeae2ba765 chore: update goreleaser ldflags (#1154)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-17 19:59:20 +01:00
renovate[bot]
602d111d85 chore(deps): update docker/login-action digest to 0d4c9c5 (#1141)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-14 10:37:03 +01:00
github-actions[bot]
c3f164eb2b chore(main): release 0.3.35 (#1150)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-14 10:19:09 +01:00
ChristianBieri1995
92dd1bd8b0 feat: add spec.template.spec.securityContext (#1109)
* feat: add spec.template.spec.securityContext 

Signed-off-by: ChristianBieri1995 <122007149+ChristianBieri1995@users.noreply.github.com>

* make securityContext adjustable

Signed-off-by: ChristianBieri1995 <122007149+ChristianBieri1995@users.noreply.github.com>

* adjust values.yaml accordingly to enable adjustable securityContext

Signed-off-by: ChristianBieri1995 <122007149+ChristianBieri1995@users.noreply.github.com>

* Remove default values from securityContext

Signed-off-by: ChristianBieri1995 <122007149+ChristianBieri1995@users.noreply.github.com>

---------

Signed-off-by: ChristianBieri1995 <122007149+ChristianBieri1995@users.noreply.github.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-06-14 09:05:24 +01:00
JuHyung Son
4867d39c66 feat: support openai organization Id (#1133)
* feat: add organization flag

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* feat: add orgId on openai backend

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

---------

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-06-14 08:39:56 +01:00
Alex Jones
c834c09996 chore: updated goreleaser config (#1149)
Signed-off-by: Alex Jones <axjns@amazon.com>
Co-authored-by: Alex Jones <axjns@amazon.com>
2024-06-14 08:37:46 +01:00
github-actions[bot]
038e52e044 chore(main): release 0.3.34 (#1144)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-14 08:30:27 +01:00
Alex Jones
f9d734ee53 Revert "chore(deps): update goreleaser/goreleaser-action digest to 5742e2a (#…" (#1148)
This reverts commit c101e8a3ea.
2024-06-14 08:27:40 +01:00
renovate[bot]
c101e8a3ea chore(deps): update goreleaser/goreleaser-action digest to 5742e2a (#1142)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-13 10:33:11 +01:00
renovate[bot]
63b63f7664 chore(deps): update google-github-actions/release-please-action action to v4.1.1 (#1143)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-13 10:27:24 +01:00
github-actions[bot]
0fe984966a chore(main): release 0.3.33 (#1128)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-13 10:02:26 +01:00
renovate[bot]
3a893184af fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/azidentity to v1.6.0 [security] (#1138)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-13 09:44:24 +01:00
Kay Yan
6652fbe7cb feat: bump golang version to 1.22 (#1117)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-06-13 09:33:19 +01:00
Alex Jones
728555c0ef fix: advisory k8sgpt ghsa 85rg 8m6h 825p (#1139)
* chore: updated helmclient and helmv3

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: fixing tests

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-06-13 09:30:09 +01:00
renovate[bot]
bdd470f9ca fix(deps): update module github.com/aws/aws-sdk-go to v1.53.21 (#1106)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-12 18:52:04 +01:00
Ronald Petty
fad00eac49 fix(deps): typo in prometheus.go (#1137)
fix(deps): typo in prometheus.go

Signed-off-by: Ronald Petty <ronald.petty@gmail.com>
2024-06-12 18:34:38 +01:00
renovate[bot]
3452c0def6 chore(deps): update actions/setup-go digest to cdcb360 (#1096)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-04 12:59:53 +01:00
github-actions[bot]
ffd017fbd7 chore(main): release 0.3.32 (#1119)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-20 09:29:10 +01:00
Rui Chen
e261c09889 fix: remove shorthand flag for topp option in add command (#1115)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-05-20 09:06:35 +01:00
github-actions[bot]
cc890dfa46 chore(main): release 0.3.31 (#1077)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-16 16:23:41 +01:00
Anders Swanson
047afd46d6 feat: oci genai (#1102)
Signed-off-by: Anders Swanson <anders.swanson@oracle.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-05-16 15:44:41 +01:00
Vaibhav Malik
eda52312ae feat: implement Top-K sampling for improved user control (#1110)
This commit adds Top-K sampling, a feature that allows users to control
the randomness of the generated text by specifying the number of most
probable next words considered by the model. This enhances user control
and potentially improves the quality of the generated outputs.

Fixes: https://github.com/k8sgpt-ai/k8sgpt/issues/1105

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-05-16 15:41:07 +01:00
JuHyung Son
882c6f5225 feat: support AWS_PROFILE (#1114)
Signed-off-by: JuHyung-Son <sonju0427@gmail.com>
2024-05-16 15:36:33 +01:00
renovate[bot]
fe53907c44 fix(deps): update module golang.org/x/net to v0.25.0 (#1092)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-09 07:49:49 +01:00
Vaibhav Malik
63f7fcfef7 test: added tests for the pkg/integration package (#904)
This commit adds new tests for the `pkg/integration` package. As a
result, the code the code coverage of the package has increased from 0%
to 100%

This also includes a minor adjustment in the error statements of the
`Activate` and `Deactive` functions to ensure better understanding of
the cause of the error.

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-05-09 07:18:59 +01:00
Vaibhav Malik
2c7c74472c test: added tests for the log analyzer (#1010)
* Added new tests for `LogAnalyzer` defined in the `pkg/analyzer`
  package. Increased the code coverage of the `log.go` file to >90%

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-05-09 07:18:22 +01:00
renovate[bot]
3c4823127c fix(deps): update module github.com/aws/aws-sdk-go to v1.52.3 (#1094)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-07 12:18:15 +01:00
Vaibhav Malik
c3a884f0c4 test: added missing tests for pkg/analysis package (#908)
This commit bumps the code coverage of the `pkg/analysis` package to
60.8%

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: JuHyung Son <sonju0427@gmail.com>
2024-05-05 17:24:26 +01:00
renovate[bot]
e74fc0838f fix(deps): update module github.com/sashabaranov/go-openai to v1.23.0 (#1091)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 19:37:34 +01:00
renovate[bot]
f30c9f5554 fix(deps): update module github.com/google/generative-ai-go to v0.11.0 (#1089)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 14:30:22 +01:00
renovate[bot]
36ccc62846 fix(deps): update module github.com/cohere-ai/cohere-go/v2 to v2.7.3 (#1087)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 14:23:48 +01:00
renovate[bot]
a809a455f5 chore(deps): update amannn/action-semantic-pull-request action to v5.5.2 (#1088)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 14:18:07 +01:00
renovate[bot]
12fa5aef4d chore(deps): update anchore/sbom-action action to v0.15.11 (#1082)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 14:10:59 +01:00
renovate[bot]
75c2addf66 fix(deps): update module github.com/aws/aws-sdk-go to v1.51.32 (#1083)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 14:05:39 +01:00
renovate[bot]
9b797d7e8b chore(deps): update actions/upload-artifact digest to 6546280 (#1079)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 13:59:19 +01:00
renovate[bot]
820cd2e16c fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.3.0-20240406062209-1cc152efbf5c.3 (#1086)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 11:33:41 +01:00
renovate[bot]
43953ffa34 fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/storage/azblob to v1.3.2 (#1085)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 09:12:47 +01:00
renovate[bot]
bd695d0987 fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/azidentity to v1.5.2 (#1084)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 20:14:39 +01:00
renovate[bot]
b12c006c63 chore(deps): update docker/build-push-action digest to 2cdde99 (#1032)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 20:01:10 +01:00
renovate[bot]
e0af76f3c9 chore(deps): pin codecov/codecov-action action to ab904c4 (#1031)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 19:55:39 +01:00
renovate[bot]
e894e778e9 fix(deps): update k8s.io/utils digest to 0849a56 (#1080)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 10:53:52 +01:00
JuHyung Son
5cfe3325cb docs: add logAnalyzer in README.md (#1081)
Signed-off-by: JuHyung Son <sonju0427@gmail.com>
2024-04-28 09:08:43 +01:00
renovate[bot]
ea8183ce84 chore(deps): update actions/checkout digest to 0ad4b8f (#1078)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-26 17:24:30 +01:00
renovate[bot]
24cff90a0c fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2 to v2.19.1-20240406062209-1cc152efbf5c.1 (#1070)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-26 14:44:25 +01:00
renovate[bot]
bf6f642c28 chore(deps): update google-github-actions/release-please-action action to v4.1.0 (#1045)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-26 10:58:29 +01:00
github-actions[bot]
6279f358ca chore(main): release 0.3.30 (#1027)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-04-26 10:17:15 +01:00
Peter Pan
b2ab94375e fix: invalid ParentObj in output (#1068)
* Fix invalid ParentObj in output

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

* fix UT as well for ParentObj changes

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

* remove meta.Name in false output

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

* fix UT as well

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

---------

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-04-26 07:26:06 +01:00
DragonAlex98
9a73d1923f feat: add keda integration (#1058)
* refactor: move FetchLatestEvent inside util package

Signed-off-by: DragonAlex98 <a.antinori@reply.it>

* feat: add Keda integration and ScaledObject analyzer

Signed-off-by: DragonAlex98 <a.antinori@reply.it>

---------

Signed-off-by: DragonAlex98 <a.antinori@reply.it>
2024-04-25 11:41:01 +01:00
Christoph Enne
85a76a3be0 chore: update license file path to avoid conflicting installations (#878) (#1073)
Signed-off-by: christoph <christoph.enne@glasskube.eu>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-04-20 21:12:49 +01:00
Peter Pan
aa276a5379 feat: add Resource Kind in output (#1069)
Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-04-20 21:11:02 +01:00
Miguel Varela Ramos
eb7687a089 chore(deps): update cohere client implementation to v2 (#1062)
* chore(deps): update cohere client implementation to v2 and to use chat endpoint

Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>

* chore: remove renovate rule for cohere-go

Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>

* style: remove unused attribute

Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>

* fix: go mod

Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>

---------

Signed-off-by: Miguel Varela Ramos <miguel@cohere.ai>
Signed-off-by: Miguel Varela Ramos <miguelvramos92@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-04-20 21:10:17 +01:00
Guido Muscioni
c162cc22ee fix: set topP from config (#1053)
* fix: set topP from config

Signed-off-by: “Guido <muscionig@gmail.com>

* style: correct format of openai ai provider

Signed-off-by: “Guido <muscionig@gmail.com>

* feat: set topP from the environment

Signed-off-by: “Guido <muscionig@gmail.com>

---------

Signed-off-by: “Guido <muscionig@gmail.com>
2024-04-19 16:38:52 +01:00
izturn
1ae4e75196 refactor: replace util.SliceContainsString with slices.Contains & make fmt (#1041)
* use std package's func instead

Signed-off-by: gang.liu <gang.liu@daocloud.io>

* refactor: replace util.SliceContainsString with slices.Contains  & make fmt

Signed-off-by: gang.liu <gang.liu@daocloud.io>

---------

Signed-off-by: gang.liu <gang.liu@daocloud.io>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-04-19 13:15:50 +01:00
renovate[bot]
693b23f1fc fix(deps): update module golang.org/x/net to v0.23.0 [security] (#1071)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-19 12:04:55 +01:00
Aris Boutselis
e6085d4191 feat: add minio support (#1048)
* feat: add minio support

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: add TLS skip for custom https minio endpoint

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: update cache with the new proto schema

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

---------

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-04-19 11:58:41 +01:00
renovate[bot]
3eaf776249 chore(deps): update docker/setup-buildx-action digest to d70bba7 (#1066)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-17 13:55:03 +01:00
renovate[bot]
ccb692c1fd fix(deps): update module github.com/aws/aws-sdk-go to v1.51.21 (#1056)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-16 07:55:03 +01:00
Kay Yan
9e0263778f fix: remove show password in auth list (#1061)
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-04-16 07:20:20 +01:00
Vaibhav Malik
9dfcce842e test: added missing tests for the Pod analyzer (#1021)
- Fixed a small bug where failures were being appended multiple times
  for CrashLoopBackOff and ContainerCreating container status reasons.

- Added missing test cases to ensure proper testing of the Pod analyzer.
  The addition of these missing test cases has increased the code
  coverage of this analyzer to 98%.

- Added checks for init containers in a pod.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-04-13 21:08:33 +01:00
renovate[bot]
6df0169491 fix(deps): update module cloud.google.com/go/storage to v1.40.0 (#1054)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-05 11:34:51 +01:00
renovate[bot]
007b4bb8ec fix(deps): update module github.com/aws/aws-sdk-go to v1.51.14 (#1051)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-04 11:23:42 +01:00
renovate[bot]
6b38a56afb fix(deps): update module github.com/google/generative-ai-go to v0.10.0 (#1047)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-03 14:40:40 +01:00
renovate[bot]
19ae31b5dd fix(deps): update module github.com/aws/aws-sdk-go to v1.51.8 (#1046)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-27 10:01:58 +00:00
renovate[bot]
6a46a26789 fix(deps): update module github.com/sashabaranov/go-openai to v1.20.4 (#1039)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-27 09:48:52 +00:00
renovate[bot]
e05a902d90 chore(deps): update anchore/sbom-action action to v0.15.10 (#1044)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-27 09:34:52 +00:00
renovate[bot]
a3896f4518 fix(deps): update module cloud.google.com/go/storage to v1.39.1 (#1029)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-26 20:26:15 +00:00
Vaibhav Malik
4262c9292c test: removed pkg/kubernetes/testdata (#1018)
The `testdata` was no longer being used. Hence, removed it.

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-26 13:48:28 +00:00
renovate[bot]
94cdce44b4 fix(deps): update k8s.io/utils digest to 4693a02 (#1037)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-25 13:16:40 +00:00
renovate[bot]
10c00ba9fe chore(deps): update docker/setup-buildx-action digest to 2b51285 (#1036)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-25 13:09:40 +00:00
renovate[bot]
c872e495ad chore(deps): update docker/login-action digest to e92390c (#1033)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-25 13:04:55 +00:00
Aris Boutselis
bd2e06bae7 chore: update renovate config and bundle deps in groups (#1026)
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-03-24 20:57:43 +00:00
github-actions[bot]
5db4bc28a7 chore(main): release 0.3.29 (#1024)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-22 10:26:55 +00:00
Alex Jones
8f8f5c6df7 chore: allows an environmental override of the default AWS region and… (#1025)
* chore: allows an environmental override of the default AWS region and using it for bedrock

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: missing provider region

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-03-22 10:19:11 +00:00
Vaibhav Malik
3c1c055ac7 test: added missing tests for the CronJob analyzer (#1019)
* test: added missing tests for the CronJob analyzer

- Fixed a small bug where pre-analysis was incorrectly appended to the
  results every time at the end of the for loop. This caused the result
  for a single cronjob failure to be appended multiple times in the
  final results.

- Added missing test cases to ensure proper testing of the CronJob
  analyzer. The addition of these missing test cases has increased the
  code coverage of this analyzer to over 96%.

Partially Addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>

* test: removed failure strings matching from tests

It is possible that the error or failure strings might change in the
future, causing the tests to fail. This commit addresses that issue by
removing the matching of failure text from various analyzer tests.

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>

---------

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-21 18:13:32 +00:00
Vaibhav Malik
ebfbba98ca test: added missing test case for events.go (#1017)
With the addition of the latest changes, the missing test case when an
event happens after the currently set latest event has been covered.

Partially Addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-03-21 11:42:12 +00:00
Vaibhav Malik
47463d4412 test: added missing tests for the Ingress analyzer (#1020)
- Added missing test cases to ensure proper testing of the Ingress
  analyzer. The addition of these missing test cases has increased the
  code coverage of this analyzer to over 97%.

Partially Addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-03-21 11:02:19 +00:00
Alex Jones
fe81d16f75 feat: codecov (#1023)
* chore: missing schedule on auto merge

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: adding codecoverage back in

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-03-20 11:07:33 +00:00
Vaibhav Malik
a1d0d0a180 test: added tests for the Node analyzer (#1014)
* Added new tests for the `Node` analyzer defined in the `pkg/analyzer`
  package.

* The addition of these new tests has increased the code coverage of the
  node.go file to over 96%.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-03-20 09:32:23 +00:00
Vaibhav Malik
f60467cd4d test: added missing tests for the Netpool analyzer (#1016)
- Added a network policy allowing traffic to all pods. Resulting in
  additional failures in the results.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-03-15 18:45:36 +00:00
Vaibhav Malik
20892b48d0 test: removed useless tests from pkg/kubernetes (#1015)
- This commit removes unnecessary tests defined in the pkg/kubernetes
package.

- The removed tests were found to be flaky and were causing a
  significant increase in CI time without adding much value to
  the codebase.

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-14 21:51:15 +00:00
github-actions[bot]
ea7f0a5b4e chore(main): release 0.3.28 (#964)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-14 10:15:49 +00:00
Vaibhav Malik
531f0bc46d test: added tests for the Service analyzer (#1011)
* Added new tests for the `Service` analyzer defined in the
  `pkg/analyzer` package.

* The addition of these new tests has increased the code coverage of the
  service.go file to over 97%.

* Additionally addressed some flaky tests related to the `ReplicaSet`and
  `PersisentVolumeClaim` analyzers.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-03-14 09:42:16 +00:00
Vaibhav Malik
28e19a9d4e test: added tests for the pkg/kubernetes package (#896)
Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-12 21:34:12 +00:00
Vaibhav Malik
3475e2de0c test: fixed various flaky tests (#1009)
- Removed test cases which required access to `/root` from the
  `pkg/util` package.

- Fixed flaky `PodDisruptionBudget` test.

- Fixed a typo in `PersistentVolumeClaim` test.

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-12 07:25:03 +00:00
Aris Boutselis
adf4f17085 chore: attempt to group renovate deps (#1007) 2024-03-11 17:48:18 +00:00
Mario
55ac0b2129 feat: add Google Vertex AI as provider to utilize gemini via GCP (#984)
* feat: add Google Vertex AI as provider to utilize gemini via GCP

Signed-off-by: Mario Fahlandt <mfahlandt@pixel-haufen.de>

* fix: adjust providerId description

Signed-off-by: Mario Fahlandt <mfahlandt@pixel-haufen.de>

---------

Signed-off-by: Mario Fahlandt <mfahlandt@pixel-haufen.de>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2024-03-11 07:33:29 +00:00
Vaibhav Malik
a0225d4f70 test: added tests for the PVC analyzer (#1000)
This commit introduces comprehensive tests for the
`PersistentVolumeClaim` analyzer defined in the `pkg/analyzer` package.

Adding these tests increases the code coverage of the `pvc.go` file to
>95%.

I also made minor modifications to the ReplicaSet test to ensure all
expectations were met.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-08 19:26:19 +00:00
renovate[bot]
b05b6a38ed chore(deps): update anchore/sbom-action action to v0.15.9 (#1004)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-08 11:21:34 +00:00
Vaibhav Malik
1340ead860 test: added tests for the PDB analyzer (#1001)
This commit introduces comprehensive tests for the `PodDisruptionBudget`
analyzer defined in the `pkg/analyzer` package.

Adding these tests increases the code coverage of the `pdb.go` file to
>96%.

Additionally, a potential crash in case of empty or nil PDB status
conditions has been addressed.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-08 11:09:14 +00:00
renovate[bot]
b58b7191af chore(deps): update docker/build-push-action digest to af5a7ed (#1003)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-08 11:08:46 +00:00
renovate[bot]
1491e67567 fix(deps): update module github.com/stretchr/testify to v1.9.0 (#999)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-03-08 09:37:23 +00:00
renovate[bot]
4ec143ab77 chore(deps): update reviewdog/action-golangci-lint digest to 00311c2 (#1002)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-08 09:36:58 +00:00
Vaibhav Malik
5199dadb2a test: added tests for mutating webhook analyzer (#995)
This commit introduces comprehensive tests for the mutating webhook
analyzer defined in the `pkg/analyzer` package.

Adding these tests increases the code coverage of the
`mutating_webhook.go` file to almost 95%.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-08 08:18:20 +00:00
renovate[bot]
425f33bb2d fix(deps): update module github.com/aws/aws-sdk-go to v1.50.34 (#974)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-08 08:12:15 +00:00
Vaibhav Malik
f5c3f18d87 test: added tests for the ReplicaSet analyzer (#997)
This commit introduces comprehensive tests for the ReplicaSet analyzer
defined in the `pkg/analyzer` package.

Adding these tests increases the code coverage of the `rs.go` file to
>95%.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-05 19:39:31 +00:00
renovate[bot]
d2754d320f fix(deps): update module github.com/sashabaranov/go-openai to v1.20.2 (#991)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-05 14:04:04 +00:00
renovate[bot]
85f18dde1f fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/storage/azblob to v1.3.1 (#992)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-05 13:57:29 +00:00
Vaibhav Malik
16a4aaab81 test: added tests for validating webhook analyzer (#996)
This commit introduces comprehensive tests for the validating webhook
analyzer defined in the `pkg/analyzer` package.

Adding these tests increases the code coverage of the
`validating_webhook.go` file to almost 95%.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-03-05 13:36:55 +00:00
renovate[bot]
4065faef13 fix(deps): update module github.com/prometheus/client_golang to v1.19.0 (#989)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-28 16:52:50 +00:00
renovate[bot]
f24bcd88b6 chore(deps): update docker/setup-buildx-action digest to 0d103c3 (#988)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-28 16:40:38 +00:00
Tanuj Dwivedi
307710eddc feat: add proxysettings for azureopenai and openai (#987)
Signed-off-by: tanujd11 <dwiveditanuj41@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-28 16:10:42 +00:00
Vaibhav Malik
aab8d77feb fix: analyze command default backend bug (#966)
Now, the default value of the `backend` flag for the analyze command
will be an empty string. And the `NewAnalysis` function has been
modified to use the default backend set by the user if the backend flag
is not provided and the `defaultprovider` is set in the config file.
Otherwise, backend will be set to "openai".

Fixes: https://github.com/k8sgpt-ai/k8sgpt/issues/902

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: JuHyung Son <sonju0427@gmail.com>
2024-02-28 16:09:30 +00:00
renovate[bot]
334a86aaf4 fix(deps): update module gopkg.in/yaml.v2 to v3 (#980)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-27 19:50:30 +00:00
renovate[bot]
88a7907db4 fix(deps): update module github.com/sashabaranov/go-openai to v1.20.1 (#986)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-27 19:39:10 +00:00
renovate[bot]
af3732ad06 fix(deps): update module github.com/schollz/progressbar/v3 to v3.14.2 (#983)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-26 18:47:52 +00:00
Alex Jones
a81377f72d feat: aws integration (#967)
* chore: updated deps

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: adding aws types

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: first cut

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: first pass at aws integration with EKS

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: fixed linting

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated wording based on PR

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: improved the kubeconfig

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-26 10:16:32 +00:00
renovate[bot]
6103c96c41 fix(deps): update module google.golang.org/api to v0.167.0 (#973)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-25 17:34:36 +00:00
renovate[bot]
35f5185914 fix(deps): update module gopkg.in/yaml.v2 to v3 (#979)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-23 11:00:30 +00:00
renovate[bot]
97446aae07 fix(deps): update module google.golang.org/grpc to v1.62.0 (#975)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-23 08:28:25 +00:00
renovate[bot]
e07822c10b fix(deps): update module github.com/sashabaranov/go-openai to v1.20.0 (#977)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-23 08:05:22 +00:00
renovate[bot]
f929e7feea fix(deps): update module gopkg.in/yaml.v2 to v3 (#957)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-22 17:48:25 +00:00
Vaibhav Malik
6e640e6921 test: added unit tests for the pkg/util package (#894)
This commit adds new unit tests for the `pkg/util` package bumping the
code coverage to 84%

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-22 16:21:33 +00:00
lili-wan
98286a965e fix: log analyzer failed with multiple containers in the pod (#920)
* Log analyzer failed with multiple containers in the pod #884

Signed-off-by: lwan3 <lili_wan@intuit.com>

* Merge conflicts from main

Signed-off-by: lwan3 <lili_wan@intuit.com>

---------

Signed-off-by: lwan3 <lili_wan@intuit.com>
Co-authored-by: lwan3 <lili_wan@intuit.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-21 12:33:44 +00:00
renovate[bot]
6ac815c10f fix(deps): update module github.com/aws/aws-sdk-go to v1.50.22 (#971)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-21 12:27:49 +00:00
renovate[bot]
8f00218090 fix(deps): update module go.uber.org/zap to v1.27.0 (#972)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-21 08:51:54 +00:00
renovate[bot]
00c91f05a6 fix(deps): update module github.com/aws/aws-sdk-go to v1.50.21 (#970)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-20 20:48:13 +00:00
renovate[bot]
6207c70c51 fix(deps): update module cloud.google.com/go/storage to v1.38.0 (#950)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-19 21:14:38 +00:00
renovate[bot]
8b0b61e596 fix(deps): update module github.com/sashabaranov/go-openai to v1.19.4 (#963)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-19 11:45:37 +00:00
renovate[bot]
248260e081 fix(deps): update module github.com/google/generative-ai-go to v0.8.0 (#965)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-19 08:10:12 +00:00
Vaibhav Malik
f55f8370eb fix: shorthand for the http flag in serve command (#969)
Removed the shorthand for the `http` flag in the serve command because
it was contradicting with the shorthand of the `help` command which is
automatically added on execution if the `help` flag is not already
defined.

Fixes: https://github.com/k8sgpt-ai/k8sgpt/issues/968

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2024-02-19 07:48:16 +00:00
Johannes Kleinlercher
a3cd7e6385 fix: set result name and namespace to trivy vulnreport and configaudi… (#869)
* fix: set result name and namespace to trivy vulnreport and configauditreport

Signed-off-by: Johannes Kleinlercher <johannes.kleinlercher@suxess-it.com>

* fix: increase linter timeout

Signed-off-by: Johannes Kleinlercher <johannes@kleinlercher.at>

---------

Signed-off-by: Johannes Kleinlercher <johannes.kleinlercher@suxess-it.com>
Signed-off-by: Johannes Kleinlercher <johannes@kleinlercher.at>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-18 15:47:19 +00:00
Sahil Badla
f2138c7101 feat: enable Rest api using grpc-gateway (#834)
* grpc-gateway changes

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* feat: grpc-gateway impl

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* feat: enable REST/http api support

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* feat: enable rest/http support

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* feat: enable rest/http support

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* feat: enable rest/http support

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* chore: resolved mod

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: fix grpc-gateway codegen path

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* feat: merge from master

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

* feat: flag to enable rest api

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>

---------

Signed-off-by: Sahil Badla <sahil_badla@intuit.com>
Signed-off-by: Sahil Badla <146279034+sbadla1@users.noreply.github.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Sahil Badla <sahil_badla@intuit.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-17 15:38:15 +00:00
renovate[bot]
3f0356be66 fix(deps): update module github.com/aws/aws-sdk-go to v1.50.20 (#930)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-17 08:43:26 +00:00
renovate[bot]
cc99bd51f0 fix(deps): update module google.golang.org/api to v0.165.0 (#959)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-16 14:07:23 +00:00
github-actions[bot]
729d14db4d chore(main): release 0.3.27 (#870)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-02-16 12:53:55 +00:00
renovate[bot]
fea2ed1fff fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/storage/azblob to v1.3.0 (#952)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-15 12:48:17 +00:00
Alex Jones
c8c9dbfadc feat: enables remote custom analyzers (#906)
* feat: enables remote custom analyzers

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: fixed test that was broken

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: hiding custom analysis behind a flag

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: resolved govet issue

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated deps

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-15 07:28:00 +00:00
renovate[bot]
070aa7fdd0 chore(deps): update actions/upload-artifact digest to 5d5d22a (#925)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-14 19:35:47 +00:00
renovate[bot]
ce7c9551bc fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/azidentity to v1.5.1 (#939)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-14 12:33:02 +00:00
renovate[bot]
d9fe7446af fix(deps): update module gopkg.in/yaml.v2 to v3 (#956)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-14 11:01:22 +00:00
renovate[bot]
9c1f1b8804 fix(deps): update module google.golang.org/grpc to v1.61.1 (#954)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-14 10:48:40 +00:00
renovate[bot]
37228d88e3 chore(deps): update golang docker tag to v1.22 (#931)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-14 10:22:39 +00:00
renovate[bot]
29b482f597 fix(deps): update module google.golang.org/api to v0.164.0 (#953)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-14 08:26:35 +00:00
Alex Jones
015bccfc2e chore: updated deps (#951)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-13 20:45:33 +00:00
Amit Amrutiya
3f0964ad38 fix: unused variable failure warning in webhooks file (#916)
Signed-off-by: amitamrutiya2210 <amitamrutiya2210@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-13 20:28:11 +00:00
renovate[bot]
3c8d9d42e5 fix(deps): update module github.com/google/generative-ai-go to v0.7.0 (#940)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-13 19:59:37 +00:00
renovate[bot]
bfbb5c7e03 fix(deps): update module github.com/pterm/pterm to v0.12.79 (#943)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-13 15:19:27 +00:00
renovate[bot]
28c4c57e45 fix(deps): update k8s.io/utils digest to e7106e6 (#897)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-13 15:09:48 +00:00
renovate[bot]
4e57088a01 fix(deps): update module golang.org/x/term to v0.17.0 (#941)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-09 22:10:45 +00:00
renovate[bot]
f2eb1ef533 fix(deps): update module github.com/sashabaranov/go-openai to v1.19.3 (#937)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-09 12:41:58 +00:00
Alex Jones
bbf61f53d4 chore: grpc update (#938)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-02-09 09:42:00 +00:00
renovate[bot]
3d2554b9cd fix(deps): update module cloud.google.com/go/storage to v1.37.0 (#934)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-09 09:25:55 +00:00
renovate[bot]
f61c3e228c chore(deps): update anchore/sbom-action action to v0.15.8 (#926)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-08 09:35:32 +01:00
renovate[bot]
c6019728ae fix(deps): update module github.com/sashabaranov/go-openai to v1.19.2 (#886)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-08 08:25:47 +00:00
renovate[bot]
e3eee6d956 fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.3.0-20240128172516-6bf6a55ff115.2 (#899)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-07 18:43:30 +00:00
renovate[bot]
599be33f38 chore(deps): update reviewdog/action-golangci-lint digest to 8e1117c (#915)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-07 15:44:45 +00:00
Amit Amrutiya
3415031006 fix: lint errors (#923)
Signed-off-by: amitamrutiya2210 <amitamrutiya2210@gmail.com>
2024-02-07 11:30:45 +00:00
simone ragonesi
d97dea2896 chore: improve codebase and doc quality (#922)
* chore(prometheus integration): fix mispelling

Signed-off-by: r3drun3 <simone.ragonesi@sighup.io>

* docs(readme): add badges to improve doc quality

Signed-off-by: r3drun3 <simone.ragonesi@sighup.io>

---------

Signed-off-by: r3drun3 <simone.ragonesi@sighup.io>
2024-02-07 09:12:41 +00:00
renovate[bot]
f9c1b90338 fix(deps): update module github.com/pterm/pterm to v0.12.78 (#890)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-05 07:38:34 +00:00
lili-wan
78126b2328 feat: added FailedMount event reason to get the failure (#883)
Signed-off-by: lwan3 <lili_wan@intuit.com>
Co-authored-by: lwan3 <lili_wan@intuit.com>
2024-02-01 18:57:20 +00:00
renovate[bot]
60853fe4eb chore(deps): update anchore/sbom-action action to v0.15.5 (#885)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 12:18:39 +00:00
renovate[bot]
a253af23b6 fix(deps): update module github.com/prometheus/prometheus to v2 (#863)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 11:21:22 +00:00
JuHyung Son
2fd476e126 feat: add huggingface provider (#893)
* feat: add huggingface ai provider

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* chore: update readme

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* fix: set huggingface maxtokens default to 500, use ptr instead of pointer

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

---------

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>
2024-01-28 15:41:49 +00:00
renovate[bot]
483a9dad10 chore(deps): update actions/upload-artifact digest to 26f96df (#888)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-24 14:09:03 +00:00
renovate[bot]
817d9cf754 fix(deps): update module github.com/aws/aws-sdk-go to v1.50.2 (#887)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-24 10:55:01 +00:00
renovate[bot]
72e08efff1 fix(deps): update module google.golang.org/api to v0.157.0 (#860)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-23 13:12:44 +00:00
renovate[bot]
e7d690afd1 fix(deps): update module github.com/pterm/pterm to v0.12.75 (#881)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-23 08:06:44 +00:00
renovate[bot]
3cf18e783e chore(deps): update actions/upload-artifact digest to 694cdab (#880)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-23 08:02:18 +00:00
souleb
cdbeb146a2 fix: typo in httproute files name (#877)
Signed-off-by: Soule BA <bah.soule@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2024-01-23 07:51:57 +00:00
Alex Jones
2effbb345a chore: linting improvements and catching false positives (#882)
* chore: linting improvements and catching false positives

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: linting improvements and catching false positives

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: linting improvements and catching false positives

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: increase linter time out

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-01-23 07:46:01 +00:00
renovate[bot]
335616c20f chore(deps): update reviewdog/action-golangci-lint digest to f016e79 (#714)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-22 07:36:28 +00:00
renovate[bot]
d213399161 chore(deps): update anchore/sbom-action action to v0.15.4 (#879)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-22 07:35:27 +00:00
renovate[bot]
1f371e2807 fix(deps): update module gopkg.in/yaml.v2 to v3 (#875)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-18 16:52:31 +00:00
renovate[bot]
4de1bbd6f7 fix(deps): update module github.com/sashabaranov/go-openai to v1.18.2 (#874)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-16 12:43:49 +00:00
renovate[bot]
81d660447d fix(deps): update module gopkg.in/yaml.v2 to v3 (#866)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-16 09:56:21 +00:00
Philip Miglinci
a34f5dea69 ci: replace deprecated brew config (#873)
tap got replaces by repository and is now deprecated.

This deprecation warning can also be seen in the goreleaser logs:

>     • DEPRECATED: brews.tap should not be used anymore, check https://goreleaser.com/deprecations#brewstap for more info


https://github.com/k8sgpt-ai/k8sgpt/actions/runs/7521548656/job/20472514099

Signed-off-by: Philip Miglinci <pmig@glasskube.eu>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2024-01-16 10:35:36 +01:00
renovate[bot]
6c62c1a0fc fix(deps): update module github.com/sashabaranov/go-openai to v1.18.1 (#871)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-16 09:30:32 +00:00
Philip Miglinci
42be51bc8f chore: set correct license during package build (#872)
Signed-off-by: Philip Miglinci <pmig@glasskube.eu>
2024-01-16 08:23:49 +00:00
renovate[bot]
88002e7e8c fix(deps): update module github.com/aws/aws-sdk-go to v1.49.21 (#868)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-15 19:21:58 +00:00
github-actions[bot]
6d3a3933cd chore(main): release 0.3.26 (#846)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-01-14 20:28:11 +00:00
Alex Jones
9da75e02bc feat: interactive mode (#854)
* chore: wip interactive mode

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: tidied up a bit

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated go mod

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: const prompt

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated based on comments feedback

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated enum

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated enum

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-01-14 20:22:00 +00:00
renovate[bot]
4ce56f38b4 chore(deps): update actions/upload-artifact digest to 1eb3cb2 (#867)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-14 20:08:49 +00:00
renovate[bot]
40b5b7e185 fix(deps): update module github.com/sashabaranov/go-openai to v1.17.11 (#861)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-12 16:41:19 +00:00
renovate[bot]
c55025d04e fix(deps): update module gopkg.in/yaml.v2 to v3 (#865)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-12 14:39:52 +00:00
renovate[bot]
36ba6c5147 fix(deps): update module gopkg.in/yaml.v2 to v3 (#864)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-12 14:27:06 +00:00
renovate[bot]
6a2f315b2f fix(deps): update module github.com/aws/aws-sdk-go to v1.49.19 (#859)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-12 12:56:45 +00:00
Daniel Clark
45fa827c04 feat: initial Prometheus analyzers (#855)
* feat: initial Prometheus analyzers

Added a prometheus integration with two analyzers:
1. PrometheusConfigValidate
2. PrometheusConfigRelabelReport

The integration does not deploy any Prometheus stack in the cluster.
Instead, it searches the provided --namespace for a Prometheus
configuration, stored in a ConfigMap or Secret. If it finds one, it
unmarshals it into memory and runs the analyzers on it.

PrometheusConfigValidate checks if the actual Prometheus configuration is valid or has
any errors.

PrometheusConfigRelabelReport tries to distill the scrape config
relabeling rules to give a concise label set per job that targets need
to have to be scraped. This analyzer is unconventional, in that it does
not necessarily mean there are issues with the config. It merely tries
to give a human-readable explanation of the relabel rules it discovers,
leaning on the LLM and prompt.

Tested on both kube-prometheus and Google Managed Prometheus
stacks.

Signed-off-by: Daniel Clark <danielclark@google.com>

* review: feedback cycle 1

Simplify ConfigValidate prompt and add comments.

Signed-off-by: Daniel Clark <danielclark@google.com>

* review: feedback cycle 2

Add Prometheus configuration discovery to integration activate command.

Also improve logging to make this more clear to users.

Signed-off-by: Daniel Clark <danielclark@google.com>

---------

Signed-off-by: Daniel Clark <danielclark@google.com>
2024-01-12 09:58:09 +00:00
renovate[bot]
4106d39c32 fix(deps): update module github.com/aws/aws-sdk-go to v1.49.18 (#856)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-11 08:44:46 +00:00
renovate[bot]
1979c86d0f fix(deps): update module github.com/sashabaranov/go-openai to v1.17.11 (#853)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-09 21:03:14 +01:00
renovate[bot]
12f764d584 chore(deps): update anchore/sbom-action action to v0.15.3 (#850)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-09 09:21:21 +00:00
renovate[bot]
85ebd12c30 fix(deps): update module github.com/aws/aws-sdk-go to v1.49.17 (#852)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-09 08:44:58 +00:00
Matthis
5c17c24055 feat: unify aiClientName const for all providers (#848) 2024-01-07 13:01:15 +01:00
renovate[bot]
ce4910bc5d fix(deps): update module github.com/aws/aws-sdk-go to v1.49.16 (#847)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-05 22:49:23 +01:00
Anais Urlichs
d8d0beef65 make cli more intuitive when adding openai default backend (#838)
Signed-off-by: AnaisUrlichs <urlichsanais@gmail.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2024-01-05 22:43:08 +01:00
Bartlomiej Plotka
745e960f49 docs: adjusted README information about providers (#844)
Mentioned the basics and referred to website for more details to keep ~one source of truth.

Signed-off-by: bwplotka <bwplotka@gmail.com>
2024-01-05 22:30:34 +01:00
github-actions[bot]
6d29fcf294 chore(main): release 0.3.25 (#812)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-01-05 07:35:44 +00:00
Bartlomiej Plotka
e7d41496dd feat: added Google GenAI client; simplified IAI/clients API surface. (#829)
* refactor: Simplified IAI; made caching and processing consisent.


Signed-off-by: bwplotka <bwplotka@gmail.com>

* feat: Added Google AI API e.g. for Gemini models.

Signed-off-by: bwplotka <bwplotka@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2024-01-05 06:53:36 +01:00
renovate[bot]
e78ff05419 fix(deps): update module github.com/aws/aws-sdk-go to v1.49.15 (#835)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-05 06:25:05 +01:00
renovate[bot]
105a239d94 fix(deps): update module google.golang.org/api to v0.155.0 (#836)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-05 06:16:07 +01:00
renovate[bot]
4de989c803 fix(deps): update module golang.org/x/term to v0.16.0 (#831)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-04 19:56:11 +01:00
Alex Jones
a7e9b486ba chore: lint fixes (#833)
* chore: added basic server startup test

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: refactored wg.add move

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-01-04 17:03:32 +00:00
Alex Jones
a77426593d chore: remove code cov (#832)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2024-01-04 16:47:39 +00:00
renovate[bot]
526e22f88b fix(deps): update module github.com/aws/aws-sdk-go to v1.49.14 (#822)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-04 08:48:08 +00:00
renovate[bot]
4314804ca7 fix(deps): update module github.com/sashabaranov/go-openai to v1.17.10 (#824)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-04 06:48:12 +01:00
Bartlomiej Plotka
035348d8a0 fix: no explain case, improved readability. (#825)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2024-01-03 17:59:28 +01:00
renovate[bot]
70c68929d8 chore(deps): update anchore/sbom-action action to v0.15.2 (#823)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-03 13:10:43 +00:00
Debasish Biswas
b17fd7c986 deps: go module bump to fix CVE: GHSA-45x7-px36-x8w8 & GHSA-7ww5-4wqc-m92c (#810)
Signed-off-by: debasishbsws <debasishbsws.dev@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-12-29 14:36:11 +00:00
renovate[bot]
2f0f2dfa8a chore(deps): pin codecov/codecov-action action to eaaf4be (#820)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-29 14:20:29 +00:00
Alex Jones
3e7cea7bd3 chore: added basic server startup test (#817)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-12-29 14:15:32 +00:00
Alex Jones
fcd29a547d feat: code_cov badge (#821)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-12-29 14:08:06 +00:00
Alex Jones
3d0ba3e78c feat: coverage reports (#819)
* Update test.yaml

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* Update test.yaml

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-12-29 14:05:27 +00:00
renovate[bot]
91613baa5c fix(deps): update module github.com/aws/aws-sdk-go to v1.49.12 (#813)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-29 08:48:36 +00:00
renovate[bot]
6eb8f6793e fix(deps): update module github.com/prometheus/client_golang to v1.18.0 (#814)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-29 08:24:31 +00:00
renovate[bot]
e5cc4a28cb fix(deps): update module github.com/aws/aws-sdk-go to v1.49.10 (#811)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-27 10:32:16 +01:00
github-actions[bot]
eac9f07abf chore(main): release 0.3.24 (#781)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-12-24 07:39:44 +00:00
renovate[bot]
130e4c2efd fix(deps): update module github.com/aws/aws-sdk-go to v1.49.9 (#808)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-23 08:15:53 +00:00
renovate[bot]
93b5ca1985 fix(deps): update module github.com/aws/aws-sdk-go to v1.49.8 (#807)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-22 12:57:46 +00:00
renovate[bot]
aa057565b5 fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/storage/azblob to v1.2.1 (#801)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-22 07:59:01 +00:00
renovate[bot]
13d64a5875 fix(deps): update module github.com/sashabaranov/go-openai to v1.17.9 (#772)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 17:00:38 +00:00
Akhil Rane
03b63befa2 fix: lowercase logs before running regex matching in LogAnalyzer (#794)
Signed-off-by: Akhil Rane <akhil131192@gmail.com>
2023-12-21 16:59:13 +00:00
renovate[bot]
3c6c7597e0 fix(deps): update module github.com/aws/aws-sdk-go to v1.49.7 (#804)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 16:08:02 +00:00
renovate[bot]
71f36bdb0b fix(deps): update module github.com/aquasecurity/trivy-operator to v0.17.1 (#780)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 16:04:07 +00:00
renovate[bot]
d6fb648e23 chore(deps): update actions/upload-artifact action to v4 (#806)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 12:15:52 +00:00
fossabot
343aec8f04 feat: Add license scan report and status (#796)
Signed off by: fossabot <badges@fossa.com>

Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2023-12-21 13:11:44 +01:00
renovate[bot]
78f7f2ba85 fix(deps): update module google.golang.org/api to v0.154.0 (#779)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 12:06:30 +00:00
renovate[bot]
a8e1932122 fix(deps): update module helm.sh/helm/v3 to v3.13.3 (#803)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 13:04:37 +01:00
renovate[bot]
390f309088 fix(deps): update module cloud.google.com/go/storage to v1.36.0 (#805)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 10:37:14 +00:00
renovate[bot]
5d54c3f840 fix(deps): update module google.golang.org/grpc to v1.60.1 (#790)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 10:12:32 +00:00
renovate[bot]
4a7bad313b fix(deps): update module github.com/mittwald/go-helm-client to v0.12.5 (#802)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 10:00:54 +00:00
renovate[bot]
be4b0bb3c2 chore(deps): update google-github-actions/release-please-action action to v4.0.2 (#800)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-20 17:14:55 +01:00
renovate[bot]
1b386f64f2 fix(deps): update module github.com/aws/aws-sdk-go to v1.49.6 (#783)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-20 16:08:33 +00:00
renovate[bot]
8dea6170a2 fix(deps): update module github.com/spf13/viper to v1.18.2 (#787)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-20 16:04:32 +00:00
Swastik Gour
928b39a728 fix: added the ability to set the trivy variables by the user (#797)
Signed-off-by: swastik959 <Sswastik959@gmail.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-12-20 15:57:28 +00:00
Alex Jones
c23f24de2e feat: version upgrade to 1.21 (#798)
* feat: version upgrade to 1.21

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: updated dockerfile

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: updated dockerfile

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-12-20 15:51:27 +00:00
Akhil Rane
ff4aaf7c32 feat: add last termination state when pod is in CrashloopBackoff (#792)
Signed-off-by: Akhil Rane <akhil131192@gmail.com>
Co-authored-by: Akhil Rane <akhil_rane@intuit.com>
2023-12-20 12:57:17 +00:00
renovate[bot]
2c28c555cf chore(deps): update google-github-actions/release-please-action action to v4 (#782)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-08 08:55:55 +00:00
renovate[bot]
d00ed33678 chore(deps): update actions/setup-go action to v5 (#788)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-07 12:46:57 +00:00
renovate[bot]
6473a2b532 chore(deps): update anchore/sbom-action action to v0.15.1 (#784)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-06 09:24:38 +00:00
Xiangkun Yin
1d196286b7 refactor: replace rest client with controller-runtime clientset for Trivy analyzers (#776)
* refactor: replace rest client with controller-runtime clientset for Trivy analyzers

Signed-off-by: ptyin <peteryin1604@gmail.com>

* refactor: remove rest client

Signed-off-by: ptyin <peteryin1604@gmail.com>

---------

Signed-off-by: ptyin <peteryin1604@gmail.com>
2023-11-29 15:13:38 +00:00
Matthis
71ae5a7301 doc: use grpcurl instead curl (#773)
Signed-off-by: Matthis Holleville <matthish29@gmail.com>
2023-11-25 16:42:49 +00:00
github-actions[bot]
eb32a0f2bc chore(main): release 0.3.23 (#769)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-11-24 14:01:28 +00:00
Aris Boutselis
ec08cac214 feat: add Gateway analysers (#764)
* feat: add GatewayClass analyser

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore: add a valid GW class object

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: add gw analyzer and switch to controller-runtime client

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore: add unit tests for gw analyser

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore: replace constants with condition status

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: add httproute analyzer

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: add HTTPRoute individual tests.

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* docs: add analyzers

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

---------

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Signed-off-by: Aris Boutselis <aris.boutselis@senseon.io>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2023-11-24 10:09:54 +00:00
renovate[bot]
dca5b4710d fix(deps): update module github.com/mittwald/go-helm-client to v0.12.4 (#767)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-23 08:14:48 +00:00
renovate[bot]
b1c791a396 fix(deps): update module github.com/aws/aws-sdk-go to v1.48.3 (#768)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-23 08:02:35 +00:00
github-actions[bot]
b780105807 chore(main): release 0.3.22 (#748)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-11-22 09:32:57 +00:00
renovate[bot]
16469c01c9 fix(deps): update module github.com/aws/aws-sdk-go to v1.48.1 (#766)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-21 09:23:08 +00:00
renovate[bot]
cf1e243708 chore(deps): update anchore/sbom-action action to v0.15.0 (#765)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-20 19:07:58 +00:00
renovate[bot]
b5853de8a6 chore(deps): update docker/build-push-action digest to 4a13e50 (#760)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-20 18:54:37 +00:00
renovate[bot]
58d182e94f fix(deps): update module cloud.google.com/go/storage to v1.35.1 (#762)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-20 13:49:32 +00:00
Jesang Myung
5b27c3e352 fix: cover more error reason messages (#759)
* fix: cover more error reasons (#758)

Signed-off-by: Jesang Myung <jesang.myung@gmail.com>

* fix: refactoring for simplify conditions

Signed-off-by: Jesang Myung <jesang.myung@gmail.com>

---------

Signed-off-by: Jesang Myung <jesang.myung@gmail.com>
2023-11-20 13:01:04 +00:00
renovate[bot]
3e3f6a903a fix(deps): update module google.golang.org/api to v0.151.0 (#763)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-20 12:42:13 +00:00
Matthis
12146bf356 feat: rework cache package - add gcs cache - add cache purge command (#750)
* feat: rework cache pkg

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: Completion of cache pkg rework. Added cache purge command.

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* doc: add purgin command note

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* fix: disable cache if noCache is set

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: improve GetCacheConfiguration lisibility & transform add method to addOrUpdate

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: transform server mode to work with new cache configuration

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* fix: use 'switch' instead 'if' to evaluate Cache from grpc

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: add mutually exclusive flags for command options

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* doc: update readme.md

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: return err on bucket creation failed

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

* feat: update dependencies

Signed-off-by: Matthis Holleville <matthish29@gmail.com>

---------

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
Signed-off-by: Matthis <matthish29@gmail.com>
2023-11-18 22:08:38 +01:00
renovate[bot]
beaa53251c fix(deps): update module github.com/sashabaranov/go-openai to v1.17.8 (#761)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-18 20:23:44 +00:00
renovate[bot]
e2bb567d2f fix(deps): update module github.com/aws/aws-sdk-go to v1.48.0 (#754)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-18 20:14:37 +00:00
renovate[bot]
24132c2d87 fix(deps): update kubernetes packages to v0.28.4 (#756)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-16 07:02:15 -05:00
Alex Jones
11e568c6c2 Update README.md (#757)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-11-16 06:47:27 -05:00
renovate[bot]
9971699fcf fix(deps): update module github.com/sashabaranov/go-openai to v1.17.7 (#753)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-15 21:10:29 +00:00
renovate[bot]
531fa79ed6 fix(deps): update module github.com/aws/aws-sdk-go to v1.47.11 (#752)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-15 06:55:39 -05:00
renovate[bot]
2aa31bc66d fix(deps): update module github.com/aws/aws-sdk-go to v1.47.10 (#751)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-13 20:14:47 -05:00
renovate[bot]
84df3640bc fix(deps): update module github.com/sashabaranov/go-openai to v1.17.6 (#749)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-13 11:51:11 -05:00
Johannes Kleinlercher
73682717ed fix: show trivy as active when activated with --no-install flag (#675)
Signed-off-by: Johannes Kleinlercher <johannes@kleinlercher.at>
Signed-off-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-11-13 11:10:13 -05:00
renovate[bot]
45312788c3 fix(deps): update module github.com/aquasecurity/trivy-operator to v0.16.4 (#676)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-12 16:52:11 -05:00
github-actions[bot]
c78c4f0cb6 chore(main): release 0.3.21 (#735)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-11-12 16:09:05 -05:00
Alex Jones
d365886753 feat: log analyzer (#744)
* feat: wip log analyzer

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: turns off log by default

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: turns off log by default

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2023-11-12 16:00:43 -05:00
renovate[bot]
4408110b1a chore(deps): pin google-github-actions/release-please-action action to db8f2c6 (#747)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-12 21:47:22 +01:00
Thomas Schuetz
c4925b2170 chore: pin release-please version (#746)
Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu>
Signed-off-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2023-11-12 21:39:38 +01:00
Thomas Schuetz
66ebb88efe chore: enable automerge for renovate (#745)
Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-11-12 21:38:47 +01:00
Tsadok Levi Firseck
1a554ae840 Update pod.go - added handling of CreateContainerConfigError (#639)
Added handling of CreateContainerConfigError error

Signed-off-by: Tsadok Levi Firseck <tsadoklf@gmail.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2023-11-12 21:24:41 +01:00
renovate[bot]
19e502a841 fix(deps): update module github.com/spf13/cobra to v1.8.0 (#732)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-12 21:20:00 +01:00
renovate[bot]
fdb2934e8f chore(deps): update google-github-actions/release-please-action digest to db8f2c6 (#736)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-12 20:54:56 +01:00
renovate[bot]
45ebad7b4d fix(deps): update module github.com/aws/aws-sdk-go to v1.47.9 (#743)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-11 05:53:31 -06:00
renovate[bot]
6a665f05d7 fix(deps): update module helm.sh/helm/v3 to v3.13.2 (#740)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-10 14:53:44 -06:00
renovate[bot]
d359caaab6 fix(deps): update module github.com/aws/aws-sdk-go to v1.47.8 (#741)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-10 14:37:54 -06:00
Pavel Sturc
9dadd186c8 feat: auth remove: add -b flag (#711)
* feat: auth remove: add -b flag

Signed-off-by: Pavel Sturc <psturc@redhat.com>

* fix: address comment

Signed-off-by: Pavel Sturc <psturc@redhat.com>

---------

Signed-off-by: Pavel Sturc <psturc@redhat.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-11-10 14:15:24 -06:00
renovate[bot]
3bff9cbe7b fix(deps): update module github.com/sashabaranov/go-openai to v1.17.5 (#742)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-10 14:14:34 -06:00
renovate[bot]
05f444dec1 fix(deps): update module github.com/schollz/progressbar/v3 to v3.14.1 (#738)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-09 11:29:35 -06:00
renovate[bot]
bb21ce80c7 fix(deps): update module github.com/aws/aws-sdk-go to v1.47.6 (#728)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-08 16:25:43 -06:00
renovate[bot]
48486e9627 fix(deps): update module github.com/sashabaranov/go-openai to v1.17.3 (#737)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-08 07:33:10 -06:00
Ajay Kemparaj
120027e3cb deps: bump docker fixes CVE GHSA-jq35-85cj-fj4p (#733)
Signed-off-by: ajayk <ajaykemparaj@gmail.com>
2023-11-07 15:47:39 -06:00
renovate[bot]
9c518badf5 chore(deps): update google-github-actions/release-please-action digest to 4c5670f (#721)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-06 14:15:22 +01:00
renovate[bot]
8ab26d96ce fix(deps): update module github.com/fatih/color to v1.16.0 (#734)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-06 14:13:00 +01:00
github-actions[bot]
4978fe2523 chore(main): release 0.3.20 (#727)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-11-05 20:22:00 +00:00
DKuroczko
ccef7f6170 feat: amazonsagemaker AI provider (#731)
* feat(amazonsagemaker): Add AmazonSageMaker AI provider

Co-authored-by: NAME 18630245+zaremb@users.noreply.github.com
Signed-off-by: Damian Kuroczko <7778327+dkuroczk@users.noreply.github.com>

* feat(amazonsagemaker): Add AmazonSageMaker AI provider

Co-authored-by: Mateusz Zaremba <18630245+zaremb@users.noreply.github.com>
Signed-off-by: Damian Kuroczko <7778327+dkuroczk@users.noreply.github.com>

* feat(auth): add top p and max tokens to auth and use them in sagemaker backend

Signed-off-by: Mateusz Zaremba <18630245+zaremb@users.noreply.github.com>

* feat: Updates SageMaker docs, validate topP, ident

Signed-off-by: Damian Kuroczko <7778327+dkuroczk@users.noreply.github.com>

* feat: list of passwordlessProviders

Signed-off-by: Damian Kuroczko <7778327+dkuroczk@users.noreply.github.com>

* feat: returns err

Signed-off-by: Damian Kuroczko <7778327+dkuroczk@users.noreply.github.com>

* fix: remove log.Fatal(err)

Signed-off-by: Damian Kuroczko <7778327+dkuroczk@users.noreply.github.com>

---------

Signed-off-by: Damian Kuroczko <7778327+dkuroczk@users.noreply.github.com>
Signed-off-by: Mateusz Zaremba <18630245+zaremb@users.noreply.github.com>
Co-authored-by: Mateusz Zaremba <18630245+zaremb@users.noreply.github.com>
2023-11-05 20:03:40 +00:00
renovate[bot]
188a8a2cd5 chore(deps): update amannn/action-semantic-pull-request action to v5.4.0 (#729)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-04 21:40:40 +00:00
Ali
37721b5dd7 fix: ensure ingress HTTP rule exists to prevent panic (#726)
Signed-off-by: Ali Harris <aliharriss1995@gmail.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
2023-11-03 14:02:51 +00:00
renovate[bot]
16b229d547 fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/storage/azblob to v1.2.0 (#723)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-03 10:54:06 +00:00
renovate[bot]
901c5ec188 fix(deps): update module google.golang.org/grpc to v1.59.0 (#713)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-03 10:33:59 +00:00
renovate[bot]
40133adaed fix(deps): update module helm.sh/helm/v3 to v3.13.1 (#706)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-03 08:30:26 +00:00
renovate[bot]
0136b8f543 fix(deps): update module github.com/aws/aws-sdk-go to v1.47.1 (#724)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-02 15:42:17 +00:00
github-actions[bot]
f4b361aed6 chore(main): release 0.3.19 (#708)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-28 13:12:15 +01:00
StevenSu
f1a7801e9e feat: add amazonbedrock (#718)
* add amazonbedrock AI provider

Signed-off-by: Su Wei <suwei007@gmail.com>

* add amazonbedrock, change model list to const var

Signed-off-by: Su Wei <suwei007@gmail.com>

* update iai config and auth cmd, add providerRegion

Signed-off-by: Wei Su <wsuam@amazon.com>

* fix filename wrong

Signed-off-by: Wei Su <wsuam@amazon.com>

* chore: added some doc info

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Su Wei <suwei007@gmail.com>
Signed-off-by: Wei Su <wsuam@amazon.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Wei Su <wsuam@amazon.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-10-28 11:49:09 +01:00
renovate[bot]
4af0ad0303 chore(deps): update module oras.land/oras-go to v1.2.4 (#665)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-27 06:31:23 +01:00
renovate[bot]
a77bd41048 chore(deps): update actions/checkout digest to b4ffde6 (#719)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-27 06:20:53 +01:00
renovate[bot]
63a226065c fix(deps): update module github.com/aws/aws-sdk-go to v1.46.5 (#712)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-27 06:13:36 +01:00
renovate[bot]
0e7219a36a fix(deps): update module github.com/azure/azure-sdk-for-go/sdk/azidentity to v1.4.0 (#722)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-25 19:26:48 +01:00
renovate[bot]
7e73f8afbc fix(deps): update kubernetes packages to v0.28.3 (#715)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-25 15:58:40 +01:00
Aris Boutselis
23ac52d5ff feat: add Azure remote cache (#690)
* feat: add Azure remote cache

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: add serve mode support and update buf schema

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix: map structure name

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* chore: add a new cache type to make code readable

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* docs: update docs to reflect new remote cache type

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module github.com/prometheus/client_golang to v1.17.0 (#687)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.3.0-20231002095256-194bc640518b.1 (#692)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module helm.sh/helm/v3 to v3.13.0 (#688)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: security warning around printing provider details in https://github.com/k8sgpt-ai/k8sgpt/security/code-scanning/1 (#695)

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go to v1.31.0-20231002095256-194bc640518b.1 (#693)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/sashabaranov/go-openai to v1.15.4 (#689)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module github.com/aws/aws-sdk-go to v1.45.20 (#685)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update amannn/action-semantic-pull-request action to v5.3.0 (#683)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module github.com/aws/aws-sdk-go to v1.45.21 (#696)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/aws/aws-sdk-go to v1.45.22 (#697)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module github.com/aws/aws-sdk-go to v1.45.23 (#699)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* fix(deps): update module github.com/aws/aws-sdk-go to v1.45.24 (#701)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

---------

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Aris Boutselis <aris.boutselis@senseon.io>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-10-22 16:08:39 +01:00
renovate[bot]
c977528ec7 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.26 (#709)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-17 14:17:34 +01:00
renovate[bot]
b5facd64a3 fix(deps): update module github.com/sashabaranov/go-openai to v1.16.0 (#703)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-16 07:39:34 +01:00
renovate[bot]
1d7360c0ae fix(deps): update module google.golang.org/grpc to v1.58.3 (#704)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-15 20:47:25 +01:00
renovate[bot]
184d148108 fix(deps): update module github.com/spf13/viper to v1.17.0 (#700)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-13 10:45:59 +01:00
renovate[bot]
3ebc86772d fix(deps): update module github.com/aws/aws-sdk-go to v1.45.25 (#707)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-13 08:39:37 +01:00
github-actions[bot]
c5c198e3d6 chore(main): release 0.3.18 (#691)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-12 13:16:42 +01:00
Aris Boutselis
539ca3b78f feat: adding temperature to server mode (#705)
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2023-10-12 13:14:43 +01:00
Alex Jones
2a34ff24d1 chore: fixing default model issue (#702)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-10-11 19:52:47 +01:00
renovate[bot]
6d3038b0e8 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.24 (#701)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-09 16:56:08 +01:00
renovate[bot]
3f36a44415 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.23 (#699)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-05 21:06:37 +01:00
renovate[bot]
923a8c13c0 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.22 (#697)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-05 06:29:38 +01:00
renovate[bot]
95c8cc0afb fix(deps): update module github.com/aws/aws-sdk-go to v1.45.21 (#696)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 20:24:51 +01:00
renovate[bot]
c5a8c46298 chore(deps): update amannn/action-semantic-pull-request action to v5.3.0 (#683)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 20:12:53 +01:00
renovate[bot]
2494946dc8 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.20 (#685)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 14:00:19 +01:00
renovate[bot]
f11d3149b2 fix(deps): update module github.com/sashabaranov/go-openai to v1.15.4 (#689)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 13:10:39 +01:00
renovate[bot]
20e6bd816f fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go to v1.31.0-20231002095256-194bc640518b.1 (#693)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 11:15:50 +01:00
Alex Jones
85ce557681 fix: security warning around printing provider details in https://github.com/k8sgpt-ai/k8sgpt/security/code-scanning/1 (#695) 2023-10-03 11:01:33 +01:00
renovate[bot]
87c8bcea4b fix(deps): update module helm.sh/helm/v3 to v3.13.0 (#688)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 09:38:08 +01:00
renovate[bot]
4d4e33bea9 fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.3.0-20231002095256-194bc640518b.1 (#692)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 08:45:35 +01:00
renovate[bot]
9597002723 fix(deps): update module github.com/prometheus/client_golang to v1.17.0 (#687)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-03 07:42:31 +01:00
github-actions[bot]
bcd058c3b0 chore(main): release 0.3.17 (#674)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-09-29 08:13:39 +01:00
Alex Jones
69fe2db8ac feat: integration refactor (#684)
* feat: more significant refactor

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: more significant refactor

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: reworked the integration activate/deactivation

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated schema for list integrations

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* fix: error with incorrect error being swallowed

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: added namespace check

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: fixed issue with namespace and skip install validation

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-09-28 07:43:05 +01:00
renovate[bot]
ddeff9fae4 fix(deps): update kubernetes packages to v0.28.2 (#607)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-26 12:50:59 +01:00
renovate[bot]
aa9e6a3549 chore(deps): update actions/checkout digest to 8ade135 (#681)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-26 10:24:19 +01:00
renovate[bot]
e1a42ff3bc fix(deps): update module github.com/aws/aws-sdk-go to v1.45.16 (#682)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-26 10:15:50 +01:00
renovate[bot]
901ffb8df4 fix(deps): update module github.com/google/gnostic to v0.7.0 (#679)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-22 12:08:52 +01:00
renovate[bot]
402e97d05e fix(deps): update module google.golang.org/grpc to v1.58.2 (#680)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-22 07:10:12 +01:00
renovate[bot]
1da4b7c8f0 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.14 (#672)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-21 06:42:23 +01:00
Alex Jones
820e4755a5 feat: added create namespace on deploy (#673)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
2023-09-20 12:43:18 +01:00
Rakshit Gondwal
cad605af46 feat: update readme with new analyzers (#671)
Signed-off-by: Rakshit Gondwal <98955085+rakshitgondwal@users.noreply.github.com>
2023-09-20 12:20:13 +01:00
github-actions[bot]
9bd11feb01 chore(main): release 0.3.16 (#655)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-09-19 20:33:34 +01:00
Jian Zhang
7461a748f8 fix: use default values when adding auth (#568)
The `auth add` cmd should use `backend` and `model` default values when user doesn't specify them

Closes: #567

Signed-off-by: Jian Zhang <jiazha@redhat.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-09-19 20:17:19 +01:00
renovate[bot]
b4656f533b fix(deps): update module github.com/aws/aws-sdk-go to v1.45.12 (#666)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-19 19:00:51 +00:00
renovate[bot]
4bfc7f996c chore(deps): update actions/upload-artifact digest to a8a3f3a (#633)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-19 18:15:45 +02:00
Alex Jones
844ff1fc78 feat: lists activate integrations (#669)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-09-19 18:15:07 +02:00
renovate[bot]
d6b7b818ae fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.3.0-20230830164712-dc062a152c20.1 (#617)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-19 12:23:17 +01:00
Peter Pan
f55946d60e feat: openAI explicit value for maxToken and temperature (#659)
* feat: openAI explicit value for maxToken and temp

Because when k8sgpt talks with vLLM, the default MaxToken is 16,
which is so small.
Given the most model supports 2048 token(like Llama1 ..etc), so
put here for a safe value.

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

* feat: make temperature a flag

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

---------

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
2023-09-18 13:14:43 +01:00
renovate[bot]
54caff837d fix(deps): update module github.com/sashabaranov/go-openai to v1.15.3 (#636)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-17 14:59:04 +01:00
Alex Jones
3277b2ad4b fix: pdb panic error guard (#664)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
2023-09-17 12:12:28 +01:00
renovate[bot]
f60736035b chore(deps): update reviewdog/action-golangci-lint digest to 24d4af2 (#642)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-17 12:10:15 +01:00
renovate[bot]
1b80b0ce95 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.11 (#662)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-17 09:09:32 +01:00
Alex Jones
2472da1673 fix: emergency fix for bad package revision in go mod (#663)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-09-17 08:55:23 +01:00
Alex Jones
ab064b940c feat: serve/integration capability (#645)
* chore: updated schema for integrations support (#616)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

wip: enabling integration activation

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

wip: enabling integration activation

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* wip

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: skipinstall fixed

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: fixed filters for integrations but its ugly

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated library

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated go mod

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: updated go mod

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-09-16 17:12:09 +01:00
Johannes Kleinlercher
6481590b29 fix: respect namespace scope in trivy analyzer (#661)
Signed-off-by: Johannes Kleinlercher <johannes@kleinlercher.at>
2023-09-15 21:30:59 +01:00
renovate[bot]
0325724658 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.10 (#657)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-15 08:36:25 +01:00
renovate[bot]
f76b572654 fix(deps): update module go.uber.org/zap to v1.26.0 (#658)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-15 07:08:05 +01:00
renovate[bot]
abfb58432f fix(deps): update module google.golang.org/grpc to v1.58.1 (#656)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-14 19:23:14 +01:00
renovate[bot]
d58e002d7d fix(deps): update module google.golang.org/grpc to v1.58.0 (#635)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-14 18:33:57 +01:00
github-actions[bot]
ac2937c821 chore(main): release 0.3.15 (#613)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-09-14 17:41:21 +01:00
Aris Boutselis
6c5a0628e4 fix: defer to service analyser when selectors are missing (#652)
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-09-14 16:57:27 +01:00
renovate[bot]
598ef22e57 chore(deps): update docker/setup-buildx-action action to v3 (#649)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-14 16:56:21 +01:00
renovate[bot]
95787f2854 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.9 (#640)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-14 16:15:08 +01:00
Johannes Kleinlercher
230eace187 feat: show each ConfigAuditReport check (#646)
* feat: show each ConfigAuditReport check

Signed-off-by: Johannes Kleinlercher <johannes@kleinlercher.at>

* feat: mask sensitive data in configauditreport messages

Signed-off-by: Johannes Kleinlercher <johannes@kleinlercher.at>

---------

Signed-off-by: Johannes Kleinlercher <johannes@kleinlercher.at>
2023-09-13 09:18:03 +01:00
renovate[bot]
b491c9200e chore(deps): update docker/login-action action to v3 (#648)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-12 21:00:06 +01:00
renovate[bot]
00d7a27ec1 chore(deps): update goreleaser/goreleaser-action action to v5 (#641)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-12 15:20:06 +00:00
renovate[bot]
241f1bd6df chore(deps): update docker/build-push-action action to v5 (#643)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-12 17:14:37 +02:00
dependabot[bot]
25890e6e38 chore(deps): bump github.com/cyphar/filepath-securejoin (#644)
Bumps [github.com/cyphar/filepath-securejoin](https://github.com/cyphar/filepath-securejoin) from 0.2.3 to 0.2.4.
- [Release notes](https://github.com/cyphar/filepath-securejoin/releases)
- [Commits](https://github.com/cyphar/filepath-securejoin/compare/v0.2.3...v0.2.4)

---
updated-dependencies:
- dependency-name: github.com/cyphar/filepath-securejoin
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 13:55:25 +01:00
renovate[bot]
3aabb4842d fix(deps): update module github.com/aws/aws-sdk-go to v1.45.6 (#634)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-08 20:50:29 +01:00
renovate[bot]
5de3b64098 chore(deps): update goreleaser/goreleaser-action digest to 5fdedb9 (#631)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-05 20:50:41 +01:00
renovate[bot]
5f73240a06 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.3 (#632)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-05 20:45:58 +01:00
renovate[bot]
44d17c51ff fix(deps): update module golang.org/x/term to v0.12.0 (#626)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-05 20:18:56 +01:00
renovate[bot]
2c81dadb4d chore(deps): update docker/setup-buildx-action digest to 885d146 (#615)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-05 19:41:46 +02:00
omahs
067c3483e6 fix: typos (#629)
* fix typos

Signed-off-by: omahs <73983677+omahs@users.noreply.github.com>

* fix typo

Signed-off-by: omahs <73983677+omahs@users.noreply.github.com>

* fix typo

Signed-off-by: omahs <73983677+omahs@users.noreply.github.com>

---------

Signed-off-by: omahs <73983677+omahs@users.noreply.github.com>
2023-09-05 14:02:34 +01:00
renovate[bot]
e65d9a6505 chore(deps): update actions/checkout action to v4 (#628)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-04 20:25:26 +01:00
guangwu
c24825b810 chore: slice loop replace (#627)
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-09-04 20:19:48 +01:00
renovate[bot]
b6498ef269 fix(deps): update module github.com/aws/aws-sdk-go to v1.45.2 (#625)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-03 16:29:54 +01:00
Alex Jones
133850f984 chore: fixes a bug where filters do not deactive (#621)
Signed-off-by: Alex Jones <alex@Alexs-MacBook-Pro.local>
Co-authored-by: Alex Jones <alex@Alexs-MacBook-Pro.local>
2023-09-03 16:13:52 +01:00
renovate[bot]
09984c245d fix(deps): update module github.com/aws/aws-sdk-go to v1.45.1 (#624)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-01 09:42:57 +01:00
Aris Boutselis
1a7f45cc55 fix: use-case while in cluster, connecting to an external (#623)
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2023-09-01 08:09:11 +00:00
renovate[bot]
fc90dc865b fix(deps): update module github.com/sashabaranov/go-openai to v1.15.1 (#622)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-31 19:14:19 +01:00
renovate[bot]
632fc9a99f fix(deps): update module github.com/aws/aws-sdk-go to v1.45.0 (#618)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-31 07:22:12 +01:00
renovate[bot]
96d97cfa30 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.333 (#611)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-29 21:27:05 +01:00
Alex Jones
8f0a2fd41d chore: updated schema for integrations support (#616)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-08-28 12:39:23 +01:00
Alex Jones
5e17e66665 chore: updated protobuf libs (#614)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-08-27 16:52:56 +01:00
renovate[bot]
6f9f7b2b60 chore(deps): update actions/checkout digest to f43a0e5 (#612)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-26 07:01:02 +01:00
github-actions[bot]
95ebc52a6b chore(main): release 0.3.14 (#571)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-25 17:39:21 +01:00
Alex Jones
44d3613c1f feat: configauditreport (#609)
* feat: adding config audit report

Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>

* feat: adding config audit report

Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>

* feat: adding config audit report analyzer mechnics

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>

* feat: adding config audit report analyzer mechnics

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>

* chore: updated naming

Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>

* chore: updated naming

Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>

* chore: updated var names

Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>

---------

Signed-off-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Alex Jones <alex@alexs-mbp.tailddc26.ts.net>
2023-08-25 17:37:53 +01:00
renovate[bot]
0e5be89e5c fix(deps): update module github.com/aws/aws-sdk-go to v1.44.329 (#610)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-23 06:55:54 +01:00
Alex Jones
13f63eda2a Revert "fix: use kubeconfig file when user specify it (#605)" (#608)
This reverts commit e3b21ec5ec.
2023-08-19 20:58:34 +01:00
Clever Hu
cc665ea4f3 fix: optimize analyze service (#461)
Signed-off-by: cleverhu <shouping.hu@daocloud.io>
Signed-off-by: cleverhu <zhubai.hsp@xuelanyun.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: cleverhu <shouping.hu@daocloud.io>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-08-19 20:52:46 +01:00
renovate[bot]
aee83b74b2 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.327 (#597)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-08-19 20:11:58 +01:00
Jian Zhang
e3b21ec5ec fix: use kubeconfig file when user specify it (#605)
If user specify `--kubeconfig` when running k8sgpt, it should use the
kubeconfig file to login the corresponding cluster instead of getting auth info via SA.

Closes #604

Signed-off-by: Jian Zhang <jiazha@redhat.com>
2023-08-19 20:11:11 +01:00
renovate[bot]
1a0ae1a086 chore(deps): update actions/setup-go digest to 93397be (#600)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-12 21:14:28 +01:00
renovate[bot]
610720a95c chore(deps): update goreleaser/goreleaser-action digest to 3fa32b8 (#601)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-12 21:08:21 +01:00
renovate[bot]
7910c9aa2c fix(deps): update module helm.sh/helm/v3 to v3.12.3 (#602)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-12 20:58:01 +01:00
Maxime Brunet
f8a53a5c03 chore(deps): exclude retracted cohere-go versions (#583)
Signed-off-by: Maxime Brunet <max@brnt.mx>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-08-12 20:47:46 +01:00
renovate[bot]
81fcf8b5d4 fix(deps): update module github.com/sashabaranov/go-openai to v1.14.2 (#603)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-12 20:38:19 +01:00
renovate[bot]
2251321696 chore(deps): update reviewdog/action-golangci-lint digest to f17c2e2 (#598)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-11 19:46:27 +01:00
renovate[bot]
9672cea228 fix(deps): update module go.uber.org/zap to v1.25.0 (#589)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-06 11:36:09 +01:00
renovate[bot]
7f109cdcfa fix(deps): update module golang.org/x/term to v0.11.0 (#593)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-06 08:59:11 +01:00
renovate[bot]
9802e82ff5 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.317 (#591)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-06 08:18:37 +01:00
renovate[bot]
9acaec00c4 chore(deps): update reviewdog/action-golangci-lint digest to 951dc8b (#594)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-06 07:57:17 +01:00
renovate[bot]
fe29361e33 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.315 (#588)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-03 06:27:19 +01:00
renovate[bot]
f1479babba fix(deps): update module github.com/aws/aws-sdk-go to v1.44.313 (#587)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-01 13:26:13 +01:00
renovate[bot]
c2770f38a6 fix(deps): update module github.com/mittwald/go-helm-client to v0.12.3 (#582)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-30 15:33:21 +01:00
renovate[bot]
59897f330a fix(deps): update module google.golang.org/grpc to v1.57.0 (#585)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-30 05:58:37 +01:00
renovate[bot]
aafac9345f fix(deps): update module github.com/aws/aws-sdk-go to v1.44.312 (#586)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 17:17:43 +01:00
renovate[bot]
227e1cd69f fix(deps): update module github.com/aws/aws-sdk-go to v1.44.309 (#584)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-27 10:34:47 +01:00
Alex Jones
5bb91ff2c9 Revert "chore: upgraded cohere backend (#580)" (#581)
This reverts commit 43b0d707e7.
2023-07-26 16:59:49 +01:00
Alex Jones
43b0d707e7 chore: upgraded cohere backend (#580)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-07-26 16:22:49 +01:00
renovate[bot]
c3640744c5 fix(deps): update module github.com/aquasecurity/trivy-operator to v0.15.1 (#576)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-26 15:57:05 +01:00
renovate[bot]
3cc7aa56d8 fix(deps): update kubernetes packages to v0.27.4 (#565)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-26 08:57:13 +01:00
renovate[bot]
7e8668a56b fix(deps): update module github.com/aws/aws-sdk-go to v1.44.308 (#579)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-26 07:01:54 +01:00
renovate[bot]
b52424a9b1 fix(deps): update module github.com/sashabaranov/go-openai to v1.14.1 (#573)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-25 08:09:59 +01:00
renovate[bot]
fba1a8ed8c chore(deps): update google-github-actions/release-please-action digest to ca6063f (#572)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-25 06:52:56 +01:00
renovate[bot]
8ae91ec744 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.307 (#574)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-25 06:33:52 +01:00
renovate[bot]
cf9069ef57 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.304 (#558)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-07-20 14:32:03 +01:00
github-actions[bot]
5ee8499e3d chore(main): release 0.3.13 (#570)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-20 13:52:42 +01:00
Aris Boutselis
153d38deb0 chore: continue on absent service (#569)
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
2023-07-20 13:49:06 +01:00
github-actions[bot]
9d2bee9b7d chore(main): release 0.3.12 (#556)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-19 20:20:36 +01:00
Jatin Mehrotra
70bec050d8 docs: fix readme for anonymization (#559)
* docs: fixed markdown for Anonymization

Signed-off-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>

* docs: added details for events which are not being masked

Signed-off-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>

* docs: removed timeframe, added issue link for event anonymization

Signed-off-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>

* docs: changed title to Further details

Signed-off-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>

* docs: fixed broken markdown for config management and remote caching section

Signed-off-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>

* Signed-off-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>

docs: added "note" for events before further details section

---------

Signed-off-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>
Co-authored-by: Jatin Mehrotra <jatin.mehrotra@classmethod.jp>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-07-19 18:30:46 +01:00
Maxime Brunet
781ecb7aad feat: add Cohere backend (#563)
Signed-off-by: Maxime Brunet <max@brnt.mx>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-07-19 18:25:27 +01:00
Alex Jones
c42221512b chore: fixing edge cases with missing wh service (#561)
* chore: fixing edge cases with missing wh service

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* chore: fixing edge cases with missing wh service

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* Update validating_webhook.go

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
2023-07-19 16:28:45 +01:00
renovate[bot]
2e0db553f9 fix(deps): update module github.com/mittwald/go-helm-client to v0.12.2 (#562)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-18 20:57:14 +01:00
renovate[bot]
cc83fe19ba fix(deps): update module google.golang.org/grpc to v1.56.2 (#546)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-17 10:16:47 +01:00
renovate[bot]
dc463334bc fix(deps): update module github.com/aws/aws-sdk-go to v1.44.300 (#554)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-17 10:02:07 +01:00
renovate[bot]
9eb96c495c fix(deps): update module helm.sh/helm/v3 to v3.12.2 (#555)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-14 21:01:04 +01:00
github-actions[bot]
ee83aa1e9e chore(main): release 0.3.11 (#552)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-14 12:09:04 +01:00
Alex Jones
06e8532f88 feat: admission webhooks (#553)
* feat: add Validating/Mutating webhook analyzer

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

* change conditions

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

* fix: use GetClient to get pods and mask pod name

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

* fix: add new cases in util.GetParent

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

* feat: implements webhooks

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: implements webhooks

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: implements webhooks

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: implements webhooks

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
2023-07-14 10:44:15 +01:00
renovate[bot]
1a3f299210 chore(deps): update docker/setup-buildx-action digest to 4c0219f (#547)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-13 09:28:24 +01:00
Alex Jones
731e1520ec Revert "feat: add Validating/Mutating webhook analyzer (#548)" (#551)
This reverts commit 750a10d44c.
2023-07-13 08:54:22 +01:00
github-actions[bot]
f844f7308e chore(main): release 0.3.10 (#544)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-12 17:28:02 +01:00
Rakshit Gondwal
750a10d44c feat: add Validating/Mutating webhook analyzer (#548)
* feat: add Validating/Mutating webhook analyzer

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

* change conditions

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

* fix: use GetClient to get pods and mask pod name

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

* fix: add new cases in util.GetParent

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

---------

Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>
Co-authored-by: Aris Boutselis <aris.boutselis@senseon.io>
2023-07-12 14:20:18 +01:00
renovate[bot]
9dcab94546 fix(deps): update module github.com/sashabaranov/go-openai to v1.14.0 (#550)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-12 13:14:41 +01:00
renovate[bot]
ecd7790efe fix(deps): update module github.com/aws/aws-sdk-go to v1.44.299 (#549)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-11 18:21:10 +01:00
renovate[bot]
d1096dc31a fix(deps): update module github.com/aws/aws-sdk-go to v1.44.298 (#545)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-10 09:50:58 +01:00
renovate[bot]
21df094bda fix(deps): update module github.com/sashabaranov/go-openai to v1.13.0 (#399)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-06 12:38:57 +01:00
renovate[bot]
1276b3e897 fix(deps): update module golang.org/x/term to v0.10.0 (#542)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-05 17:31:45 +01:00
github-actions[bot]
ad112eae2e chore(main): release 0.3.9 (#509)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-04 13:03:45 +01:00
Alexandre Steppé
da750df16b fix: typo in add command (#539)
Signed-off-by: Alexandre Steppé <alexandre.steppe@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-07-04 12:55:06 +01:00
renovate[bot]
767e4cbc41 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.295 (#540)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-04 10:23:20 +01:00
renovate[bot]
3067fa98f4 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.294 (#535)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-03 12:37:06 +01:00
Alexandre Steppé
2309b0dfe2 feat: details flag to list command (#537)
Signed-off-by: Alexandre Steppé <alexandre.steppe@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-07-03 11:47:38 +01:00
Peter Pan
1f5462c80b fix: add --no-install for activate command (#536)
to fix #534

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
2023-07-03 11:36:02 +01:00
Rakshit Gondwal
5a983c4a0a fix: remove provider from default on delete (#529)
Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-29 16:05:43 +01:00
renovate[bot]
5662d5932f chore(deps): update docker/setup-buildx-action digest to 16c0bc4 (#532)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-29 09:57:54 +01:00
Alex Jones
367fe8f74c feat: upgrading azure client impl (#526)
* feat: upgrading azure client impl

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: upgrading azure client impl

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* fix: displaying correct yaml config location on app start (#521)

Signed-off-by: Ali Mohsin <aliofthemohsins@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>

* fix(deps): update module github.com/aws/aws-sdk-go to v1.44.289 (#524)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: upgrading azure client impl

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Signed-off-by: Ali Mohsin <aliofthemohsins@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ali Mohsin <aliofthemohsins@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-29 09:47:12 +01:00
renovate[bot]
566f7525ee fix(deps): update module github.com/aws/aws-sdk-go to v1.44.292 (#530)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-29 09:45:32 +01:00
renovate[bot]
fafb69544f fix(deps): update module github.com/aws/aws-sdk-go to v1.44.289 (#524)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-26 09:51:08 +01:00
Ali Mohsin
b7d4602cb8 fix: displaying correct yaml config location on app start (#521)
Signed-off-by: Ali Mohsin <aliofthemohsins@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-26 09:40:14 +01:00
renovate[bot]
d56861d4ba chore(deps): update google-github-actions/release-please-action digest to 8016a66 (#523)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-26 08:00:37 +01:00
renovate[bot]
3146754779 chore(deps): update reviewdog/action-golangci-lint digest to 22adb9d (#525)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-25 19:21:13 +01:00
renovate[bot]
57695b44b6 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.288 (#519)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
2023-06-23 17:52:10 +02:00
renovate[bot]
be52308c99 fix(deps): update module google.golang.org/grpc to v1.56.1 (#520)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-23 17:50:34 +02:00
Alex Jones
cd7807a484 chore: sorting out the dependency hell (#518)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-21 10:58:07 +01:00
renovate[bot]
0521060410 chore(deps): update anchore/sbom-action action to v0.14.3 (#517)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-21 10:42:04 +01:00
renovate[bot]
b9cf522685 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.286 (#514)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-21 10:41:22 +01:00
renovate[bot]
06e50d57db fix(deps): update module buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go to v1.3.0-20230620082254-6f80f9533908.1 (#516)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-20 09:36:01 +01:00
Alex Jones
c88fc889e4 feat: upgrading the proto files to fix user issues (#515)
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-20 09:29:21 +01:00
renovate[bot]
c15a561b63 chore(deps): update docker/login-action digest to 465a078 (#488)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-19 22:27:52 +01:00
renovate[bot]
1819c3bf15 chore(deps): update reviewdog/action-golangci-lint digest to 994abff (#513)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-19 22:27:08 +01:00
renovate[bot]
f4d7876838 chore(deps): update docker/setup-buildx-action digest to ecf9528 (#498)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-19 11:47:13 +01:00
renovate[bot]
d87127a309 fix(deps): update module github.com/aws/aws-sdk-go to v1.44.284 (#501)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-19 09:44:02 +01:00
renovate[bot]
9df75cc959 chore(deps): update docker/build-push-action digest to 2eb1c19 (#499)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-19 09:26:01 +01:00
renovate[bot]
f3e0b9b56d fix(deps): update module google.golang.org/grpc to v1.56.0 (#510)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-19 09:25:21 +01:00
renovate[bot]
0f03ddcf0f fix(deps): update module helm.sh/helm/v3 to v3.12.1 (#503)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-16 11:57:16 +01:00
renovate[bot]
14e5691190 fix(deps): update module github.com/prometheus/client_golang to v1.16.0 (#507)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-16 11:19:20 +01:00
Ben Parees
64b93c9116 fix: 'intergration' typos (#508)
Signed-off-by: bparees <bparees@redhat.com>
2023-06-15 19:13:15 +01:00
github-actions[bot]
4038318adc chore(main): release 0.3.8 (#506)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-15 14:04:21 +01:00
renovate[bot]
b1c6ec3c09 fix(deps): update kubernetes packages to v0.27.3 (#504)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-15 12:22:04 +00:00
Alex Jones
f6db6ce861 feat: fix for s3 cache from operator
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
2023-06-15 13:17:43 +01:00
200 changed files with 24272 additions and 2520 deletions

View File

@@ -8,13 +8,16 @@ on:
pull_request:
branches:
- 'main'
- fix/build-branch
- '[0-9]+.[1-9][0-9]*.x'
paths-ignore:
- "**.md"
env:
GO_VERSION: "~1.20"
GO_VERSION: "~1.24"
IMAGE_NAME: "k8sgpt"
REGISTRY_IMAGE: ghcr.io/k8sgpt-ai/k8sgpt
defaults:
run:
shell: bash
@@ -22,7 +25,7 @@ defaults:
jobs:
prepare_ci_run:
name: Prepare CI Run
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
outputs:
GIT_SHA: ${{ steps.extract_branch.outputs.GIT_SHA }}
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }}
@@ -33,7 +36,7 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Extract branch name
id: extract_branch
@@ -51,97 +54,61 @@ jobs:
id: get_run_type
run: |
NON_FORKED_AND_NON_ROBOT_RUN=${{ ( github.actor != 'renovate[bot]' && github.actor != 'dependabot[bot]' ) && ( github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository ) }}
echo "github.actor != 'renovate[bot]' = ${{ github.actor != 'renovate[bot]' }}"
echo "github.actor != 'dependabot[bot]' = ${{ github.actor != 'dependabot[bot]' }}"
echo "github.event_name == 'push' = ${{ github.event_name == 'push' }}"
echo "github.event.pull_request.head.repo.full_name == github.repository = ${{ github.event.pull_request.head.repo.full_name == github.repository }}"
echo "NON_FORKED_AND_NON_ROBOT_RUN = $NON_FORKED_AND_NON_ROBOT_RUN"
echo "NON_FORKED_AND_NON_ROBOT_RUN=$NON_FORKED_AND_NON_ROBOT_RUN" >> "$GITHUB_OUTPUT"
build_image:
name: Build Container Image
build-and-push:
name: Build and Push Multi-arch Image
needs: prepare_ci_run
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
if: ${{ needs.prepare_ci_run.outputs.NON_FORKED_AND_NON_ROBOT_RUN == 'true' }}
env:
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }}
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
RELEASE_REGISTRY: "localhost:5000/k8sgpt"
steps:
- name: Check out code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@6a58db7e0d21ca03e6c44877909e80e45217eed2 # v2
- name: Build Docker Image
uses: docker/build-push-action@44ea916f6c540f9302d50c2b1e5a8dc071f15cdf # v4
- name: Docker meta
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5
with:
context: .
platforms: linux/amd64
file: ./container/Dockerfile
target: production
images: ${{ env.REGISTRY_IMAGE }}
tags: |
${{ env.RELEASE_REGISTRY }}/${{ env.IMAGE_NAME }}:dev-${{ env.DATETIME }}
build-args: |
GIT_HASH=${{ env.GIT_SHA }}
RELEASE_VERSION=dev-${{ env.DATETIME }}
BUILD_TIME=${{ env.BUILD_TIME }}
builder: ${{ steps.buildx.outputs.name }}
push: false
cache-from: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
outputs: type=docker,dest=/tmp/${{ env.IMAGE_NAME }}-image.tar
- name: Upload image as artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
with:
name: ${{ env.IMAGE_NAME }}-image.tar
path: /tmp/${{ env.IMAGE_NAME }}-image.tar
upload_images:
name: Upload images to ghcr registry
needs: [ prepare_ci_run, build_image ]
if: github.event_name == 'push' && needs.prepare_ci_run.outputs.NON_FORKED_AND_NON_ROBOT_RUN == 'true' # only run on push to main/maintenance branches
runs-on: ubuntu-22.04
env:
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
permissions:
packages: write # Needed for pushing images to the registry
contents: read # Needed for checking out the repository
steps:
- name: Check out code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=dev-${{ env.DATETIME }}
- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3
with:
registry: "ghcr.io"
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.K8SGPT_BOT_SECRET }}
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@6a58db7e0d21ca03e6c44877909e80e45217eed2 # v2
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
- name: Build Docker Image
uses: docker/build-push-action@44ea916f6c540f9302d50c2b1e5a8dc071f15cdf # v4
- name: Build and push multi-arch image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
with:
context: .
file: ./container/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
target: production
tags: |
ghcr.io/k8sgpt-ai/${{ env.IMAGE_NAME }}:dev-${{ env.DATETIME }}
build-args: |
GIT_HASH=${{ env.GIT_SHA }}
RELEASE_VERSION=dev-${{ env.DATETIME }}
BUILD_TIME=${{ env.BUILD_TIME }}
builder: ${{ steps.buildx.outputs.name }}
push: true
cache-from: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
tags: |
${{ env.REGISTRY_IMAGE }}:${{ env.DATETIME }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
GIT_AUTH_TOKEN=${{ secrets.K8SGPT_BOT_SECRET }}

View File

@@ -2,17 +2,17 @@ name: Run golangci-lint
on:
pull_request:
branches: [ main ]
branches: [main]
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: golangci-lint
uses: reviewdog/action-golangci-lint@79d32f10b2ea0d4cebb755d849b048c4b40c3d50 # v2
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
version: v2.1.0
only-new-issues: true

View File

@@ -23,9 +23,9 @@ jobs:
# Release-please creates a PR that tracks all changes
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- uses: google-github-actions/release-please-action@51ee8ae2605bd5ce1cfdcc5938684908f1cd9f69 # v3
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- uses: google-github-actions/release-please-action@e4dc86ba9405554aeba3c6bb2d169500e7d3b4ee # v4.1.1
id: release
with:
command: manifest
@@ -40,18 +40,32 @@ jobs:
- release-please
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: false
dotnet: false
haskell: false
large-packages: true
docker-images: true
swap-storage: true
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: '1.20'
go-version: '~1.24'
- name: Download Syft
uses: anchore/sbom-action/download-syft@4d571ad1038a9cc29d676154ef265ab8f9027042 # v0.14.2
uses: anchore/sbom-action/download-syft@55dc4ee22412511ee8c3142cbea40418e6cec693 # v0.17.8
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
@@ -59,12 +73,15 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.K8SGPT_BOT_SECRET }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
# - name: Update new version in krew-index
# uses: rajatjindal/krew-release-bot@3d9faef30a82761d610544f62afddca00993eef9 # v0.0.47
build-container:
if: needs.release-please.outputs.releases_created == 'true'
needs:
- release-please
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
@@ -74,23 +91,23 @@ jobs:
IMAGE_NAME: k8sgpt
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
submodules: recursive
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@6a58db7e0d21ca03e6c44877909e80e45217eed2 # v2
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.K8SGPT_BOT_SECRET }}
- name: Build Docker Image
uses: docker/build-push-action@44ea916f6c540f9302d50c2b1e5a8dc071f15cdf # v4
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
with:
context: .
file: ./container/Dockerfile
@@ -104,14 +121,14 @@ jobs:
cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_TAG }}
- name: Generate SBOM
uses: anchore/sbom-action@4d571ad1038a9cc29d676154ef265ab8f9027042 # v0.14.2
uses: anchore/sbom-action@55dc4ee22412511ee8c3142cbea40418e6cec693 # v0.17.8
with:
image: ${{ env.IMAGE_TAG }}
artifact-name: sbom-${{ env.IMAGE_NAME }}
output-file: ./sbom-${{ env.IMAGE_NAME }}.spdx.json
- name: Attach SBOM to release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
files: ./sbom-${{ env.IMAGE_NAME }}.spdx.json
files: ./sbom-${{ env.IMAGE_NAME }}.spdx.json

View File

@@ -10,13 +10,13 @@ defaults:
shell: bash
jobs:
validate:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
contents: read # Needed for checking out the repository
pull-requests: read # Needed for reading prs
steps:
- name: Validate Pull Request
uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 # v5.2.0
uses: amannn/action-semantic-pull-request@fdd4d3ddf614fbcd8c29e4b106d3bbe0cb2c605d # v6.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:

View File

@@ -9,23 +9,22 @@ on:
- main
env:
GO_VERSION: "~1.20"
GO_VERSION: "~1.24"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Unit Test
run: make test
# - name: Fmt Test
# run: fmtFiles=$(make fmt); if [ "$fmtFiles" != "" ];then exit 1; fi
- name: Run test
run: go test ./... -coverprofile=coverage.txt
- name: Upload coverage to Codecov
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

3
.gitignore vendored
View File

@@ -1,3 +1,5 @@
.idea
__debug*
.DS_Store
k8sgpt*
!charts/k8sgpt
@@ -5,3 +7,4 @@ k8sgpt*
dist/
bin/
pkg/server/example/example

View File

@@ -1,3 +1,4 @@
version: 2
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
@@ -14,16 +15,18 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X main.version={{.Version}}
- -s -w -X main.commit={{.ShortCommit}}
- -s -w -X main.Date={{.CommitDate}}
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.ShortCommit}}
- -X main.Date={{.CommitDate}}
nfpms:
- file_name_template: '{{ .ProjectName }}_{{ .Arch }}'
- file_name_template: "{{ .ProjectName }}_{{ .Arch }}"
maintainer: "K8sGPT Maintainers <contact@k8sgpt.ai>"
homepage: https://k8sgpt.ai
description: >-
K8sGPT is a tool for scanning your kubernetes clusters, diagnosing and triaging issues in simple english. It has SRE experience codified into its analyzers and helps to pull out the most relevant information to enrich it with AI.
license: "MIT"
license: "Apache-2.0"
formats:
- deb
- rpm
@@ -32,7 +35,7 @@ nfpms:
section: utils
contents:
- src: ./LICENSE
dst: /usr/share/doc/nfpm/copyright
dst: /usr/share/doc/k8sgpt/copyright
file_info:
mode: 0644
@@ -51,26 +54,44 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
- goos: windows
format: zip
brews:
- name: k8sgpt
homepage: https://k8sgpt.ai
tap:
repository:
owner: k8sgpt-ai
name: homebrew-k8sgpt
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
skip: true
announce:
slack:
# Whether its enabled or not.
#
# Templates: allowed (since v2.6).
enabled: true
# Message template to use while publishing.
#
# Default: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'.
# Templates: allowed.
message_template: "{{ .ProjectName }} release {{.Tag}} is out!"
# The name of the channel that the user selected as a destination for webhook messages.
channel: "#general"
# Set your Webhook's user name.
username: "K8sGPT"
# Emoji to use as the icon for this message. Overrides icon_url.
icon_emoji: ""
# URL to an image to use as the icon for this message.
icon_url: ""
# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

110
.krew.yaml Normal file
View File

@@ -0,0 +1,110 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: gpt
spec:
version: {{ .TagName }}
homepage: https://github.com/k8sgpt-ai/k8sgpt
shortDescription: "Giving Kubernetes Superpowers to everyone"
description: |
A tool for scanning your Kubernetes clusters, diagnosing, and triaging issues in simple English.
platforms:
##########
# Darwin #
##########
- selector:
matchLabels:
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Darwin_x86_64.tar.gz" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt
- selector:
matchLabels:
os: darwin
arch: arm64
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Darwin_arm64.tar.gz" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt
#########
# Linux #
#########
- selector:
matchLabels:
os: linux
arch: amd64
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Linux_x86_64.tar.gz" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt
- selector:
matchLabels:
os: linux
arch: arm64
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Linux_arm64.tar.gz" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt
- selector:
matchLabels:
os: linux
arch: "386"
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Linux_i386.tar.gz" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt
###########
# Windows #
###########
- selector:
matchLabels:
os: windows
arch: amd64
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Windows_x86_64.zip" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt
- selector:
matchLabels:
os: windows
arch: arm64
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Windows_arm64.zip" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt
- selector:
matchLabels:
os: windows
arch: "386"
{{addURIAndSha "https://github.com/k8sgpt-ai/k8sgpt/releases/download/{{ .TagName }}/k8sgpt_Windows_i386.zip" .TagName | indent 6 }}
files:
- from: "k8sgpt"
to: "kubectl-gpt"
- from: "LICENSE"
to: "."
bin: kubectl-gpt

View File

@@ -1 +1 @@
{".":"0.3.7"}
{".":"0.4.30"}

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
We're happy that you want to contribute to this project. Please read the sections to make the process as smooth as possible.
## Requirements
- Golang `1.20`
- Golang `1.24+`
- An OpenAI API key
* OpenAI API keys can be obtained from [OpenAI](https://platform.openai.com/account/api-keys)
* You can set the API key for k8sgpt using `./k8sgpt auth key`
@@ -30,7 +30,7 @@ We're happy that you want to contribute to this project. Please read the section
- Assign yourself to the issue, if you are working on it (if you are not a member of the organization, please leave a comment on the issue)
- Make your changes
- Keep pull requests small and focused, if you have multiple changes, please open multiple PRs
- Create a pull request back to the upstream repository and follow follow the [pull request template](.github/pull_request_template.md) guidelines.
- Create a pull request back to the upstream repository and follow the [pull request template](.github/pull_request_template.md) guidelines.
- Wait for a review and address any comments
**Opening PRs**

482
MCP.md Normal file
View File

@@ -0,0 +1,482 @@
# K8sGPT Model Context Protocol (MCP) Server
K8sGPT provides a Model Context Protocol (MCP) server that exposes Kubernetes cluster operations as standardized tools, resources, and prompts for AI assistants like Claude, ChatGPT, and other MCP-compatible clients.
## Table of Contents
- [What is MCP?](#what-is-mcp)
- [Quick Start](#quick-start)
- [Server Modes](#server-modes)
- [Available Tools](#available-tools)
- [Available Resources](#available-resources)
- [Available Prompts](#available-prompts)
- [Usage Examples](#usage-examples)
- [Integration with AI Assistants](#integration-with-ai-assistants)
- [HTTP API Reference](#http-api-reference)
## What is MCP?
The Model Context Protocol (MCP) is an open standard that enables AI assistants to securely connect to external data sources and tools. K8sGPT's MCP server exposes Kubernetes operations through this standardized interface, allowing AI assistants to:
- Analyze cluster health and issues
- Query Kubernetes resources
- Access pod logs and events
- Get troubleshooting guidance
- Manage analyzer filters
## Quick Start
### Start the MCP Server
**Stdio mode (for local AI assistants):**
```bash
k8sgpt serve --mcp
```
**HTTP mode (for network access):**
```bash
k8sgpt serve --mcp --mcp-http --mcp-port 8089
```
### Test with curl
```bash
curl -X POST http://localhost:8089/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'
```
## Server Modes
### Stdio Mode (Default)
Used by local AI assistants like Claude Desktop:
```bash
k8sgpt serve --mcp
```
Configure in your MCP client (e.g., Claude Desktop's `claude_desktop_config.json`):
```json
{
"mcpServers": {
"k8sgpt": {
"command": "k8sgpt",
"args": ["serve", "--mcp"]
}
}
}
```
### HTTP Mode
Used for network access and webhooks:
```bash
k8sgpt serve --mcp --mcp-http --mcp-port 8089
```
The server runs in stateless mode, so no session management is required. Each request is independent.
## Available Tools
The MCP server exposes 12 tools for Kubernetes operations:
### Cluster Analysis
**analyze**
- Analyze Kubernetes resources for issues and problems
- Parameters:
- `namespace` (optional): Namespace to analyze
- `explain` (optional): Get AI explanations for issues
- `filters` (optional): Comma-separated list of analyzers to use
**cluster-info**
- Get Kubernetes cluster information and version
### Resource Management
**list-resources**
- List Kubernetes resources of a specific type
- Parameters:
- `resourceType` (required): Type of resource (pods, deployments, services, nodes, jobs, cronjobs, statefulsets, daemonsets, replicasets, configmaps, secrets, ingresses, pvcs, pvs)
- `namespace` (optional): Namespace to query
- `labelSelector` (optional): Label selector for filtering
**get-resource**
- Get detailed information about a specific Kubernetes resource
- Parameters:
- `resourceType` (required): Type of resource
- `name` (required): Resource name
- `namespace` (optional): Namespace
**list-namespaces**
- List all namespaces in the cluster
### Debugging and Troubleshooting
**get-logs**
- Get logs from a pod container
- Parameters:
- `podName` (required): Name of the pod
- `namespace` (optional): Namespace
- `container` (optional): Container name
- `tail` (optional): Number of lines to show
- `previous` (optional): Show logs from previous container instance
- `sinceSeconds` (optional): Show logs from last N seconds
**list-events**
- List Kubernetes events for debugging
- Parameters:
- `namespace` (optional): Namespace to query
- `involvedObjectName` (optional): Filter by object name
- `involvedObjectKind` (optional): Filter by object kind
### Analyzer Management
**list-filters**
- List all available and active analyzers/filters
**add-filters**
- Add filters to enable specific analyzers
- Parameters:
- `filters` (required): Comma-separated list of analyzer names
**remove-filters**
- Remove filters to disable specific analyzers
- Parameters:
- `filters` (required): Comma-separated list of analyzer names
### Integrations
**list-integrations**
- List available integrations (Prometheus, AWS, Keda, Kyverno, etc.)
### Configuration
**config**
- Configure K8sGPT settings including custom analyzers and cache
## Available Resources
Resources provide read-only access to cluster information:
**cluster-info**
- URI: `cluster-info`
- Get information about the Kubernetes cluster
**namespaces**
- URI: `namespaces`
- List all namespaces in the cluster
**active-filters**
- URI: `active-filters`
- Get currently active analyzers/filters
## Available Prompts
Prompts provide guided troubleshooting workflows:
**troubleshoot-pod**
- Interactive pod debugging workflow
- Arguments:
- `podName` (required): Name of the pod to troubleshoot
- `namespace` (required): Namespace of the pod
**troubleshoot-deployment**
- Interactive deployment debugging workflow
- Arguments:
- `deploymentName` (required): Name of the deployment
- `namespace` (required): Namespace of the deployment
**troubleshoot-cluster**
- General cluster troubleshooting workflow
## Usage Examples
### Example 1: Analyze a Namespace
```bash
curl -X POST http://localhost:8089/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "analyze",
"arguments": {
"namespace": "production",
"explain": "true"
}
}
}'
```
### Example 2: List Pods
```bash
curl -X POST http://localhost:8089/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "list-resources",
"arguments": {
"resourceType": "pods",
"namespace": "default"
}
}
}'
```
### Example 3: Get Pod Logs
```bash
curl -X POST http://localhost:8089/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get-logs",
"arguments": {
"podName": "nginx-abc123",
"namespace": "default",
"tail": "100"
}
}
}'
```
### Example 4: Access a Resource
```bash
curl -X POST http://localhost:8089/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 4,
"method": "resources/read",
"params": {
"uri": "namespaces"
}
}'
```
### Example 5: Get a Troubleshooting Prompt
```bash
curl -X POST http://localhost:8089/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 5,
"method": "prompts/get",
"params": {
"name": "troubleshoot-pod",
"arguments": {
"podName": "nginx-abc123",
"namespace": "default"
}
}
}'
```
## Integration with AI Assistants
### Claude Desktop
Add to `claude_desktop_config.json`:
```json
{
"mcpServers": {
"k8sgpt": {
"command": "k8sgpt",
"args": ["serve", "--mcp"]
}
}
}
```
Restart Claude Desktop and you'll see k8sgpt tools available in the tool selector.
### Custom MCP Clients
Any MCP-compatible client can connect to the k8sgpt server. For HTTP-based clients:
1. Start the server: `k8sgpt serve --mcp --mcp-http --mcp-port 8089`
2. Connect to: `http://localhost:8089/mcp`
3. Use standard MCP protocol methods: `tools/list`, `tools/call`, `resources/read`, `prompts/get`
## HTTP API Reference
### Endpoint
```
POST http://localhost:8089/mcp
Content-Type: application/json
```
### Request Format
All requests follow the JSON-RPC 2.0 format:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "method_name",
"params": {
...
}
}
```
### Discovery Methods
**List Tools**
```json
{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}
```
**List Resources**
```json
{"jsonrpc": "2.0", "id": 2, "method": "resources/list"}
```
**List Prompts**
```json
{"jsonrpc": "2.0", "id": 3, "method": "prompts/list"}
```
### Tool Invocation
```json
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "tool_name",
"arguments": {
"arg1": "value1",
"arg2": "value2"
}
}
}
```
### Resource Access
```json
{
"jsonrpc": "2.0",
"id": 5,
"method": "resources/read",
"params": {
"uri": "resource_uri"
}
}
```
### Prompt Access
```json
{
"jsonrpc": "2.0",
"id": 6,
"method": "prompts/get",
"params": {
"name": "prompt_name",
"arguments": {
"arg1": "value1"
}
}
}
```
### Response Format
Successful responses:
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
...
}
}
```
Error responses:
```json
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32600,
"message": "Error description"
}
}
```
## Advanced Configuration
### Custom Port
```bash
k8sgpt serve --mcp --mcp-http --mcp-port 9000
```
### With Specific Backend
```bash
k8sgpt serve --mcp --backend openai
```
### With Kubeconfig
```bash
k8sgpt serve --mcp --kubeconfig ~/.kube/config
```
## Troubleshooting
### Connection Issues
Verify the server is running:
```bash
curl http://localhost:8089/mcp
```
### Permission Issues
Ensure your kubeconfig has appropriate cluster access:
```bash
kubectl cluster-info
```
### Tool Errors
List available tools to verify names:
```bash
curl -X POST http://localhost:8089/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'
```
## Learn More
- [MCP Specification](https://modelcontextprotocol.io/)
- [K8sGPT Documentation](https://docs.k8sgpt.ai/)
- [MCP Go Library](https://github.com/mark3labs/mcp-go)

View File

@@ -85,6 +85,12 @@ docker-build:
@echo "===========> Building docker image"
docker buildx build --build-arg=VERSION="$$(git describe --tags --abbrev=0)" --build-arg=COMMIT="$$(git rev-parse --short HEAD)" --build-arg DATE="$$(date +%FT%TZ)" --platform="linux/amd64,linux/arm64" -t ${IMG} -f container/Dockerfile . --push
## docker-build-local: Build docker image for local testing
.PHONY: docker-build-local
docker-build-local:
@echo "===========> Building docker image for local testing"
docker build --build-arg=VERSION="$$(git describe --tags --abbrev=0)" --build-arg=COMMIT="$$(git rev-parse --short HEAD)" --build-arg DATE="$$(date +%FT%TZ)" -t k8sgpt:local -f container/Dockerfile .
## fmt: Run go fmt against code.
.PHONY: fmt
fmt:
@@ -98,7 +104,7 @@ vet:
## lint: Run go lint against code.
.PHONY: lint
lint:
@golangci-lint run -v ./...
@golangci-lint run -v --timeout=5m ./...
## style: Code style -> fmt,vet,lint
.PHONY: style

548
README.md
View File

@@ -9,21 +9,52 @@
![GitHub release (latest by date)](https://img.shields.io/github/v/release/k8sgpt-ai/k8sgpt)
[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7272/badge)](https://bestpractices.coreinfrastructure.org/projects/7272)
[![Link to documentation](https://img.shields.io/static/v1?label=%F0%9F%93%96&message=Documentation&color=blue)](https://docs.k8sgpt.ai/)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt?ref=badge_shield)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Go version](https://img.shields.io/github/go-mod/go-version/k8sgpt-ai/k8sgpt.svg)](https://github.com/k8sgpt-ai/k8sgpt)
[![codecov](https://codecov.io/github/k8sgpt-ai/k8sgpt/graph/badge.svg?token=ZLR7NG8URE)](https://codecov.io/github/k8sgpt-ai/k8sgpt)
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/k8sgpt-ai/k8sgpt/main)
`k8sgpt` is a tool for scanning your Kubernetes clusters, diagnosing, and triaging issues in simple English.
It has SRE experience codified into its analyzers and helps to pull out the most relevant information to enrich it with AI.
<a href="https://www.producthunt.com/posts/k8sgpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-k8sgpt" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=389489&theme=light" alt="K8sGPT - K8sGPT&#0032;gives&#0032;Kubernetes&#0032;Superpowers&#0032;to&#0032;everyone | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
_Out of the box integration with OpenAI, Azure, Cohere, Amazon Bedrock, Google Gemini and local models._
<img src="images/demo4.gif" width=650px; />
> **Sister project:** Check out [sympozium](https://github.com/AlexsJones/sympozium/) for managing agents in Kubernetes.
<a href="https://www.producthunt.com/posts/k8sgpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-k8sgpt" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=389489&theme=light" alt="K8sGPT - K8sGPT&#0032;gives&#0032;Kubernetes&#0032;Superpowers&#0032;to&#0032;everyone | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a> <a href="https://hellogithub.com/repository/9dfe44c18dfb4d6fa0181baf8b2cf2e1" target="_blank"><img src="https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=9dfe44c18dfb4d6fa0181baf8b2cf2e1&claim_uid=gqG4wmzkMrP0eFy" alt="FeaturedHelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
<img src="images/demo4.gif" width="650px">
# Table of Contents
- [Overview](#k8sgpt)
- [Installation](#cli-installation)
- [Quick Start](#quick-start)
- [Analyzers](#analyzers)
- [Examples](#examples)
- [LLM AI Backends](#llm-ai-backends)
- [Key Features](#key-features)
- [Model Context Protocol (MCP)](#model-context-protocol-mcp)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Community](#community)
- [License](#license)
# CLI Installation
### Linux/Mac via brew
```sh
brew install k8sgpt
```
or
```sh
brew tap k8sgpt-ai/k8sgpt
brew install k8sgpt
```
@@ -31,20 +62,20 @@ brew install k8sgpt
<details>
<summary>RPM-based installation (RedHat/CentOS/Fedora)</summary>
**32 bit:**
**32 bit:**
<!---x-release-please-start-version-->
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.3.7/k8sgpt_386.rpm
sudo rpm -ivh k8sgpt_386.rpm
sudo rpm -ivh https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.4.30/k8sgpt_386.rpm
```
<!---x-release-please-end-->
**64 bit:**
**64 bit:**
<!---x-release-please-start-version-->
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.3.7/k8sgpt_amd64.rpm
sudo rpm -ivh -i k8sgpt_amd64.rpm
sudo rpm -ivh https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.4.30/k8sgpt_amd64.rpm
```
<!---x-release-please-end-->
</details>
@@ -52,20 +83,26 @@ brew install k8sgpt
<details>
<summary>DEB-based installation (Ubuntu/Debian)</summary>
**32 bit:**
<!---x-release-please-start-version-->
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.3.7/k8sgpt_386.deb
sudo dpkg -i k8sgpt_386.deb
```
<!---x-release-please-end-->
**64 bit:**
**32 bit:**
<!---x-release-please-start-version-->
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.3.7/k8sgpt_amd64.deb
sudo dpkg -i k8sgpt_amd64.deb
```
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.4.30/k8sgpt_386.deb
sudo dpkg -i k8sgpt_386.deb
```
<!---x-release-please-end-->
**64 bit:**
<!---x-release-please-start-version-->
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.4.30/k8sgpt_amd64.deb
sudo dpkg -i k8sgpt_amd64.deb
```
<!---x-release-please-end-->
</details>
@@ -73,44 +110,48 @@ brew install k8sgpt
<summary>APK-based installation (Alpine)</summary>
**32 bit:**
**32 bit:**
<!---x-release-please-start-version-->
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.3.7/k8sgpt_386.apk
apk add k8sgpt_386.apk
wget https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.4.30/k8sgpt_386.apk
apk add --allow-untrusted k8sgpt_386.apk
```
<!---x-release-please-end-->
**64 bit:**
**64 bit:**
<!---x-release-please-start-version-->
```
curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.3.7/k8sgpt_amd64.apk
apk add k8sgpt_amd64.apk
wget https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.4.30/k8sgpt_amd64.apk
apk add --allow-untrusted k8sgpt_amd64.apk
```
<!---x-release-please-end-->x
<!---x-release-please-end-->
</details>
<details>
<summary>Failing Installation on WSL or Linux (missing gcc)</summary>
When installing Homebrew on WSL or Linux, you may encounter the following error:
```
==> Installing k8sgpt from k8sgpt-ai/k8sgpt Error: The following formula cannot be installed from a bottle and must be
built from the source. k8sgpt Install Clang or run brew install gcc.
```
```
==> Installing k8sgpt from k8sgpt-ai/k8sgpt Error: The following formula cannot be installed from a bottle and must be
built from the source. k8sgpt Install Clang or run brew install gcc.
```
If you install gcc as suggested, the problem will persist. Therefore, you need to install the build-essential package.
```
sudo apt-get update
sudo apt-get install build-essential
```
</details>
```
sudo apt-get update
sudo apt-get install build-essential
```
</details>
### Windows
* Download the latest Windows binaries of **k8sgpt** from the [Release](https://github.com/k8sgpt-ai/k8sgpt/releases)
- Download the latest Windows binaries of **k8sgpt** from the [Release](https://github.com/k8sgpt-ai/k8sgpt/releases)
tab based on your system architecture.
* Extract the downloaded package to your desired location. Configure the system *path* variable with the binary location
- Extract the downloaded package to your desired location. Configure the system _PATH_ environment variable with the binary location
## Operator Installation
@@ -118,17 +159,86 @@ To install within a Kubernetes cluster please use our `k8sgpt-operator` with ins
_This mode of operation is ideal for continuous monitoring of your cluster and can integrate with your existing monitoring such as Prometheus and Alertmanager._
## Quick Start
* Currently the default AI provider is OpenAI, you will need to generate an API key from [OpenAI](https://openai.com)
* You can do this by running `k8sgpt generate` to open a browser link to generate it
* Run `k8sgpt auth add` to set it in k8sgpt.
* You can provide the password directly using the `--password` flag.
* Run `k8sgpt filters` to manage the active filters used by the analyzer. By default, all filters are executed during analysis.
* Run `k8sgpt analyze` to run a scan.
* And use `k8sgpt analyze --explain` to get a more detailed explanation of the issues.
* You also run `k8sgpt analyze --with-doc` (with or without the explain flag) to get the official documention from kubernetes.
- Currently, the default AI provider is OpenAI, you will need to generate an API key from [OpenAI](https://openai.com)
- You can do this by running `k8sgpt generate` to open a browser link to generate it
- Run `k8sgpt auth add` to set it in k8sgpt.
- You can provide the password directly using the `--password` flag.
- Run `k8sgpt filters` to manage the active filters used by the analyzer. By default, all filters are executed during analysis.
- Run `k8sgpt analyze` to run a scan.
- And use `k8sgpt analyze --explain` to get a more detailed explanation of the issues.
- You also run `k8sgpt analyze --with-doc` (with or without the explain flag) to get the official documentation from Kubernetes.
# Using with Claude Desktop
K8sGPT can be integrated with Claude Desktop to provide AI-powered Kubernetes cluster analysis. This integration requires K8sGPT v0.4.14 or later.
## Prerequisites
1. Install K8sGPT v0.4.14 or later:
```sh
brew install k8sgpt
```
2. Install Claude Desktop from the official website
3. Configure K8sGPT with your preferred AI backend:
```sh
k8sgpt auth
```
## Setup
1. Start the K8sGPT MCP server:
```sh
k8sgpt serve --mcp
```
2. In Claude Desktop:
- Open Settings
- Navigate to the Integrations section
- Add K8sGPT as a new integration
- The MCP server will be automatically detected
3. Configure Claude Desktop with the following JSON:
```json
{
"mcpServers": {
"k8sgpt": {
"command": "k8sgpt",
"args": [
"serve",
"--mcp"
]
}
}
}
```
## Usage
Once connected, you can use Claude Desktop to:
- Analyze your Kubernetes cluster
- Get detailed insights about cluster health
- Receive recommendations for fixing issues
- Query cluster information
Example commands in Claude Desktop:
- "Analyze my Kubernetes cluster"
- "What's the health status of my cluster?"
- "Show me any issues in the default namespace"
## Troubleshooting
If you encounter connection issues:
1. Ensure K8sGPT is running with the MCP server enabled
2. Verify your Kubernetes cluster is accessible
3. Check that your AI backend is properly configured
4. Restart both K8sGPT and Claude Desktop
For more information, visit our [documentation](https://docs.k8sgpt.ai).
## Analyzers
@@ -147,14 +257,32 @@ you will be able to write your own analyzers.
- [x] ingressAnalyzer
- [x] statefulSetAnalyzer
- [x] deploymentAnalyzer
- [x] jobAnalyzer
- [x] cronJobAnalyzer
- [x] nodeAnalyzer
- [x] mutatingWebhookAnalyzer
- [x] validatingWebhookAnalyzer
- [x] configMapAnalyzer
#### Optional
- [x] hpaAnalyzer
- [x] pdbAnalyzer
- [x] networkPolicyAnalyzer
- [x] gatewayClass
- [x] gateway
- [x] httproute
- [x] logAnalyzer
- [x] storageAnalyzer
- [x] securityAnalyzer
- [x] CatalogSource
- [x] ClusterCatalog
- [x] ClusterExtension
- [x] ClusterService
- [x] ClusterServiceVersion
- [x] OperatorGroup
- [x] InstallPlan
- [x] Subscription
## Examples
@@ -174,6 +302,7 @@ k8sgpt analyze --explain --filter=Service
```
_Filter by namespace_
```
k8sgpt analyze --explain --filter=Pod --namespace=default
```
@@ -242,7 +371,7 @@ k8sgpt auth update $MY_BACKEND1,$MY_BACKEND2..
_Remove configured backends_
```
k8sgpt auth remove $MY_BACKEND1,$MY_BACKEND2..
k8sgpt auth remove -b $MY_BACKEND1,$MY_BACKEND2..
```
_List integrations_
@@ -275,87 +404,94 @@ _Serve mode_
k8sgpt serve
```
_Serve mode with MCP (Model Context Protocol)_
```
# Enable MCP server on default port 8089
k8sgpt serve --mcp --mcp-http
# Enable MCP server on custom port
k8sgpt serve --mcp --mcp-http --mcp-port 8089
# Full serve mode with MCP
k8sgpt serve --mcp --mcp-http --port 8080 --metrics-port 8081 --mcp-port 8089
```
The MCP server enables integration with tools like Claude Desktop and other MCP-compatible clients. It runs on port 8089 by default and provides:
- Kubernetes cluster analysis via MCP protocol
- Resource information and health status
- AI-powered issue explanations and recommendations
For Helm chart deployment with MCP support, see the `charts/k8sgpt/values-mcp-example.yaml` file.
_Analysis with serve mode_
```
curl -X GET "http://localhost:8080/analyze?namespace=k8sgpt&explain=false"
```
</details>
## Key Features
<details>
<summary> LocalAI provider </summary>
To run local models, it is possible to use OpenAI compatible APIs, for instance [LocalAI](https://github.com/go-skynet/LocalAI) which uses [llama.cpp](https://github.com/ggerganov/llama.cpp) and [ggml](https://github.com/ggerganov/ggml) to run inference on consumer-grade hardware. Models supported by LocalAI for instance are Vicuna, Alpaca, LLaMA, Cerebras, GPT4ALL, GPT4ALL-J and koala.
To run local inference, you need to download the models first, for instance you can find `ggml` compatible models in [huggingface.com](https://huggingface.co/models?search=ggml) (for example vicuna, alpaca and koala).
### Start the API server
To start the API server, follow the instruction in [LocalAI](https://github.com/go-skynet/LocalAI#example-use-gpt4all-j-model).
### Run k8sgpt
To run k8sgpt, run `k8sgpt auth add` with the `localai` backend:
```
k8sgpt auth add --backend localai --model <model_name> --baseurl http://localhost:8080/v1
grpcurl -plaintext -d '{"namespace": "k8sgpt", "explain" : "true"}' localhost:8080 schema.v1.ServerAnalyzerService/Analyze
{
"status": "OK"
}
```
Now you can analyze with the `localai` backend:
_Analysis with custom headers_
```
k8sgpt analyze --explain --backend localai
k8sgpt analyze --explain --custom-headers CustomHeaderKey:CustomHeaderValue
```
_Print analysis stats_
```
k8sgpt analyze -s
The stats mode allows for debugging and understanding the time taken by an analysis by displaying the statistics of each analyzer.
- Analyzer Ingress took 47.125583ms
- Analyzer PersistentVolumeClaim took 53.009167ms
- Analyzer CronJob took 57.517792ms
- Analyzer Deployment took 156.6205ms
- Analyzer Node took 160.109833ms
- Analyzer ReplicaSet took 245.938333ms
- Analyzer StatefulSet took 448.0455ms
- Analyzer Pod took 5.662594708s
- Analyzer Service took 38.583359166s
```
_Diagnostic information_
To collect diagnostic information use the following command to create a `dump_<timestamp>_json` in your local directory.
```
k8sgpt dump
```
</details>
<details>
<summary> AzureOpenAI provider </summary>
## LLM AI Backends
<em>Prerequisites:</em> an Azure OpenAI deployment is needed, please visit MS official [documentation](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource) to create your own.
K8sGPT uses the chosen LLM, generative AI provider when you want to explain the analysis results using --explain flag e.g. `k8sgpt analyze --explain`. You can use `--backend` flag to specify a configured provider (it's `openai` by default).
To authenticate with k8sgpt, you will need the Azure OpenAI endpoint of your tenant `"https://your Azure OpenAI Endpoint"`, the api key to access your deployment, the deployment name of your model and the model name itself.
To run k8sgpt, run `k8sgpt auth` with the `azureopenai` backend:
```
k8sgpt auth add --backend azureopenai --baseurl https://<your Azure OpenAI endpoint> --engine <deployment_name> --model <model_name>
```
Lastly, enter your Azure API key, after the prompt.
Now you are ready to analyze with the azure openai backend:
```
k8sgpt analyze --explain --backend azureopenai
```
</details>
<details>
<summary>Setting a new default AI provider</summary>
There may be scenarios where you wish to have K8sGPT plugged into several default AI providers. In this case you may wish to use one as a new default, other than OpenAI which is the project default.
_To view available providers_
You can list available providers using `k8sgpt auth list`:
```
k8sgpt auth list
Default:
> openai
Active:
> openai
> azureopenai
Unused:
> openai
> localai
> ollama
> azureopenai
> cohere
> amazonbedrock
> amazonsagemaker
> google
> huggingface
> noopai
> googlevertexai
> watsonxai
> customrest
> ibmwatsonxai
```
For detailed documentation on how to configure and use each provider see [here](https://docs.k8sgpt.ai/reference/providers/backend/).
_To set a new default provider_
@@ -364,90 +500,250 @@ k8sgpt auth default -p azureopenai
Default provider set to azureopenai
```
_Using Amazon Bedrock with inference profiles_
</details>
_System Inference Profile_
```
k8sgpt auth add --backend amazonbedrock --providerRegion us-east-1 --model arn:aws:bedrock:us-east-1:123456789012:inference-profile/my-inference-profile
```
_Application Inference Profile_
```
k8sgpt auth add --backend amazonbedrock --providerRegion us-east-1 --model arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/2uzp4s0w39t6
```
## Key Features
<details>
With this option, the data is anonymized before being sent to the AI Backend. During the analysis execution, `k8sgpt` retrieves sensitive data (Kubernetes object names, labels, etc.). This data is masked when sent to the AI backend and replaced by a key that can be used to de-anonymize the data when the solution is returned to the user.
<summary> Anonymization </summary>
1. Error reported during analysis:
```bash
Error: HorizontalPodAutoscaler uses StatefulSet/fake-deployment as ScaleTargetRef which does not exist.
```
2. Payload sent to the AI backend:
```bash
Error: HorizontalPodAutoscaler uses StatefulSet/tGLcCRcHa1Ce5Rs as ScaleTargetRef which does not exist.
```
3. Payload returned by the AI:
```bash
The Kubernetes system is trying to scale a StatefulSet named tGLcCRcHa1Ce5Rs using the HorizontalPodAutoscaler, but it cannot find the StatefulSet. The solution is to verify that the StatefulSet name is spelled correctly and exists in the same namespace as the HorizontalPodAutoscaler.
```
4. Payload returned to the user:
```bash
The Kubernetes system is trying to scale a StatefulSet named fake-deployment using the HorizontalPodAutoscaler, but it cannot find the StatefulSet. The solution is to verify that the StatefulSet name is spelled correctly and exists in the same namespace as the HorizontalPodAutoscaler.
```
**Anonymization does not currently apply to events.**
### Further Details
Note: **Anonymization does not currently apply to events.**
_In a few analysers like Pod, we feed to the AI backend the event messages which are not known beforehand thus we are not masking them for the **time being**._
- The following is the list of analysers in which data is **being masked**:-
- Statefulset
- Service
- PodDisruptionBudget
- Node
- NetworkPolicy
- Ingress
- HPA
- Deployment
- Cronjob
- The following is the list of analysers in which data is **not being masked**:-
- ReplicaSet
- PersistentVolumeClaim
- Pod
- Log
- **_\*Events_**
**\*Note**:
- k8gpt will not mask the above analysers because they do not send any identifying information except **Events** analyser.
- Masking for **Events** analyzer is scheduled in the near future as seen in this [issue](https://github.com/k8sgpt-ai/k8sgpt/issues/560). _Further research has to be made to understand the patterns and be able to mask the sensitive parts of an event like pod name, namespace etc._
- The following is the list of fields which are not **being masked**:-
- Describe
- ObjectStatus
- Replicas
- ContainerStatus
- **_\*Event Message_**
- ReplicaStatus
- Count (Pod)
**\*Note**:
- It is quite possible the payload of the event message might have something like "super-secret-project-pod-X crashed" which we don't currently redact _(scheduled in the near future as seen in this [issue](https://github.com/k8sgpt-ai/k8sgpt/issues/560))_.
### Proceed with care
- The K8gpt team recommends using an entirely different backend **(a local model) in critical production environments**. By using a local model, you can rest assured that everything stays within your DMZ, and nothing is leaked.
- If there is any uncertainty about the possibility of sending data to a public LLM (open AI, Azure AI) and it poses a risk to business-critical operations, then, in such cases, the use of public LLM should be avoided based on personal assessment and the jurisdiction of risks involved.
</details>
<details>
<summary> Configuration management</summary>
`k8sgpt` stores config data in the `$XDG_CONFIG_HOME/k8sgpt/k8sgpt.yaml` file. The data is stored in plain text, including your OpenAI key.
Config file locations:
| OS | Path |
| OS | Path |
| ------- | ------------------------------------------------ |
| MacOS | ~/Library/Application Support/k8sgpt/k8sgpt.yaml |
| Linux | ~/.config/k8sgpt/k8sgpt.yaml |
| Windows | %LOCALAPPDATA%/k8sgpt/k8sgpt.yaml |
| MacOS | ~/Library/Application Support/k8sgpt/k8sgpt.yaml |
| Linux | ~/.config/k8sgpt/k8sgpt.yaml |
| Windows | %LOCALAPPDATA%/k8sgpt/k8sgpt.yaml |
</details>
<details>
There may be scenarios where caching remotely is prefered.
In these scenarios K8sGPT supports AWS S3 Integration.
There may be scenarios where caching remotely is preferred.
In these scenarios K8sGPT supports AWS S3 or Azure Blob storage Integration.
<summary> Remote caching </summary>
_As a prerequisite `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are required as environmental variables._
<em>Note: You can configure and use only one remote cache at a time</em>
_Adding a remote cache_
Note: this will create the bucket if it does not exist
```
k8sgpt cache add --region <aws region> --bucket <name>
```
- AWS S3
- _As a prerequisite `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are required as environmental variables._
- Configuration, `k8sgpt cache add s3 --region <aws region> --bucket <name>`
- Minio Configuration with HTTP endpoint ` k8sgpt cache add s3 --bucket <name> --endpoint <http://localhost:9000>`
- Minio Configuration with HTTPs endpoint, skipping TLS verification ` k8sgpt cache add s3 --bucket <name> --endpoint <https://localhost:9000> --insecure`
- K8sGPT will create the bucket if it does not exist
- Azure Storage
- We support a number of [techniques](https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication?tabs=bash#2-authenticate-with-azure) to authenticate against Azure
- Configuration, `k8sgpt cache add azure --storageacc <storage account name> --container <container name>`
- K8sGPT assumes that the storage account already exist and it will create the container if it does not exist
- It is the **user** responsibility have to grant specific permissions to their identity in order to be able to upload blob files and create SA containers (e.g Storage Blob Data Contributor)
- Google Cloud Storage
- _As a prerequisite `GOOGLE_APPLICATION_CREDENTIALS` are required as environmental variables._
- Configuration, ` k8sgpt cache add gcs --region <gcp region> --bucket <name> --projectid <project id>`
- K8sGPT will create the bucket if it does not exist
_Listing cache items_
```
k8sgpt cache list
```
_Purging an object from the cache_
Note: purging an object using this command will delete upstream files, so it requires appropriate permissions.
```
k8sgpt cache purge $OBJECT_NAME
```
_Removing the remote cache_
Note: this will not delete the bucket
Note: this will not delete the upstream S3 bucket or Azure storage container
```
k8sgpt cache remove --bucket <name>
k8sgpt cache remove
```
</details>
<details>
<summary> Custom Analyzers</summary>
There may be scenarios where you wish to write your own analyzer in a language of your choice.
K8sGPT now supports the ability to do so by abiding by the [schema](https://github.com/k8sgpt-ai/schemas/blob/main/protobuf/schema/v1/custom_analyzer.proto) and serving the analyzer for consumption.
To do so, define the analyzer within the K8sGPT configuration and it will add it into the scanning process.
In addition to this you will need to enable the following flag on analysis:
```
k8sgpt analyze --custom-analysis
```
Here is an example local host analyzer in [Rust](https://github.com/k8sgpt-ai/host-analyzer)
When this is run on `localhost:8080` the K8sGPT config can pick it up with the following additions:
```
custom_analyzers:
- name: host-analyzer
connection:
url: localhost
port: 8080
```
This now gives the ability to pass through hostOS information ( from this analyzer example ) to K8sGPT to use as context with normal analysis.
_See the docs on how to write a custom analyzer_
_Listing custom analyzers configured_
```
k8sgpt custom-analyzer list
```
_Adding custom analyzer without install_
```
k8sgpt custom-analyzer add --name my-custom-analyzer --port 8085
```
_Removing custom analyzer_
```
k8sgpt custom-analyzer remove --names "my-custom-analyzer,my-custom-analyzer-2"
```
</details>
## Model Context Protocol (MCP)
K8sGPT provides a Model Context Protocol server that exposes Kubernetes operations as standardized tools for AI assistants like Claude, ChatGPT, and other MCP-compatible clients.
**Start the MCP server:**
Stdio mode (for local AI assistants):
```bash
k8sgpt serve --mcp
```
HTTP mode (for network access):
```bash
k8sgpt serve --mcp --mcp-http --mcp-port 8089
```
**Features:**
- 12 tools for cluster analysis, resource management, and debugging
- 3 resources for cluster information access
- 3 interactive troubleshooting prompts
- Stateless HTTP mode for one-off invocations
- Full integration with Claude Desktop and other MCP clients
**Learn more:** See [MCP.md](MCP.md) for complete documentation, usage examples, and integration guides.
## Documentation
Find our official documentation available [here](https://docs.k8sgpt.ai)
## Contributing
Please read our [contributing guide](./CONTRIBUTING.md).
## Community
Find us on [Slack](https://join.slack.com/t/k8sgpt/shared_invite/zt-1rwe5fpzq-VNtJK8DmYbbm~iWL1H34nw)
Find us on [Slack](https://join.slack.com/t/k8sgpt/shared_invite/zt-332vhyaxv-bfjJwHZLXWVCB3QaXafEYQ)
<a href="https://github.com/k8sgpt-ai/k8sgpt/graphs/contributors">
<img src="https://contrib.rocks/image?repo=k8sgpt-ai/k8sgpt" />
</a>
## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt?ref=badge_large)

View File

@@ -8,4 +8,4 @@ For example if there is a vulnerability in release `0.1.0` we will fix that rele
## Reporting a Vulnerability
If you are aware of a vulnverability please feel free to disclose it responsibly to contact@k8sgpt.ai or to one of our maintainers in our Slack community.
If you are aware of a vulnerability please feel free to disclose it responsibly to contact@k8sgpt.ai or to one of our maintainers in our Slack community.

83
SUPPORTED_MODELS.md Normal file
View File

@@ -0,0 +1,83 @@
# Supported AI Providers and Models in K8sGPT
K8sGPT supports a variety of AI/LLM providers (backends). Some providers have a fixed set of supported models, while others allow you to specify any model supported by the provider.
---
## Providers and Supported Models
### OpenAI
- **Model:** User-configurable (any model supported by OpenAI, e.g., `gpt-3.5-turbo`, `gpt-4`, etc.)
### Azure OpenAI
- **Model:** User-configurable (any model deployed in your Azure OpenAI resource)
### LocalAI
- **Model:** User-configurable (default: `llama3`)
### Ollama
- **Model:** User-configurable (default: `llama3`, others can be specified)
### NoOpAI
- **Model:** N/A (no real model, used for testing)
### Cohere
- **Model:** User-configurable (any model supported by Cohere)
### Amazon Bedrock
- **Supported Models:**
- anthropic.claude-sonnet-4-20250514-v1:0
- us.anthropic.claude-sonnet-4-20250514-v1:0
- eu.anthropic.claude-sonnet-4-20250514-v1:0
- apac.anthropic.claude-sonnet-4-20250514-v1:0
- us.anthropic.claude-3-7-sonnet-20250219-v1:0
- eu.anthropic.claude-3-7-sonnet-20250219-v1:0
- apac.anthropic.claude-3-7-sonnet-20250219-v1:0
- anthropic.claude-3-5-sonnet-20240620-v1:0
- us.anthropic.claude-3-5-sonnet-20241022-v2:0
- anthropic.claude-v2
- anthropic.claude-v1
- anthropic.claude-instant-v1
- ai21.j2-ultra-v1
- ai21.j2-jumbo-instruct
- amazon.titan-text-express-v1
- amazon.nova-pro-v1:0
- eu.amazon.nova-pro-v1:0
- us.amazon.nova-pro-v1:0
- amazon.nova-lite-v1:0
- eu.amazon.nova-lite-v1:0
- us.amazon.nova-lite-v1:0
- anthropic.claude-3-haiku-20240307-v1:0
> **Note:**
> If you use an AWS Bedrock inference profile ARN (e.g., `arn:aws:bedrock:us-east-1:<account>:application-inference-profile/<id>`) as the model, you must still provide a valid modelId (e.g., `anthropic.claude-3-sonnet-20240229-v1:0`). K8sGPT will automatically set the required `X-Amzn-Bedrock-Inference-Profile-ARN` header for you when making requests to Bedrock.
### Amazon SageMaker
- **Model:** User-configurable (any model deployed in your SageMaker endpoint)
### Google GenAI
- **Model:** User-configurable (any model supported by Google GenAI, e.g., `gemini-pro`)
### Huggingface
- **Model:** User-configurable (any model supported by Huggingface Inference API)
### Google VertexAI
- **Supported Models:**
- gemini-1.0-pro-001
### OCI GenAI
- **Model:** User-configurable (any model supported by OCI GenAI)
### Custom REST
- **Model:** User-configurable (any model your custom REST endpoint supports)
### IBM Watsonx
- **Supported Models:**
- ibm/granite-13b-chat-v2
### Groq
- **Model:** User-configurable (any model supported by Groq, e.g., `llama-3.3-70b-versatile`, `mixtral-8x7b-32768`)
---
For more details on configuring each provider and model, refer to the official K8sGPT documentation and the provider's own documentation.

View File

@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: v0.3.0 #x-release-please-version
appVersion: v0.4.23 #x-release-please-version
description: A Helm chart for K8SGPT
name: k8sgpt
type: application

View File

@@ -21,6 +21,10 @@ spec:
app.kubernetes.io/name: {{ include "k8sgpt.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- if .Values.deployment.securityContext }}
securityContext:
{{- toYaml .Values.deployment.securityContext | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "k8sgpt.fullname" . }}
containers:
- name: k8sgpt-container
@@ -28,7 +32,13 @@ spec:
image: {{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag | default .Chart.AppVersion }}
ports:
- containerPort: 8080
args: ["serve"]
{{- if .Values.deployment.mcp.enabled }}
- containerPort: {{ .Values.deployment.mcp.port | int }}
{{- end }}
args: ["serve"
{{- if .Values.deployment.mcp.enabled }}, "--mcp", "-v","--mcp-http", "--mcp-port", {{ .Values.deployment.mcp.port | quote }}
{{- end }}
]
{{- if .Values.deployment.resources }}
resources:
{{- toYaml .Values.deployment.resources | nindent 10 }}

View File

@@ -19,4 +19,9 @@ spec:
- name: metrics
port: 8081
targetPort: 8081
{{- if .Values.deployment.mcp.enabled }}
- name: mcp
port: {{ .Values.deployment.mcp.port | int }}
targetPort: {{ .Values.deployment.mcp.port | int }}
{{- end }}
type: {{ .Values.service.type }}

View File

@@ -0,0 +1,39 @@
# Example values file to enable MCP (Model Context Protocol) service
# Copy this file and modify as needed, then use: helm install -f values-mcp-example.yaml
deployment:
# Enable MCP server
mcp:
enabled: true
port: "8089" # Port for MCP server (default: 8089)
http: true # Enable HTTP mode for MCP server
# Other deployment settings remain the same
image:
repository: ghcr.io/k8sgpt-ai/k8sgpt
tag: "" # defaults to Chart.appVersion if unspecified
imagePullPolicy: Always
env:
model: "gpt-3.5-turbo"
backend: "openai"
resources:
limits:
cpu: "1"
memory: "512Mi"
requests:
cpu: "0.2"
memory: "156Mi"
# Service configuration
service:
type: ClusterIP
annotations: {}
# Secret configuration for AI backend
secret:
secretKey: "" # base64 encoded OpenAI token
# ServiceMonitor for Prometheus metrics
serviceMonitor:
enabled: false
additionalLabels: {}

View File

@@ -7,6 +7,11 @@ deployment:
env:
model: "gpt-3.5-turbo"
backend: "openai" # one of: [ openai | llama ]
# MCP (Model Context Protocol) server configuration
mcp:
enabled: false # Enable MCP server
port: "8089" # Port for MCP server
http: true # Enable HTTP mode for MCP server
resources:
limits:
cpu: "1"
@@ -14,7 +19,10 @@ deployment:
requests:
cpu: "0.2"
memory: "156Mi"
securityContext: {}
# Set securityContext.runAsUser/runAsGroup if necessary. Values below were taken from https://github.com/k8sgpt-ai/k8sgpt/blob/main/container/Dockerfile
# runAsUser: 65532
# runAsGroup: 65532
secret:
secretKey: "" # base64 encoded OpenAI token

View File

@@ -16,23 +16,32 @@ package analyze
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/ai/interactive"
"github.com/k8sgpt-ai/k8sgpt/pkg/analysis"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
explain bool
backend string
output string
filters []string
language string
nocache bool
namespace string
anonymize bool
maxConcurrency int
withDoc bool
explain bool
backend string
output string
filters []string
language string
nocache bool
namespace string
labelSelector string
anonymize bool
maxConcurrency int
withDoc bool
interactiveMode bool
customAnalysis bool
customHeaders []string
withStats bool
)
// AnalyzeCmd represents the problems command
@@ -43,37 +52,101 @@ var AnalyzeCmd = &cobra.Command{
Long: `This command will find problems within your Kubernetes cluster and
provide you with a list of issues that need to be resolved`,
Run: func(cmd *cobra.Command, args []string) {
// Create analysis configuration first.
config, err := analysis.NewAnalysis(
backend,
language,
filters,
namespace,
labelSelector,
nocache,
explain,
maxConcurrency,
withDoc,
interactiveMode,
customHeaders,
withStats,
)
// AnalysisResult configuration
config, err := analysis.NewAnalysis(backend,
language, filters, namespace, nocache, explain, maxConcurrency, withDoc)
verbose := viper.GetBool("verbose")
if verbose {
fmt.Println("Debug: Checking analysis configuration.")
}
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
if verbose {
fmt.Println("Debug: Analysis initialized.")
}
defer config.Close()
if customAnalysis {
config.RunCustomAnalysis()
if verbose {
fmt.Println("Debug: All custom analyzers completed.")
}
}
config.RunAnalysis()
if verbose {
fmt.Println("Debug: All core analyzers completed.")
}
if explain {
err := config.GetAIResults(output, anonymize)
if verbose {
fmt.Println("Debug: Checking AI results.")
}
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
}
// print results
output, err := config.PrintOutput(output)
output_data, err := config.PrintOutput(output)
if verbose {
fmt.Println("Debug: Checking output.")
}
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
fmt.Println(string(output))
if withStats {
statsData := config.PrintStats()
fmt.Println(string(statsData))
}
fmt.Println(string(output_data))
if interactiveMode && explain {
if output == "json" {
color.Yellow("Caution: interactive mode using --json enabled may use additional tokens.")
}
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
interactiveClient := interactive.NewInteractionRunner(config, output_data)
go interactiveClient.StartInteraction()
for {
select {
case res := <-sigs:
switch res {
default:
os.Exit(0)
}
case res := <-interactiveClient.State:
switch res {
case interactive.E_EXITED:
os.Exit(0)
}
}
}
}
},
}
func init() {
// namespace flag
AnalyzeCmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Namespace to analyze")
// no cache flag
@@ -85,7 +158,7 @@ func init() {
// explain flag
AnalyzeCmd.Flags().BoolVarP(&explain, "explain", "e", false, "Explain the problem to me")
// add flag for backend
AnalyzeCmd.Flags().StringVarP(&backend, "backend", "b", "openai", "Backend AI provider")
AnalyzeCmd.Flags().StringVarP(&backend, "backend", "b", "", "Backend AI provider")
// output as json
AnalyzeCmd.Flags().StringVarP(&output, "output", "o", "text", "Output format (text, json)")
// add language options for output
@@ -94,4 +167,14 @@ func init() {
AnalyzeCmd.Flags().IntVarP(&maxConcurrency, "max-concurrency", "m", 10, "Maximum number of concurrent requests to the Kubernetes API server")
// kubernetes doc flag
AnalyzeCmd.Flags().BoolVarP(&withDoc, "with-doc", "d", false, "Give me the official documentation of the involved field")
// interactive mode flag
AnalyzeCmd.Flags().BoolVarP(&interactiveMode, "interactive", "i", false, "Enable interactive mode that allows further conversation with LLM about the problem. Works only with --explain flag")
// custom analysis flag
AnalyzeCmd.Flags().BoolVarP(&customAnalysis, "custom-analysis", "z", false, "Enable custom analyzers")
// add custom headers flag
AnalyzeCmd.Flags().StringSliceVarP(&customHeaders, "custom-headers", "r", []string{}, "Custom Headers, <key>:<value> (e.g CustomHeaderKey:CustomHeaderValue AnotherHeader:AnotherValue)")
// label selector flag
AnalyzeCmd.Flags().StringVarP(&labelSelector, "selector", "L", "", "Label selector (label query) to filter on, supports '=', '==', and '!='. (e.g. -L key1=value1,key2=value2). Matching objects must satisfy all of the specified label constraints.")
// print stats
AnalyzeCmd.Flags().BoolVarP(&withStats, "with-stat", "s", false, "Print analysis stats. This option disables errors display.")
}

View File

@@ -26,19 +26,54 @@ import (
"golang.org/x/term"
)
const (
defaultBackend = "openai"
defaultModel = "gpt-4o"
)
var addCmd = &cobra.Command{
Use: "add",
Short: "Configure new provider",
Long: "The new command allows to configure a new backend AI provider",
Short: "Add new provider",
Long: "The add command allows to configure a new backend AI provider",
PreRun: func(cmd *cobra.Command, args []string) {
backend, _ := cmd.Flags().GetString("backend")
if strings.ToLower(backend) == "azureopenai" {
_ = cmd.MarkFlagRequired("engine")
_ = cmd.MarkFlagRequired("baseurl")
}
if strings.ToLower(backend) == "amazonsagemaker" {
_ = cmd.MarkFlagRequired("endpointname")
_ = cmd.MarkFlagRequired("providerRegion")
}
if strings.ToLower(backend) == "amazonbedrock" {
_ = cmd.MarkFlagRequired("providerRegion")
}
if strings.ToLower(backend) == "ibmwatsonxai" {
_ = cmd.MarkFlagRequired("providerId")
}
},
Run: func(cmd *cobra.Command, args []string) {
validBackend := func(validBackends []string, backend string) bool {
for _, b := range validBackends {
if b == backend {
return true
}
}
return false
}
// check if backend is not empty and a valid value
if backend == "" {
color.Yellow(fmt.Sprintf("Warning: backend input is empty, will use the default value: %s", defaultBackend))
backend = defaultBackend
} else {
if !validBackend(ai.Backends, backend) {
color.Red("Error: Backend AI accepted values are '%v'", strings.Join(ai.Backends, ", "))
os.Exit(1)
}
}
// get ai configuration
err := viper.UnmarshalKey("ai", &configAI)
if err != nil {
@@ -55,24 +90,27 @@ var addCmd = &cobra.Command{
}
}
validBackend := func(validBackends []string, backend string) bool {
for _, b := range validBackends {
if b == backend {
return true
}
}
return false
}
// check if backend is not empty and a valid value
if backend == "" || !validBackend(ai.Backends, backend) {
color.Red("Error: Backend AI cannot be empty and accepted values are '%v'", strings.Join(ai.Backends, ", "))
if providerIndex != -1 {
// provider with same name exists, update provider info
color.Yellow("Provider with same name already exists.")
os.Exit(1)
}
// check if model is not empty
if model == "" {
color.Red("Error: Model cannot be empty.")
model = defaultModel
color.Yellow(fmt.Sprintf("Warning: model input is empty, will use the default value: %s", defaultModel))
}
if temperature > 1.0 || temperature < 0.0 {
color.Red("Error: temperature ranges from 0 to 1.")
os.Exit(1)
}
if topP > 1.0 || topP < 0.0 {
color.Red("Error: topP ranges from 0 to 1.")
os.Exit(1)
}
if topK < 1 || topK > 100 {
color.Red("Error: topK ranges from 1 to 100.")
os.Exit(1)
}
@@ -89,11 +127,20 @@ var addCmd = &cobra.Command{
// create new provider object
newProvider := ai.AIProvider{
Name: backend,
Model: model,
Password: password,
BaseURL: baseURL,
Engine: engine,
Name: backend,
Model: model,
Password: password,
BaseURL: baseURL,
EndpointName: endpointName,
Engine: engine,
Temperature: temperature,
ProviderRegion: providerRegion,
ProviderId: providerId,
CompartmentId: compartmentId,
TopP: topP,
TopK: topK,
MaxTokens: maxTokens,
OrganizationId: organizationId,
}
if providerIndex == -1 {
@@ -105,22 +152,37 @@ var addCmd = &cobra.Command{
os.Exit(1)
}
color.Green("%s added to the AI backend provider list", backend)
} else {
// provider with same name exists, update provider info
color.Yellow("Provider with same name already exists.")
}
},
}
func init() {
// add flag for backend
addCmd.Flags().StringVarP(&backend, "backend", "b", "openai", "Backend AI provider")
addCmd.Flags().StringVarP(&backend, "backend", "b", defaultBackend, "Backend AI provider")
// add flag for model
addCmd.Flags().StringVarP(&model, "model", "m", "gpt-3.5-turbo", "Backend AI model")
addCmd.Flags().StringVarP(&model, "model", "m", defaultModel, "Backend AI model")
// add flag for password
addCmd.Flags().StringVarP(&password, "password", "p", "", "Backend AI password")
// add flag for url
addCmd.Flags().StringVarP(&baseURL, "baseurl", "u", "", "URL AI provider, (e.g `http://localhost:8080/v1`)")
// add flag for endpointName
addCmd.Flags().StringVarP(&endpointName, "endpointname", "n", "", "Endpoint Name, e.g. `endpoint-xxxxxxxxxxxx` (only for amazonbedrock, amazonsagemaker backends)")
// add flag for topP
addCmd.Flags().Float32VarP(&topP, "topp", "", 0.5, "Probability Cutoff: Set a threshold (0.0-1.0) to limit word choices. Higher values add randomness, lower values increase predictability.")
// add flag for topK
addCmd.Flags().Int32VarP(&topK, "topk", "c", 50, "Sampling Cutoff: Set a threshold (1-100) to restrict the sampling process to the top K most probable words at each step. Higher values lead to greater variability, lower values increases predictability.")
// max tokens
addCmd.Flags().IntVarP(&maxTokens, "maxtokens", "l", 2048, "Specify a maximum output length. Adjust (1-...) to control text length. Higher values produce longer output, lower values limit length")
// add flag for temperature
addCmd.Flags().Float32VarP(&temperature, "temperature", "t", 0.7, "The sampling temperature, value ranges between 0 ( output be more deterministic) and 1 (more random)")
// add flag for azure open ai engine/deployment name
addCmd.Flags().StringVarP(&engine, "engine", "e", "", "Azure AI deployment name")
addCmd.Flags().StringVarP(&engine, "engine", "e", "", "Azure AI deployment name (only for azureopenai backend)")
//add flag for amazonbedrock region name
addCmd.Flags().StringVarP(&providerRegion, "providerRegion", "r", "", "Provider Region name (only for amazonbedrock, googlevertexai backend)")
//add flag for vertexAI/WatsonxAI Project ID
addCmd.Flags().StringVarP(&providerId, "providerId", "i", "", "Provider specific ID for e.g. project (only for googlevertexai/ibmwatsonxai backend)")
//add flag for OCI Compartment ID
addCmd.Flags().StringVarP(&compartmentId, "compartmentId", "k", "", "Compartment ID for generative AI model (only for oci backend)")
// add flag for openai organization
addCmd.Flags().StringVarP(&organizationId, "organizationId", "o", "", "OpenAI or AzureOpenAI Organization ID (only for openai and azureopenai backend)")
}

View File

@@ -19,11 +19,20 @@ import (
)
var (
backend string
password string
baseURL string
model string
engine string
backend string
password string
baseURL string
endpointName string
model string
engine string
temperature float32
providerRegion string
providerId string
compartmentId string
topP float32
topK int32
maxTokens int
organizationId string
)
var configAI ai.AIConfiguration

View File

@@ -23,6 +23,8 @@ import (
"github.com/spf13/viper"
)
var details bool
var listCmd = &cobra.Command{
Use: "list",
Short: "List configured providers",
@@ -55,6 +57,13 @@ var listCmd = &cobra.Command{
}
if providerExists {
fmt.Printf("> %s\n", color.GreenString(aiBackend))
if details {
for _, provider := range configAI.Providers {
if provider.Name == aiBackend {
printDetails(provider)
}
}
}
}
}
fmt.Print(color.YellowString("Unused: \n"))
@@ -71,3 +80,19 @@ var listCmd = &cobra.Command{
}
},
}
func init() {
listCmd.Flags().BoolVar(&details, "details", false, "Print active provider configuration details")
}
func printDetails(provider ai.AIProvider) {
if provider.Model != "" {
fmt.Printf(" - Model: %s\n", provider.Model)
}
if provider.Engine != "" {
fmt.Printf(" - Engine: %s\n", provider.Engine)
}
if provider.BaseURL != "" {
fmt.Printf(" - BaseURL: %s\n", provider.BaseURL)
}
}

View File

@@ -23,39 +23,45 @@ import (
)
var removeCmd = &cobra.Command{
Use: "remove [backend(s)]",
Short: "Remove a provider",
Long: "The command to remove an AI backend provider",
Args: cobra.ExactArgs(1),
Use: "remove",
Short: "Remove provider(s)",
Long: "The command to remove AI backend provider(s)",
PreRun: func(cmd *cobra.Command, args []string) {
_ = cmd.MarkFlagRequired("backends")
},
Run: func(cmd *cobra.Command, args []string) {
inputBackends := strings.Split(args[0], ",")
if backend == "" {
color.Red("Error: backends must be set.")
_ = cmd.Help()
return
}
inputBackends := strings.Split(backend, ",")
err := viper.UnmarshalKey("ai", &configAI)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
if len(inputBackends) == 0 {
color.Red("Error: backend must be set.")
os.Exit(1)
}
for _, b := range inputBackends {
foundBackend := false
for i, provider := range configAI.Providers {
if b == provider.Name {
foundBackend = true
configAI.Providers = append(configAI.Providers[:i], configAI.Providers[i+1:]...)
if configAI.DefaultProvider == b {
configAI.DefaultProvider = "openai"
}
color.Green("%s deleted from the AI backend provider list", b)
break
}
}
if !foundBackend {
color.Red("Error: %s does not exist in configuration file. Please use k8sgpt auth new.", backend)
color.Red("Error: %s does not exist in configuration file. Please use k8sgpt auth new.", b)
os.Exit(1)
}
}
viper.Set("ai", configAI)
if err := viper.WriteConfig(); err != nil {
color.Red("Error writing config file: %s", err.Error())
@@ -64,3 +70,8 @@ var removeCmd = &cobra.Command{
},
}
func init() {
// add flag for backends
removeCmd.Flags().StringVarP(&backend, "backends", "b", "", "Backend AI providers to remove (separated by a comma)")
}

View File

@@ -26,13 +26,21 @@ var updateCmd = &cobra.Command{
Use: "update",
Short: "Update a backend provider",
Long: "The command to update an AI backend provider",
Args: cobra.ExactArgs(1),
// Args: cobra.ExactArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
_ = cmd.MarkFlagRequired("backend")
backend, _ := cmd.Flags().GetString("backend")
if strings.ToLower(backend) == "azureopenai" {
_ = cmd.MarkFlagRequired("engine")
_ = cmd.MarkFlagRequired("baseurl")
}
organizationId, _ := cmd.Flags().GetString("organizationId")
if strings.ToLower(backend) != "azureopenai" && strings.ToLower(backend) != "openai" {
if organizationId != "" {
color.Red("Error: organizationId must be empty for backends other than azureopenai or openai.")
os.Exit(1)
}
}
},
Run: func(cmd *cobra.Command, args []string) {
@@ -43,45 +51,47 @@ var updateCmd = &cobra.Command{
os.Exit(1)
}
inputBackends := strings.Split(args[0], ",")
backend, _ := cmd.Flags().GetString("backend")
if len(inputBackends) == 0 {
color.Red("Error: backend must be set.")
if temperature > 1.0 || temperature < 0.0 {
color.Red("Error: temperature ranges from 0 to 1.")
os.Exit(1)
}
for _, b := range inputBackends {
foundBackend := false
for i, provider := range configAI.Providers {
if b == provider.Name {
foundBackend = true
if backend != "" {
configAI.Providers[i].Name = backend
color.Blue("Backend name updated successfully")
}
if model != "" {
configAI.Providers[i].Model = model
color.Blue("Model updated successfully")
}
if password != "" {
configAI.Providers[i].Password = password
color.Blue("Password updated successfully")
}
if baseURL != "" {
configAI.Providers[i].BaseURL = baseURL
color.Blue("Base URL updated successfully")
}
if engine != "" {
configAI.Providers[i].Engine = engine
}
color.Green("%s updated in the AI backend provider list", b)
foundBackend := false
for i, provider := range configAI.Providers {
if backend == provider.Name {
foundBackend = true
if backend != "" {
configAI.Providers[i].Name = backend
color.Blue("Backend name updated successfully")
}
if model != "" {
configAI.Providers[i].Model = model
color.Blue("Model updated successfully")
}
if password != "" {
configAI.Providers[i].Password = password
color.Blue("Password updated successfully")
}
if baseURL != "" {
configAI.Providers[i].BaseURL = baseURL
color.Blue("Base URL updated successfully")
}
if engine != "" {
configAI.Providers[i].Engine = engine
}
if organizationId != "" {
configAI.Providers[i].OrganizationId = organizationId
color.Blue("Organization Id updated successfully")
}
configAI.Providers[i].Temperature = temperature
color.Green("%s updated in the AI backend provider list", backend)
}
if !foundBackend {
color.Red("Error: %s does not exist in configuration file. Please use k8sgpt auth new.", args[0])
os.Exit(1)
}
}
if !foundBackend {
color.Red("Error: %s does not exist in configuration file. Please use k8sgpt auth new.", backend)
os.Exit(1)
}
viper.Set("ai", configAI)
@@ -101,6 +111,10 @@ func init() {
updateCmd.Flags().StringVarP(&password, "password", "p", "", "Update backend AI password")
// update flag for url
updateCmd.Flags().StringVarP(&baseURL, "baseurl", "u", "", "Update URL AI provider, (e.g `http://localhost:8080/v1`)")
// add flag for temperature
updateCmd.Flags().Float32VarP(&temperature, "temperature", "t", 0.7, "The sampling temperature, value ranges between 0 ( output be more deterministic) and 1 (more random)")
// update flag for azure open ai engine/deployment name
updateCmd.Flags().StringVarP(&engine, "engine", "e", "", "Update Azure AI deployment name")
// update flag for organizationId
updateCmd.Flags().StringVarP(&organizationId, "organizationId", "o", "", "Update OpenAI or Azure organization Id")
}

49
cmd/cache/add.go vendored
View File

@@ -17,6 +17,7 @@ package cache
import (
"fmt"
"os"
"strings"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
@@ -25,18 +26,38 @@ import (
var (
region string
//nolint:unused
bucketName string
storageAccount string
containerName string
projectId string
endpoint string
insecure bool
)
// addCmd represents the add command
var addCmd = &cobra.Command{
Use: "add",
Use: "add [cache type]",
Short: "Add a remote cache",
Long: `This command allows you to add a remote cache to store the results of an analysis.
The supported cache types are:
- S3`,
- Azure Blob storage (e.g., k8sgpt cache add azure)
- Google Cloud storage (e.g., k8sgpt cache add gcs)
- S3 (e.g., k8sgpt cache add s3)
- Interplex (e.g., k8sgpt cache add interplex)`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(color.YellowString("Adding remote S3 based cache"))
err := cache.AddRemoteCache(bucketname, region)
if len(args) == 0 {
color.Red("Error: Please provide a value for cache types. Run k8sgpt cache add --help")
os.Exit(1)
}
fmt.Println(color.YellowString("Adding remote based cache"))
cacheType := args[0]
remoteCache, err := cache.NewCacheProvider(strings.ToLower(cacheType), bucketName, region, endpoint, storageAccount, containerName, projectId, insecure)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
err = cache.AddRemoteCache(remoteCache)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
@@ -46,9 +67,19 @@ var addCmd = &cobra.Command{
func init() {
CacheCmd.AddCommand(addCmd)
addCmd.Flags().StringVarP(&region, "region", "r", "", "The region to use for the cache")
addCmd.Flags().StringVarP(&bucketname, "bucket", "b", "", "The name of the bucket to use for the cache")
addCmd.MarkFlagRequired("bucket")
addCmd.MarkFlagRequired("region")
addCmd.Flags().StringVarP(&region, "region", "r", "us-east-1", "The region to use for the AWS S3 or GCS cache")
addCmd.Flags().StringVarP(&endpoint, "endpoint", "e", "", "The S3 or minio endpoint")
addCmd.Flags().BoolVarP(&insecure, "insecure", "i", false, "Skip TLS verification for S3/Minio custom endpoint")
addCmd.Flags().StringVarP(&bucketName, "bucket", "b", "", "The name of the AWS S3 bucket to use for the cache")
addCmd.Flags().StringVarP(&projectId, "projectid", "p", "", "The GCP project ID")
addCmd.Flags().StringVarP(&storageAccount, "storageacc", "s", "", "The Azure storage account name of the container")
addCmd.Flags().StringVarP(&containerName, "container", "c", "", "The Azure container name to use for the cache")
addCmd.MarkFlagsRequiredTogether("storageacc", "container")
// Tedious check to ensure we don't include arguments from different providers
addCmd.MarkFlagsMutuallyExclusive("region", "storageacc")
addCmd.MarkFlagsMutuallyExclusive("region", "container")
addCmd.MarkFlagsMutuallyExclusive("bucket", "storageacc")
addCmd.MarkFlagsMutuallyExclusive("bucket", "container")
addCmd.MarkFlagsMutuallyExclusive("projectid", "storageacc")
addCmd.MarkFlagsMutuallyExclusive("projectid", "container")
}

9
cmd/cache/cache.go vendored
View File

@@ -18,17 +18,16 @@ import (
"github.com/spf13/cobra"
)
var (
bucketname string
)
// cacheCmd represents the cache command
var CacheCmd = &cobra.Command{
Use: "cache",
Short: "For working with the cache the results of an analysis",
Long: `Cache commands allow you to add a remote cache, list the contents of the cache, and remove items from the cache.`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
err := cmd.Help()
if err != nil {
panic(err)
}
},
}

45
cmd/cache/get.go vendored Normal file
View File

@@ -0,0 +1,45 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cache
import (
"fmt"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/spf13/cobra"
"os"
)
// listCmd represents the list command
var getCmd = &cobra.Command{
Use: "get",
Short: "Get the current cache",
Long: `Returns the current remote cache being used`,
Run: func(cmd *cobra.Command, args []string) {
// load remote cache if it is configured
c, err := cache.GetCacheConfiguration()
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
fmt.Printf("Current remote cache is: %s", c.GetName())
},
}
func init() {
CacheCmd.AddCommand(getCmd)
}

24
cmd/cache/list.go vendored
View File

@@ -16,9 +16,11 @@ package cache
import (
"os"
"reflect"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)
@@ -30,22 +32,32 @@ var listCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
// load remote cache if it is configured
remoteCacheEnabled, err := cache.RemoteCacheEnabled()
c, err := cache.GetCacheConfiguration()
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
c := cache.New(false, remoteCacheEnabled)
// list the contents of the cache
names, err := c.List()
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
for _, name := range names {
println(name)
var headers []string
obj := cache.CacheObjectDetails{}
objType := reflect.TypeOf(obj)
for i := 0; i < objType.NumField(); i++ {
field := objType.Field(i)
headers = append(headers, field.Name)
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader(headers)
for _, v := range names {
table.Append([]string{v.Name, v.UpdatedAt.String()})
}
table.Render()
},
}

83
cmd/cache/purge.go vendored Normal file
View File

@@ -0,0 +1,83 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cache
import (
"fmt"
"os"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/spf13/cobra"
)
var all bool
var purgeCmd = &cobra.Command{
Use: "purge [object name]",
Short: "Purge a remote cache",
Long: "This command allows you to delete/purge one object from the cache or all objects with --all flag.",
Run: func(cmd *cobra.Command, args []string) {
c, err := cache.GetCacheConfiguration()
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
if all {
fmt.Println(color.YellowString("Purging all objects from the remote cache."))
names, err := c.List()
if err != nil {
color.Red("Error listing cache objects: %v", err)
os.Exit(1)
}
if len(names) == 0 {
fmt.Println(color.GreenString("No objects to delete."))
return
}
var failed []string
for _, obj := range names {
err := c.Remove(obj.Name)
if err != nil {
failed = append(failed, obj.Name)
}
}
if len(failed) > 0 {
color.Red("Failed to delete: %v", failed)
os.Exit(1)
}
fmt.Println(color.GreenString("All objects deleted."))
return
}
if len(args) == 0 {
color.Red("Error: Please provide a value for object name or use --all. Run k8sgpt cache purge --help")
os.Exit(1)
}
objectKey := args[0]
fmt.Println(color.YellowString("Purging a remote cache."))
err = c.Remove(objectKey)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
fmt.Println(color.GreenString("Object deleted."))
},
}
func init() {
purgeCmd.Flags().BoolVar(&all, "all", false, "Purge all objects in the cache")
CacheCmd.AddCommand(purgeCmd)
}

2
cmd/cache/remove.go vendored
View File

@@ -29,7 +29,7 @@ var removeCmd = &cobra.Command{
Long: `This command allows you to remove the remote cache and use the default filecache.`,
Run: func(cmd *cobra.Command, args []string) {
err := cache.RemoveRemoteCache(bucketname)
err := cache.RemoveRemoteCache()
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)

73
cmd/customAnalyzer/add.go Normal file
View File

@@ -0,0 +1,73 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package customanalyzer
import (
"os"
"github.com/fatih/color"
customAnalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/custom_analyzer"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
name string
url string
port int
)
var addCmd = &cobra.Command{
Use: "add",
Aliases: []string{"add"},
Short: "This command will add a custom analyzer from source",
Long: "This command allows you to add/remote/list an existing custom analyzer.",
Run: func(cmd *cobra.Command, args []string) {
err := viper.UnmarshalKey("custom_analyzers", &configCustomAnalyzer)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
analyzer := customAnalyzer.NewCustomAnalyzer()
// Check if configuration is valid
err = analyzer.Check(configCustomAnalyzer, name, url, port)
if err != nil {
color.Red("Error adding custom analyzer: %s", err.Error())
os.Exit(1)
}
configCustomAnalyzer = append(configCustomAnalyzer, customAnalyzer.CustomAnalyzerConfiguration{
Name: name,
Connection: customAnalyzer.Connection{
Url: url,
Port: port,
},
})
viper.Set("custom_analyzers", configCustomAnalyzer)
if err := viper.WriteConfig(); err != nil {
color.Red("Error writing config file: %s", err.Error())
os.Exit(1)
}
color.Green("%s added to the custom analyzers config list", name)
},
}
func init() {
addCmd.Flags().StringVarP(&name, "name", "n", "my-custom-analyzer", "Name of the custom analyzer.")
addCmd.Flags().StringVarP(&url, "url", "u", "localhost", "URL for the custom analyzer connection.")
addCmd.Flags().IntVarP(&port, "port", "r", 8085, "Port for the custom analyzer connection.")
}

View File

@@ -0,0 +1,43 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package customanalyzer
import (
customAnalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/custom_analyzer"
"github.com/spf13/cobra"
)
var configCustomAnalyzer []customAnalyzer.CustomAnalyzerConfiguration
// authCmd represents the auth command
var CustomAnalyzerCmd = &cobra.Command{
Use: "custom-analyzer",
Short: "Manage a custom analyzer",
Long: `This command allows you to manage custom analyzers, including adding, removing, and listing them.`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
_ = cmd.Help()
return
}
},
}
func init() {
// add subcommand to add custom analyzer
CustomAnalyzerCmd.AddCommand(addCmd)
// remove subcomment to remove custom analyzer
CustomAnalyzerCmd.AddCommand(removeCmd)
// list subcomment to list custom analyzer
CustomAnalyzerCmd.AddCommand(listCmd)
}

View File

@@ -0,0 +1,60 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package customanalyzer
import (
"fmt"
"os"
"github.com/fatih/color"
customAnalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/custom_analyzer"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var details bool
var listCmd = &cobra.Command{
Use: "list",
Short: "List configured custom analyzers",
Long: "The list command displays a list of configured custom analyzers",
Run: func(cmd *cobra.Command, args []string) {
// get custom_analyzers configuration
err := viper.UnmarshalKey("custom_analyzers", &configCustomAnalyzer)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
// Get list of all Custom Analyers configured
fmt.Print(color.YellowString("Active: \n"))
for _, analyzer := range configCustomAnalyzer {
fmt.Printf("> %s\n", color.GreenString(analyzer.Name))
if details {
printDetails(analyzer)
}
}
},
}
func init() {
listCmd.Flags().BoolVar(&details, "details", false, "Print custom analyzers configuration details")
}
func printDetails(analyzer customAnalyzer.CustomAnalyzerConfiguration) {
fmt.Printf(" - Url: %s\n", analyzer.Connection.Url)
fmt.Printf(" - Port: %d\n", analyzer.Connection.Port)
}

View File

@@ -0,0 +1,90 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package customanalyzer
import (
"os"
"strings"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
names string
)
var removeCmd = &cobra.Command{
Use: "remove",
Short: "Remove custom analyzer(s)",
Long: "The command to remove custom analyzer(s)",
PreRun: func(cmd *cobra.Command, args []string) {
// Ensure that the "names" flag is provided before running the command
_ = cmd.MarkFlagRequired("names")
},
Run: func(cmd *cobra.Command, args []string) {
if names == "" {
// Display an error message and show command help if "names" is not set
color.Red("Error: names must be set.")
_ = cmd.Help()
return
}
// Split the provided names by comma
inputCustomAnalyzers := strings.Split(names, ",")
// Load the custom analyzers from the configuration file
err := viper.UnmarshalKey("custom_analyzers", &configCustomAnalyzer)
if err != nil {
// Display an error message if the configuration cannot be loaded
color.Red("Error: %v", err)
os.Exit(1)
}
// Iterate over each input analyzer name
for _, inputAnalyzer := range inputCustomAnalyzers {
foundAnalyzer := false
// Search for the analyzer in the current configuration
for i, analyzer := range configCustomAnalyzer {
if analyzer.Name == inputAnalyzer {
foundAnalyzer = true
// Remove the analyzer from the configuration list
configCustomAnalyzer = append(configCustomAnalyzer[:i], configCustomAnalyzer[i+1:]...)
color.Green("%s deleted from the custom analyzer list", analyzer.Name)
break
}
}
if !foundAnalyzer {
// Display an error if the analyzer is not found in the configuration
color.Red("Error: %s does not exist in configuration file. Please use k8sgpt custom-analyzer add.", inputAnalyzer)
os.Exit(1)
}
}
// Save the updated configuration back to the file
viper.Set("custom_analyzers", configCustomAnalyzer)
if err := viper.WriteConfig(); err != nil {
// Display an error if the configuration cannot be written
color.Red("Error writing config file: %s", err.Error())
os.Exit(1)
}
},
}
func init() {
// add flag for names
removeCmd.Flags().StringVarP(&names, "names", "n", "", "Custom analyzers to remove (separated by a comma)")
}

113
cmd/dump/dump.go Normal file
View File

@@ -0,0 +1,113 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package dump
import (
"encoding/json"
"fmt"
"net/http"
"os"
"time"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/ai"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/apimachinery/pkg/version"
)
type K8sGPTInfo struct {
Version string
Commit string
Date string
}
type DumpOut struct {
AIConfiguration ai.AIConfiguration
ActiveFilters []string
KubenetesServerVersion *version.Info
K8sGPTInfo K8sGPTInfo
}
var DumpCmd = &cobra.Command{
Use: "dump",
Short: "Creates a dumpfile for debugging issues with K8sGPT",
Long: `The dump command will create a dump.*.json which will contain K8sGPT non-sensitive configuration information.`,
Run: func(cmd *cobra.Command, args []string) {
// Fetch the configuration object(s)
// get ai configuration
var configAI ai.AIConfiguration
err := viper.UnmarshalKey("ai", &configAI)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
var newProvider []ai.AIProvider
for _, config := range configAI.Providers {
// we blank out the custom headers for data protection reasons
config.CustomHeaders = make([]http.Header, 0)
// blank out the password
if len(config.Password) > 4 {
config.Password = config.Password[:4] + "***"
} else {
// If the password is shorter than 4 characters
config.Password = "***"
}
newProvider = append(newProvider, config)
}
configAI.Providers = newProvider
activeFilters := viper.GetStringSlice("active_filters")
kubecontext := viper.GetString("kubecontext")
kubeconfig := viper.GetString("kubeconfig")
client, err := kubernetes.NewClient(kubecontext, kubeconfig)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
v, err := client.Client.Discovery().ServerVersion()
if err != nil {
color.Yellow("Could not find kubernetes server version")
}
var dumpOut DumpOut = DumpOut{
AIConfiguration: configAI,
ActiveFilters: activeFilters,
KubenetesServerVersion: v,
K8sGPTInfo: K8sGPTInfo{
Version: viper.GetString("Version"),
Commit: viper.GetString("Commit"),
Date: viper.GetString("Date"),
},
}
// Serialize dumpOut to JSON
jsonData, err := json.MarshalIndent(dumpOut, "", " ")
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
// Write JSON data to file
f := fmt.Sprintf("dump_%s.json", time.Now().Format("20060102150405"))
err = os.WriteFile(f, jsonData, 0644)
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
}
color.Green("Dump created successfully: %s", f)
},
}
func init() {
}

View File

@@ -45,6 +45,13 @@ var addCmd = &cobra.Command{
for _, filter := range availableFilters {
if filter == f {
foundFilter = true
// WARNING: This is to enable users correctly understand implications
// of enabling logs
if filter == "Log" {
color.Yellow("Warning: by enabling logs, you will be sending potentially sensitive data to the AI backend.")
}
break
}
}

View File

@@ -15,9 +15,11 @@ package filters
import (
"fmt"
"slices"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
"github.com/k8sgpt-ai/k8sgpt/pkg/integration"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -30,7 +32,7 @@ var listCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
activeFilters := viper.GetStringSlice("active_filters")
coreFilters, additionalFilters, integrationFilters := analyzer.ListFilters()
integration := integration.NewIntegration()
availableFilters := append(append(coreFilters, additionalFilters...), integrationFilters...)
if len(activeFilters) == 0 {
@@ -39,12 +41,17 @@ var listCmd = &cobra.Command{
inactiveFilters := util.SliceDiff(availableFilters, activeFilters)
fmt.Print(color.YellowString("Active: \n"))
for _, filter := range activeFilters {
// if the filter is an integration, mark this differently
if util.SliceContainsString(integrationFilters, filter) {
// but if the integration is inactive, remove
if slices.Contains(integrationFilters, filter) {
fmt.Printf("> %s\n", color.BlueString("%s (integration)", filter))
} else {
fmt.Printf("> %s\n", color.GreenString(filter))
// This strange bit of logic will loop through every integration via
// OwnsAnalyzer subcommand to check the filter and as the integrationFilters...
// was no match, we know this isn't part of an active integration
if _, err := integration.AnalyzerByIntegration(filter); err != nil {
fmt.Printf("> %s\n", color.GreenString(filter))
}
}
}
@@ -53,13 +60,12 @@ var listCmd = &cobra.Command{
fmt.Print(color.YellowString("Unused: \n"))
for _, filter := range inactiveFilters {
// if the filter is an integration, mark this differently
if util.SliceContainsString(integrationFilters, filter) {
if slices.Contains(integrationFilters, filter) {
fmt.Printf("> %s\n", color.BlueString("%s (integration)", filter))
} else {
fmt.Printf("> %s\n", color.RedString(filter))
}
}
}
},
}

View File

@@ -15,15 +15,17 @@ package generate
import (
"fmt"
"os/exec"
"runtime"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os/exec"
"runtime"
)
var (
backend string
backend string
backendType string
)
// generateCmd represents the auth command
@@ -33,7 +35,7 @@ var GenerateCmd = &cobra.Command{
Long: `Opens your browser to generate a key for your chosen backend.`,
Run: func(cmd *cobra.Command, args []string) {
backendType := viper.GetString("backend_type")
backendType = viper.GetString("backend_type")
if backendType == "" {
// Set the default backend
backend = "openai"
@@ -43,7 +45,7 @@ var GenerateCmd = &cobra.Command{
backendType = backend
}
fmt.Println("")
openbrowser("https://beta.openai.com/account/api-keys")
openbrowser("https://platform.openai.com/api-keys")
},
}
@@ -79,12 +81,12 @@ func openbrowser(url string) {
func printInstructions(isGui bool, backendType string) {
fmt.Println("")
if isGui {
color.Green("Opening: https://beta.openai.com/account/api-keys to generate a key for %s", backendType)
color.Green("Opening: https://platform.openai.com/api-keys to generate a key for %s", backendType)
fmt.Println("")
} else {
color.Green("Please open: https://beta.openai.com/account/api-keys to generate a key for %s", backendType)
color.Green("Please open: https://platform.openai.com/api-keys to generate a key for %s", backendType)
fmt.Println("")
}
color.Green("Please copy the generated key and run `k8sgpt auth` to add it to your config file")
color.Green("Please copy the generated key and run `k8sgpt auth add` to add it to your config file")
fmt.Println("")
}

View File

@@ -21,6 +21,8 @@ import (
"github.com/spf13/viper"
)
var skipInstall bool
// activateCmd represents the activate command
var activateCmd = &cobra.Command{
Use: "activate [integration]",
@@ -39,7 +41,7 @@ var activateCmd = &cobra.Command{
integration := integration.NewIntegration()
// Check if the integation exists
err := integration.Activate(integrationName, namespace, activeFilters)
err := integration.Activate(integrationName, namespace, activeFilters, skipInstall)
if err != nil {
color.Red("Error: %v", err)
return
@@ -51,5 +53,5 @@ var activateCmd = &cobra.Command{
func init() {
IntegrationCmd.AddCommand(activateCmd)
activateCmd.Flags().BoolVarP(&skipInstall, "no-install", "s", false, "Only activate the integration filter without installing the filter (for example, if that filter plugin is already deployed in cluster, we do not need to re-install it again)")
}

View File

@@ -24,7 +24,7 @@ var deactivateCmd = &cobra.Command{
Use: "deactivate [integration]",
Short: "Deactivate an integration",
Args: cobra.ExactArgs(1),
Long: `For example e.g. k8sgpt integration deactivate trivy`,
Long: `For example e.g. k8sgpt integration deactivate prometheus`,
Run: func(cmd *cobra.Command, args []string) {
integrationName := args[0]

View File

@@ -25,12 +25,12 @@ var (
var IntegrationCmd = &cobra.Command{
Use: "integration",
Aliases: []string{"integrations"},
Short: "Intergrate another tool into K8sGPT",
Long: `Intergrate another tool into K8sGPT. For example:
Short: "Integrate another tool into K8sGPT",
Long: `Integrate another tool into K8sGPT. For example:
k8sgpt integration activate trivy
k8sgpt integration activate prometheus
This would allow you to deploy trivy into your cluster and use a K8sGPT analyzer to parse trivy results.`,
This would allow you to connect to prometheus running with your cluster.`,
Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Help()
},

View File

@@ -14,6 +14,7 @@ limitations under the License.
package cmd
import (
"fmt"
"os"
"path/filepath"
@@ -21,6 +22,8 @@ import (
"github.com/k8sgpt-ai/k8sgpt/cmd/analyze"
"github.com/k8sgpt-ai/k8sgpt/cmd/auth"
"github.com/k8sgpt-ai/k8sgpt/cmd/cache"
customanalyzer "github.com/k8sgpt-ai/k8sgpt/cmd/customAnalyzer"
"github.com/k8sgpt-ai/k8sgpt/cmd/dump"
"github.com/k8sgpt-ai/k8sgpt/cmd/filters"
"github.com/k8sgpt-ai/k8sgpt/cmd/generate"
"github.com/k8sgpt-ai/k8sgpt/cmd/integration"
@@ -34,6 +37,7 @@ var (
cfgFile string
kubecontext string
kubeconfig string
verbose bool
Version string
Commit string
Date string
@@ -55,6 +59,9 @@ func Execute(v string, c string, d string) {
Version = v
Commit = c
Date = d
viper.Set("Version", Version)
viper.Set("Commit", Commit)
viper.Set("Date", Date)
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
@@ -68,14 +75,17 @@ func init() {
rootCmd.AddCommand(auth.AuthCmd)
rootCmd.AddCommand(analyze.AnalyzeCmd)
rootCmd.AddCommand(dump.DumpCmd)
rootCmd.AddCommand(filters.FiltersCmd)
rootCmd.AddCommand(generate.GenerateCmd)
rootCmd.AddCommand(integration.IntegrationCmd)
rootCmd.AddCommand(serve.ServeCmd)
rootCmd.AddCommand(cache.CacheCmd)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.k8sgpt.yaml)")
rootCmd.AddCommand(customanalyzer.CustomAnalyzerCmd)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", fmt.Sprintf("Default config file (%s/k8sgpt/k8sgpt.yaml)", xdg.ConfigHome))
rootCmd.PersistentFlags().StringVar(&kubecontext, "kubecontext", "", "Kubernetes context to use. Only required if out-of-cluster.")
rootCmd.PersistentFlags().StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Show detailed tool actions (e.g., API calls, checks).")
}
// initConfig reads in config file and ENV variables if set.
@@ -96,6 +106,7 @@ func initConfig() {
viper.Set("kubecontext", kubecontext)
viper.Set("kubeconfig", kubeconfig)
viper.Set("verbose", verbose)
viper.SetEnvPrefix("K8SGPT")
viper.AutomaticEnv() // read in environment variables that match

30
cmd/root_test.go Normal file
View File

@@ -0,0 +1,30 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"testing"
"github.com/spf13/viper"
)
// Test that verbose flag is correctly set in viper.
func TestInitConfig_VerboseFlag(t *testing.T) {
verbose = true
viper.Reset()
initConfig()
if !viper.GetBool("verbose") {
t.Error("Expected verbose flag to be true")
}
}

View File

@@ -15,19 +15,34 @@ package serve
import (
"os"
"strconv"
k8sgptserver "github.com/k8sgpt-ai/k8sgpt/pkg/server"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/ai"
k8sgptserver "github.com/k8sgpt-ai/k8sgpt/pkg/server"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap"
)
const (
defaultTemperature float32 = 0.7
defaultTopP float32 = 1.0
defaultTopK int32 = 50
defaultMaxTokens int = 2048
)
var (
port string
metricsPort string
backend string
enableHttp bool
enableMCP bool
mcpPort string
mcpHTTP bool
// filters can be injected into the server (repeatable flag)
filters []string
)
var ServeCmd = &cobra.Command{
@@ -44,22 +59,91 @@ var ServeCmd = &cobra.Command{
}
var aiProvider *ai.AIProvider
if len(configAI.Providers) == 0 {
// we validate and set temperature for our backend
temperature := func() float32 {
env := os.Getenv("K8SGPT_TEMPERATURE")
if env == "" {
return defaultTemperature
}
temperature, err := strconv.ParseFloat(env, 32)
if err != nil {
color.Red("Unable to convert Temperature value: %v", err)
os.Exit(1)
}
if temperature > 1.0 || temperature < 0.0 {
color.Red("Error: temperature ranges from 0 to 1.")
os.Exit(1)
}
return float32(temperature)
}
topP := func() float32 {
env := os.Getenv("K8SGPT_TOP_P")
if env == "" {
return defaultTopP
}
topP, err := strconv.ParseFloat(env, 32)
if err != nil {
color.Red("Unable to convert topP value: %v", err)
os.Exit(1)
}
if topP > 1.0 || topP < 0.0 {
color.Red("Error: topP ranges from 0 to 1.")
os.Exit(1)
}
return float32(topP)
}
topK := func() int32 {
env := os.Getenv("K8SGPT_TOP_K")
if env == "" {
return defaultTopK
}
topK, err := strconv.ParseFloat(env, 32)
if err != nil {
color.Red("Unable to convert topK value: %v", err)
os.Exit(1)
}
if topK < 10 || topK > 100 {
color.Red("Error: topK ranges from 1 to 100.")
os.Exit(1)
}
return int32(topK)
}
maxTokens := func() int {
env := os.Getenv("K8SGPT_MAX_TOKENS")
if env == "" {
return defaultMaxTokens
}
maxTokens, err := strconv.ParseInt(env, 10, 32)
if err != nil {
color.Red("Unable to convert maxTokens value: %v", err)
os.Exit(1)
}
return int(maxTokens)
}
// Check for env injection
backend = os.Getenv("K8SGPT_BACKEND")
password := os.Getenv("K8SGPT_PASSWORD")
model := os.Getenv("K8SGPT_MODEL")
baseURL := os.Getenv("K8SGPT_BASEURL")
engine := os.Getenv("K8SGPT_ENGINE")
proxyEndpoint := os.Getenv("K8SGPT_PROXY_ENDPOINT")
providerId := os.Getenv("K8SGPT_PROVIDER_ID")
// If the envs are set, allocate in place to the aiProvider
// else exit with error
envIsSet := backend != "" || password != "" || model != ""
if envIsSet {
aiProvider = &ai.AIProvider{
Name: backend,
Password: password,
Model: model,
BaseURL: baseURL,
Engine: engine,
Name: backend,
Password: password,
Model: model,
BaseURL: baseURL,
Engine: engine,
ProxyEndpoint: proxyEndpoint,
ProviderId: providerId,
Temperature: temperature(),
TopP: topP(),
TopK: topK(),
MaxTokens: maxTokens(),
}
configAI.Providers = append(configAI.Providers, *aiProvider)
@@ -87,7 +171,7 @@ var ServeCmd = &cobra.Command{
}
}
if aiProvider.Name == "" {
if aiProvider == nil || aiProvider.Name == "" {
color.Red("Error: AI provider %s not specified in configuration. Please run k8sgpt auth", backend)
os.Exit(1)
}
@@ -97,14 +181,41 @@ var ServeCmd = &cobra.Command{
color.Red("failed to create logger: %v", err)
os.Exit(1)
}
defer logger.Sync()
defer func() {
if err := logger.Sync(); err != nil {
color.Red("failed to sync logger: %v", err)
os.Exit(1)
}
}()
if enableMCP {
// Create and start MCP server
mcpServer, err := k8sgptserver.NewMCPServer(mcpPort, aiProvider, mcpHTTP, logger)
if err != nil {
color.Red("Error creating MCP server: %v", err)
os.Exit(1)
}
go func() {
if err := mcpServer.Start(); err != nil {
color.Red("Error starting MCP server: %v", err)
os.Exit(1)
}
}()
}
// Allow metrics port to be overridden by environment variable
if envMetricsPort := os.Getenv("K8SGPT_METRICS_PORT"); envMetricsPort != "" && !cmd.Flags().Changed("metrics-port") {
metricsPort = envMetricsPort
}
server := k8sgptserver.Config{
Backend: aiProvider.Name,
Port: port,
MetricsPort: metricsPort,
EnableHttp: enableHttp,
Token: aiProvider.Password,
Logger: logger,
Filters: filters,
}
go func() {
if err := server.ServeMetrics(); err != nil {
@@ -128,6 +239,12 @@ var ServeCmd = &cobra.Command{
func init() {
// add flag for backend
ServeCmd.Flags().StringVarP(&port, "port", "p", "8080", "Port to run the server on")
ServeCmd.Flags().StringVarP(&metricsPort, "metrics-port", "", "8081", "Port to run the metrics-server on")
ServeCmd.Flags().StringVarP(&metricsPort, "metrics-port", "m", "8081", "Port to run the metrics-server on (env: K8SGPT_METRICS_PORT)")
ServeCmd.Flags().StringVarP(&backend, "backend", "b", "openai", "Backend AI provider")
ServeCmd.Flags().BoolVarP(&enableHttp, "http", "", false, "Enable REST/http using gppc-gateway")
ServeCmd.Flags().BoolVarP(&enableMCP, "mcp", "", false, "Enable Mission Control Protocol server")
ServeCmd.Flags().StringVarP(&mcpPort, "mcp-port", "", "8089", "Port to run the MCP server on")
ServeCmd.Flags().BoolVarP(&mcpHTTP, "mcp-http", "", false, "Enable HTTP mode for MCP server")
// allow injecting filters into the running server (repeatable)
ServeCmd.Flags().StringSliceVar(&filters, "filter", []string{}, "Filter to apply (can be specified multiple times)")
}

View File

@@ -9,7 +9,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM golang:1.20.4-alpine3.16 AS builder
FROM golang:1.24-alpine3.23 AS builder
ENV CGO_ENABLED=0
ARG VERSION
@@ -36,4 +36,4 @@ WORKDIR /
COPY --from=builder /workspace/k8sgpt .
USER 65532:65532
ENTRYPOINT ["/k8sgpt"]
ENTRYPOINT ["/k8sgpt"]

358
go.mod
View File

@@ -1,191 +1,299 @@
module github.com/k8sgpt-ai/k8sgpt
go 1.20
go 1.24.1
toolchain go1.24.11
require (
github.com/aquasecurity/trivy-operator v0.13.2
github.com/fatih/color v1.15.0
github.com/magiconair/properties v1.8.7
github.com/mittwald/go-helm-client v0.12.1
github.com/sashabaranov/go-openai v1.9.3
github.com/schollz/progressbar/v3 v3.13.1
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
golang.org/x/term v0.9.0
helm.sh/helm/v3 v3.12.0
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
k8s.io/kubectl v0.27.2
github.com/fatih/color v1.18.0
github.com/kedacore/keda/v2 v2.16.0
github.com/magiconair/properties v1.8.9
github.com/mittwald/go-helm-client v0.12.14
github.com/ollama/ollama v0.13.4
github.com/sashabaranov/go-openai v1.36.0
github.com/schollz/progressbar/v3 v3.17.1
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
golang.org/x/term v0.33.0
helm.sh/helm/v3 v3.17.4
k8s.io/api v0.32.3
k8s.io/apimachinery v0.32.3
k8s.io/client-go v0.32.3
k8s.io/kubectl v0.32.2 // indirect
)
require github.com/adrg/xdg v0.4.0
require github.com/adrg/xdg v0.5.3
require (
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230524215339-41d88e13ab7e.1
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.30.0-20230524215339-41d88e13ab7e.1
github.com/aws/aws-sdk-go v1.44.281
buf.build/gen/go/interplex-ai/schemas/grpc/go v1.5.1-20241117203254-a91193b62179.1
buf.build/gen/go/interplex-ai/schemas/protocolbuffers/go v1.35.2-20241117203254-a91193b62179.1
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2 v2.24.0-20241118152629-1379a5a1889d.1
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.5.1-20241118152629-1379a5a1889d.1
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.35.2-20241118152629-1379a5a1889d.1
cloud.google.com/go/storage v1.50.0
cloud.google.com/go/vertexai v0.13.2
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0
github.com/IBM/watsonx-go v1.0.1
github.com/agiledragon/gomonkey/v2 v2.13.0
github.com/aws/aws-sdk-go v1.55.7
github.com/aws/aws-sdk-go-v2 v1.36.3
github.com/aws/aws-sdk-go-v2/config v1.29.14
github.com/aws/aws-sdk-go-v2/service/bedrock v1.33.0
github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.30.0
github.com/aws/smithy-go v1.22.2
github.com/cohere-ai/cohere-go/v2 v2.12.2
github.com/go-logr/zapr v1.3.0
github.com/google/generative-ai-go v0.19.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3
github.com/hupe1980/go-huggingface v0.0.15
github.com/kyverno/policy-reporter-kyverno-plugin v1.6.4
github.com/mark3labs/mcp-go v0.36.0
github.com/olekukonko/tablewriter v0.0.5
github.com/oracle/oci-go-sdk/v65 v65.79.0
github.com/prometheus/prometheus v0.306.0
github.com/pterm/pterm v0.12.80
google.golang.org/api v0.239.0
gopkg.in/yaml.v2 v2.4.0
sigs.k8s.io/controller-runtime v0.19.3
sigs.k8s.io/gateway-api v1.2.1
)
require github.com/jmespath/go-jmespath v0.4.0 // indirect
require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
cel.dev/expr v0.23.0 // indirect
cloud.google.com/go v0.120.0 // indirect
cloud.google.com/go/ai v0.8.0 // indirect
cloud.google.com/go/aiplatform v1.85.0 // indirect
cloud.google.com/go/auth v0.16.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.7.0 // indirect
cloud.google.com/go/iam v1.5.2 // indirect
cloud.google.com/go/longrunning v0.6.7 // indirect
cloud.google.com/go/monitoring v1.24.2 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.50.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.50.0 // indirect
github.com/Microsoft/hcsshim v0.12.4 // indirect
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/expr-lang/expr v1.17.7 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
github.com/googleapis/gax-go/v2 v2.14.2 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/moby/sys/mountinfo v0.7.1 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/prometheus/sigv4 v0.2.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sony/gobreaker v0.5.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
github.com/zeebo/errs v1.4.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/detectors/gcp v1.35.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
go.opentelemetry.io/otel/metric v1.36.0 // indirect
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.36.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
knative.dev/pkg v0.0.0-20241026180704-25f6002b00f3 // indirect
)
require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Masterminds/squirrel v1.5.3 // indirect
github.com/aquasecurity/defsec v0.86.0 // indirect
github.com/aquasecurity/go-dep-parser v0.0.0-20230413091456-df0396537e15 // indirect
github.com/aquasecurity/table v1.8.0 // indirect
github.com/aquasecurity/tml v0.6.1 // indirect
github.com/aquasecurity/trivy v0.40.0 // indirect
github.com/aquasecurity/trivy-db v0.0.0-20230411140759-3c2ee2168575 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/containerd/containerd v1.7.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v23.0.1+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v23.0.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.3 // indirect
github.com/containerd/containerd v1.7.29 // indirect
github.com/cyphar/filepath-securejoin v0.3.6 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/cli v26.1.4+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v28.3.0+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.2 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/gnostic v0.6.9
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-containerregistry v0.14.0 // indirect
github.com/google/gnostic v0.7.0
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmoiron/sqlx v1.3.5 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/masahiro331/go-xfs-filesystem v0.0.0-20221225060805-c02764233454 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/moby/spdystream v0.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221020182949-4df8887994e8 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.0-rc.1
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.1-0.20250703115700-7f8b2a0d32d3 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/robfig/cron/v3 v3.0.1
github.com/rubenv/sql-migrate v1.3.1 // indirect
github.com/rubenv/sql-migrate v1.7.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/samber/lo v1.37.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spdx/tools-golang v0.5.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.starlark.net v0.0.0-20221020143700-22309ac47eac // indirect
go.uber.org/atomic v1.10.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.opentelemetry.io/otel v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230124195608-d38c7dcee874 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0 // indirect
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
golang.org/x/net v0.42.0
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.27.0 // indirect
golang.org/x/time v0.12.0 // indirect
google.golang.org/grpc v1.73.0
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.27.1 // indirect
k8s.io/apiserver v0.27.1 // indirect
k8s.io/cli-runtime v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 // indirect
oras.land/oras-go v1.2.2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
k8s.io/apiextensions-apiserver v0.32.2
k8s.io/apiserver v0.32.2 // indirect
k8s.io/cli-runtime v0.32.2 // indirect
k8s.io/component-base v0.32.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
oras.land/oras-go v1.2.5 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/kustomize/api v0.18.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.18.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
// v1.2.0 is taken from github.com/open-policy-agent/opa v0.42.0
// v1.2.0 incompatible with github.com/docker/docker v23.0.0-rc.1+incompatible
replace oras.land/oras-go => oras.land/oras-go v1.2.3
//replace oras.land/oras-go => oras.land/oras-go v1.2.4
replace github.com/docker/docker => github.com/docker/docker v28.0.4+incompatible
// v0.3.1-0.20230104082527-d6f58551be3f is taken from github.com/moby/buildkit v0.11.0
// spdx logic write on v0.3.0 and incompatible with v0.3.1-0.20230104082527-d6f58551be3f
replace github.com/spdx/tools-golang => github.com/spdx/tools-golang v0.3.0
replace dario.cat/mergo => github.com/imdario/mergo v1.0.1

1478
go.sum

File diff suppressed because it is too large Load Diff

626
pkg/ai/amazonbedrock.go Normal file
View File

@@ -0,0 +1,626 @@
package ai
import (
"context"
"errors"
"fmt"
"os"
"regexp"
"strings"
"github.com/k8sgpt-ai/k8sgpt/pkg/ai/bedrock_support"
"github.com/aws/aws-sdk-go-v2/aws"
awsconfig "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/bedrock"
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
const amazonbedrockAIClientName = "amazonbedrock"
// AmazonBedRockClient represents the client for interacting with the Amazon Bedrock service.
type AmazonBedRockClient struct {
nopCloser
client BedrockRuntimeAPI
mgmtClient BedrockManagementAPI
model *bedrock_support.BedrockModel
temperature float32
topP float32
maxTokens int
models []bedrock_support.BedrockModel
}
// AmazonCompletion BedRock support region list US East (N. Virginia),US West (Oregon),Asia Pacific (Singapore),Asia Pacific (Tokyo),Europe (Frankfurt)
// https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html#bedrock-regions
const BEDROCK_DEFAULT_REGION = "us-east-1" // default use us-east-1 region
const (
US_East_1 = "us-east-1"
US_West_2 = "us-west-2"
AP_Southeast_1 = "ap-southeast-1"
AP_Northeast_1 = "ap-northeast-1"
EU_Central_1 = "eu-central-1"
AP_South_1 = "ap-south-1"
US_Gov_West_1 = "us-gov-west-1"
US_Gov_East_1 = "us-gov-east-1"
)
var BEDROCKER_SUPPORTED_REGION = []string{
US_East_1,
US_West_2,
AP_Southeast_1,
AP_Northeast_1,
EU_Central_1,
AP_South_1,
US_Gov_West_1,
US_Gov_East_1,
}
var defaultModels = []bedrock_support.BedrockModel{
{
Name: "anthropic.claude-sonnet-4-20250514-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-sonnet-4-20250514-v1:0",
},
},
{
Name: "us.anthropic.claude-sonnet-4-20250514-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "us.anthropic.claude-sonnet-4-20250514-v1:0",
},
},
{
Name: "eu.anthropic.claude-sonnet-4-20250514-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "eu.anthropic.claude-sonnet-4-20250514-v1:0",
},
},
{
Name: "apac.anthropic.claude-sonnet-4-20250514-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "apac.anthropic.claude-sonnet-4-20250514-v1:0",
},
},
{
Name: "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
},
},
{
Name: "eu.anthropic.claude-3-7-sonnet-20250219-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "eu.anthropic.claude-3-7-sonnet-20250219-v1:0",
},
},
{
Name: "apac.anthropic.claude-3-7-sonnet-20250219-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "apac.anthropic.claude-3-7-sonnet-20250219-v1:0",
},
},
{
Name: "anthropic.claude-3-5-sonnet-20240620-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-3-5-sonnet-20240620-v1:0",
},
},
{
Name: "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
},
},
{
Name: "anthropic.claude-v2",
Completion: &bedrock_support.CohereCompletion{},
Response: &bedrock_support.CohereResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-v2",
},
},
{
Name: "anthropic.claude-v1",
Completion: &bedrock_support.CohereCompletion{},
Response: &bedrock_support.CohereResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-v1",
},
},
{
Name: "anthropic.claude-instant-v1",
Completion: &bedrock_support.CohereCompletion{},
Response: &bedrock_support.CohereResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-instant-v1",
},
},
{
Name: "ai21.j2-ultra-v1",
Completion: &bedrock_support.AI21{},
Response: &bedrock_support.AI21Response{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "ai21.j2-ultra-v1",
},
},
{
Name: "ai21.j2-jumbo-instruct",
Completion: &bedrock_support.AI21{},
Response: &bedrock_support.AI21Response{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "ai21.j2-jumbo-instruct",
},
},
{
Name: "amazon.titan-text-express-v1",
Completion: &bedrock_support.AmazonCompletion{},
Response: &bedrock_support.AmazonResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "amazon.titan-text-express-v1",
},
},
{
Name: "amazon.nova-pro-v1:0",
Completion: &bedrock_support.AmazonCompletion{},
Response: &bedrock_support.NovaResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
// https://docs.aws.amazon.com/nova/latest/userguide/getting-started-api.html
MaxTokens: 100, // max of 300k tokens
Temperature: 0.5,
TopP: 0.9,
ModelName: "amazon.nova-pro-v1:0",
},
},
{
Name: "eu.amazon.nova-pro-v1:0",
Completion: &bedrock_support.AmazonCompletion{},
Response: &bedrock_support.NovaResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
// https://docs.aws.amazon.com/nova/latest/userguide/getting-started-api.html
MaxTokens: 100, // max of 300k tokens
Temperature: 0.5,
TopP: 0.9,
ModelName: "eu.amazon.nova-pro-v1:0",
},
},
{
Name: "us.amazon.nova-pro-v1:0",
Completion: &bedrock_support.AmazonCompletion{},
Response: &bedrock_support.NovaResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
// https://docs.aws.amazon.com/nova/latest/userguide/getting-started-api.html
MaxTokens: 100, // max of 300k tokens
Temperature: 0.5,
TopP: 0.9,
ModelName: "us.amazon.nova-pro-v1:0",
},
},
{
Name: "amazon.nova-lite-v1:0",
Completion: &bedrock_support.AmazonCompletion{},
Response: &bedrock_support.NovaResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100, // max of 300k tokens
Temperature: 0.5,
TopP: 0.9,
ModelName: "amazon.nova-lite-v1:0",
},
},
{
Name: "eu.amazon.nova-lite-v1:0",
Completion: &bedrock_support.AmazonCompletion{},
Response: &bedrock_support.NovaResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100, // max of 300k tokens
Temperature: 0.5,
TopP: 0.9,
ModelName: "eu.amazon.nova-lite-v1:0",
},
},
{
Name: "us.amazon.nova-lite-v1:0",
Completion: &bedrock_support.AmazonCompletion{},
Response: &bedrock_support.NovaResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100, // max of 300k tokens
Temperature: 0.5,
TopP: 0.9,
ModelName: "us.amazon.nova-lite-v1:0",
},
},
{
Name: "anthropic.claude-3-haiku-20240307-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
// sensible defaults
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-3-haiku-20240307-v1:0",
},
},
}
// NewAmazonBedRockClient creates a new AmazonBedRockClient with the given models
func NewAmazonBedRockClient(models []bedrock_support.BedrockModel) *AmazonBedRockClient {
if models == nil {
models = defaultModels // Use default models if none provided
}
return &AmazonBedRockClient{
models: models,
}
}
// GetModelOrDefault check config region
func GetRegionOrDefault(region string) string {
if os.Getenv("AWS_DEFAULT_REGION") != "" {
region = os.Getenv("AWS_DEFAULT_REGION")
}
// Check if the provided model is in the list
for _, m := range BEDROCKER_SUPPORTED_REGION {
if m == region {
return region // Return the provided model
}
}
// Return the default model if the provided model is not in the list
return BEDROCK_DEFAULT_REGION
}
func validateModelArn(model string) bool {
var re = regexp.MustCompile(`(?m)^arn:(?P<Partition>[^:\n]*):bedrock:(?P<Region>[^:\n]*):(?P<AccountID>[^:\n]*):(?P<Ignore>(?P<ResourceType>[^:\/\n]*)[:\/])?(?P<Resource>.*)$`)
return re.MatchString(model)
}
func validateInferenceProfileArn(inferenceProfile string) bool {
// Support both inference-profile and application-inference-profile formats
var re = regexp.MustCompile(`(?m)^arn:(?P<Partition>[^:\n]*):bedrock:(?P<Region>[^:\n]*):(?P<AccountID>[^:\n]*):(?:inference-profile|application-inference-profile)\/(?P<ProfileName>.+)$`)
return re.MatchString(inferenceProfile)
}
// Get model from string
func (a *AmazonBedRockClient) getModelFromString(model string) (*bedrock_support.BedrockModel, error) {
if model == "" {
return nil, errors.New("model name cannot be empty")
}
// Trim spaces from the model name
model = strings.TrimSpace(model)
// Try to find an exact match first
for i := range a.models {
if strings.EqualFold(model, a.models[i].Name) || strings.EqualFold(model, a.models[i].Config.ModelName) {
// Create a copy to avoid returning a pointer to a loop variable
modelCopy := a.models[i]
return &modelCopy, nil
}
}
supportedModels := make([]string, len(a.models))
for i, m := range a.models {
supportedModels[i] = m.Name
}
supportedRegions := BEDROCKER_SUPPORTED_REGION
// Pretty-print supported models and regions
modelList := ""
for _, m := range supportedModels {
modelList += " - " + m + "\n"
}
regionList := ""
for _, r := range supportedRegions {
regionList += " - " + r + "\n"
}
return nil, fmt.Errorf(
"model '%s' not found in supported models.\n\nSupported models:\n%sSupported regions:\n%s",
model, modelList, regionList,
)
}
// Configure configures the AmazonBedRockClient with the provided configuration.
func (a *AmazonBedRockClient) Configure(config IAIConfig) error {
// Initialize models if not already initialized
if a.models == nil {
a.models = defaultModels
}
// Get the model input
modelInput := config.GetModel()
// Determine the appropriate region to use
var region string
// Check if the model input is actually an inference profile ARN
if validateInferenceProfileArn(modelInput) {
// Extract the region from the inference profile ARN
arnParts := strings.Split(modelInput, ":")
if len(arnParts) >= 4 {
region = arnParts[3]
} else {
return fmt.Errorf("could not extract region from inference profile ARN: %s", modelInput)
}
} else {
// Use the provided region or default
region = GetRegionOrDefault(config.GetProviderRegion())
}
// Only create AWS clients if they haven't been injected (for testing)
if a.client == nil || a.mgmtClient == nil {
// Create a new AWS config with the determined region
cfg, err := awsconfig.LoadDefaultConfig(context.Background(),
awsconfig.WithRegion(region),
)
if err != nil {
if strings.Contains(err.Error(), "InvalidAccessKeyId") || strings.Contains(err.Error(), "SignatureDoesNotMatch") || strings.Contains(err.Error(), "NoCredentialProviders") {
return fmt.Errorf("AWS credentials are invalid or missing. Please check your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables or AWS config. Details: %v", err)
}
return fmt.Errorf("failed to load AWS config for region %s: %w", region, err)
}
// Create clients with the config
a.client = bedrockruntime.NewFromConfig(cfg)
a.mgmtClient = bedrock.NewFromConfig(cfg)
}
// Handle model selection based on input type
if validateInferenceProfileArn(modelInput) {
// Get the inference profile details
profile, err := a.getInferenceProfile(context.Background(), modelInput)
if err != nil {
return fmt.Errorf("failed to get inference profile: %v", err)
}
// Extract the model ID from the inference profile
modelID, err := a.extractModelFromInferenceProfile(profile)
if err != nil {
return fmt.Errorf("failed to extract model ID from inference profile: %v", err)
}
// Find the model configuration for the extracted model ID
foundModel, err := a.getModelFromString(modelID)
if err != nil {
// Instead of failing, use a generic config for completion/response
// But still warn user
return fmt.Errorf("failed to find model configuration for %s: %v", modelID, err)
}
// Use the found model config for completion/response, but set ModelName to the profile ARN
a.model = foundModel
a.model.Config.ModelName = modelInput
// Mark that we're using an inference profile
// (could add a field if needed)
} else {
// Regular model ID provided
foundModel, err := a.getModelFromString(modelInput)
if err != nil {
return fmt.Errorf("model '%s' is not supported: %v", modelInput, err)
}
a.model = foundModel
a.model.Config.ModelName = foundModel.Config.ModelName
}
// Set common configuration parameters
a.temperature = config.GetTemperature()
a.topP = config.GetTopP()
a.maxTokens = config.GetMaxTokens()
return nil
}
// getInferenceProfile retrieves the inference profile details from Amazon Bedrock
func (a *AmazonBedRockClient) getInferenceProfile(ctx context.Context, inferenceProfileARN string) (*bedrock.GetInferenceProfileOutput, error) {
// Extract the profile ID from the ARN
// ARN format: arn:aws:bedrock:region:account-id:inference-profile/profile-id
// or arn:aws:bedrock:region:account-id:application-inference-profile/profile-id
parts := strings.Split(inferenceProfileARN, "/")
if len(parts) != 2 {
return nil, fmt.Errorf("invalid inference profile ARN format: %s", inferenceProfileARN)
}
profileID := parts[1]
// Create the input for the GetInferenceProfile API call
input := &bedrock.GetInferenceProfileInput{
InferenceProfileIdentifier: aws.String(profileID),
}
// Call the GetInferenceProfile API
output, err := a.mgmtClient.GetInferenceProfile(ctx, input)
if err != nil {
return nil, fmt.Errorf("failed to get inference profile: %w", err)
}
return output, nil
}
// extractModelFromInferenceProfile extracts the model ID from the inference profile
func (a *AmazonBedRockClient) extractModelFromInferenceProfile(profile *bedrock.GetInferenceProfileOutput) (string, error) {
if profile == nil || len(profile.Models) == 0 {
return "", fmt.Errorf("inference profile does not contain any models")
}
// Check if the first model has a non-nil ModelArn
if profile.Models[0].ModelArn == nil {
return "", fmt.Errorf("model information is missing in inference profile")
}
// Get the first model ARN from the profile
modelARN := aws.ToString(profile.Models[0].ModelArn)
if modelARN == "" {
return "", fmt.Errorf("model ARN is empty in inference profile")
}
// Extract the model ID from the ARN
// ARN format: arn:aws:bedrock:region::foundation-model/model-id
parts := strings.Split(modelARN, "/")
if len(parts) != 2 {
return "", fmt.Errorf("invalid model ARN format: %s", modelARN)
}
modelID := parts[1]
return modelID, nil
}
// GetCompletion sends a request to the model for generating completion based on the provided prompt.
func (a *AmazonBedRockClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
// override config defaults
a.model.Config.MaxTokens = a.maxTokens
a.model.Config.Temperature = a.temperature
a.model.Config.TopP = a.topP
supportedModels := make([]string, len(a.models))
for i, m := range a.models {
supportedModels[i] = m.Name
}
// Allow valid inference profile ARNs as supported models
if !bedrock_support.IsModelSupported(a.model.Config.ModelName, supportedModels) && !validateInferenceProfileArn(a.model.Config.ModelName) {
return "", fmt.Errorf("model '%s' is not supported.\nSupported models:\n%s", a.model.Config.ModelName, func() string {
s := ""
for _, m := range supportedModels {
s += " - " + m + "\n"
}
return s
}())
}
body, err := a.model.Completion.GetCompletion(ctx, prompt, a.model.Config)
if err != nil {
return "", err
}
// Build the parameters for the model invocation
params := &bedrockruntime.InvokeModelInput{
Body: body,
ModelId: aws.String(a.model.Config.ModelName),
ContentType: aws.String("application/json"),
Accept: aws.String("application/json"),
}
// Detect if the model name is an inference profile ARN and set the header if so
var optFns []func(*bedrockruntime.Options)
if validateInferenceProfileArn(a.model.Config.ModelName) {
inferenceProfileArn := a.model.Config.ModelName
optFns = append(optFns, func(options *bedrockruntime.Options) {
options.APIOptions = append(options.APIOptions, func(stack *middleware.Stack) error {
return stack.Initialize.Add(middleware.InitializeMiddlewareFunc("InferenceProfileHeader", func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (out middleware.InitializeOutput, metadata middleware.Metadata, err error) {
req, ok := in.Parameters.(*smithyhttp.Request)
if ok {
req.Header.Set("X-Amzn-Bedrock-Inference-Profile-ARN", inferenceProfileArn)
}
return next.HandleInitialize(ctx, in)
}), middleware.Before)
})
})
}
// Invoke the model
var resp *bedrockruntime.InvokeModelOutput
if len(optFns) > 0 {
resp, err = a.client.InvokeModel(ctx, params, optFns...)
} else {
resp, err = a.client.InvokeModel(ctx, params)
}
if err != nil {
if strings.Contains(err.Error(), "InvalidAccessKeyId") || strings.Contains(err.Error(), "SignatureDoesNotMatch") || strings.Contains(err.Error(), "NoCredentialProviders") {
return "", fmt.Errorf("AWS credentials are invalid or missing. Please check your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables or AWS config. Details: %v", err)
}
return "", err
}
// Parse the response
return a.model.Response.ParseResponse(resp.Body)
}
// GetName returns the name of the AmazonBedRockClient.
func (a *AmazonBedRockClient) GetName() string {
return amazonbedrockAIClientName
}

View File

@@ -0,0 +1,103 @@
package ai
import (
"context"
"testing"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/bedrock"
"github.com/aws/aws-sdk-go-v2/service/bedrock/types"
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
"github.com/k8sgpt-ai/k8sgpt/pkg/ai/bedrock_support"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
// Mock for Bedrock Management Client
type MockBedrockClient struct {
mock.Mock
}
func (m *MockBedrockClient) GetInferenceProfile(ctx context.Context, params *bedrock.GetInferenceProfileInput, optFns ...func(*bedrock.Options)) (*bedrock.GetInferenceProfileOutput, error) {
args := m.Called(ctx, params)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*bedrock.GetInferenceProfileOutput), args.Error(1)
}
// Mock for Bedrock Runtime Client
type MockBedrockRuntimeClient struct {
mock.Mock
}
func (m *MockBedrockRuntimeClient) InvokeModel(ctx context.Context, params *bedrockruntime.InvokeModelInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error) {
args := m.Called(ctx, params)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*bedrockruntime.InvokeModelOutput), args.Error(1)
}
// TestBedrockInferenceProfileARNWithMocks tests the inference profile ARN validation with mocks
func TestBedrockInferenceProfileARNWithMocks(t *testing.T) {
// Create test models
testModels := []bedrock_support.BedrockModel{
{
Name: "anthropic.claude-3-5-sonnet-20240620-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-3-5-sonnet-20240620-v1:0",
},
},
}
// Create a client with test models
client := &AmazonBedRockClient{models: testModels}
// Create mock clients
mockMgmtClient := new(MockBedrockClient)
mockRuntimeClient := new(MockBedrockRuntimeClient)
// Inject mock clients into the AmazonBedRockClient
client.mgmtClient = mockMgmtClient
client.client = mockRuntimeClient
// Test with a valid inference profile ARN
inferenceProfileARN := "arn:aws:bedrock:us-east-1:123456789012:inference-profile/my-profile"
// Setup mock response for GetInferenceProfile
mockMgmtClient.On("GetInferenceProfile", mock.Anything, &bedrock.GetInferenceProfileInput{
InferenceProfileIdentifier: aws.String("my-profile"),
}).Return(&bedrock.GetInferenceProfileOutput{
Models: []types.InferenceProfileModel{
{
ModelArn: aws.String("arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-5-sonnet-20240620-v1:0"),
},
},
}, nil)
// Configure the client with the inference profile ARN
config := AIProvider{
Model: inferenceProfileARN,
ProviderRegion: "us-east-1",
}
// Test the Configure method with the inference profile ARN
err := client.Configure(&config)
// Verify that the configuration was successful
assert.NoError(t, err)
assert.Equal(t, inferenceProfileARN, client.model.Config.ModelName)
// Verify that the mock was called
mockMgmtClient.AssertExpectations(t)
}

View File

@@ -0,0 +1,262 @@
package ai
import (
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/ai/bedrock_support"
"github.com/stretchr/testify/assert"
)
// Test models for unit testing
var testModels = []bedrock_support.BedrockModel{
{
Name: "anthropic.claude-3-5-sonnet-20240620-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-3-5-sonnet-20240620-v1:0",
},
},
{
Name: "anthropic.claude-3-5-sonnet-20241022-v2:0",
Completion: &bedrock_support.CohereCompletion{},
Response: &bedrock_support.CohereResponse{},
Config: bedrock_support.BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-3-5-sonnet-20241022-v2:0",
},
},
{
Name: "anthropic.claude-3-7-sonnet-20250219-v1:0",
Completion: &bedrock_support.CohereCompletion{},
Response: &bedrock_support.CohereResponse{},
Config: bedrock_support.BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: "anthropic.claude-3-7-sonnet-20250219-v1:0",
},
},
}
func TestBedrockModelConfig(t *testing.T) {
client := &AmazonBedRockClient{models: testModels}
// Should return error for ARN input (no exact match)
_, err := client.getModelFromString("arn:aws:bedrock:us-east-1:*:inference-policy/anthropic.claude-3-5-sonnet-20240620-v1:0")
assert.NotNil(t, err, "Should return error for ARN input")
}
func TestBedrockInvalidModel(t *testing.T) {
client := &AmazonBedRockClient{models: testModels}
// Should return error for invalid model name
_, err := client.getModelFromString("arn:aws:s3:us-east-1:*:inference-policy/anthropic.claude-3-5-sonnet-20240620-v1:0")
assert.NotNil(t, err, "Should return error for invalid model name")
}
func TestBedrockInferenceProfileARN(t *testing.T) {
// Create a mock client with test models
client := &AmazonBedRockClient{models: testModels}
// Test with a valid inference profile ARN
inferenceProfileARN := "arn:aws:bedrock:us-east-1:123456789012:inference-profile/my-profile"
config := AIProvider{
Model: inferenceProfileARN,
ProviderRegion: "us-east-1",
}
// This will fail in a real environment without mocks, but we're just testing the validation logic
err := client.Configure(&config)
// We expect an error since we can't actually call AWS in tests
assert.NotNil(t, err, "Error should not be nil without AWS mocks")
// Test with a valid application inference profile ARN
appInferenceProfileARN := "arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/my-profile"
config = AIProvider{
Model: appInferenceProfileARN,
ProviderRegion: "us-east-1",
}
// This will fail in a real environment without mocks, but we're just testing the validation logic
err = client.Configure(&config)
// We expect an error since we can't actually call AWS in tests
assert.NotNil(t, err, "Error should not be nil without AWS mocks")
// Test with an invalid inference profile ARN format
invalidARN := "arn:aws:bedrock:us-east-1:123456789012:invalid-resource/my-profile"
config = AIProvider{
Model: invalidARN,
ProviderRegion: "us-east-1",
}
err = client.Configure(&config)
assert.NotNil(t, err, "Error should not be nil for invalid inference profile ARN format")
}
func TestBedrockGetCompletionInferenceProfile(t *testing.T) {
modelName := "arn:aws:bedrock:us-east-1:*:inference-policy/anthropic.claude-3-5-sonnet-20240620-v1:0"
var inferenceModelModels = []bedrock_support.BedrockModel{
{
Name: "anthropic.claude-3-5-sonnet-20240620-v1:0",
Completion: &bedrock_support.CohereMessagesCompletion{},
Response: &bedrock_support.CohereMessagesResponse{},
Config: bedrock_support.BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.5,
TopP: 0.9,
ModelName: modelName,
},
},
}
client := &AmazonBedRockClient{models: inferenceModelModels}
config := AIProvider{
Model: modelName,
}
err := client.Configure(&config)
assert.Nil(t, err, "Error should be nil")
assert.Equal(t, modelName, client.model.Config.ModelName, "Model name should match")
}
func TestGetModelFromString(t *testing.T) {
client := &AmazonBedRockClient{models: testModels}
tests := []struct {
name string
model string
wantModel string
wantErr bool
}{
{
name: "exact model name match",
model: "anthropic.claude-3-5-sonnet-20240620-v1:0",
wantModel: "anthropic.claude-3-5-sonnet-20240620-v1:0",
wantErr: false,
},
{
name: "partial model name match",
model: "claude-3-5-sonnet",
wantModel: "anthropic.claude-3-5-sonnet-20240620-v1:0",
wantErr: true,
},
{
name: "model name with different version",
model: "anthropic.claude-3-5-sonnet-20241022-v2:0",
wantModel: "anthropic.claude-3-5-sonnet-20241022-v2:0",
wantErr: false,
},
{
name: "non-existent model",
model: "non-existent-model",
wantModel: "",
wantErr: true,
},
{
name: "empty model name",
model: "",
wantModel: "",
wantErr: true,
},
{
name: "model name with extra spaces",
model: " anthropic.claude-3-5-sonnet-20240620-v1:0 ",
wantModel: "anthropic.claude-3-5-sonnet-20240620-v1:0",
wantErr: false,
},
{
name: "case insensitive match",
model: "ANTHROPIC.CLAUDE-3-5-SONNET-20240620-V1:0",
wantModel: "anthropic.claude-3-5-sonnet-20240620-v1:0",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotModel, err := client.getModelFromString(tt.model)
if (err != nil) != tt.wantErr {
t.Errorf("getModelFromString() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !tt.wantErr && gotModel.Name != tt.wantModel {
t.Errorf("getModelFromString() = %v, want %v", gotModel.Name, tt.wantModel)
}
})
}
}
// TestDefaultModels tests that the client works with default models
func TestDefaultModels(t *testing.T) {
client := &AmazonBedRockClient{}
// Configure should initialize default models
err := client.Configure(&AIProvider{
Model: "anthropic.claude-v2",
})
assert.NoError(t, err, "Configure should not return an error")
assert.NotNil(t, client.models, "Models should be initialized")
assert.NotEmpty(t, client.models, "Models should not be empty")
// Test finding a default model
model, err := client.getModelFromString("anthropic.claude-v2")
assert.NoError(t, err, "Should find the model")
assert.Equal(t, "anthropic.claude-v2", model.Name, "Should find the correct model")
}
func TestValidateInferenceProfileArn(t *testing.T) {
tests := []struct {
name string
arn string
valid bool
}{
{
name: "valid inference profile ARN",
arn: "arn:aws:bedrock:us-east-1:123456789012:inference-profile/my-profile",
valid: true,
},
{
name: "valid application inference profile ARN",
arn: "arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/my-profile",
valid: true,
},
{
name: "invalid service in ARN",
arn: "arn:aws:s3:us-east-1:123456789012:inference-profile/my-profile",
valid: false,
},
{
name: "invalid resource type in ARN",
arn: "arn:aws:bedrock:us-east-1:123456789012:model/my-profile",
valid: false,
},
{
name: "malformed ARN",
arn: "arn:aws:bedrock:us-east-1:inference-profile/my-profile",
valid: false,
},
{
name: "not an ARN",
arn: "not-an-arn",
valid: false,
},
{
name: "empty string",
arn: "",
valid: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := validateInferenceProfileArn(tt.arn)
assert.Equal(t, tt.valid, result, "validateInferenceProfileArn() result should match expected")
})
}
}

141
pkg/ai/amazonsagemaker.go Normal file
View File

@@ -0,0 +1,141 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"context"
"encoding/json"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sagemakerruntime"
)
const amazonsagemakerAIClientName = "amazonsagemaker"
type SageMakerAIClient struct {
nopCloser
client *sagemakerruntime.SageMakerRuntime
model string
temperature float32
endpoint string
topP float32
topK int32
maxTokens int
}
type Generations []struct {
Generation struct {
Role string `json:"role"`
Content string `json:"content"`
} `json:"generation"`
}
type Request struct {
Inputs [][]Message `json:"inputs"`
Parameters Parameters `json:"parameters"`
}
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
}
type Parameters struct {
MaxNewTokens int `json:"max_new_tokens"`
TopP float64 `json:"top_p"`
TopK float64 `json:"top_k"`
Temperature float64 `json:"temperature"`
}
func (c *SageMakerAIClient) Configure(config IAIConfig) error {
// Create a new AWS session
sess := session.Must(session.NewSessionWithOptions(session.Options{
Config: aws.Config{Region: aws.String(config.GetProviderRegion())},
SharedConfigState: session.SharedConfigEnable,
}))
// Create a new SageMaker runtime client
c.client = sagemakerruntime.New(sess)
c.model = config.GetModel()
c.endpoint = config.GetEndpointName()
c.temperature = config.GetTemperature()
c.maxTokens = config.GetMaxTokens()
c.topP = config.GetTopP()
c.topK = config.GetTopK()
return nil
}
func (c *SageMakerAIClient) GetCompletion(_ context.Context, prompt string) (string, error) {
// Create a completion request
request := Request{
Inputs: [][]Message{
{
{Role: "system", Content: "DEFAULT_PROMPT"},
{Role: "user", Content: prompt},
},
},
Parameters: Parameters{
MaxNewTokens: int(c.maxTokens),
TopP: float64(c.topP),
TopK: float64(c.topK),
Temperature: float64(c.temperature),
},
}
// Convert request to []byte
bytesData, err := json.Marshal(request)
if err != nil {
return "", err
}
// Create an input object
input := &sagemakerruntime.InvokeEndpointInput{
Body: bytesData,
EndpointName: aws.String(c.endpoint),
ContentType: aws.String("application/json"), // Set the content type as per your model's requirements
Accept: aws.String("application/json"), // Set the accept type as per your model's requirements
CustomAttributes: aws.String("accept_eula=true"),
}
// Call the InvokeEndpoint function
result, err := c.client.InvokeEndpoint(input)
if err != nil {
return "", err
}
// // Define a slice of Generations
var generations Generations
err = json.Unmarshal([]byte(string(result.Body)), &generations)
if err != nil {
return "", err
}
// Check for length of generations
if len(generations) != 1 {
return "", fmt.Errorf("Expected exactly one generation, but got %d", len(generations))
}
// Access the content
content := generations[0].Generation.Content
return content, nil
}
func (c *SageMakerAIClient) GetName() string {
return amazonsagemakerAIClientName
}

View File

@@ -2,50 +2,79 @@ package ai
import (
"context"
"encoding/base64"
"errors"
"fmt"
"strings"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
"github.com/fatih/color"
"net/http"
"net/url"
"github.com/sashabaranov/go-openai"
)
const azureAIClientName = "azureopenai"
type AzureAIClient struct {
client *openai.Client
language string
model string
nopCloser
client *openai.Client
model string
temperature float32
// organizationId string
}
func (c *AzureAIClient) Configure(config IAIConfig, lang string) error {
func (c *AzureAIClient) Configure(config IAIConfig) error {
token := config.GetPassword()
baseURL := config.GetBaseURL()
engine := config.GetEngine()
defaultConfig := openai.DefaultAzureConfig(token, baseURL, engine)
proxyEndpoint := config.GetProxyEndpoint()
defaultConfig := openai.DefaultAzureConfig(token, baseURL)
orgId := config.GetOrganizationId()
defaultConfig.AzureModelMapperFunc = func(model string) string {
// If you use a deployment name different from the model name, you can customize the AzureModelMapperFunc function
azureModelMapping := map[string]string{
model: engine,
}
return azureModelMapping[model]
}
if proxyEndpoint != "" {
proxyUrl, err := url.Parse(proxyEndpoint)
if err != nil {
return err
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
}
defaultConfig.HTTPClient = &http.Client{
Transport: transport,
}
}
if orgId != "" {
defaultConfig.OrgID = orgId
}
client := openai.NewClientWithConfig(defaultConfig)
if client == nil {
return errors.New("error creating Azure OpenAI client")
}
c.language = lang
c.client = client
c.model = config.GetModel()
c.temperature = config.GetTemperature()
return nil
}
func (c *AzureAIClient) GetCompletion(ctx context.Context, prompt string, promptTmpl string) (string, error) {
func (c *AzureAIClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
// Create a completion request
resp, err := c.client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
Model: c.model,
Messages: []openai.ChatCompletionMessage{
{
Role: "user",
Content: fmt.Sprintf(default_prompt, c.language, prompt),
Role: openai.ChatMessageRoleUser,
Content: prompt,
},
},
Temperature: c.temperature,
})
if err != nil {
return "", err
@@ -53,42 +82,6 @@ func (c *AzureAIClient) GetCompletion(ctx context.Context, prompt string, prompt
return resp.Choices[0].Message.Content, nil
}
func (a *AzureAIClient) Parse(ctx context.Context, prompt []string, cache cache.ICache, promptTmpl string) (string, error) {
inputKey := strings.Join(prompt, " ")
// Check for cached data
cacheKey := util.GetCacheKey(a.GetName(), a.language, inputKey)
if !cache.IsCacheDisabled() && cache.Exists(cacheKey) {
response, err := cache.Load(cacheKey)
if err != nil {
return "", err
}
if response != "" {
output, err := base64.StdEncoding.DecodeString(response)
if err != nil {
color.Red("error decoding cached data: %v", err)
return "", nil
}
return string(output), nil
}
}
response, err := a.GetCompletion(ctx, inputKey, promptTmpl)
if err != nil {
return "", err
}
err = cache.Store(cacheKey, base64.StdEncoding.EncodeToString([]byte(response)))
if err != nil {
color.Red("error storing value to cache: %v", err)
return "", nil
}
return response, nil
}
func (a *AzureAIClient) GetName() string {
return "azureopenai"
func (c *AzureAIClient) GetName() string {
return azureAIClientName
}

View File

@@ -0,0 +1,18 @@
package ai
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/bedrock"
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
)
// BedrockManagementAPI defines the interface for Bedrock management operations
type BedrockManagementAPI interface {
GetInferenceProfile(ctx context.Context, params *bedrock.GetInferenceProfileInput, optFns ...func(*bedrock.Options)) (*bedrock.GetInferenceProfileOutput, error)
}
// BedrockRuntimeAPI defines the interface for Bedrock runtime operations
type BedrockRuntimeAPI interface {
InvokeModel(ctx context.Context, params *bedrockruntime.InvokeModelInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error)
}

View File

@@ -0,0 +1,140 @@
package bedrock_support
import (
"context"
"encoding/json"
"fmt"
"strings"
)
type ICompletion interface {
GetCompletion(ctx context.Context, prompt string, modelConfig BedrockModelConfig) ([]byte, error)
}
type CohereCompletion struct {
completion ICompletion
}
func (a *CohereCompletion) GetCompletion(ctx context.Context, prompt string, modelConfig BedrockModelConfig) ([]byte, error) {
request := map[string]interface{}{
"prompt": fmt.Sprintf("\n\nHuman: %s \n\nAssistant:", prompt),
"max_tokens_to_sample": modelConfig.MaxTokens,
"temperature": modelConfig.Temperature,
"top_p": modelConfig.TopP,
}
body, err := json.Marshal(request)
if err != nil {
return []byte{}, err
}
return body, nil
}
type CohereMessagesCompletion struct {
completion ICompletion
}
func (a *CohereMessagesCompletion) GetCompletion(ctx context.Context, prompt string, modelConfig BedrockModelConfig) ([]byte, error) {
request := map[string]interface{}{
"max_tokens": modelConfig.MaxTokens,
"temperature": modelConfig.Temperature,
"top_p": modelConfig.TopP,
"anthropic_version": "bedrock-2023-05-31", // Or another valid version
"messages": []map[string]interface{}{
{
"role": "user",
"content": prompt,
},
},
}
body, err := json.Marshal(request)
if err != nil {
return []byte{}, err
}
return body, nil
}
type AI21 struct {
completion ICompletion
}
func (a *AI21) GetCompletion(ctx context.Context, prompt string, modelConfig BedrockModelConfig) ([]byte, error) {
request := map[string]interface{}{
"prompt": prompt,
"maxTokens": modelConfig.MaxTokens,
"temperature": modelConfig.Temperature,
"topP": modelConfig.TopP,
}
body, err := json.Marshal(request)
if err != nil {
return []byte{}, err
}
return body, nil
}
type AmazonCompletion struct {
completion ICompletion
}
// Accepts a list of supported model names
func IsModelSupported(modelName string, supportedModels []string) bool {
for _, supportedModel := range supportedModels {
if strings.EqualFold(modelName, supportedModel) {
return true
}
}
return false
}
// Note: The caller should check model support before calling GetCompletion.
func (a *AmazonCompletion) GetCompletion(ctx context.Context, prompt string, modelConfig BedrockModelConfig) ([]byte, error) {
if a == nil || modelConfig.ModelName == "" {
return nil, fmt.Errorf("no model name provided to Bedrock completion")
}
if strings.Contains(modelConfig.ModelName, "nova") {
return a.GetNovaCompletion(ctx, prompt, modelConfig)
} else {
return a.GetDefaultCompletion(ctx, prompt, modelConfig)
}
}
func (a *AmazonCompletion) GetDefaultCompletion(ctx context.Context, prompt string, modelConfig BedrockModelConfig) ([]byte, error) {
request := map[string]interface{}{
"inputText": fmt.Sprintf("\n\nUser: %s", prompt),
"textGenerationConfig": map[string]interface{}{
"maxTokenCount": modelConfig.MaxTokens,
"temperature": modelConfig.Temperature,
"topP": modelConfig.TopP,
},
}
body, err := json.Marshal(request)
if err != nil {
return []byte{}, err
}
return body, nil
}
func (a *AmazonCompletion) GetNovaCompletion(ctx context.Context, prompt string, modelConfig BedrockModelConfig) ([]byte, error) {
request := map[string]interface{}{
"inferenceConfig": map[string]interface{}{
"max_new_tokens": modelConfig.MaxTokens,
"temperature": modelConfig.Temperature,
"topP": modelConfig.TopP,
},
"messages": []map[string]interface{}{
{
"role": "user",
"content": []map[string]interface{}{
{
"text": prompt,
},
},
},
},
}
body, err := json.Marshal(request)
if err != nil {
return []byte{}, err
}
return body, nil
}

View File

@@ -0,0 +1,182 @@
package bedrock_support
import (
"context"
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCohereCompletion_GetCompletion(t *testing.T) {
completion := &CohereCompletion{}
modelConfig := BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.7,
TopP: 0.9,
}
prompt := "Test prompt"
body, err := completion.GetCompletion(context.Background(), prompt, modelConfig)
assert.NoError(t, err)
var request map[string]interface{}
err = json.Unmarshal(body, &request)
assert.NoError(t, err)
assert.Equal(t, "\n\nHuman: Test prompt \n\nAssistant:", request["prompt"])
assert.Equal(t, 100, int(request["max_tokens_to_sample"].(float64)))
assert.Equal(t, 0.7, request["temperature"])
assert.Equal(t, 0.9, request["top_p"])
}
func TestAI21_GetCompletion(t *testing.T) {
completion := &AI21{}
modelConfig := BedrockModelConfig{
MaxTokens: 150,
Temperature: 0.6,
TopP: 0.8,
}
prompt := "Another test prompt"
body, err := completion.GetCompletion(context.Background(), prompt, modelConfig)
assert.NoError(t, err)
var request map[string]interface{}
err = json.Unmarshal(body, &request)
assert.NoError(t, err)
assert.Equal(t, "Another test prompt", request["prompt"])
assert.Equal(t, 150, int(request["maxTokens"].(float64)))
assert.Equal(t, 0.6, request["temperature"])
assert.Equal(t, 0.8, request["topP"])
}
func TestAmazonCompletion_GetDefaultCompletion(t *testing.T) {
completion := &AmazonCompletion{}
modelConfig := BedrockModelConfig{
MaxTokens: 200,
Temperature: 0.5,
TopP: 0.7,
ModelName: "amazon.titan-text-express-v1",
}
prompt := "Default test prompt"
body, err := completion.GetDefaultCompletion(context.Background(), prompt, modelConfig)
assert.NoError(t, err)
var request map[string]interface{}
err = json.Unmarshal(body, &request)
assert.NoError(t, err)
assert.Equal(t, "\n\nUser: Default test prompt", request["inputText"])
textConfig := request["textGenerationConfig"].(map[string]interface{})
assert.Equal(t, 200, int(textConfig["maxTokenCount"].(float64)))
assert.Equal(t, 0.5, textConfig["temperature"])
assert.Equal(t, 0.7, textConfig["topP"])
}
func TestAmazonCompletion_GetNovaCompletion(t *testing.T) {
completion := &AmazonCompletion{}
modelConfig := BedrockModelConfig{
MaxTokens: 250,
Temperature: 0.4,
TopP: 0.6,
ModelName: "amazon.nova-pro-v1:0",
}
prompt := "Nova test prompt"
body, err := completion.GetNovaCompletion(context.Background(), prompt, modelConfig)
assert.NoError(t, err)
var request map[string]interface{}
err = json.Unmarshal(body, &request)
assert.NoError(t, err)
inferenceConfig := request["inferenceConfig"].(map[string]interface{})
assert.Equal(t, 250, int(inferenceConfig["max_new_tokens"].(float64)))
assert.Equal(t, 0.4, inferenceConfig["temperature"])
assert.Equal(t, 0.6, inferenceConfig["topP"])
messages := request["messages"].([]interface{})
message := messages[0].(map[string]interface{})
content := message["content"].([]interface{})
contentMap := content[0].(map[string]interface{})
assert.Equal(t, "Nova test prompt", contentMap["text"])
}
func TestAmazonCompletion_GetCompletion_Nova(t *testing.T) {
completion := &AmazonCompletion{}
modelConfig := BedrockModelConfig{
MaxTokens: 250,
Temperature: 0.4,
TopP: 0.6,
ModelName: "amazon.nova-pro-v1:0",
}
prompt := "Nova test prompt"
body, err := completion.GetCompletion(context.Background(), prompt, modelConfig)
assert.NoError(t, err)
var request map[string]interface{}
err = json.Unmarshal(body, &request)
assert.NoError(t, err)
inferenceConfig := request["inferenceConfig"].(map[string]interface{})
assert.Equal(t, 250, int(inferenceConfig["max_new_tokens"].(float64)))
assert.Equal(t, 0.4, inferenceConfig["temperature"])
assert.Equal(t, 0.6, inferenceConfig["topP"])
messages := request["messages"].([]interface{})
message := messages[0].(map[string]interface{})
content := message["content"].([]interface{})
contentMap := content[0].(map[string]interface{})
assert.Equal(t, "Nova test prompt", contentMap["text"])
}
func TestAmazonCompletion_GetCompletion_Default(t *testing.T) {
completion := &AmazonCompletion{}
modelConfig := BedrockModelConfig{
MaxTokens: 200,
Temperature: 0.5,
TopP: 0.7,
ModelName: "amazon.titan-text-express-v1",
}
prompt := "Default test prompt"
body, err := completion.GetCompletion(context.Background(), prompt, modelConfig)
assert.NoError(t, err)
var request map[string]interface{}
err = json.Unmarshal(body, &request)
assert.NoError(t, err)
assert.Equal(t, "\n\nUser: Default test prompt", request["inputText"])
textConfig := request["textGenerationConfig"].(map[string]interface{})
assert.Equal(t, 200, int(textConfig["maxTokenCount"].(float64)))
assert.Equal(t, 0.5, textConfig["temperature"])
assert.Equal(t, 0.7, textConfig["topP"])
}
func TestAmazonCompletion_GetCompletion_Inference_Profile(t *testing.T) {
completion := &AmazonCompletion{}
modelConfig := BedrockModelConfig{
MaxTokens: 200,
Temperature: 0.5,
TopP: 0.7,
ModelName: "arn:aws:bedrock:us-east-1:*:inference-policy/anthropic.claude-3-5-sonnet-20240620-v1:0",
}
prompt := "Test prompt"
_, err := completion.GetCompletion(context.Background(), prompt, modelConfig)
assert.NoError(t, err)
}
func TestIsModelSupported(t *testing.T) {
supported := []string{
"anthropic.claude-v2",
"anthropic.claude-v1",
}
assert.True(t, IsModelSupported("anthropic.claude-v2", supported))
assert.False(t, IsModelSupported("unsupported-model", supported))
}

View File

@@ -0,0 +1,14 @@
package bedrock_support
type BedrockModelConfig struct {
MaxTokens int
Temperature float32
TopP float32
ModelName string
}
type BedrockModel struct {
Name string
Completion ICompletion
Response IResponse
Config BedrockModelConfig
}

View File

@@ -0,0 +1,59 @@
package bedrock_support
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBedrockModelConfig(t *testing.T) {
config := BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.7,
TopP: 0.9,
ModelName: "test-model",
}
assert.Equal(t, 100, config.MaxTokens)
assert.Equal(t, float32(0.7), config.Temperature)
assert.Equal(t, float32(0.9), config.TopP)
assert.Equal(t, "test-model", config.ModelName)
}
func TestBedrockModel(t *testing.T) {
completion := &MockCompletion{}
response := &MockResponse{}
config := BedrockModelConfig{
MaxTokens: 100,
Temperature: 0.7,
TopP: 0.9,
ModelName: "test-model",
}
model := BedrockModel{
Name: "Test Model",
Completion: completion,
Response: response,
Config: config,
}
assert.Equal(t, "Test Model", model.Name)
assert.Equal(t, completion, model.Completion)
assert.Equal(t, response, model.Response)
assert.Equal(t, config, model.Config)
}
// MockCompletion is a mock implementation of the ICompletion interface
type MockCompletion struct{}
func (m *MockCompletion) GetCompletion(ctx context.Context, prompt string, config BedrockModelConfig) ([]byte, error) {
return []byte(`{"prompt": "mock prompt"}`), nil
}
// MockResponse is a mock implementation of the IResponse interface
type MockResponse struct{}
func (m *MockResponse) ParseResponse(body []byte) (string, error) {
return "mock response", nil
}

View File

@@ -0,0 +1,155 @@
package bedrock_support
import (
"encoding/json"
)
type IResponse interface {
ParseResponse(rawResponse []byte) (string, error)
}
type CohereMessagesResponse struct {
response IResponse
}
func (a *CohereMessagesResponse) ParseResponse(rawResponse []byte) (string, error) {
type InvokeModelResponseBody struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Model string `json:"model"`
Content []struct {
Type string `json:"type"`
Text string `json:"text"`
} `json:"content"`
StopReason string `json:"stop_reason"`
StopSequence interface{} `json:"stop_sequence"` // Could be null
Usage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
} `json:"usage"`
}
output := &InvokeModelResponseBody{}
err := json.Unmarshal(rawResponse, output)
if err != nil {
return "", err
}
// Extract the text content from the Content array
var resultText string
for _, content := range output.Content {
if content.Type == "text" {
resultText += content.Text
}
}
return resultText, nil
}
type CohereResponse struct {
response IResponse
}
func (a *CohereResponse) ParseResponse(rawResponse []byte) (string, error) {
type InvokeModelResponseBody struct {
Completion string `json:"completion"`
Stop_reason string `json:"stop_reason"`
}
output := &InvokeModelResponseBody{}
err := json.Unmarshal(rawResponse, output)
if err != nil {
return "", err
}
return output.Completion, nil
}
type AI21Response struct {
response IResponse
}
func (a *AI21Response) ParseResponse(rawResponse []byte) (string, error) {
type Data struct {
Text string `json:"text"`
}
type Completion struct {
Data Data `json:"data"`
}
type InvokeModelResponseBody struct {
Completions []Completion `json:"completions"`
}
output := &InvokeModelResponseBody{}
err := json.Unmarshal(rawResponse, output)
if err != nil {
return "", err
}
return output.Completions[0].Data.Text, nil
}
type AmazonResponse struct {
response IResponse
}
type NovaResponse struct {
response NResponse
}
type NResponse interface {
ParseResponse(rawResponse []byte) (string, error)
}
func (a *AmazonResponse) ParseResponse(rawResponse []byte) (string, error) {
type Result struct {
TokenCount int `json:"tokenCount"`
OutputText string `json:"outputText"`
CompletionReason string `json:"completionReason"`
}
type InvokeModelResponseBody struct {
InputTextTokenCount int `json:"inputTextTokenCount"`
Results []Result `json:"results"`
}
output := &InvokeModelResponseBody{}
err := json.Unmarshal(rawResponse, output)
if err != nil {
return "", err
}
return output.Results[0].OutputText, nil
}
func (a *NovaResponse) ParseResponse(rawResponse []byte) (string, error) {
type Content struct {
Text string `json:"text"`
}
type Message struct {
Role string `json:"role"`
Content []Content `json:"content"`
}
type UsageDetails struct {
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
TotalTokens int `json:"totalTokens"`
CacheReadInputTokenCount int `json:"cacheReadInputTokenCount"`
CacheWriteInputTokenCount int `json:"cacheWriteInputTokenCount,omitempty"`
}
type AmazonNovaResponse struct {
Output struct {
Message Message `json:"message"`
} `json:"output"`
StopReason string `json:"stopReason"`
Usage UsageDetails `json:"usage"`
}
response := &AmazonNovaResponse{}
err := json.Unmarshal(rawResponse, response)
if err != nil {
return "", err
}
if len(response.Output.Message.Content) > 0 {
return response.Output.Message.Content[0].Text, nil
}
return "", nil
}

View File

@@ -0,0 +1,65 @@
package bedrock_support
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCohereResponse_ParseResponse(t *testing.T) {
response := &CohereResponse{}
rawResponse := []byte(`{"completion": "Test completion", "stop_reason": "max_tokens"}`)
result, err := response.ParseResponse(rawResponse)
assert.NoError(t, err)
assert.Equal(t, "Test completion", result)
invalidResponse := []byte(`{"completion": "Test completion", "invalid_json":]`)
_, err = response.ParseResponse(invalidResponse)
assert.Error(t, err)
}
func TestAI21Response_ParseResponse(t *testing.T) {
response := &AI21Response{}
rawResponse := []byte(`{"completions": [{"data": {"text": "AI21 test"}}], "id": "123"}`)
result, err := response.ParseResponse(rawResponse)
assert.NoError(t, err)
assert.Equal(t, "AI21 test", result)
invalidResponse := []byte(`{"completions": [{"data": {"text": "AI21 test"}}, "invalid_json":]`)
_, err = response.ParseResponse(invalidResponse)
assert.Error(t, err)
}
func TestAmazonResponse_ParseResponse(t *testing.T) {
response := &AmazonResponse{}
rawResponse := []byte(`{"inputTextTokenCount": 10, "results": [{"tokenCount": 20, "outputText": "Amazon test", "completionReason": "stop"}]}`)
result, err := response.ParseResponse(rawResponse)
assert.NoError(t, err)
assert.Equal(t, "Amazon test", result)
invalidResponse := []byte(`{"inputTextTokenCount": 10, "results": [{"tokenCount": 20, "outputText": "Amazon test", "invalid_json":]`)
_, err = response.ParseResponse(invalidResponse)
assert.Error(t, err)
}
func TestNovaResponse_ParseResponse(t *testing.T) {
response := &NovaResponse{}
rawResponse := []byte(`{"output": {"message": {"content": [{"text": "Nova test"}]}}, "stopReason": "stop", "usage": {"inputTokens": 10, "outputTokens": 20, "totalTokens": 30, "cacheReadInputTokenCount": 5}}`)
result, err := response.ParseResponse(rawResponse)
assert.NoError(t, err)
assert.Equal(t, "Nova test", result)
rawResponseEmptyContent := []byte(`{"output": {"message": {"content": []}}, "stopReason": "stop", "usage": {"inputTokens": 10, "outputTokens": 20, "totalTokens": 30, "cacheReadInputTokenCount": 5}}`)
resultEmptyContent, errEmptyContent := response.ParseResponse(rawResponseEmptyContent)
assert.NoError(t, errEmptyContent)
assert.Equal(t, "", resultEmptyContent)
invalidResponse := []byte(`{"output": {"message": {"content": [{"text": "Nova test"}}, "invalid_json":]`)
_, err = response.ParseResponse(invalidResponse)
assert.Error(t, err)
}

80
pkg/ai/cohere.go Normal file
View File

@@ -0,0 +1,80 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"context"
"errors"
api "github.com/cohere-ai/cohere-go/v2"
cohere "github.com/cohere-ai/cohere-go/v2/client"
"github.com/cohere-ai/cohere-go/v2/option"
)
const cohereAIClientName = "cohere"
type CohereClient struct {
nopCloser
client *cohere.Client
model string
temperature float32
maxTokens int
}
func (c *CohereClient) Configure(config IAIConfig) error {
token := config.GetPassword()
opts := []option.RequestOption{
cohere.WithToken(token),
}
baseURL := config.GetBaseURL()
if baseURL != "" {
opts = append(opts, cohere.WithBaseURL(baseURL))
}
client := cohere.NewClient(opts...)
if client == nil {
return errors.New("error creating Cohere client")
}
c.client = client
c.model = config.GetModel()
c.temperature = config.GetTemperature()
c.maxTokens = config.GetMaxTokens()
return nil
}
func (c *CohereClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
// Create a completion request
response, err := c.client.Chat(ctx, &api.ChatRequest{
Message: prompt,
Model: &c.model,
K: api.Int(0),
Preamble: api.String(""),
Temperature: api.Float64(float64(c.temperature)),
RawPrompting: api.Bool(false),
MaxTokens: api.Int(c.maxTokens),
})
if err != nil {
return "", err
}
return response.Text, nil
}
func (c *CohereClient) GetName() string {
return cohereAIClientName
}

147
pkg/ai/customrest.go Normal file
View File

@@ -0,0 +1,147 @@
package ai
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
)
const CustomRestClientName = "customrest"
type CustomRestClient struct {
nopCloser
client *http.Client
base *url.URL
token string
model string
temperature float32
topP float32
topK int32
}
type CustomRestRequest struct {
Model string `json:"model"`
// Prompt is the textual prompt to send to the model.
Prompt string `json:"prompt"`
// Options lists model-specific options. For example, temperature can be
// set through this field, if the model supports it.
Options map[string]interface{} `json:"options"`
}
type CustomRestResponse struct {
// Model is the model name that generated the response.
Model string `json:"model"`
// CreatedAt is the timestamp of the response.
CreatedAt time.Time `json:"created_at"`
// Response is the textual response itself.
Response string `json:"response"`
}
func (c *CustomRestClient) Configure(config IAIConfig) error {
baseURL := config.GetBaseURL()
if baseURL == "" {
baseURL = defaultBaseURL
}
c.token = config.GetPassword()
baseClientURL, err := url.Parse(baseURL)
if err != nil {
return err
}
c.base = baseClientURL
proxyEndpoint := config.GetProxyEndpoint()
c.client = http.DefaultClient
if proxyEndpoint != "" {
proxyUrl, err := url.Parse(proxyEndpoint)
if err != nil {
return err
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
}
c.client = &http.Client{
Transport: transport,
}
}
c.model = config.GetModel()
if c.model == "" {
c.model = defaultModel
}
c.temperature = config.GetTemperature()
c.topP = config.GetTopP()
c.topK = config.GetTopK()
return nil
}
func (c *CustomRestClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
var promptDetail struct {
Language string `json:"language,omitempty"`
Message string `json:"message"`
Prompt string `json:"prompt,omitempty"`
}
prompt = strings.NewReplacer("\n", "\\n", "\t", "\\t").Replace(prompt)
if err := json.Unmarshal([]byte(prompt), &promptDetail); err != nil {
return "", err
}
generateRequest := &CustomRestRequest{
Model: c.model,
Prompt: promptDetail.Prompt,
Options: map[string]interface{}{
"temperature": c.temperature,
"top_p": c.topP,
"top_k": c.topK,
"message": promptDetail.Message,
"language": promptDetail.Language,
},
}
requestBody, err := json.Marshal(generateRequest)
if err != nil {
return "", err
}
request, err := http.NewRequestWithContext(ctx, http.MethodPost, c.base.String(), bytes.NewBuffer(requestBody))
if err != nil {
return "", err
}
if c.token != "" {
request.Header.Set("Authorization", "Bearer "+c.token)
}
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Accept", "application/x-ndjson")
response, err := c.client.Do(request)
if err != nil {
return "", err
}
defer response.Body.Close()
responseBody, err := io.ReadAll(response.Body)
if err != nil {
return "", fmt.Errorf("could not read response body: %w", err)
}
if response.StatusCode >= http.StatusBadRequest {
return "", fmt.Errorf("Request Error, StatusCode: %d, ErrorMessage: %s", response.StatusCode, responseBody)
}
var result CustomRestResponse
if err := json.Unmarshal(responseBody, &result); err != nil {
return "", err
}
return result.Response, nil
}
func (c *CustomRestClient) GetName() string {
return CustomRestClientName
}

87
pkg/ai/factory.go Normal file
View File

@@ -0,0 +1,87 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"github.com/spf13/viper"
)
// AIClientFactory is an interface for creating AI clients
type AIClientFactory interface {
NewClient(provider string) IAI
}
// DefaultAIClientFactory is the default implementation of AIClientFactory
type DefaultAIClientFactory struct{}
// NewClient creates a new AI client using the default implementation
func (f *DefaultAIClientFactory) NewClient(provider string) IAI {
return NewClient(provider)
}
// ConfigProvider is an interface for accessing configuration
type ConfigProvider interface {
UnmarshalKey(key string, rawVal interface{}) error
}
// ViperConfigProvider is the default implementation of ConfigProvider using Viper
type ViperConfigProvider struct{}
// UnmarshalKey unmarshals a key from the configuration using Viper
func (p *ViperConfigProvider) UnmarshalKey(key string, rawVal interface{}) error {
return viper.UnmarshalKey(key, rawVal)
}
// Default instances to be used
var (
DefaultClientFactory = &DefaultAIClientFactory{}
DefaultConfigProvider = &ViperConfigProvider{}
)
// For testing - these variables can be overridden in tests
var (
testAIClientFactory AIClientFactory = nil
testConfigProvider ConfigProvider = nil
)
// GetAIClientFactory returns the test factory if set, otherwise the default
func GetAIClientFactory() AIClientFactory {
if testAIClientFactory != nil {
return testAIClientFactory
}
return DefaultClientFactory
}
// GetConfigProvider returns the test provider if set, otherwise the default
func GetConfigProvider() ConfigProvider {
if testConfigProvider != nil {
return testConfigProvider
}
return DefaultConfigProvider
}
// For testing - set the test implementations
func SetTestAIClientFactory(factory AIClientFactory) {
testAIClientFactory = factory
}
func SetTestConfigProvider(provider ConfigProvider) {
testConfigProvider = provider
}
// Reset test implementations
func ResetTestImplementations() {
testAIClientFactory = nil
testConfigProvider = nil
}

122
pkg/ai/googlegenai.go Normal file
View File

@@ -0,0 +1,122 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"context"
"errors"
"fmt"
"github.com/fatih/color"
"github.com/google/generative-ai-go/genai"
"google.golang.org/api/option"
)
const googleAIClientName = "google"
type GoogleGenAIClient struct {
client *genai.Client
model string
temperature float32
topP float32
topK int32
maxTokens int
}
func (c *GoogleGenAIClient) Configure(config IAIConfig) error {
ctx := context.Background()
// Access your API key as an environment variable (see "Set up your API key" above)
token := config.GetPassword()
authOption := option.WithAPIKey(token)
if token[0] == '{' {
authOption = option.WithCredentialsJSON([]byte(token))
}
client, err := genai.NewClient(ctx, authOption)
if err != nil {
return fmt.Errorf("creating genai Google SDK client: %w", err)
}
c.client = client
c.model = config.GetModel()
c.temperature = config.GetTemperature()
c.topP = config.GetTopP()
c.topK = config.GetTopK()
c.maxTokens = config.GetMaxTokens()
return nil
}
func (c *GoogleGenAIClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
// Available models are at https://ai.google.dev/models e.g.gemini-pro.
model := c.client.GenerativeModel(c.model)
model.SetTemperature(c.temperature)
model.SetTopP(c.topP)
model.SetTopK(c.topK)
model.SetMaxOutputTokens(int32(c.maxTokens))
// Google AI SDK is capable of different inputs than just text, for now set explicit text prompt type.
// Similarly, we could stream the response. For now k8sgpt does not support streaming.
resp, err := model.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
return "", err
}
if len(resp.Candidates) == 0 {
if resp.PromptFeedback.BlockReason == genai.BlockReasonSafety {
for _, r := range resp.PromptFeedback.SafetyRatings {
if !r.Blocked {
continue
}
return "", fmt.Errorf("completion blocked due to %v with probability %v", r.Category.String(), r.Probability.String())
}
}
return "", errors.New("no completion returned; unknown reason")
}
// Format output.
// TODO(bwplotka): Provider richer output in certain cases e.g. suddenly finished
// completion based on finish reasons or safety rankings.
got := resp.Candidates[0]
var output string
for _, part := range got.Content.Parts {
switch o := part.(type) {
case genai.Text:
output += string(o)
output += "\n"
default:
color.Yellow("found unsupported AI response part of type %T; ignoring", part)
}
}
if got.CitationMetadata != nil && len(got.CitationMetadata.CitationSources) > 0 {
output += "Citations:\n"
for _, source := range got.CitationMetadata.CitationSources {
// TODO(bwplotka): Give details around what exactly words could be attributed to the citation.
output += fmt.Sprintf("* %s, %s\n", *source.URI, source.License)
}
}
return output, nil
}
func (c *GoogleGenAIClient) GetName() string {
return googleAIClientName
}
func (c *GoogleGenAIClient) Close() {
if err := c.client.Close(); err != nil {
color.Red("googleai client close error: %v", err)
}
}

193
pkg/ai/googlevertexai.go Normal file
View File

@@ -0,0 +1,193 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"context"
"errors"
"fmt"
"cloud.google.com/go/vertexai/genai"
"github.com/fatih/color"
)
const googleVertexAIClientName = "googlevertexai"
type GoogleVertexAIClient struct {
client *genai.Client
model string
temperature float32
topP float32
topK int32
maxTokens int
}
// Vertex AI Gemini supported Regions
// https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/gemini
const VERTEXAI_DEFAULT_REGION = "us-central1" // default use us-east-1 region
const (
US_Central_1 = "us-central1"
US_West_4 = "us-west4"
North_America_Northeast1 = "northamerica-northeast1"
US_East_4 = "us-east4"
US_West_1 = "us-west1"
Asia_Northeast_3 = "asia-northeast3"
Asia_Southeast_1 = "asia-southeast1"
Asia_Northeast_1 = "asia-northeast1"
)
var VERTEXAI_SUPPORTED_REGION = []string{
US_Central_1,
US_West_4,
North_America_Northeast1,
US_East_4,
US_West_1,
Asia_Northeast_3,
Asia_Southeast_1,
Asia_Northeast_1,
}
const (
ModelGeminiProV1 = "gemini-1.0-pro-001" // Retired Model
ModelGeminiProV2_5 = "gemini-2.5-pro" // Latest Stable Model
ModelGeminiFlashV2_5 = "gemini-2.5-flash" // Latest Stable Model
ModelGeminiFlashV2 = "gemini-2.0-flash" // Latest Stable Model
ModelGeminiFlashLiteV2 = "gemini-2.0-flash-lite" // Latest Stable Model
ModelGeminiProV1_5 = "gemini-1.5-pro-002*" // Legacy Stable Model
ModelGeminiFlashV1_5 = "gemini-1.5-flash-002*" // Legacy Stable Model
)
var VERTEXAI_MODELS = []string{
ModelGeminiProV2_5,
ModelGeminiFlashV2_5,
ModelGeminiFlashV2,
ModelGeminiFlashLiteV2,
ModelGeminiProV1_5,
ModelGeminiFlashV1_5,
ModelGeminiProV1,
}
// GetModelOrDefault check config model
func GetVertexAIModelOrDefault(model string) string {
// Check if the provided model is in the list
for _, m := range VERTEXAI_MODELS {
if m == model {
return model // Return the provided model
}
}
// Return the default model if the provided model is not in the list
return VERTEXAI_MODELS[0]
}
// GetModelOrDefault check config region
func GetVertexAIRegionOrDefault(region string) string {
// Check if the provided model is in the list
for _, m := range VERTEXAI_SUPPORTED_REGION {
if m == region {
return region // Return the provided model
}
}
// Return the default model if the provided model is not in the list
return VERTEXAI_DEFAULT_REGION
}
func (g *GoogleVertexAIClient) Configure(config IAIConfig) error {
ctx := context.Background()
// Currently you can access VertexAI either by being authenticated via OAuth or Bearer token so we need to consider both
projectId := config.GetProviderId()
region := GetVertexAIRegionOrDefault(config.GetProviderRegion())
client, err := genai.NewClient(ctx, projectId, region)
if err != nil {
return fmt.Errorf("creating genai Google SDK client: %w", err)
}
g.client = client
g.model = GetVertexAIModelOrDefault(config.GetModel())
g.temperature = config.GetTemperature()
g.topP = config.GetTopP()
g.topK = config.GetTopK()
g.maxTokens = config.GetMaxTokens()
return nil
}
func (g *GoogleVertexAIClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
model := g.client.GenerativeModel(g.model)
model.SetTemperature(g.temperature)
model.SetTopP(g.topP)
model.SetTopK(g.topK)
model.SetMaxOutputTokens(int32(g.maxTokens))
// Google AI SDK is capable of different inputs than just text, for now set explicit text prompt type.
// Similarly, we could stream the response. For now k8sgpt does not support streaming.
resp, err := model.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
return "", err
}
if len(resp.Candidates) == 0 {
if resp.PromptFeedback.BlockReason > 0 {
for _, r := range resp.PromptFeedback.SafetyRatings {
if !r.Blocked {
continue
}
return "", fmt.Errorf("completion blocked due to %v with probability %v", r.Category.String(), r.Probability.String())
}
}
return "", errors.New("no completion returned; unknown reason")
}
// Format output.
// TODO(bwplotka): Provider richer output in certain cases e.g. suddenly finished
// completion based on finish reasons or safety rankings.
got := resp.Candidates[0]
var output string
for _, part := range got.Content.Parts {
switch o := part.(type) {
case genai.Text:
output += string(o)
output += "\n"
default:
color.Yellow("found unsupported AI response part of type %T; ignoring", part)
}
}
if got.CitationMetadata != nil && len(got.CitationMetadata.Citations) > 0 {
output += "Citations:\n"
for _, source := range got.CitationMetadata.Citations {
// TODO(bwplotka): Give details around what exactly words could be attributed to the citation.
output += fmt.Sprintf("* %s, %s\n", source.URI, source.License)
}
}
return output, nil
}
func (g *GoogleVertexAIClient) GetName() string {
return googleVertexAIClientName
}
func (g *GoogleVertexAIClient) Close() {
if err := g.client.Close(); err != nil {
color.Red("googleai client close error: %v", err)
}
}

102
pkg/ai/groq.go Normal file
View File

@@ -0,0 +1,102 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"context"
"errors"
"net/http"
"net/url"
"github.com/sashabaranov/go-openai"
)
const groqAIClientName = "groq"
// Default Groq API endpoint (OpenAI-compatible)
const groqAPIBaseURL = "https://api.groq.com/openai/v1"
type GroqClient struct {
nopCloser
client *openai.Client
model string
temperature float32
topP float32
}
func (c *GroqClient) Configure(config IAIConfig) error {
token := config.GetPassword()
defaultConfig := openai.DefaultConfig(token)
proxyEndpoint := config.GetProxyEndpoint()
baseURL := config.GetBaseURL()
if baseURL != "" {
defaultConfig.BaseURL = baseURL
} else {
defaultConfig.BaseURL = groqAPIBaseURL
}
transport := &http.Transport{}
if proxyEndpoint != "" {
proxyUrl, err := url.Parse(proxyEndpoint)
if err != nil {
return err
}
transport.Proxy = http.ProxyURL(proxyUrl)
}
customHeaders := config.GetCustomHeaders()
defaultConfig.HTTPClient = &http.Client{
Transport: &OpenAIHeaderTransport{
Origin: transport,
Headers: customHeaders,
},
}
client := openai.NewClientWithConfig(defaultConfig)
if client == nil {
return errors.New("error creating Groq client")
}
c.client = client
c.model = config.GetModel()
c.temperature = config.GetTemperature()
c.topP = config.GetTopP()
return nil
}
func (c *GroqClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
resp, err := c.client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
Model: c.model,
Messages: []openai.ChatCompletionMessage{
{
Role: "user",
Content: prompt,
},
},
Temperature: c.temperature,
MaxTokens: maxToken,
PresencePenalty: presencePenalty,
FrequencyPenalty: frequencyPenalty,
TopP: c.topP,
})
if err != nil {
return "", err
}
return resp.Choices[0].Message.Content, nil
}
func (c *GroqClient) GetName() string {
return groqAIClientName
}

63
pkg/ai/huggingface.go Normal file
View File

@@ -0,0 +1,63 @@
package ai
import (
"context"
"github.com/hupe1980/go-huggingface"
"k8s.io/utils/ptr"
)
const huggingfaceAIClientName = "huggingface"
type HuggingfaceClient struct {
nopCloser
client *huggingface.InferenceClient
model string
topP float32
topK int32
temperature float32
maxTokens int
}
func (c *HuggingfaceClient) Configure(config IAIConfig) error {
token := config.GetPassword()
client := huggingface.NewInferenceClient(token)
c.client = client
c.model = config.GetModel()
c.topP = config.GetTopP()
c.topK = config.GetTopK()
c.temperature = config.GetTemperature()
if config.GetMaxTokens() > 500 {
c.maxTokens = 500
} else {
c.maxTokens = config.GetMaxTokens()
}
return nil
}
func (c *HuggingfaceClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
resp, err := c.client.Conversational(ctx, &huggingface.ConversationalRequest{
Inputs: huggingface.ConverstationalInputs{
Text: prompt,
},
Model: c.model,
Parameters: huggingface.ConversationalParameters{
TopP: ptr.To[float64](float64(c.topP)),
TopK: ptr.To[int](int(c.topK)),
Temperature: ptr.To[float64](float64(c.temperature)),
MaxLength: &c.maxTokens,
},
Options: huggingface.Options{
WaitForModel: ptr.To[bool](true),
},
})
if err != nil {
return "", err
}
return resp.GeneratedText, nil
}
func (c *HuggingfaceClient) GetName() string { return huggingfaceAIClientName }

View File

@@ -15,8 +15,7 @@ package ai
import (
"context"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"net/http"
)
var (
@@ -24,28 +23,72 @@ var (
&OpenAIClient{},
&AzureAIClient{},
&LocalAIClient{},
&OllamaClient{},
&NoOpAIClient{},
&CohereClient{},
&AmazonBedRockClient{},
&SageMakerAIClient{},
&GoogleGenAIClient{},
&HuggingfaceClient{},
&GoogleVertexAIClient{},
&OCIGenAIClient{},
&CustomRestClient{},
&IBMWatsonxAIClient{},
&GroqClient{},
}
Backends = []string{
"openai",
"localai",
"azureopenai",
"noopai",
openAIClientName,
localAIClientName,
ollamaClientName,
azureAIClientName,
cohereAIClientName,
amazonbedrockAIClientName,
amazonsagemakerAIClientName,
googleAIClientName,
noopAIClientName,
huggingfaceAIClientName,
googleVertexAIClientName,
ociClientName,
CustomRestClientName,
ibmWatsonxAIClientName,
groqAIClientName,
}
)
// IAI is an interface all clients (representing backends) share.
type IAI interface {
Configure(config IAIConfig, language string) error
GetCompletion(ctx context.Context, prompt string, promptTmpl string) (string, error)
Parse(ctx context.Context, prompt []string, cache cache.ICache, promptTmpl string) (string, error)
// Configure sets up client for given configuration. This is expected to be
// executed once per client life-time (e.g. analysis CLI command invocation).
Configure(config IAIConfig) error
// GetCompletion generates text based on prompt.
GetCompletion(ctx context.Context, prompt string) (string, error)
// GetName returns name of the backend/client.
GetName() string
// Close cleans all the resources. No other methods should be used on the
// objects after this method is invoked.
Close()
}
type nopCloser struct{}
func (nopCloser) Close() {}
type IAIConfig interface {
GetPassword() string
GetModel() string
GetBaseURL() string
GetProxyEndpoint() string
GetEndpointName() string
GetEngine() string
GetTemperature() float32
GetProviderRegion() string
GetTopP() float32
GetTopK() int32
GetMaxTokens() int
GetProviderId() string
GetCompartmentId() string
GetOrganizationId() string
GetCustomHeaders() []http.Header
}
func NewClient(provider string) IAI {
@@ -64,17 +107,49 @@ type AIConfiguration struct {
}
type AIProvider struct {
Name string `mapstructure:"name"`
Model string `mapstructure:"model"`
Password string `mapstructure:"password" yaml:"password,omitempty"`
BaseURL string `mapstructure:"baseurl" yaml:"baseurl,omitempty"`
Engine string `mapstructure:"engine" yaml:"engine,omitempty"`
Name string `mapstructure:"name"`
Model string `mapstructure:"model"`
Password string `mapstructure:"password" yaml:"password,omitempty"`
BaseURL string `mapstructure:"baseurl" yaml:"baseurl,omitempty"`
ProxyEndpoint string `mapstructure:"proxyEndpoint" yaml:"proxyEndpoint,omitempty"`
ProxyPort string `mapstructure:"proxyPort" yaml:"proxyPort,omitempty"`
EndpointName string `mapstructure:"endpointname" yaml:"endpointname,omitempty"`
Engine string `mapstructure:"engine" yaml:"engine,omitempty"`
Temperature float32 `mapstructure:"temperature" yaml:"temperature,omitempty"`
ProviderRegion string `mapstructure:"providerregion" yaml:"providerregion,omitempty"`
ProviderId string `mapstructure:"providerid" yaml:"providerid,omitempty"`
CompartmentId string `mapstructure:"compartmentid" yaml:"compartmentid,omitempty"`
TopP float32 `mapstructure:"topp" yaml:"topp,omitempty"`
TopK int32 `mapstructure:"topk" yaml:"topk,omitempty"`
MaxTokens int `mapstructure:"maxtokens" yaml:"maxtokens,omitempty"`
OrganizationId string `mapstructure:"organizationid" yaml:"organizationid,omitempty"`
CustomHeaders []http.Header `mapstructure:"customHeaders"`
}
func (p *AIProvider) GetBaseURL() string {
return p.BaseURL
}
func (p *AIProvider) GetProxyEndpoint() string {
return p.ProxyEndpoint
}
func (p *AIProvider) GetEndpointName() string {
return p.EndpointName
}
func (p *AIProvider) GetTopP() float32 {
return p.TopP
}
func (p *AIProvider) GetTopK() int32 {
return p.TopK
}
func (p *AIProvider) GetMaxTokens() int {
return p.MaxTokens
}
func (p *AIProvider) GetPassword() string {
return p.Password
}
@@ -86,7 +161,37 @@ func (p *AIProvider) GetModel() string {
func (p *AIProvider) GetEngine() string {
return p.Engine
}
func (p *AIProvider) GetTemperature() float32 {
return p.Temperature
}
func (p *AIProvider) GetProviderRegion() string {
return p.ProviderRegion
}
func (p *AIProvider) GetProviderId() string {
return p.ProviderId
}
func (p *AIProvider) GetCompartmentId() string {
return p.CompartmentId
}
func (p *AIProvider) GetOrganizationId() string {
return p.OrganizationId
}
func (p *AIProvider) GetCustomHeaders() []http.Header {
return p.CustomHeaders
}
var passwordlessProviders = []string{"localai", "ollama", "amazonsagemaker", "amazonbedrock", "googlevertexai", "oci", "customrest"}
func NeedPassword(backend string) bool {
return backend != "localai"
for _, b := range passwordlessProviders {
if b == backend {
return false
}
}
return true
}

View File

@@ -0,0 +1,67 @@
package interactive
import (
"fmt"
"strings"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/analysis"
"github.com/pterm/pterm"
)
type INTERACTIVE_STATE int
const (
prompt = "Given the following context: "
)
const (
E_RUNNING INTERACTIVE_STATE = iota
E_EXITED = iota
)
type InteractionRunner struct {
config *analysis.Analysis
State chan INTERACTIVE_STATE
contextWindow []byte
}
func NewInteractionRunner(config *analysis.Analysis, contextWindow []byte) *InteractionRunner {
return &InteractionRunner{
config: config,
contextWindow: contextWindow,
State: make(chan INTERACTIVE_STATE),
}
}
func (a *InteractionRunner) StartInteraction() {
a.State <- E_RUNNING
pterm.Println("Interactive mode enabled [type exit to close.]")
for {
query := pterm.DefaultInteractiveTextInput.WithMultiLine(false)
queryString, err := query.Show()
if err != nil {
fmt.Println(err)
}
if queryString == "" {
continue
}
if strings.Contains(queryString, "exit") {
a.State <- E_EXITED
continue
}
pterm.Println()
contextWindow := fmt.Sprintf("%s %s %s", prompt, string(a.contextWindow),
queryString)
response, err := a.config.AIClient.GetCompletion(a.config.Context,
contextWindow)
if err != nil {
color.Red("Error: %v", err)
a.State <- E_EXITED
continue
}
pterm.Println(response)
}
}

View File

@@ -1,9 +1,11 @@
package ai
const localAIClientName = "localai"
type LocalAIClient struct {
OpenAIClient
}
func (a *LocalAIClient) GetName() string {
return "localai"
return localAIClientName
}

View File

@@ -15,58 +15,23 @@ package ai
import (
"context"
"encoding/base64"
"fmt"
"strings"
"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
)
const noopAIClientName = "noopai"
type NoOpAIClient struct {
client string
language string
model string
nopCloser
}
func (c *NoOpAIClient) Configure(config IAIConfig, language string) error {
token := config.GetPassword()
c.language = language
c.client = fmt.Sprintf("I am a noop client with the token %s ", token)
c.model = config.GetModel()
func (c *NoOpAIClient) Configure(_ IAIConfig) error {
return nil
}
func (c *NoOpAIClient) GetCompletion(ctx context.Context, prompt string, promptTmpl string) (string, error) {
// Create a completion request
func (c *NoOpAIClient) GetCompletion(_ context.Context, prompt string) (string, error) {
response := "I am a noop response to the prompt " + prompt
return response, nil
}
func (a *NoOpAIClient) Parse(ctx context.Context, prompt []string, cache cache.ICache, promptTmpl string) (string, error) {
// parse the text with the AI backend
inputKey := strings.Join(prompt, " ")
// Check for cached data
sEnc := base64.StdEncoding.EncodeToString([]byte(inputKey))
cacheKey := util.GetCacheKey(a.GetName(), a.language, sEnc)
response, err := a.GetCompletion(ctx, inputKey, promptTmpl)
if err != nil {
color.Red("error getting completion: %v", err)
return "", err
}
err = cache.Store(cacheKey, base64.StdEncoding.EncodeToString([]byte(response)))
if err != nil {
color.Red("error storing value to cache: %v", err)
return "", nil
}
return response, nil
}
func (a *NoOpAIClient) GetName() string {
return "noopai"
func (c *NoOpAIClient) GetName() string {
return noopAIClientName
}

185
pkg/ai/ocigenai.go Normal file
View File

@@ -0,0 +1,185 @@
/*
Copyright 2024 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"context"
"errors"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/generativeai"
"github.com/oracle/oci-go-sdk/v65/generativeaiinference"
"reflect"
)
const ociClientName = "oci"
type ociModelVendor string
const (
vendorCohere = "cohere"
vendorMeta = "meta"
)
type OCIGenAIClient struct {
nopCloser
client *generativeaiinference.GenerativeAiInferenceClient
model *generativeai.Model
modelID string
compartmentId string
temperature float32
topP float32
topK int32
maxTokens int
}
func (c *OCIGenAIClient) GetName() string {
return ociClientName
}
func (c *OCIGenAIClient) Configure(config IAIConfig) error {
config.GetEndpointName()
c.modelID = config.GetModel()
c.temperature = config.GetTemperature()
c.topP = config.GetTopP()
c.topK = config.GetTopK()
c.maxTokens = config.GetMaxTokens()
c.compartmentId = config.GetCompartmentId()
provider := common.DefaultConfigProvider()
client, err := generativeaiinference.NewGenerativeAiInferenceClientWithConfigurationProvider(provider)
if err != nil {
return err
}
c.client = &client
model, err := c.getModel(provider)
if err != nil {
return err
}
c.model = model
return nil
}
func (c *OCIGenAIClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
request := c.newChatRequest(prompt)
response, err := c.client.Chat(ctx, request)
if err != nil {
return "", err
}
if err != nil {
return "", err
}
return extractGeneratedText(response.ChatResponse)
}
func (c *OCIGenAIClient) newChatRequest(prompt string) generativeaiinference.ChatRequest {
return generativeaiinference.ChatRequest{
ChatDetails: generativeaiinference.ChatDetails{
CompartmentId: &c.compartmentId,
ServingMode: c.getServingMode(),
ChatRequest: c.getChatModelRequest(prompt),
},
}
}
func (c *OCIGenAIClient) getChatModelRequest(prompt string) generativeaiinference.BaseChatRequest {
temperatureF64 := float64(c.temperature)
topPF64 := float64(c.topP)
topK := int(c.topK)
switch c.getVendor() {
case vendorMeta:
messages := []generativeaiinference.Message{
generativeaiinference.UserMessage{
Content: []generativeaiinference.ChatContent{
generativeaiinference.TextContent{
Text: &prompt,
},
},
},
}
// 0 is invalid for Meta vendor type, instead use -1 to disable topK sampling.
if topK == 0 {
topK = -1
}
return generativeaiinference.GenericChatRequest{
Messages: messages,
TopK: &topK,
TopP: &topPF64,
Temperature: &temperatureF64,
MaxTokens: &c.maxTokens,
}
default: // Default to cohere
return generativeaiinference.CohereChatRequest{
Message: &prompt,
MaxTokens: &c.maxTokens,
Temperature: &temperatureF64,
TopK: &topK,
TopP: &topPF64,
}
}
}
func extractGeneratedText(llmInferenceResponse generativeaiinference.BaseChatResponse) (string, error) {
switch response := llmInferenceResponse.(type) {
case generativeaiinference.GenericChatResponse:
if len(response.Choices) > 0 && len(response.Choices[0].Message.GetContent()) > 0 {
if content, ok := response.Choices[0].Message.GetContent()[0].(generativeaiinference.TextContent); ok {
return *content.Text, nil
}
}
return "", errors.New("no text found in oci response")
case generativeaiinference.CohereChatResponse:
return *response.Text, nil
default:
return "", fmt.Errorf("unknown oci response type: %s", reflect.TypeOf(llmInferenceResponse).Name())
}
}
func (c *OCIGenAIClient) getServingMode() generativeaiinference.ServingMode {
if c.isBaseModel() {
return generativeaiinference.OnDemandServingMode{
ModelId: &c.modelID,
}
}
return generativeaiinference.DedicatedServingMode{
EndpointId: &c.modelID,
}
}
func (c *OCIGenAIClient) getModel(provider common.ConfigurationProvider) (*generativeai.Model, error) {
client, err := generativeai.NewGenerativeAiClientWithConfigurationProvider(provider)
if err != nil {
return nil, err
}
response, err := client.GetModel(context.Background(), generativeai.GetModelRequest{
ModelId: &c.modelID,
})
if err != nil {
return nil, err
}
return &response.Model, nil
}
func (c *OCIGenAIClient) isBaseModel() bool {
return c.model != nil && c.model.Type == generativeai.ModelTypeBase
}
func (c *OCIGenAIClient) getVendor() ociModelVendor {
if c.model == nil || c.model.Vendor == nil {
return ""
}
return ociModelVendor(*c.model.Vendor)
}

102
pkg/ai/ollama.go Normal file
View File

@@ -0,0 +1,102 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai
import (
"context"
"errors"
"net/http"
"net/url"
ollama "github.com/ollama/ollama/api"
)
const ollamaClientName = "ollama"
type OllamaClient struct {
nopCloser
client *ollama.Client
model string
temperature float32
topP float32
}
const (
defaultBaseURL = "http://localhost:11434"
defaultModel = "llama3"
)
func (c *OllamaClient) Configure(config IAIConfig) error {
baseURL := config.GetBaseURL()
if baseURL == "" {
baseURL = defaultBaseURL
}
baseClientURL, err := url.Parse(baseURL)
if err != nil {
return err
}
proxyEndpoint := config.GetProxyEndpoint()
httpClient := http.DefaultClient
if proxyEndpoint != "" {
proxyUrl, err := url.Parse(proxyEndpoint)
if err != nil {
return err
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
}
httpClient = &http.Client{
Transport: transport,
}
}
c.client = ollama.NewClient(baseClientURL, httpClient)
if c.client == nil {
return errors.New("error creating Ollama client")
}
c.model = config.GetModel()
if c.model == "" {
c.model = defaultModel
}
c.temperature = config.GetTemperature()
c.topP = config.GetTopP()
return nil
}
func (c *OllamaClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
req := &ollama.GenerateRequest{
Model: c.model,
Prompt: prompt,
Stream: new(bool),
Options: map[string]interface{}{
"temperature": c.temperature,
"top_p": c.topP,
},
}
completion := ""
respFunc := func(resp ollama.GenerateResponse) error {
completion = resp.Response
return nil
}
err := c.client.Generate(ctx, req, respFunc)
if err != nil {
return "", err
}
return completion, nil
}
func (a *OllamaClient) GetName() string {
return ollamaClientName
}

View File

@@ -15,57 +15,90 @@ package ai
import (
"context"
"encoding/base64"
"errors"
"fmt"
"strings"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
"net/http"
"net/url"
"github.com/sashabaranov/go-openai"
"github.com/fatih/color"
)
const openAIClientName = "openai"
type OpenAIClient struct {
client *openai.Client
language string
model string
nopCloser
client *openai.Client
model string
temperature float32
topP float32
// organizationId string
}
func (c *OpenAIClient) Configure(config IAIConfig, language string) error {
const (
// OpenAI completion parameters
maxToken = 2048
presencePenalty = 0.0
frequencyPenalty = 0.0
)
func (c *OpenAIClient) Configure(config IAIConfig) error {
token := config.GetPassword()
defaultConfig := openai.DefaultConfig(token)
orgId := config.GetOrganizationId()
proxyEndpoint := config.GetProxyEndpoint()
baseURL := config.GetBaseURL()
if baseURL != "" {
defaultConfig.BaseURL = baseURL
}
transport := &http.Transport{}
if proxyEndpoint != "" {
proxyUrl, err := url.Parse(proxyEndpoint)
if err != nil {
return err
}
transport.Proxy = http.ProxyURL(proxyUrl)
}
if orgId != "" {
defaultConfig.OrgID = orgId
}
customHeaders := config.GetCustomHeaders()
defaultConfig.HTTPClient = &http.Client{
Transport: &OpenAIHeaderTransport{
Origin: transport,
Headers: customHeaders,
},
}
client := openai.NewClientWithConfig(defaultConfig)
if client == nil {
return errors.New("error creating OpenAI client")
}
c.language = language
c.client = client
c.model = config.GetModel()
c.temperature = config.GetTemperature()
c.topP = config.GetTopP()
return nil
}
func (c *OpenAIClient) GetCompletion(ctx context.Context, prompt string, promptTmpl string) (string, error) {
func (c *OpenAIClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
// Create a completion request
if len(promptTmpl) == 0 {
promptTmpl = PromptMap["default"]
}
resp, err := c.client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
Model: c.model,
Messages: []openai.ChatCompletionMessage{
{
Role: "user",
Content: fmt.Sprintf(promptTmpl, c.language, prompt),
Content: prompt,
},
},
Temperature: c.temperature,
MaxCompletionTokens: maxToken,
PresencePenalty: presencePenalty,
FrequencyPenalty: frequencyPenalty,
TopP: c.topP,
})
if err != nil {
return "", err
@@ -73,42 +106,28 @@ func (c *OpenAIClient) GetCompletion(ctx context.Context, prompt string, promptT
return resp.Choices[0].Message.Content, nil
}
func (a *OpenAIClient) Parse(ctx context.Context, prompt []string, cache cache.ICache, promptTmpl string) (string, error) {
inputKey := strings.Join(prompt, " ")
// Check for cached data
cacheKey := util.GetCacheKey(a.GetName(), a.language, inputKey)
func (c *OpenAIClient) GetName() string {
return openAIClientName
}
if !cache.IsCacheDisabled() && cache.Exists(cacheKey) {
response, err := cache.Load(cacheKey)
if err != nil {
return "", err
}
// OpenAIHeaderTransport is an http.RoundTripper that adds the given headers to each request.
type OpenAIHeaderTransport struct {
Origin http.RoundTripper
Headers []http.Header
}
if response != "" {
output, err := base64.StdEncoding.DecodeString(response)
if err != nil {
color.Red("error decoding cached data: %v", err)
return "", nil
// RoundTrip implements the http.RoundTripper interface.
func (t *OpenAIHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error) {
// Clone the request to avoid modifying the original request
clonedReq := req.Clone(req.Context())
for _, header := range t.Headers {
for key, values := range header {
// Possible values per header: RFC 2616
for _, value := range values {
clonedReq.Header.Add(key, value)
}
return string(output), nil
}
}
response, err := a.GetCompletion(ctx, inputKey, promptTmpl)
if err != nil {
return "", err
}
err = cache.Store(cacheKey, base64.StdEncoding.EncodeToString([]byte(response)))
if err != nil {
color.Red("error storing value to cache: %v", err)
return "", nil
}
return response, nil
}
func (a *OpenAIClient) GetName() string {
return "openai"
return t.Origin.RoundTrip(clonedReq)
}

View File

@@ -0,0 +1,106 @@
package ai
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
// Mock configuration
type mockConfig struct {
baseURL string
}
func (m *mockConfig) GetPassword() string {
return ""
}
func (m *mockConfig) GetOrganizationId() string {
return ""
}
func (m *mockConfig) GetProxyEndpoint() string {
return ""
}
func (m *mockConfig) GetBaseURL() string {
return m.baseURL
}
func (m *mockConfig) GetCustomHeaders() []http.Header {
return []http.Header{
{"X-Custom-Header-1": []string{"Value1"}},
{"X-Custom-Header-2": []string{"Value2"}},
{"X-Custom-Header-2": []string{"Value3"}}, // Testing multiple values for the same header
}
}
func (m *mockConfig) GetModel() string {
return ""
}
func (m *mockConfig) GetTemperature() float32 {
return 0.0
}
func (m *mockConfig) GetTopP() float32 {
return 0.0
}
func (m *mockConfig) GetCompartmentId() string {
return ""
}
func (m *mockConfig) GetTopK() int32 {
return 0.0
}
func (m *mockConfig) GetMaxTokens() int {
return 0
}
func (m *mockConfig) GetEndpointName() string {
return ""
}
func (m *mockConfig) GetEngine() string {
return ""
}
func (m *mockConfig) GetProviderId() string {
return ""
}
func (m *mockConfig) GetProviderRegion() string {
return ""
}
func TestOpenAIClient_CustomHeaders(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "Value1", r.Header.Get("X-Custom-Header-1"))
assert.ElementsMatch(t, []string{"Value2", "Value3"}, r.Header["X-Custom-Header-2"])
w.WriteHeader(http.StatusOK)
// Mock response for openai completion
mockResponse := `{"choices": [{"message": {"content": "test"}}]}`
n, err := w.Write([]byte(mockResponse))
if err != nil {
t.Fatalf("error writing response: %v", err)
}
if n != len(mockResponse) {
t.Fatalf("expected to write %d bytes but wrote %d bytes", len(mockResponse), n)
}
}))
defer server.Close()
config := &mockConfig{baseURL: server.URL}
client := &OpenAIClient{}
err := client.Configure(config)
assert.NoError(t, err)
// Make a completion request to trigger the headers
ctx := context.Background()
_, err = client.GetCompletion(ctx, "foo prompt")
assert.NoError(t, err)
}

View File

@@ -6,10 +6,64 @@ const (
Error: {Explain error here}
Solution: {Step by step solution here}
`
trivy_prompt = "Explain the following trivy scan result and the detail risk or root cause of the CVE ID, then provide a solution. Response in %s: %s"
prom_conf_prompt = `Simplify the following Prometheus error message delimited by triple dashes written in --- %s --- language; --- %s ---.
This error came when validating the Prometheus configuration file.
Provide step by step instructions to fix, with suggestions, referencing Prometheus documentation if relevant.
Write the output in the following format in no more than 300 characters:
Error: {Explain error here}
Solution: {Step by step solution here}
`
prom_relabel_prompt = `
Return your prompt in this language: %s, beginning with
The following is a list of the form:
job_name:
{Prometheus job_name}
relabel_configs:
{Prometheus relabel_configs}
kubernetes_sd_configs:
{Prometheus service discovery config}
---
%s
---
For each job_name, describe the Kubernetes service and pod labels,
namespaces, ports, and containers they match.
Return the message:
Discovered and parsed Prometheus scrape configurations.
For targets to be scraped by Prometheus, ensure they are running with
at least one of the following label sets:
Then for each job, write this format:
- Job: {job_name}
- Service Labels:
- {list of service labels}
- Pod Labels:
- {list of pod labels}
- Namespaces:
- {list of namespaces}
- Ports:
- {list of ports}
- Containers:
- {list of container names}
`
kyverno_prompt = `Simplify the following Kyverno warnings message delimited by triple dashes written in --- %s --- language; --- %s ---.
Provide the most probable solution as a kubectl command.
Write the output in the following format, for the solution, only show the kubectl command:
Error: {Explain error here}
Solution: {kubectl command}
`
raw_promt = `{"language": "%s","message": "%s","prompt": "%s"}`
)
var PromptMap = map[string]string{
"default": default_prompt,
"VulnerabilityReport": trivy_prompt, // for Trivy intergration, the key should match `Result.Kind` in pkg/common/types.go
"raw": raw_promt,
"default": default_prompt,
"PrometheusConfigValidate": prom_conf_prompt,
"PrometheusConfigRelabelReport": prom_relabel_prompt,
"PolicyReport": kyverno_prompt,
"ClusterPolicyReport": kyverno_prompt,
}

86
pkg/ai/watsonxai.go Normal file
View File

@@ -0,0 +1,86 @@
package ai
import (
"context"
"errors"
"fmt"
wx "github.com/IBM/watsonx-go/pkg/models"
)
const ibmWatsonxAIClientName = "ibmwatsonxai"
type IBMWatsonxAIClient struct {
nopCloser
client *wx.Client
model string
temperature float32
topP float32
topK int32
maxNewTokens int
}
const (
modelMetallama = "ibm/granite-13b-chat-v2"
maxTokens = 2048
)
func (c *IBMWatsonxAIClient) Configure(config IAIConfig) error {
if config.GetModel() == "" {
c.model = modelMetallama
} else {
c.model = config.GetModel()
}
if config.GetMaxTokens() == 0 {
c.maxNewTokens = maxTokens
} else {
c.maxNewTokens = config.GetMaxTokens()
}
c.temperature = config.GetTemperature()
c.topP = config.GetTopP()
c.topK = config.GetTopK()
apiKey := config.GetPassword()
if apiKey == "" {
return errors.New("No watsonx API key provided")
}
projectId := config.GetProviderId()
if projectId == "" {
return errors.New("No watsonx project ID provided")
}
client, err := wx.NewClient(
wx.WithWatsonxAPIKey(apiKey),
wx.WithWatsonxProjectID(projectId),
)
if err != nil {
return fmt.Errorf("Failed to create client for testing. Error: %v", err)
}
c.client = client
return nil
}
func (c *IBMWatsonxAIClient) GetCompletion(ctx context.Context, prompt string) (string, error) {
result, err := c.client.GenerateText(
c.model,
prompt,
wx.WithTemperature((float64)(c.temperature)),
wx.WithTopP((float64)(c.topP)),
wx.WithTopK((uint)(c.topK)),
wx.WithMaxNewTokens((uint)(c.maxNewTokens)),
)
if err != nil {
return "", fmt.Errorf("Expected no error, but got an error: %v", err)
}
if result.Text == "" {
return "", errors.New("Expected a result, but got an empty string")
}
return result.Text, nil
}
func (c *IBMWatsonxAIClient) GetName() string {
return ibmWatsonxAIClientName
}

View File

@@ -15,12 +15,14 @@ package analysis
import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"os"
"reflect"
"strings"
"sync"
"time"
"github.com/fatih/color"
openapi_v2 "github.com/google/gnostic/openapiv2"
@@ -28,29 +30,37 @@ import (
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/custom"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
"github.com/schollz/progressbar/v3"
"github.com/spf13/viper"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type Analysis struct {
Context context.Context
Filters []string
Client *kubernetes.Client
Language string
AIClient ai.IAI
Results []common.Result
Errors []string
Namespace string
LabelSelector string
Cache cache.ICache
Explain bool
MaxConcurrency int
AnalysisAIProvider string // The name of the AI Provider used for this analysis
WithDoc bool
WithStats bool
Stats []common.AnalysisStats
}
type AnalysisStatus string
type AnalysisErrors []string
type (
AnalysisStatus string
AnalysisErrors []string
)
const (
StateOK AnalysisStatus = "OK"
@@ -65,23 +75,114 @@ type JsonOutput struct {
Results []common.Result `json:"results"`
}
func NewAnalysis(backend string, language string, filters []string, namespace string, noCache bool, explain bool, maxConcurrency int, withDoc bool) (*Analysis, error) {
var configAI ai.AIConfiguration
err := viper.UnmarshalKey("ai", &configAI)
func NewAnalysis(
backend string,
language string,
filters []string,
namespace string,
labelSelector string,
noCache bool,
explain bool,
maxConcurrency int,
withDoc bool,
interactiveMode bool,
httpHeaders []string,
withStats bool,
) (*Analysis, error) {
// Get kubernetes client from viper.
kubecontext := viper.GetString("kubecontext")
kubeconfig := viper.GetString("kubeconfig")
verbose := viper.GetBool("verbose")
client, err := kubernetes.NewClient(kubecontext, kubeconfig)
if verbose {
fmt.Println("Debug: Checking kubernetes client initialization.")
}
if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
return nil, fmt.Errorf("initialising kubernetes client: %w", err)
}
if verbose {
fmt.Printf("Debug: Kubernetes client initialized, server=%s.\n", client.Config.Host)
}
if len(configAI.Providers) == 0 && explain {
color.Red("Error: AI provider not specified in configuration. Please run k8sgpt auth")
os.Exit(1)
// Load remote cache if it is configured.
cache, err := cache.GetCacheConfiguration()
if verbose {
fmt.Println("Debug: Checking cache configuration.")
}
if err != nil {
return nil, err
}
if verbose {
fmt.Printf("Debug: Cache configuration loaded, type=%s.\n", cache.GetName())
}
if noCache {
cache.DisableCache()
if verbose {
fmt.Println("Debug: Cache disabled.")
}
}
a := &Analysis{
Context: context.Background(),
Filters: filters,
Client: client,
Language: language,
Namespace: namespace,
LabelSelector: labelSelector,
Cache: cache,
Explain: explain,
MaxConcurrency: maxConcurrency,
WithDoc: withDoc,
WithStats: withStats,
}
if verbose {
fmt.Print("Debug: Analysis configuration loaded, ")
fmt.Printf("filters=%v, language=%s, ", filters, language)
if namespace == "" {
fmt.Printf("namespace=none, ")
} else {
fmt.Printf("namespace=%s, ", namespace)
}
if labelSelector == "" {
fmt.Printf("labelSelector=none, ")
} else {
fmt.Printf("labelSelector=%s, ", labelSelector)
}
fmt.Printf("explain=%t, maxConcurrency=%d, ", explain, maxConcurrency)
fmt.Printf("withDoc=%t, withStats=%t.\n", withDoc, withStats)
}
if !explain {
// Return early if AI use was not requested.
return a, nil
}
var configAI ai.AIConfiguration
if verbose {
fmt.Println("Debug: Checking AI configuration.")
}
if err := viper.UnmarshalKey("ai", &configAI); err != nil {
return nil, err
}
if len(configAI.Providers) == 0 {
return nil, errors.New("AI provider not specified in configuration. Please run k8sgpt auth")
}
// Backend string will have high priority than a default provider
// Backend as "openai" represents the default CLI argument passed through
if configAI.DefaultProvider != "" && backend == "openai" {
// Hence, use the default provider only if the backend is not specified by the user.
if configAI.DefaultProvider != "" && backend == "" {
backend = configAI.DefaultProvider
if verbose {
fmt.Printf("Debug: Using default AI provider %s.\n", backend)
}
}
if backend == "" {
backend = "openai"
if verbose {
fmt.Printf("Debug: Using default AI provider %s.\n", backend)
}
}
var aiProvider ai.AIProvider
@@ -93,49 +194,117 @@ func NewAnalysis(backend string, language string, filters []string, namespace st
}
if aiProvider.Name == "" {
color.Red("Error: AI provider %s not specified in configuration. Please run k8sgpt auth", backend)
return nil, errors.New("AI provider not specified in configuration")
return nil, fmt.Errorf("AI provider %s not specified in configuration. Please run k8sgpt auth", backend)
}
if verbose {
fmt.Printf("Debug: AI configuration loaded, provider=%s, ", backend)
fmt.Printf("baseUrl=%s, model=%s.\n", aiProvider.BaseURL, aiProvider.Model)
}
aiClient := ai.NewClient(aiProvider.Name)
if err := aiClient.Configure(&aiProvider, language); err != nil {
color.Red("Error: %v", err)
customHeaders := util.NewHeaders(httpHeaders)
aiProvider.CustomHeaders = customHeaders
if verbose {
fmt.Println("Debug: Checking AI client initialization.")
}
if err := aiClient.Configure(&aiProvider); err != nil {
return nil, err
}
if verbose {
fmt.Println("Debug: AI client initialized.")
}
a.AIClient = aiClient
a.AnalysisAIProvider = aiProvider.Name
return a, nil
}
ctx := context.Background()
// Get kubernetes client from viper
func (a *Analysis) CustomAnalyzersAreAvailable() bool {
var customAnalyzers []custom.CustomAnalyzer
if err := viper.UnmarshalKey("custom_analyzers", &customAnalyzers); err != nil {
return false
}
return len(customAnalyzers) > 0
}
kubecontext := viper.GetString("kubecontext")
kubeconfig := viper.GetString("kubeconfig")
client, err := kubernetes.NewClient(kubecontext, kubeconfig)
if err != nil {
color.Red("Error initialising kubernetes client: %v", err)
return nil, err
func (a *Analysis) RunCustomAnalysis() {
// Validate namespace if specified, consistent with built-in filter behavior
if a.Namespace != "" && a.Client != nil {
_, err := a.Client.Client.CoreV1().Namespaces().Get(a.Context, a.Namespace, metav1.GetOptions{})
if err != nil {
a.Errors = append(a.Errors, fmt.Sprintf("namespace %q not found: %s", a.Namespace, err))
return
}
}
// load remote cache if it is configured
remoteCacheEnabled, err := cache.RemoteCacheEnabled()
if err != nil {
return nil, err
var customAnalyzers []custom.CustomAnalyzer
if err := viper.UnmarshalKey("custom_analyzers", &customAnalyzers); err != nil {
a.Errors = append(a.Errors, err.Error())
return
}
return &Analysis{
Context: ctx,
Filters: filters,
Client: client,
AIClient: aiClient,
Namespace: namespace,
Cache: cache.New(noCache, remoteCacheEnabled),
Explain: explain,
MaxConcurrency: maxConcurrency,
AnalysisAIProvider: backend,
WithDoc: withDoc,
}, nil
semaphore := make(chan struct{}, a.MaxConcurrency)
var wg sync.WaitGroup
var mutex sync.Mutex
verbose := viper.GetBool("verbose")
if verbose {
if len(customAnalyzers) == 0 {
fmt.Println("Debug: No custom analyzers found.")
} else {
cAnalyzerNames := make([]string, len(customAnalyzers))
for i, cAnalyzer := range customAnalyzers {
cAnalyzerNames[i] = cAnalyzer.Name
}
fmt.Printf("Debug: Found custom analyzers %v.\n", cAnalyzerNames)
}
}
for _, cAnalyzer := range customAnalyzers {
wg.Add(1)
semaphore <- struct{}{}
go func(analyzer custom.CustomAnalyzer, wg *sync.WaitGroup, semaphore chan struct{}) {
defer wg.Done()
canClient, err := custom.NewClient(cAnalyzer.Connection)
if err != nil {
mutex.Lock()
a.Errors = append(a.Errors, fmt.Sprintf("Client creation error for %s analyzer", cAnalyzer.Name))
mutex.Unlock()
return
}
if verbose {
fmt.Printf("Debug: %s launched.\n", cAnalyzer.Name)
}
result, err := canClient.Run()
if result.Kind == "" {
// for custom analyzer name, we must use a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.',
//and must start and end with an alphanumeric character (e.g. 'example.com',
//regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
result.Kind = cAnalyzer.Name
}
if err != nil {
mutex.Lock()
a.Errors = append(a.Errors, fmt.Sprintf("[%s] %s", cAnalyzer.Name, err))
mutex.Unlock()
if verbose {
fmt.Printf("Debug: %s completed with errors.\n", cAnalyzer.Name)
}
} else {
mutex.Lock()
a.Results = append(a.Results, result)
mutex.Unlock()
if verbose {
fmt.Printf("Debug: %s completed without errors.\n", cAnalyzer.Name)
}
}
<-semaphore
}(cAnalyzer, &wg, semaphore)
}
wg.Wait()
}
func (a *Analysis) RunAnalysis() {
activeFilters := viper.GetStringSlice("active_filters")
verbose := viper.GetBool("verbose")
coreAnalyzerMap, analyzerMap := analyzer.GetAnalyzerMap()
@@ -144,7 +313,13 @@ func (a *Analysis) RunAnalysis() {
if a.WithDoc {
var openApiErr error
if verbose {
fmt.Println("Debug: Fetching Kubernetes docs.")
}
openapiSchema, openApiErr = a.Client.Client.Discovery().OpenAPISchema()
if verbose {
fmt.Println("Debug: Checking Kubernetes docs.")
}
if openApiErr != nil {
a.Errors = append(a.Errors, fmt.Sprintf("[KubernetesDoc] %s", openApiErr))
}
@@ -154,58 +329,47 @@ func (a *Analysis) RunAnalysis() {
Client: a.Client,
Context: a.Context,
Namespace: a.Namespace,
LabelSelector: a.LabelSelector,
AIClient: a.AIClient,
OpenapiSchema: openapiSchema,
}
semaphore := make(chan struct{}, a.MaxConcurrency)
// Set a reasonable maximum for concurrency to prevent excessive memory allocation
const maxAllowedConcurrency = 100
concurrency := a.MaxConcurrency
if concurrency <= 0 {
concurrency = 10 // Default value if not set
} else if concurrency > maxAllowedConcurrency {
concurrency = maxAllowedConcurrency // Cap at a reasonable maximum
}
semaphore := make(chan struct{}, concurrency)
var wg sync.WaitGroup
var mutex sync.Mutex
// if there are no filters selected and no active_filters then run coreAnalyzer
if len(a.Filters) == 0 && len(activeFilters) == 0 {
var wg sync.WaitGroup
var mutex sync.Mutex
for _, analyzer := range coreAnalyzerMap {
if verbose {
fmt.Println("Debug: No filters selected and no active filters found, run all core analyzers.")
}
for name, analyzer := range coreAnalyzerMap {
wg.Add(1)
semaphore <- struct{}{}
go func(analyzer common.IAnalyzer, wg *sync.WaitGroup, semaphore chan struct{}) {
defer wg.Done()
results, err := analyzer.Analyze(analyzerConfig)
if err != nil {
mutex.Lock()
a.Errors = append(a.Errors, fmt.Sprintf("[%s] %s", reflect.TypeOf(analyzer).Name(), err))
mutex.Unlock()
}
mutex.Lock()
a.Results = append(a.Results, results...)
mutex.Unlock()
<-semaphore
}(analyzer, &wg, semaphore)
go a.executeAnalyzer(analyzer, name, analyzerConfig, semaphore, &wg, &mutex)
}
wg.Wait()
return
}
semaphore = make(chan struct{}, a.MaxConcurrency)
// if the filters flag is specified
if len(a.Filters) != 0 {
var wg sync.WaitGroup
var mutex sync.Mutex
if verbose {
fmt.Printf("Debug: Filter flags %v specified, run selected core analyzers.\n", a.Filters)
}
for _, filter := range a.Filters {
if analyzer, ok := analyzerMap[filter]; ok {
semaphore <- struct{}{}
wg.Add(1)
go func(analyzer common.IAnalyzer, filter string) {
defer wg.Done()
results, err := analyzer.Analyze(analyzerConfig)
if err != nil {
mutex.Lock()
a.Errors = append(a.Errors, fmt.Sprintf("[%s] %s", filter, err))
mutex.Unlock()
}
mutex.Lock()
a.Results = append(a.Results, results...)
mutex.Unlock()
<-semaphore
}(analyzer, filter)
go a.executeAnalyzer(analyzer, filter, analyzerConfig, semaphore, &wg, &mutex)
} else {
a.Errors = append(a.Errors, fmt.Sprintf("\"%s\" filter does not exist. Please run k8sgpt filters list.", filter))
}
@@ -214,37 +378,82 @@ func (a *Analysis) RunAnalysis() {
return
}
var wg sync.WaitGroup
var mutex sync.Mutex
semaphore = make(chan struct{}, a.MaxConcurrency)
// use active_filters
if len(activeFilters) > 0 && verbose {
fmt.Printf("Debug: Found active filters %v, run selected core analyzers.\n", activeFilters)
}
for _, filter := range activeFilters {
if analyzer, ok := analyzerMap[filter]; ok {
semaphore <- struct{}{}
wg.Add(1)
go func(analyzer common.IAnalyzer, filter string) {
defer wg.Done()
results, err := analyzer.Analyze(analyzerConfig)
if err != nil {
mutex.Lock()
a.Errors = append(a.Errors, fmt.Sprintf("[%s] %s", filter, err))
mutex.Unlock()
}
mutex.Lock()
a.Results = append(a.Results, results...)
mutex.Unlock()
<-semaphore
}(analyzer, filter)
go a.executeAnalyzer(analyzer, filter, analyzerConfig, semaphore, &wg, &mutex)
}
}
wg.Wait()
}
func (a *Analysis) executeAnalyzer(analyzer common.IAnalyzer, filter string, analyzerConfig common.Analyzer, semaphore chan struct{}, wg *sync.WaitGroup, mutex *sync.Mutex) {
defer wg.Done()
var startTime time.Time
var elapsedTime time.Duration
// Start the timer
if a.WithStats {
startTime = time.Now()
}
// Run the analyzer
verbose := viper.GetBool("verbose")
if verbose {
fmt.Printf("Debug: %s launched.\n", reflect.TypeOf(analyzer).Name())
}
results, err := analyzer.Analyze(analyzerConfig)
if err != nil {
fmt.Println(err)
}
// Measure the time taken
if a.WithStats {
elapsedTime = time.Since(startTime)
}
stat := common.AnalysisStats{
Analyzer: filter,
DurationTime: elapsedTime,
}
mutex.Lock()
defer mutex.Unlock()
if err != nil {
if a.WithStats {
a.Stats = append(a.Stats, stat)
}
a.Errors = append(a.Errors, fmt.Sprintf("[%s] %s", filter, err))
if verbose {
fmt.Printf("Debug: %s completed with errors.\n", reflect.TypeOf(analyzer).Name())
}
} else {
if a.WithStats {
a.Stats = append(a.Stats, stat)
}
a.Results = append(a.Results, results...)
if verbose {
fmt.Printf("Debug: %s completed without errors.\n", reflect.TypeOf(analyzer).Name())
}
}
<-semaphore
}
func (a *Analysis) GetAIResults(output string, anonymize bool) error {
if len(a.Results) == 0 {
return nil
}
verbose := viper.GetBool("verbose")
if verbose {
fmt.Println("Debug: Generating AI analysis.")
}
var bar *progressbar.ProgressBar
if output != "json" {
bar = progressbar.Default(int64(len(a.Results)))
@@ -253,6 +462,10 @@ func (a *Analysis) GetAIResults(output string, anonymize bool) error {
for index, analysis := range a.Results {
var texts []string
if bar != nil && verbose {
bar.Describe(fmt.Sprintf("Analyzing %s", analysis.Kind))
}
for _, failure := range analysis.Error {
if anonymize {
for _, s := range failure.Sensitive {
@@ -261,14 +474,14 @@ func (a *Analysis) GetAIResults(output string, anonymize bool) error {
}
texts = append(texts, failure.Text)
}
// If the resource `Kind` comes from a "integration plugin", maybe a customized prompt template will be involved.
var promptTemplate string
promptTemplate := ai.PromptMap["default"]
// If the resource `Kind` comes from an "integration plugin",
// maybe a customized prompt template will be involved.
if prompt, ok := ai.PromptMap[analysis.Kind]; ok {
promptTemplate = prompt
} else {
promptTemplate = ai.PromptMap["default"]
}
parsedText, err := a.AIClient.Parse(a.Context, texts, a.Cache, promptTemplate)
result, err := a.getAIResultForSanitizedFailures(texts, promptTemplate)
if err != nil {
// FIXME: can we avoid checking if output is json multiple times?
// maybe implement the progress bar better?
@@ -276,23 +489,22 @@ func (a *Analysis) GetAIResults(output string, anonymize bool) error {
_ = bar.Exit()
}
// Check for exhaustion
// Check for exhaustion.
if strings.Contains(err.Error(), "status code: 429") {
return fmt.Errorf("exhausted API quota for AI provider %s: %v", a.AIClient.GetName(), err)
} else {
return fmt.Errorf("failed while calling AI provider %s: %v", a.AIClient.GetName(), err)
}
return fmt.Errorf("failed while calling AI provider %s: %v", a.AIClient.GetName(), err)
}
if anonymize {
for _, failure := range analysis.Error {
for _, s := range failure.Sensitive {
parsedText = strings.ReplaceAll(parsedText, s.Masked, s.Unmasked)
result = strings.ReplaceAll(result, s.Masked, s.Unmasked)
}
}
}
analysis.Details = parsedText
analysis.Details = result
if output != "json" {
_ = bar.Add(1)
}
@@ -300,3 +512,62 @@ func (a *Analysis) GetAIResults(output string, anonymize bool) error {
}
return nil
}
func (a *Analysis) getAIResultForSanitizedFailures(texts []string, promptTmpl string) (string, error) {
inputKey := strings.Join(texts, " ")
// Check for cached data.
// TODO(bwplotka): This might depend on model too (or even other client configuration pieces), fix it in later PRs.
cacheKey := util.GetCacheKey(a.AIClient.GetName(), a.Language, inputKey)
if !a.Cache.IsCacheDisabled() && a.Cache.Exists(cacheKey) {
response, err := a.Cache.Load(cacheKey)
if err != nil {
return "", err
}
if response != "" {
output, err := base64.StdEncoding.DecodeString(response)
if err == nil {
return string(output), nil
}
color.Red("error decoding cached data; ignoring cache item: %v", err)
}
}
// Process template.
prompt := fmt.Sprintf(strings.TrimSpace(promptTmpl), a.Language, inputKey)
if a.AIClient.GetName() == ai.CustomRestClientName {
// Use proper JSON marshaling to handle special characters in error messages
// This fixes issues with quotes, newlines, and other special chars in inputKey
customRestPrompt := struct {
Language string `json:"language"`
Message string `json:"message"`
Prompt string `json:"prompt"`
}{
Language: a.Language,
Message: inputKey,
Prompt: prompt,
}
promptBytes, err := json.Marshal(customRestPrompt)
if err != nil {
return "", fmt.Errorf("failed to marshal customrest prompt: %w", err)
}
prompt = string(promptBytes)
}
response, err := a.AIClient.GetCompletion(a.Context, prompt)
if err != nil {
return "", err
}
if err = a.Cache.Store(cacheKey, base64.StdEncoding.EncodeToString([]byte(response))); err != nil {
color.Red("error storing value to cache; value won't be cached: %v", err)
}
return response, nil
}
func (a *Analysis) Close() {
if a.AIClient == nil {
return
}
a.AIClient.Close()
}

View File

@@ -17,8 +17,17 @@ import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"testing"
"github.com/agiledragon/gomonkey/v2"
"github.com/k8sgpt-ai/k8sgpt/pkg/ai"
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
"github.com/magiconair/properties/assert"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
@@ -26,11 +35,15 @@ import (
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
"strings"
"testing"
"k8s.io/client-go/rest"
)
// sub-function
// helper function: get type name of an analyzer
func getTypeName(i interface{}) string {
return reflect.TypeOf(i).Name()
}
// helper function: run analysis with filter
func analysis_RunAnalysisFilterTester(t *testing.T, filterFlag string) []common.Result {
clientset := fake.NewSimpleClientset(
&v1.Pod{
@@ -85,6 +98,7 @@ func analysis_RunAnalysisFilterTester(t *testing.T, filterFlag string) []common.
Client: &kubernetes.Client{
Client: clientset,
},
WithDoc: true,
}
if len(filterFlag) > 0 {
// `--filter` is explicitly given
@@ -133,6 +147,10 @@ func TestAnalysis_RunAnalysisActiveFilter(t *testing.T) {
viper.SetDefault("active_filters", []string{"Ingress", "Service", "Pod"})
results = analysis_RunAnalysisFilterTester(t, "")
assert.Equal(t, len(results), 3)
// Invalid filter
results = analysis_RunAnalysisFilterTester(t, "invalid")
assert.Equal(t, len(results), 0)
}
func TestAnalysis_NoProblemJsonOutput(t *testing.T) {
@@ -279,3 +297,369 @@ func TestAnalysis_MultipleProblemJsonOutput(t *testing.T) {
require.Equal(t, got, expected)
}
func TestNewAnalysis(t *testing.T) {
disabledCache := cache.New("disabled-cache")
disabledCache.DisableCache()
aiClient := &ai.NoOpAIClient{}
results := []common.Result{
{
Kind: "VulnerabilityReport",
Error: []common.Failure{
{
Text: "This is a custom failure",
KubernetesDoc: "test-kubernetes-doc",
Sensitive: []common.Sensitive{
{
Masked: "masked-error",
Unmasked: "unmasked-error",
},
},
},
},
},
}
tests := []struct {
name string
a Analysis
output string
anonymize bool
expectedErr string
}{
{
name: "Empty results",
a: Analysis{},
},
{
name: "cache disabled",
a: Analysis{
AIClient: aiClient,
Cache: disabledCache,
Results: results,
},
},
{
name: "output and anonymize both set",
a: Analysis{
AIClient: aiClient,
Cache: cache.New("test-cache"),
Results: results,
},
output: "test-output",
anonymize: true,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
err := tt.a.GetAIResults(tt.output, tt.anonymize)
if tt.expectedErr == "" {
require.NoError(t, err)
} else {
require.ErrorContains(t, err, tt.expectedErr)
}
})
}
}
func TestGetAIResultForSanitizedFailures(t *testing.T) {
enabledCache := cache.New("enabled-cache")
disabledCache := cache.New("disabled-cache")
disabledCache.DisableCache()
aiClient := &ai.NoOpAIClient{}
tests := []struct {
name string
a Analysis
texts []string
promptTmpl string
expectedOutput string
expectedErr string
}{
{
name: "Cache enabled",
a: Analysis{
AIClient: aiClient,
Cache: enabledCache,
},
texts: []string{"some-data"},
expectedOutput: "I am a noop response to the prompt %!(EXTRA string=, string=some-data)",
},
{
name: "cache disabled",
a: Analysis{
AIClient: aiClient,
Cache: disabledCache,
Language: "English",
},
texts: []string{"test input"},
promptTmpl: "Response in %s: %s",
expectedOutput: "I am a noop response to the prompt Response in English: test input",
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
output, err := tt.a.getAIResultForSanitizedFailures(tt.texts, tt.promptTmpl)
if tt.expectedErr == "" {
require.NoError(t, err)
require.Equal(t, tt.expectedOutput, output)
} else {
require.ErrorContains(t, err, tt.expectedErr)
require.Empty(t, output)
}
})
}
}
// Test: Verbose output in NewAnalysis with explain=false
func TestVerbose_NewAnalysisWithoutExplain(t *testing.T) {
// Set viper config.
viper.Set("verbose", true)
viper.Set("kubecontext", "dummy")
viper.Set("kubeconfig", "dummy")
// Patch kubernetes.NewClient to return a dummy client.
patches := gomonkey.ApplyFunc(kubernetes.NewClient, func(kubecontext, kubeconfig string) (*kubernetes.Client, error) {
return &kubernetes.Client{
Config: &rest.Config{Host: "fake-server"},
}, nil
})
defer patches.Reset()
output := util.CaptureOutput(func() {
a, err := NewAnalysis(
"", "english", []string{"Pod"}, "default", "", true,
false, // explain
10, false, false, []string{}, false,
)
require.NoError(t, err)
a.Close()
})
expectedOutputs := []string{
"Debug: Checking kubernetes client initialization.",
"Debug: Kubernetes client initialized, server=fake-server.",
"Debug: Checking cache configuration.",
"Debug: Cache configuration loaded, type=file.",
"Debug: Cache disabled.",
"Debug: Analysis configuration loaded, filters=[Pod], language=english, namespace=default, labelSelector=none, explain=false, maxConcurrency=10, withDoc=false, withStats=false.",
}
for _, expected := range expectedOutputs {
if !util.Contains(output, expected) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expected, output)
}
}
}
// Test: Verbose output in NewAnalysis with explain=true
func TestVerbose_NewAnalysisWithExplain(t *testing.T) {
// Set viper config.
viper.Set("verbose", true)
viper.Set("kubecontext", "dummy")
viper.Set("kubeconfig", "dummy")
// Set a dummy AI configuration.
dummyAIConfig := map[string]interface{}{
"defaultProvider": "dummy",
"providers": []map[string]interface{}{
{
"name": "dummy",
"baseUrl": "http://dummy",
"model": "dummy-model",
"customHeaders": map[string]string{},
},
},
}
viper.Set("ai", dummyAIConfig)
// Patch kubernetes.NewClient to return a dummy client.
patches := gomonkey.ApplyFunc(kubernetes.NewClient, func(kubecontext, kubeconfig string) (*kubernetes.Client, error) {
return &kubernetes.Client{
Config: &rest.Config{Host: "fake-server"},
}, nil
})
defer patches.Reset()
// Patch ai.NewClient to return a NoOp client.
patches2 := gomonkey.ApplyFunc(ai.NewClient, func(name string) ai.IAI {
return &ai.NoOpAIClient{}
})
defer patches2.Reset()
output := util.CaptureOutput(func() {
a, err := NewAnalysis(
"", "english", []string{"Pod"}, "default", "", true,
true, // explain
10, false, false, []string{}, false,
)
require.NoError(t, err)
a.Close()
})
expectedOutputs := []string{
"Debug: Checking AI configuration.",
"Debug: Using default AI provider dummy.",
"Debug: AI configuration loaded, provider=dummy, baseUrl=http://dummy, model=dummy-model.",
"Debug: Checking AI client initialization.",
"Debug: AI client initialized.",
}
for _, expected := range expectedOutputs {
if !util.Contains(output, expected) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expected, output)
}
}
}
// Test: Verbose output in RunAnalysis with filter flag
func TestVerbose_RunAnalysisWithFilter(t *testing.T) {
viper.Set("verbose", true)
// Run analysis with a filter flag ("Pod") to trigger debug output.
output := util.CaptureOutput(func() {
_ = analysis_RunAnalysisFilterTester(t, "Pod")
})
expectedOutputs := []string{
"Debug: Filter flags [Pod] specified, run selected core analyzers.",
"Debug: PodAnalyzer launched.",
"Debug: PodAnalyzer completed without errors.",
}
for _, expected := range expectedOutputs {
if !util.Contains(output, expected) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expected, output)
}
}
}
// Test: Verbose output in RunAnalysis with active filter
func TestVerbose_RunAnalysisWithActiveFilter(t *testing.T) {
viper.Set("verbose", true)
viper.SetDefault("active_filters", "Ingress")
output := util.CaptureOutput(func() {
_ = analysis_RunAnalysisFilterTester(t, "")
})
expectedOutputs := []string{
"Debug: Found active filters [Ingress], run selected core analyzers.",
"Debug: IngressAnalyzer launched.",
"Debug: IngressAnalyzer completed without errors.",
}
for _, expected := range expectedOutputs {
if !util.Contains(output, expected) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expected, output)
}
}
}
// Test: Verbose output in RunAnalysis without any filter (run all core analyzers)
func TestVerbose_RunAnalysisWithoutFilter(t *testing.T) {
viper.Set("verbose", true)
// Clear filter flag and active_filters to run all core analyzers.
viper.SetDefault("active_filters", []string{})
output := util.CaptureOutput(func() {
_ = analysis_RunAnalysisFilterTester(t, "")
})
// Check for debug message indicating no filters.
expectedNoFilter := "Debug: No filters selected and no active filters found, run all core analyzers."
if !util.Contains(output, expectedNoFilter) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expectedNoFilter, output)
}
// Get all core analyzers from analyzer.GetAnalyzerMap()
coreAnalyzerMap, _ := analyzer.GetAnalyzerMap()
for _, analyzerInstance := range coreAnalyzerMap {
analyzerType := getTypeName(analyzerInstance)
expectedLaunched := fmt.Sprintf("Debug: %s launched.", analyzerType)
expectedCompleted := fmt.Sprintf("Debug: %s completed without errors.", analyzerType)
if !util.Contains(output, expectedLaunched) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expectedLaunched, output)
}
if !util.Contains(output, expectedCompleted) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expectedCompleted, output)
}
}
}
// Test: Verbose output in RunCustomAnalysis without custom analyzer
func TestVerbose_RunCustomAnalysisWithoutCustomAnalyzer(t *testing.T) {
viper.Set("verbose", true)
// Set custom_analyzers to empty array to trigger "No custom analyzers" debug message.
viper.Set("custom_analyzers", []interface{}{})
analysisObj := &Analysis{
MaxConcurrency: 1,
}
output := util.CaptureOutput(func() {
analysisObj.RunCustomAnalysis()
})
expected := "Debug: No custom analyzers found."
if !util.Contains(output, "Debug: No custom analyzers found.") {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expected, output)
}
}
// Test: Verbose output in RunCustomAnalysis with custom analyzer
func TestVerbose_RunCustomAnalysisWithCustomAnalyzer(t *testing.T) {
viper.Set("verbose", true)
// Set custom_analyzers with one custom analyzer using "fake" connection.
viper.Set("custom_analyzers", []map[string]interface{}{
{
"name": "TestCustomAnalyzer",
"connection": map[string]interface{}{"url": "127.0.0.1", "port": "2333"},
},
})
analysisObj := &Analysis{
MaxConcurrency: 1,
}
output := util.CaptureOutput(func() {
analysisObj.RunCustomAnalysis()
})
assert.Equal(t, 1, len(analysisObj.Errors)) // connection error
expectedOutputs := []string{
"Debug: Found custom analyzers [TestCustomAnalyzer].",
"Debug: TestCustomAnalyzer launched.",
"Debug: TestCustomAnalyzer completed with errors.",
}
for _, expected := range expectedOutputs {
if !util.Contains(output, expected) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expected, output)
}
}
}
// Test: Verbose output in GetAIResults
func TestVerbose_GetAIResults(t *testing.T) {
viper.Set("verbose", true)
disabledCache := cache.New("disabled-cache")
disabledCache.DisableCache()
aiClient := &ai.NoOpAIClient{}
analysisObj := Analysis{
AIClient: aiClient,
Cache: disabledCache,
Results: []common.Result{
{
Kind: "Deployment",
Name: "test-deployment",
Error: []common.Failure{{Text: "test-problem", Sensitive: []common.Sensitive{}}},
Details: "test-solution",
ParentObject: "parent-resource",
},
},
Namespace: "default",
}
output := util.CaptureOutput(func() {
_ = analysisObj.GetAIResults("json", false)
})
expected := "Debug: Generating AI analysis."
if !util.Contains(output, expected) {
t.Errorf("Expected output to contain: '%s', but got output: '%s'", expected, output)
}
}

View File

@@ -55,11 +55,27 @@ func (a *Analysis) jsonOutput() ([]byte, error) {
return output, nil
}
func (a *Analysis) PrintStats() []byte {
var output strings.Builder
output.WriteString(color.YellowString("The stats mode allows for debugging and understanding the time taken by an analysis by displaying the statistics of each analyzer.\n"))
for _, stat := range a.Stats {
output.WriteString(fmt.Sprintf("- Analyzer %s took %s \n", color.YellowString(stat.Analyzer), stat.DurationTime))
}
return []byte(output.String())
}
func (a *Analysis) textOutput() ([]byte, error) {
var output strings.Builder
// Print the AI provider used for this analysis
output.WriteString(fmt.Sprintf("AI Provider: %s\n", color.YellowString(a.AnalysisAIProvider)))
// Print the AI provider used for this analysis (if explain was enabled).
if a.Explain {
output.WriteString(fmt.Sprintf("AI Provider: %s\n", color.YellowString(a.AnalysisAIProvider)))
} else {
output.WriteString(fmt.Sprintf("AI Provider: %s\n", color.YellowString("AI not used; --explain not set")))
}
if len(a.Errors) != 0 {
output.WriteString("\n")
@@ -74,8 +90,10 @@ func (a *Analysis) textOutput() ([]byte, error) {
return []byte(output.String()), nil
}
for n, result := range a.Results {
output.WriteString(fmt.Sprintf("%s %s(%s)\n", color.CyanString("%d", n),
color.YellowString(result.Name), color.CyanString(result.ParentObject)))
output.WriteString(fmt.Sprintf("%s: %s %s(%s)\n", color.CyanString("%d", n),
color.HiYellowString(result.Kind),
color.YellowString(result.Name),
color.CyanString(result.ParentObject)))
for _, err := range result.Error {
output.WriteString(fmt.Sprintf("- %s %s\n", color.RedString("Error:"), color.RedString(err.Text)))
if err.KubernetesDoc != "" {

View File

@@ -0,0 +1,64 @@
/*
Copyright 2024 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analysis
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestPrintOutput(t *testing.T) {
require.NotEmpty(t, getOutputFormats())
tests := []struct {
name string
a *Analysis
format string
expectedOutput string
expectedErr string
}{
{
name: "json format",
a: &Analysis{},
format: "json",
expectedOutput: "{\n \"provider\": \"\",\n \"errors\": null,\n \"status\": \"OK\",\n \"problems\": 0,\n \"results\": null\n}",
},
{
name: "text format",
a: &Analysis{},
format: "text",
expectedOutput: "AI Provider: AI not used; --explain not set\n\nNo problems detected\n",
},
{
name: "unsupported format",
a: &Analysis{},
format: "unsupported",
expectedErr: "unsupported output format: unsupported. Available format",
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
output, err := tt.a.PrintOutput(tt.format)
if tt.expectedErr == "" {
require.NoError(t, err)
require.Contains(t, string(output), tt.expectedOutput)
} else {
require.ErrorContains(t, err, tt.expectedErr)
require.Nil(t, output)
}
})
}
}

View File

@@ -32,21 +32,38 @@ var (
)
var coreAnalyzerMap = map[string]common.IAnalyzer{
"Pod": PodAnalyzer{},
"Deployment": DeploymentAnalyzer{},
"ReplicaSet": ReplicaSetAnalyzer{},
"PersistentVolumeClaim": PvcAnalyzer{},
"Service": ServiceAnalyzer{},
"Ingress": IngressAnalyzer{},
"StatefulSet": StatefulSetAnalyzer{},
"CronJob": CronJobAnalyzer{},
"Node": NodeAnalyzer{},
"Pod": PodAnalyzer{},
"Deployment": DeploymentAnalyzer{},
"ReplicaSet": ReplicaSetAnalyzer{},
"PersistentVolumeClaim": PvcAnalyzer{},
"Service": ServiceAnalyzer{},
"Ingress": IngressAnalyzer{},
"StatefulSet": StatefulSetAnalyzer{},
"Job": JobAnalyzer{},
"CronJob": CronJobAnalyzer{},
"Node": NodeAnalyzer{},
"ValidatingWebhookConfiguration": ValidatingWebhookAnalyzer{},
"MutatingWebhookConfiguration": MutatingWebhookAnalyzer{},
"ConfigMap": ConfigMapAnalyzer{},
}
var additionalAnalyzerMap = map[string]common.IAnalyzer{
"HorizontalPodAutoScaler": HpaAnalyzer{},
"HorizontalPodAutoscaler": HpaAnalyzer{},
"PodDisruptionBudget": PdbAnalyzer{},
"NetworkPolicy": NetworkPolicyAnalyzer{},
"Log": LogAnalyzer{},
"GatewayClass": GatewayClassAnalyzer{},
"Gateway": GatewayAnalyzer{},
"HTTPRoute": HTTPRouteAnalyzer{},
"Storage": StorageAnalyzer{},
"Security": SecurityAnalyzer{},
"ClusterCatalog": ClusterCatalogAnalyzer{},
"ClusterExtension": ClusterExtensionAnalyzer{},
"ClusterServiceVersion": ClusterServiceVersionAnalyzer{},
"Subscription": SubscriptionAnalyzer{},
"InstallPlan": InstallPlanAnalyzer{},
"CatalogSource": CatalogSourceAnalyzer{},
"OperatorGroup": OperatorGroupAnalyzer{},
}
func ListFilters() ([]string, []string, []string) {
@@ -71,7 +88,7 @@ func ListFilters() ([]string, []string, []string) {
fmt.Println(color.RedString(err.Error()))
os.Exit(1)
}
integrationAnalyzers = append(integrationAnalyzers, in.GetAnalyzerName())
integrationAnalyzers = append(integrationAnalyzers, in.GetAnalyzerName()...)
}
}

View File

@@ -0,0 +1,53 @@
package analyzer
import (
"fmt"
"strings"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
)
type CatalogSourceAnalyzer struct{}
var catSrcGVR = schema.GroupVersionResource{
Group: "operators.coreos.com",
Version: "v1alpha1",
Resource: "catalogsources",
}
func (CatalogSourceAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
kind := "CatalogSource"
if a.Client.GetDynamicClient() == nil {
return nil, fmt.Errorf("dynamic client is nil in %s analyzer", kind)
}
list, err := a.Client.GetDynamicClient().
Resource(catSrcGVR).Namespace(metav1.NamespaceAll).
List(a.Context, metav1.ListOptions{})
if err != nil {
return nil, err
}
var results []common.Result
for _, item := range list.Items {
ns, name := item.GetNamespace(), item.GetName()
state, _, _ := unstructured.NestedString(item.Object, "status", "connectionState", "lastObservedState")
addr, _, _ := unstructured.NestedString(item.Object, "status", "connectionState", "address")
// Only report if state is present and not READY
if state != "" && strings.ToUpper(state) != "READY" {
results = append(results, common.Result{
Kind: kind,
Name: ns + "/" + name,
Error: []common.Failure{{
Text: fmt.Sprintf("connectionState=%s (address=%s)", state, addr),
}},
})
}
}
return results, nil
}

View File

@@ -0,0 +1,107 @@
package analyzer
import (
"context"
"strings"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
dynamicfake "k8s.io/client-go/dynamic/fake"
)
func TestCatalogSourceAnalyzer_UnhealthyState_ReturnsResult(t *testing.T) {
cs := &unstructured.Unstructured{
Object: map[string]any{
"apiVersion": "operators.coreos.com/v1alpha1",
"kind": "CatalogSource",
"metadata": map[string]any{
"name": "broken-operators-external",
"namespace": "openshift-marketplace",
},
"status": map[string]any{
"connectionState": map[string]any{
"lastObservedState": "TRANSIENT_FAILURE",
"address": "not-a-real-host.invalid:50051",
},
},
},
}
listKinds := map[schema.GroupVersionResource]string{
{Group: "operators.coreos.com", Version: "v1alpha1", Resource: "catalogsources"}: "CatalogSourceList",
}
scheme := runtime.NewScheme()
dc := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(scheme, listKinds, cs)
a := common.Analyzer{
Context: context.TODO(),
Client: &kubernetes.Client{DynamicClient: dc},
}
res, err := (CatalogSourceAnalyzer{}).Analyze(a)
if err != nil {
t.Fatalf("Analyze error: %v", err)
}
if len(res) != 1 {
t.Fatalf("expected 1 result, got %d", len(res))
}
if res[0].Kind != "CatalogSource" || !strings.Contains(res[0].Name, "openshift-marketplace/broken-operators-external") {
t.Fatalf("unexpected result: %#v", res[0])
}
if len(res[0].Error) == 0 || !strings.Contains(res[0].Error[0].Text, "TRANSIENT_FAILURE") {
t.Fatalf("expected TRANSIENT_FAILURE in message, got %#v", res[0].Error)
}
}
func TestCatalogSourceAnalyzer_HealthyOrNoState_Ignored(t *testing.T) {
// One READY (healthy), one with no status at all: both should be ignored.
ready := &unstructured.Unstructured{
Object: map[string]any{
"apiVersion": "operators.coreos.com/v1alpha1",
"kind": "CatalogSource",
"metadata": map[string]any{
"name": "ready-operators",
"namespace": "openshift-marketplace",
},
"status": map[string]any{
"connectionState": map[string]any{
"lastObservedState": "READY",
"address": "somewhere",
},
},
},
}
nostate := &unstructured.Unstructured{
Object: map[string]any{
"apiVersion": "operators.coreos.com/v1alpha1",
"kind": "CatalogSource",
"metadata": map[string]any{
"name": "no-status-operators",
"namespace": "openshift-marketplace",
},
},
}
listKinds := map[schema.GroupVersionResource]string{
{Group: "operators.coreos.com", Version: "v1alpha1", Resource: "catalogsources"}: "CatalogSourceList",
}
scheme := runtime.NewScheme()
dc := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(scheme, listKinds, ready, nostate)
a := common.Analyzer{
Context: context.TODO(),
Client: &kubernetes.Client{DynamicClient: dc},
}
res, err := (CatalogSourceAnalyzer{}).Analyze(a)
if err != nil {
t.Fatalf("Analyze error: %v", err)
}
if len(res) != 0 {
t.Fatalf("expected 0 results (healthy/nostate ignored), got %d", len(res))
}
}

View File

@@ -0,0 +1,161 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analyzer
import (
"fmt"
"regexp"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
type ClusterCatalogAnalyzer struct{}
func (ClusterCatalogAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
kind := "ClusterCatalog"
AnalyzerErrorsMetric.DeletePartialMatch(map[string]string{
"analyzer_name": kind,
})
var clusterCatalogGVR = schema.GroupVersionResource{
Group: "olm.operatorframework.io",
Version: "v1",
Resource: "clustercatalogs",
}
if a.Client == nil {
return nil, fmt.Errorf("client is nil in ClusterCatalogAnalyzer")
}
if a.Client.GetDynamicClient() == nil {
return nil, fmt.Errorf("dynamic client is nil in ClusterCatalogAnalyzer")
}
list, err := a.Client.GetDynamicClient().Resource(clusterCatalogGVR).Namespace("").List(a.Context, metav1.ListOptions{})
if err != nil {
return nil, err
}
var preAnalysis = map[string]common.PreAnalysis{}
for _, item := range list.Items {
var failures []common.Failure
catalog, err := ConvertToClusterCatalog(&item)
if err != nil {
continue
}
fmt.Printf("ClusterCatalog: %s | Source: %s\n", catalog.Name, catalog.Spec.Source.Image.Ref)
failures, err = ValidateClusterCatalog(failures, catalog)
if err != nil {
continue
}
if len(failures) > 0 {
preAnalysis[catalog.Name] = common.PreAnalysis{
Catalog: *catalog,
FailureDetails: failures,
}
AnalyzerErrorsMetric.WithLabelValues(kind, catalog.Name, "").Set(float64(len(failures)))
}
}
for key, value := range preAnalysis {
var currentAnalysis = common.Result{
Kind: kind,
Name: key,
Error: value.FailureDetails,
}
parent, found := util.GetParent(a.Client, value.Node.ObjectMeta)
if found {
currentAnalysis.ParentObject = parent
}
a.Results = append(a.Results, currentAnalysis)
}
return a.Results, err
}
func ConvertToClusterCatalog(u *unstructured.Unstructured) (*common.ClusterCatalog, error) {
var cc common.ClusterCatalog
err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, &cc)
if err != nil {
return nil, fmt.Errorf("failed to convert to ClusterCatalog: %w", err)
}
return &cc, nil
}
func addCatalogConditionFailure(failures []common.Failure, catalogName string, catalogCondition metav1.Condition) []common.Failure {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("OLMv1 ClusterCatalog: %s has condition of type %s, reason %s: %s", catalogName, catalogCondition.Type, catalogCondition.Reason, catalogCondition.Message),
Sensitive: []common.Sensitive{
{
Unmasked: catalogName,
Masked: util.MaskString(catalogName),
},
},
})
return failures
}
func addCatalogFailure(failures []common.Failure, catalogName string, err error) []common.Failure {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("%s has error: %s", catalogName, err.Error()),
Sensitive: []common.Sensitive{
{
Unmasked: catalogName,
Masked: util.MaskString(catalogName),
},
},
})
return failures
}
func ValidateClusterCatalog(failures []common.Failure, catalog *common.ClusterCatalog) ([]common.Failure, error) {
if !isValidImageRef(catalog.Spec.Source.Image.Ref) {
failures = addCatalogFailure(failures, catalog.Name, fmt.Errorf("invalid image ref format in spec.source.image.ref: %s", catalog.Spec.Source.Image.Ref))
}
// Check status.resolvedSource.image.ref ends with @sha256:...
if catalog.Status.ResolvedSource != nil {
if catalog.Status.ResolvedSource.Image.Ref == "" {
failures = addCatalogFailure(failures, catalog.Name, fmt.Errorf("missing status.resolvedSource.image.ref"))
}
if !regexp.MustCompile(`@sha256:[a-f0-9]{64}$`).MatchString(catalog.Status.ResolvedSource.Image.Ref) {
failures = addCatalogFailure(failures, catalog.Name, fmt.Errorf("status.resolvedSource.image.ref must end with @sha256:<digest>"))
}
}
for _, condition := range catalog.Status.Conditions {
if condition.Status != "True" && condition.Type == "Serving" {
failures = addCatalogConditionFailure(failures, catalog.Name, condition)
}
if condition.Type == "Progressing" && condition.Reason != "Succeeded" {
failures = addCatalogConditionFailure(failures, catalog.Name, condition)
}
}
return failures, nil
}
// isValidImageRef does a simple regex check to validate image refs
func isValidImageRef(ref string) bool {
pattern := `^([a-zA-Z0-9\-\.]+(?::[0-9]+)?/)?([a-z0-9]+(?:[._\-\/][a-z0-9]+)*)(:[\w][\w.-]{0,127})?(?:@sha256:[a-f0-9]{64})?$`
return regexp.MustCompile(pattern).MatchString(ref)
}

View File

@@ -0,0 +1,182 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analyzer
import (
"context"
"fmt"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
dynamicfake "k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/kubernetes/fake"
)
func TestClusterCatalogAnalyzer(t *testing.T) {
gvr := schema.GroupVersionResource{
Group: "olm.operatorframework.io",
Version: "v1",
Resource: "clustercatalogs",
}
scheme := runtime.NewScheme()
dynamicClient := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(
scheme,
map[schema.GroupVersionResource]string{
gvr: "ClusterCatalogList",
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterCatalog",
"metadata": map[string]interface{}{
"name": "Valid ClusterCatalog",
},
"spec": map[string]interface{}{
"availabilityMode": "Available",
"source": map[string]interface{}{
"type": "Image",
"image": map[string]interface{}{
"ref": "registry.redhat.io/redhat/community-operator-index:v4.19",
"pollIntervalMinutes": float64(10),
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Progressing",
"status": "True",
"reason": "Succeeded",
},
map[string]interface{}{
"type": "Serving",
"status": "True",
"reason": "Available",
},
},
},
},
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterCatalog",
"metadata": map[string]interface{}{
"name": "Invalid availabilityMode",
},
"spec": map[string]interface{}{
"availabilityMode": "test",
"source": map[string]interface{}{
"type": "Image",
"image": map[string]interface{}{
"ref": "registry.redhat.io/redhat/community-operator-index:v4.19",
"pollIntervalMinutes": float64(10),
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Progressing",
"status": "True",
"reason": "Retrying",
},
},
},
},
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterCatalog",
"metadata": map[string]interface{}{
"name": "Invalid pollIntervalMinutes",
},
"spec": map[string]interface{}{
"availabilityMode": "Available",
"source": map[string]interface{}{
"type": "Image",
"image": map[string]interface{}{
"ref": "registry.redhat.io/redhat/community-operator-index:v4.19",
"pollIntervalMinutes": float64(0),
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Progressing",
"status": "True",
"reason": "Retrying",
},
},
},
},
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterCatalog",
"metadata": map[string]interface{}{
"name": "Invalid image reference",
},
"spec": map[string]interface{}{
"availabilityMode": "Available",
"source": map[string]interface{}{
"type": "Image",
"image": map[string]interface{}{
"ref": "quay.io/test/community-operator-index:v4.19",
"pollIntervalMinutes": float64(10),
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Progressing",
"status": "True",
"reason": "Retrying",
},
},
},
},
},
)
config := common.Analyzer{
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(),
DynamicClient: dynamicClient,
},
Context: context.Background(),
Namespace: "test",
}
ccAnalyzer := ClusterCatalogAnalyzer{}
results, err := ccAnalyzer.Analyze(config)
for _, res := range results {
fmt.Printf("Result: %s | Failures: %d\n", res.Name, len(res.Error))
for _, err := range res.Error {
fmt.Printf(" - %s\n", err)
}
}
require.NoError(t, err)
require.Equal(t, 3, len(results))
}

View File

@@ -0,0 +1,148 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analyzer
import (
"fmt"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
type ClusterExtensionAnalyzer struct{}
func (ClusterExtensionAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
kind := "ClusterExtension"
AnalyzerErrorsMetric.DeletePartialMatch(map[string]string{
"analyzer_name": kind,
})
var clusterExtensionGVR = schema.GroupVersionResource{
Group: "olm.operatorframework.io",
Version: "v1",
Resource: "clusterextensions",
}
if a.Client == nil {
return nil, fmt.Errorf("client is nil in ClusterExtensionAnalyzer")
}
if a.Client.GetDynamicClient() == nil {
return nil, fmt.Errorf("dynamic client is nil in ClusterExtensionAnalyzer")
}
list, err := a.Client.GetDynamicClient().Resource(clusterExtensionGVR).Namespace("").List(a.Context, metav1.ListOptions{})
if err != nil {
return nil, err
}
var preAnalysis = map[string]common.PreAnalysis{}
for _, item := range list.Items {
var failures []common.Failure
extension, err := ConvertToClusterExtension(&item)
if err != nil {
continue
}
fmt.Printf("ClusterExtension: %s | Source: %s\n", extension.Name, extension.Spec.Source.Catalog.PackageName)
failures, err = ValidateClusterExtension(failures, extension)
if err != nil {
continue
}
if len(failures) > 0 {
preAnalysis[extension.Name] = common.PreAnalysis{
Extension: *extension,
FailureDetails: failures,
}
AnalyzerErrorsMetric.WithLabelValues(kind, extension.Name, "").Set(float64(len(failures)))
}
}
for key, value := range preAnalysis {
var currentAnalysis = common.Result{
Kind: kind,
Name: key,
Error: value.FailureDetails,
}
parent, found := util.GetParent(a.Client, value.Node.ObjectMeta)
if found {
currentAnalysis.ParentObject = parent
}
a.Results = append(a.Results, currentAnalysis)
}
return a.Results, err
}
func ConvertToClusterExtension(u *unstructured.Unstructured) (*common.ClusterExtension, error) {
var ce common.ClusterExtension
err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, &ce)
if err != nil {
return nil, fmt.Errorf("failed to convert to ClusterExtension: %w", err)
}
return &ce, nil
}
func addExtensionConditionFailure(failures []common.Failure, extensionName string, extensionCondition metav1.Condition) []common.Failure {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("OLMv1 ClusterExtension: %s has condition of type %s, reason %s: %s", extensionName, extensionCondition.Type, extensionCondition.Reason, extensionCondition.Message),
Sensitive: []common.Sensitive{
{
Unmasked: extensionName,
Masked: util.MaskString(extensionName),
},
},
})
return failures
}
func addExtensionFailure(failures []common.Failure, extensionName string, err error) []common.Failure {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("%s has error: %s", extensionName, err.Error()),
Sensitive: []common.Sensitive{
{
Unmasked: extensionName,
Masked: util.MaskString(extensionName),
},
},
})
return failures
}
func ValidateClusterExtension(failures []common.Failure, extension *common.ClusterExtension) ([]common.Failure, error) {
if extension.Spec.Source.Catalog != nil && extension.Spec.Source.Catalog.UpgradeConstraintPolicy != "CatalogProvided" && extension.Spec.Source.Catalog.UpgradeConstraintPolicy != "SelfCertified" {
failures = addExtensionFailure(failures, extension.Name, fmt.Errorf("invalid or missing extension.Spec.Source.Catalog.UpgradeConstraintPolicy (expecting 'SelfCertified' or 'CatalogProvided')"))
}
if extension.Spec.Source.SourceType != "Catalog" {
failures = addExtensionFailure(failures, extension.Name, fmt.Errorf("invalid or missing spec.source.sourceType (expecting 'Catalog')"))
}
for _, condition := range extension.Status.Conditions {
if condition.Status != "True" && condition.Type == "Installed" {
failures = addExtensionConditionFailure(failures, extension.Name, condition)
}
if condition.Type == "Progressing" && condition.Reason != "Succeeded" {
failures = addExtensionConditionFailure(failures, extension.Name, condition)
}
}
return failures, nil
}

View File

@@ -0,0 +1,179 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analyzer
import (
"context"
"fmt"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
dynamicfake "k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/kubernetes/fake"
)
func TestClusterExtensionAnalyzer(t *testing.T) {
gvr := schema.GroupVersionResource{
Group: "olm.operatorframework.io",
Version: "v1",
Resource: "clusterextensions",
}
scheme := runtime.NewScheme()
dynamicClient := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(
scheme,
map[schema.GroupVersionResource]string{
gvr: "ClusterExtensionList",
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterExtension",
"metadata": map[string]interface{}{
"name": "Valid SelfCertified ClusterExtension",
},
"spec": map[string]interface{}{
"source": map[string]interface{}{
"sourceType": "Catalog",
"catalog": map[string]interface{}{
"upgradeConstraintPolicy": "SelfCertified",
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Installed",
"status": "True",
"reason": "Succeeded",
},
},
},
},
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterExtension",
"metadata": map[string]interface{}{
"name": "Valid CatalogProvided ClusterExtension",
},
"spec": map[string]interface{}{
"source": map[string]interface{}{
"sourceType": "Catalog",
"catalog": map[string]interface{}{
"upgradeConstraintPolicy": "CatalogProvided",
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Installed",
"status": "True",
"reason": "Succeeded",
},
},
},
},
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterExtension",
"metadata": map[string]interface{}{
"name": "Invalid UpgradeConstraintPolicy",
},
"spec": map[string]interface{}{
"source": map[string]interface{}{
"sourceType": "Catalog",
"catalog": map[string]interface{}{
"upgradeConstraintPolicy": "InvalidPolicy",
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Progressing",
"status": "True",
"reason": "Retrying",
},
map[string]interface{}{
"type": "Installed",
"status": "False",
"reason": "Failed",
},
},
},
},
},
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "olm.operatorframework.io/v1",
"kind": "ClusterExtension",
"metadata": map[string]interface{}{
"name": "Invalid SourceType",
},
"spec": map[string]interface{}{
"source": map[string]interface{}{
"sourceType": "Git",
"catalog": map[string]interface{}{
"upgradeConstraintPolicy": "CatalogProvided",
},
},
},
"status": map[string]interface{}{
"conditions": []interface{}{
map[string]interface{}{
"type": "Progressing",
"status": "True",
"reason": "Retrying",
},
map[string]interface{}{
"type": "Installed",
"status": "False",
"reason": "Failed",
},
},
},
},
},
)
config := common.Analyzer{
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(),
DynamicClient: dynamicClient,
},
Context: context.Background(),
Namespace: "test",
}
ceAnalyzer := ClusterExtensionAnalyzer{}
results, err := ceAnalyzer.Analyze(config)
for _, res := range results {
fmt.Printf("Result: %s | Failures: %d\n", res.Name, len(res.Error))
for _, err := range res.Error {
fmt.Printf(" - %s\n", err)
}
}
require.NoError(t, err)
require.Equal(t, 2, len(results))
}

View File

@@ -0,0 +1,82 @@
package analyzer
import (
"fmt"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
)
type ClusterServiceVersionAnalyzer struct{}
var csvGVR = schema.GroupVersionResource{
Group: "operators.coreos.com", Version: "v1alpha1", Resource: "clusterserviceversions",
}
func (ClusterServiceVersionAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
kind := "ClusterServiceVersion"
if a.Client.GetDynamicClient() == nil {
return nil, fmt.Errorf("dynamic client is nil in %s analyzer", kind)
}
list, err := a.Client.GetDynamicClient().
Resource(csvGVR).Namespace(metav1.NamespaceAll).
List(a.Context, metav1.ListOptions{})
if err != nil {
return nil, err
}
var results []common.Result
for _, item := range list.Items {
ns := item.GetNamespace()
name := item.GetName()
phase, _, _ := unstructured.NestedString(item.Object, "status", "phase")
var failures []common.Failure
if phase != "" && phase != "Succeeded" {
// Superfície de condições para contexto
if conds, _, _ := unstructured.NestedSlice(item.Object, "status", "conditions"); len(conds) > 0 {
if msg := pickWorstCondition(conds); msg != "" {
failures = append(failures, common.Failure{Text: fmt.Sprintf("phase=%q: %s", phase, msg)})
}
} else {
failures = append(failures, common.Failure{Text: fmt.Sprintf("phase=%q (see status.conditions)", phase)})
}
}
if len(failures) > 0 {
results = append(results, common.Result{
Kind: kind,
Name: ns + "/" + name,
Error: failures,
})
}
}
return results, nil
}
// reaproveitamos o heurístico já usado em outros pontos
func pickWorstCondition(conds []interface{}) string {
for _, c := range conds {
m, ok := c.(map[string]any)
if !ok {
continue
}
if s, _ := m["status"].(string); s == "True" {
continue
}
r, _ := m["reason"].(string)
msg, _ := m["message"].(string)
if r == "" && msg == "" {
continue
}
if r != "" && msg != "" {
return r + ": " + msg
}
return r + msg
}
return ""
}

View File

@@ -0,0 +1,78 @@
package analyzer
import (
"context"
"strings"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
dynamicfake "k8s.io/client-go/dynamic/fake"
)
func TestClusterServiceVersionAnalyzer(t *testing.T) {
ok := &unstructured.Unstructured{
Object: map[string]any{
"apiVersion": "operators.coreos.com/v1alpha1",
"kind": "ClusterServiceVersion",
"metadata": map[string]any{
"name": "ok",
"namespace": "ns1",
},
"status": map[string]any{"phase": "Succeeded"},
},
}
bad := &unstructured.Unstructured{
Object: map[string]any{
"apiVersion": "operators.coreos.com/v1alpha1",
"kind": "ClusterServiceVersion",
"metadata": map[string]any{
"name": "bad",
"namespace": "ns1",
},
"status": map[string]any{
"phase": "Failed",
// IMPORTANT: conditions must be []interface{}, not []map[string]any
"conditions": []interface{}{
map[string]any{
"status": "False",
"reason": "ErrorResolving",
"message": "missing dep",
},
},
},
},
}
listKinds := map[schema.GroupVersionResource]string{
{Group: "operators.coreos.com", Version: "v1alpha1", Resource: "clusterserviceversions"}: "ClusterServiceVersionList",
}
// Use a non-nil scheme with dynamicfake
scheme := runtime.NewScheme()
dc := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(scheme, listKinds, ok, bad)
a := common.Analyzer{
Context: context.TODO(),
Client: &kubernetes.Client{DynamicClient: dc},
}
res, err := (ClusterServiceVersionAnalyzer{}).Analyze(a)
if err != nil {
t.Fatalf("Analyze error: %v", err)
}
if len(res) != 1 {
t.Fatalf("expected 1 result, got %d", len(res))
}
if res[0].Kind != "ClusterServiceVersion" || !strings.Contains(res[0].Name, "ns1/bad") {
t.Fatalf("unexpected result: %#v", res[0])
}
if len(res[0].Error) == 0 || !strings.Contains(res[0].Error[0].Text, "missing dep") {
t.Fatalf("expected 'missing dep' in failure, got %#v", res[0].Error)
}
}

125
pkg/analyzer/configmap.go Normal file
View File

@@ -0,0 +1,125 @@
/*
Copyright 2024 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analyzer
import (
"fmt"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ConfigMapAnalyzer struct{}
func (ConfigMapAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
kind := "ConfigMap"
AnalyzerErrorsMetric.DeletePartialMatch(map[string]string{
"analyzer_name": kind,
})
// Get all ConfigMaps in the namespace
configMaps, err := a.Client.GetClient().CoreV1().ConfigMaps(a.Namespace).List(a.Context, metav1.ListOptions{
LabelSelector: a.LabelSelector,
})
if err != nil {
return nil, err
}
// Get all Pods to check ConfigMap usage
pods, err := a.Client.GetClient().CoreV1().Pods(a.Namespace).List(a.Context, metav1.ListOptions{})
if err != nil {
return nil, err
}
var results []common.Result
// Track which ConfigMaps are used
usedConfigMaps := make(map[string]bool)
configMapUsage := make(map[string][]string) // maps ConfigMap name to list of pods using it
// Analyze ConfigMap usage in Pods
for _, pod := range pods.Items {
// Check volume mounts
for _, volume := range pod.Spec.Volumes {
if volume.ConfigMap != nil {
usedConfigMaps[volume.ConfigMap.Name] = true
configMapUsage[volume.ConfigMap.Name] = append(configMapUsage[volume.ConfigMap.Name], pod.Name)
}
}
// Check environment variables
for _, container := range pod.Spec.Containers {
for _, env := range container.EnvFrom {
if env.ConfigMapRef != nil {
usedConfigMaps[env.ConfigMapRef.Name] = true
configMapUsage[env.ConfigMapRef.Name] = append(configMapUsage[env.ConfigMapRef.Name], pod.Name)
}
}
for _, env := range container.Env {
if env.ValueFrom != nil && env.ValueFrom.ConfigMapKeyRef != nil {
usedConfigMaps[env.ValueFrom.ConfigMapKeyRef.Name] = true
configMapUsage[env.ValueFrom.ConfigMapKeyRef.Name] = append(configMapUsage[env.ValueFrom.ConfigMapKeyRef.Name], pod.Name)
}
}
}
}
// Analyze each ConfigMap
for _, cm := range configMaps.Items {
var failures []common.Failure
// Check for unused ConfigMaps
if !usedConfigMaps[cm.Name] {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("ConfigMap %s is not used by any pods in the namespace", cm.Name),
Sensitive: []common.Sensitive{},
})
}
// Check for empty ConfigMaps
if len(cm.Data) == 0 && len(cm.BinaryData) == 0 {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("ConfigMap %s is empty", cm.Name),
Sensitive: []common.Sensitive{},
})
}
// Check for large ConfigMaps (over 1MB)
totalSize := 0
for _, value := range cm.Data {
totalSize += len(value)
}
for _, value := range cm.BinaryData {
totalSize += len(value)
}
if totalSize > 1024*1024 { // 1MB
failures = append(failures, common.Failure{
Text: fmt.Sprintf("ConfigMap %s is larger than 1MB (%d bytes)", cm.Name, totalSize),
Sensitive: []common.Sensitive{},
})
}
if len(failures) > 0 {
results = append(results, common.Result{
Kind: kind,
Name: fmt.Sprintf("%s/%s", cm.Namespace, cm.Name),
Error: failures,
})
AnalyzerErrorsMetric.WithLabelValues(kind, cm.Name, cm.Namespace).Set(float64(len(failures)))
}
}
return results, nil
}

View File

@@ -0,0 +1,149 @@
/*
Copyright 2024 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analyzer
import (
"context"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
)
func TestConfigMapAnalyzer(t *testing.T) {
tests := []struct {
name string
namespace string
configMaps []v1.ConfigMap
pods []v1.Pod
expectedErrors int
}{
{
name: "unused configmap",
namespace: "default",
configMaps: []v1.ConfigMap{
{
ObjectMeta: metav1.ObjectMeta{
Name: "unused-cm",
Namespace: "default",
},
Data: map[string]string{
"key": "value",
},
},
},
expectedErrors: 1,
},
{
name: "empty configmap",
namespace: "default",
configMaps: []v1.ConfigMap{
{
ObjectMeta: metav1.ObjectMeta{
Name: "empty-cm",
Namespace: "default",
},
},
},
expectedErrors: 1,
},
{
name: "large configmap",
namespace: "default",
configMaps: []v1.ConfigMap{
{
ObjectMeta: metav1.ObjectMeta{
Name: "large-cm",
Namespace: "default",
},
Data: map[string]string{
"key": string(make([]byte, 1024*1024+1)), // 1MB + 1 byte
},
},
},
expectedErrors: 1,
},
{
name: "used configmap",
namespace: "default",
configMaps: []v1.ConfigMap{
{
ObjectMeta: metav1.ObjectMeta{
Name: "used-cm",
Namespace: "default",
},
Data: map[string]string{
"key": "value",
},
},
},
pods: []v1.Pod{
{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pod",
Namespace: "default",
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "test-container",
EnvFrom: []v1.EnvFromSource{
{
ConfigMapRef: &v1.ConfigMapEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "used-cm",
},
},
},
},
},
},
},
},
},
expectedErrors: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := fake.NewSimpleClientset()
// Create test resources
for _, cm := range tt.configMaps {
_, err := client.CoreV1().ConfigMaps(tt.namespace).Create(context.TODO(), &cm, metav1.CreateOptions{})
assert.NoError(t, err)
}
for _, pod := range tt.pods {
_, err := client.CoreV1().Pods(tt.namespace).Create(context.TODO(), &pod, metav1.CreateOptions{})
assert.NoError(t, err)
}
analyzer := ConfigMapAnalyzer{}
results, err := analyzer.Analyze(common.Analyzer{
Client: &kubernetes.Client{Client: client},
Context: context.TODO(),
Namespace: tt.namespace,
})
assert.NoError(t, err)
assert.Equal(t, tt.expectedErrors, len(results))
})
}
}

View File

@@ -43,7 +43,7 @@ func (analyzer CronJobAnalyzer) Analyze(a common.Analyzer) ([]common.Result, err
"analyzer_name": kind,
})
cronJobList, err := a.Client.GetClient().BatchV1().CronJobs(a.Namespace).List(a.Context, v1.ListOptions{})
cronJobList, err := a.Client.GetClient().BatchV1().CronJobs(a.Namespace).List(a.Context, v1.ListOptions{LabelSelector: a.LabelSelector})
if err != nil {
return nil, err
}
@@ -123,15 +123,15 @@ func (analyzer CronJobAnalyzer) Analyze(a common.Analyzer) ([]common.Result, err
AnalyzerErrorsMetric.WithLabelValues(kind, cronJob.Name, cronJob.Namespace).Set(float64(len(failures)))
}
}
for key, value := range preAnalysis {
currentAnalysis := common.Result{
Kind: kind,
Name: key,
Error: value.FailureDetails,
}
a.Results = append(a.Results, currentAnalysis)
for key, value := range preAnalysis {
currentAnalysis := common.Result{
Kind: kind,
Name: key,
Error: value.FailureDetails,
}
a.Results = append(a.Results, currentAnalysis)
}
return a.Results, nil

View File

@@ -15,219 +15,281 @@ package analyzer
import (
"context"
"sort"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/magiconair/properties/assert"
"github.com/stretchr/testify/require"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
)
func TestCronJobSuccess(t *testing.T) {
clientset := fake.NewSimpleClientset(&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "example-cronjob",
Namespace: "default",
Annotations: map[string]string{
"analysisDate": "2022-04-01",
},
Labels: map[string]string{
"app": "example-app",
},
},
Spec: batchv1.CronJobSpec{
Schedule: "*/1 * * * *",
ConcurrencyPolicy: "Allow",
JobTemplate: batchv1.JobTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": "example-app",
},
},
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "example-container",
Image: "nginx",
},
func TestCronJobAnalyzer(t *testing.T) {
tests := []struct {
name string
config common.Analyzer
expectations []struct {
name string
failuresCount int
}
}{
{
name: "Suspended CronJob",
config: common.Analyzer{
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "suspended-job",
Namespace: "default",
},
RestartPolicy: v1.RestartPolicyOnFailure,
},
},
},
},
},
})
config := common.Analyzer{
Client: &kubernetes.Client{
Client: clientset,
},
Context: context.Background(),
Namespace: "default",
}
analyzer := CronJobAnalyzer{}
analysisResults, err := analyzer.Analyze(config)
if err != nil {
t.Error(err)
}
assert.Equal(t, len(analysisResults), 0)
}
func TestCronJobBroken(t *testing.T) {
clientset := fake.NewSimpleClientset(&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "example-cronjob",
Namespace: "default",
Annotations: map[string]string{
"analysisDate": "2022-04-01",
},
Labels: map[string]string{
"app": "example-app",
},
},
Spec: batchv1.CronJobSpec{
Schedule: "*** * * * *",
ConcurrencyPolicy: "Allow",
JobTemplate: batchv1.JobTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": "example-app",
},
},
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "example-container",
Image: "nginx",
},
Spec: batchv1.CronJobSpec{
Schedule: "*/5 * * * *",
Suspend: boolPtr(true),
},
RestartPolicy: v1.RestartPolicyOnFailure,
},
},
),
},
},
},
})
config := common.Analyzer{
Client: &kubernetes.Client{
Client: clientset,
},
Context: context.Background(),
Namespace: "default",
}
analyzer := CronJobAnalyzer{}
analysisResults, err := analyzer.Analyze(config)
if err != nil {
t.Error(err)
}
assert.Equal(t, len(analysisResults), 1)
assert.Equal(t, analysisResults[0].Name, "default/example-cronjob")
assert.Equal(t, analysisResults[0].Kind, "CronJob")
}
func TestCronJobBrokenMultipleNamespaceFiltering(t *testing.T) {
clientset := fake.NewSimpleClientset(
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "example-cronjob",
Context: context.Background(),
Namespace: "default",
Annotations: map[string]string{
"analysisDate": "2022-04-01",
},
expectations: []struct {
name string
failuresCount int
}{
{
name: "default/suspended-job",
failuresCount: 1, // One failure for being suspended
},
},
},
{
name: "Invalid schedule format",
config: common.Analyzer{
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "invalid-schedule",
Namespace: "default",
},
Spec: batchv1.CronJobSpec{
Schedule: "invalid-cron", // Invalid cron format
},
},
),
},
Context: context.Background(),
Namespace: "default",
},
expectations: []struct {
name string
failuresCount int
}{
{
name: "default/invalid-schedule",
failuresCount: 1, // One failure for invalid schedule
},
},
},
{
name: "Negative starting deadline",
config: common.Analyzer{
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "negative-deadline",
Namespace: "default",
},
Spec: batchv1.CronJobSpec{
Schedule: "*/5 * * * *",
StartingDeadlineSeconds: int64Ptr(-60), // Negative deadline
},
},
),
},
Context: context.Background(),
Namespace: "default",
},
expectations: []struct {
name string
failuresCount int
}{
{
name: "default/negative-deadline",
failuresCount: 1, // One failure for negative deadline
},
},
},
{
name: "Valid CronJob",
config: common.Analyzer{
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "valid-job",
Namespace: "default",
},
Spec: batchv1.CronJobSpec{
Schedule: "*/5 * * * *", // Valid cron format
},
},
),
},
Context: context.Background(),
Namespace: "default",
},
expectations: []struct {
name string
failuresCount int
}{
// No expectations for valid job
},
},
{
name: "Multiple issues",
config: common.Analyzer{
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "multiple-issues",
Namespace: "default",
},
Spec: batchv1.CronJobSpec{
Schedule: "invalid-cron",
StartingDeadlineSeconds: int64Ptr(-60),
},
},
),
},
Context: context.Background(),
Namespace: "default",
},
expectations: []struct {
name string
failuresCount int
}{
{
name: "default/multiple-issues",
failuresCount: 2, // Two failures: invalid schedule and negative deadline
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
analyzer := CronJobAnalyzer{}
results, err := analyzer.Analyze(tt.config)
require.NoError(t, err)
require.Len(t, results, len(tt.expectations))
// Sort results by name for consistent comparison
sort.Slice(results, func(i, j int) bool {
return results[i].Name < results[j].Name
})
for i, expectation := range tt.expectations {
require.Equal(t, expectation.name, results[i].Name)
require.Len(t, results[i].Error, expectation.failuresCount)
}
})
}
}
func TestCronJobAnalyzerLabelSelector(t *testing.T) {
clientSet := fake.NewSimpleClientset(
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "job-with-label",
Namespace: "default",
Labels: map[string]string{
"app": "example-app",
"app": "test",
},
},
Spec: batchv1.CronJobSpec{
Schedule: "*** * * * *",
ConcurrencyPolicy: "Allow",
JobTemplate: batchv1.JobTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": "example-app",
},
},
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "example-container",
Image: "nginx",
},
},
RestartPolicy: v1.RestartPolicyOnFailure,
},
},
},
},
Schedule: "invalid-cron", // This should trigger a failure
},
},
&batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "example-cronjob",
Namespace: "other-namespace",
Annotations: map[string]string{
"analysisDate": "2022-04-01",
},
Labels: map[string]string{
"app": "example-app",
},
Name: "job-without-label",
Namespace: "default",
},
Spec: batchv1.CronJobSpec{
Schedule: "*** * * * *",
ConcurrencyPolicy: "Allow",
JobTemplate: batchv1.JobTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": "example-app",
},
},
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "example-container",
Image: "nginx",
},
},
RestartPolicy: v1.RestartPolicyOnFailure,
},
},
},
},
Schedule: "invalid-cron", // This should trigger a failure
},
})
},
)
// Test with label selector
config := common.Analyzer{
Client: &kubernetes.Client{
Client: clientset,
Client: clientSet,
},
Context: context.Background(),
Namespace: "default",
Context: context.Background(),
Namespace: "default",
LabelSelector: "app=test",
}
analyzer := CronJobAnalyzer{}
analysisResults, err := analyzer.Analyze(config)
if err != nil {
t.Error(err)
results, err := analyzer.Analyze(config)
require.NoError(t, err)
require.Equal(t, 1, len(results))
require.Equal(t, "default/job-with-label", results[0].Name)
}
func TestCheckCronScheduleIsValid(t *testing.T) {
tests := []struct {
name string
schedule string
wantErr bool
}{
{
name: "Valid schedule - every 5 minutes",
schedule: "*/5 * * * *",
wantErr: false,
},
{
name: "Valid schedule - specific time",
schedule: "0 2 * * *",
wantErr: false,
},
{
name: "Valid schedule - complex",
schedule: "0 0 1,15 * 3",
wantErr: false,
},
{
name: "Invalid schedule - wrong format",
schedule: "invalid-cron",
wantErr: true,
},
{
name: "Invalid schedule - too many fields",
schedule: "* * * * * *",
wantErr: true,
},
{
name: "Invalid schedule - empty string",
schedule: "",
wantErr: true,
},
}
assert.Equal(t, len(analysisResults), 1)
assert.Equal(t, analysisResults[0].Name, "default/example-cronjob")
assert.Equal(t, analysisResults[0].Kind, "CronJob")
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := CheckCronScheduleIsValid(tt.schedule)
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
}

View File

@@ -46,7 +46,7 @@ func (d DeploymentAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error)
"analyzer_name": kind,
})
deployments, err := a.Client.GetClient().AppsV1().Deployments(a.Namespace).List(context.Background(), v1.ListOptions{})
deployments, err := a.Client.GetClient().AppsV1().Deployments(a.Namespace).List(context.Background(), v1.ListOptions{LabelSelector: a.LabelSelector})
if err != nil {
return nil, err
}
@@ -54,22 +54,41 @@ func (d DeploymentAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error)
for _, deployment := range deployments.Items {
var failures []common.Failure
if *deployment.Spec.Replicas != deployment.Status.Replicas {
doc := apiDoc.GetApiDocV2("spec.replicas")
if *deployment.Spec.Replicas != deployment.Status.ReadyReplicas {
if deployment.Status.Replicas > *deployment.Spec.Replicas {
doc := apiDoc.GetApiDocV2("spec.replicas")
failures = append(failures, common.Failure{
Text: fmt.Sprintf("Deployment %s/%s has %d replicas but %d are available", deployment.Namespace, deployment.Name, *deployment.Spec.Replicas, deployment.Status.Replicas),
KubernetesDoc: doc,
Sensitive: []common.Sensitive{
{
Unmasked: deployment.Namespace,
Masked: util.MaskString(deployment.Namespace),
},
{
Unmasked: deployment.Name,
Masked: util.MaskString(deployment.Name),
},
}})
failures = append(failures, common.Failure{
Text: fmt.Sprintf("Deployment %s/%s has %d replicas in spec but %d replicas in status because status field is not updated yet after scaling and %d replicas are available with status running", deployment.Namespace, deployment.Name, *deployment.Spec.Replicas, deployment.Status.Replicas, deployment.Status.ReadyReplicas),
KubernetesDoc: doc,
Sensitive: []common.Sensitive{
{
Unmasked: deployment.Namespace,
Masked: util.MaskString(deployment.Namespace),
},
{
Unmasked: deployment.Name,
Masked: util.MaskString(deployment.Name),
},
}})
} else {
doc := apiDoc.GetApiDocV2("spec.replicas")
failures = append(failures, common.Failure{
Text: fmt.Sprintf("Deployment %s/%s has %d replicas but %d are available with status running", deployment.Namespace, deployment.Name, *deployment.Spec.Replicas, deployment.Status.ReadyReplicas),
KubernetesDoc: doc,
Sensitive: []common.Sensitive{
{
Unmasked: deployment.Namespace,
Masked: util.MaskString(deployment.Namespace),
},
{
Unmasked: deployment.Name,
Masked: util.MaskString(deployment.Name),
},
}})
}
}
if len(failures) > 0 {
preAnalysis[fmt.Sprintf("%s/%s", deployment.Namespace, deployment.Name)] = common.PreAnalysis{

View File

@@ -151,3 +151,55 @@ func TestDeploymentAnalyzerNamespaceFiltering(t *testing.T) {
assert.Equal(t, analysisResults[0].Kind, "Deployment")
assert.Equal(t, analysisResults[0].Name, "default/example")
}
func TestDeploymentAnalyzerLabelSelectorFiltering(t *testing.T) {
clientset := fake.NewSimpleClientset(
&appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "example",
Namespace: "default",
Labels: map[string]string{
"app": "deployment",
},
},
Spec: appsv1.DeploymentSpec{
Replicas: func() *int32 { i := int32(3); return &i }(),
Template: v1.PodTemplateSpec{
Spec: v1.PodSpec{
Containers: []v1.Container{},
},
},
},
},
&appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "example2",
Namespace: "default",
},
Spec: appsv1.DeploymentSpec{
Replicas: func() *int32 { i := int32(3); return &i }(),
Template: v1.PodTemplateSpec{
Spec: v1.PodSpec{
Containers: []v1.Container{},
},
},
},
},
)
config := common.Analyzer{
Client: &kubernetes.Client{
Client: clientset,
},
Context: context.Background(),
Namespace: "default",
LabelSelector: "app=deployment",
}
deploymentAnalyzer := DeploymentAnalyzer{}
analysisResults, err := deploymentAnalyzer.Analyze(config)
if err != nil {
t.Error(err)
}
assert.Equal(t, len(analysisResults), 1)
}

View File

@@ -1,50 +0,0 @@
/*
Copyright 2023 The K8sGPT Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package analyzer
import (
"context"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func FetchLatestEvent(ctx context.Context, kubernetesClient *kubernetes.Client, namespace string, name string) (*v1.Event, error) {
// get the list of events
events, err := kubernetesClient.GetClient().CoreV1().Events(namespace).List(ctx,
metav1.ListOptions{
FieldSelector: "involvedObject.name=" + name,
})
if err != nil {
return nil, err
}
// find most recent event
var latestEvent *v1.Event
for _, event := range events.Items {
if latestEvent == nil {
// this is required, as a pointer to a loop variable would always yield the latest value in the range
e := event
latestEvent = &e
}
if event.LastTimestamp.After(latestEvent.LastTimestamp.Time) {
// this is required, as a pointer to a loop variable would always yield the latest value in the range
e := event
latestEvent = &e
}
}
return latestEvent, nil
}

137
pkg/analyzer/events_test.go Normal file
View File

@@ -0,0 +1,137 @@
package analyzer_test
import (
"context"
"errors"
"testing"
"time"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/fake"
)
func FetchLatestEvent(ctx context.Context, client kubernetes.Interface, namespace, eventName string) (*v1.Event, error) {
// List events in the specified namespace
events, err := client.CoreV1().Events(namespace).List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
var latestEvent *v1.Event
for _, event := range events.Items {
// Check if the event name matches the requested name (partial match)
if eventName == "" || event.Name == eventName {
if latestEvent == nil || event.LastTimestamp.Time.After(latestEvent.LastTimestamp.Time) {
latestEvent = &event
}
}
}
// If no matching event is found, return an error
if latestEvent == nil {
return nil, errors.New("no matching events found")
}
return latestEvent, nil
}
func TestFetchLatestEvent(t *testing.T) {
fakeClient := fake.NewSimpleClientset()
// Simulating events with different timestamps
event1 := &v1.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test-event-1",
Namespace: "default",
},
LastTimestamp: metav1.Time{Time: time.Now()},
}
event2 := &v1.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test-event-2",
Namespace: "default",
},
LastTimestamp: metav1.Time{Time: time.Now().Add(-time.Hour)}, // event1 should be fetched as it's newer
}
// ✅ Explicitly ensure namespace exists
_, err := fakeClient.CoreV1().Namespaces().Create(context.TODO(), &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{Name: "default"},
}, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create namespace: %v", err)
}
// ✅ Ensure events are properly created and stored in the fake client
_, err = fakeClient.CoreV1().Events("default").Create(context.TODO(), event1, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create event1: %v", err)
}
_, err = fakeClient.CoreV1().Events("default").Create(context.TODO(), event2, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create event2: %v", err)
}
// 🔍 Debug: Check if events exist before running FetchLatestEvent
storedEvents, _ := fakeClient.CoreV1().Events("default").List(context.TODO(), metav1.ListOptions{})
if len(storedEvents.Items) == 0 {
t.Fatal("No events were found in the fake client. Ensure event creation is working correctly.")
}
// Test cases
tests := []struct {
name string
namespace string
nameToFind string
expected *v1.Event
shouldFail bool
}{
{
name: "Valid case - fetch the latest event",
namespace: "default",
nameToFind: "test-event-1", // Match exact event name
expected: event1, // event1 has the latest timestamp
shouldFail: false,
},
{
name: "Nonexistent event",
namespace: "default",
nameToFind: "nonexistent-event", // Should not exist
expected: nil,
shouldFail: true,
},
{
name: "Nonexistent namespace",
namespace: "nonexistent-namespace", // Namespace doesn't exist
nameToFind: "test-event",
expected: nil,
shouldFail: true,
},
}
// Run tests
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Call the function to fetch the latest event
event, err := FetchLatestEvent(context.TODO(), fakeClient, tt.namespace, tt.nameToFind)
// Handle the expected outcomes based on the test case
if tt.shouldFail {
if err == nil {
t.Error("Expected an error, but got nil")
}
if event != nil {
t.Errorf("Expected nil event, but got event: %s", event.Name)
}
} else {
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if event != nil && event.Name != tt.expected.Name {
t.Errorf("Expected event name %s, got %s", tt.expected.Name, event.Name)
}
}
})
}
}

Some files were not shown because too many files have changed in this diff Show More