Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
{
"name": "Codefresh Support Package",
"image": "mcr.microsoft.com/devcontainers/universal:3",
"onCreateCommand": "curl -fsSL https://deno.land/install.sh | sh -s -- -y",
"postCreateCommand": "pip install -e .",
"customizations": {
"vscode": {
"settings": {
"deno.enable": true,
"deno.lint": true
},
// "settings": {
// },
"extensions": [
"denoland.vscode-deno",
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml"
"redhat.vscode-yaml",
"usernamehw.errorlens",
"ms-python.python"
]
}
}
Expand Down
157 changes: 29 additions & 128 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,132 +1,33 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.pyc
*.pyd
*.so

# Virtual environment
venv/
.venv/
env/

# IDE specific files
.idea/
*.iml
.vscode/

# Jupyter Notebook
.ipynb_checkpoints

# Distribution / build files
dist/
build/
*.egg-info/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# OS generated files
.DS_Store
bin
Thumbs.db

# Auto Generated Version
_version.py
3 changes: 3 additions & 0 deletions codresh-support-package.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CF_API_KEY=
CF_URL=
USERPROFILE=
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[project]
name = "cf-support"
dynamic = ["version"]
description = "Codefresh Support Package"
authors = [{ name = "Codefresh Support", email = "support@codefresh.io" }]
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"click>=8.1",
"kubernetes>=31.1",
"PyYAML>=6.0",
"requests>=2.32"
]

[project.scripts]
cf-support = "cf_support.cli:cli"

[build-system]
requires = ["setuptools>=80.9", "setuptools_scm[toml]>=8.3"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/cf_support/_version.py"
23 changes: 23 additions & 0 deletions src/cf_support/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import click
from .commands import pipelines, gitops, onprem, oss

try:
from ._version import version as __version__
except ImportError:
__version__ = "0.0.0+dev.uninstalled"

@click.group()
@click.version_option(version=__version__, prog_name="cf-support")
def cli():
"""Codefresh Support Package

Tool to gather information for Codefresh Support
"""
pass

# Add individual commands directly to the main 'cli' group
cli.add_command(pipelines.pipelines_command)
cli.add_command(gitops.gitops_command)
cli.add_command(onprem.onprem_command)
cli.add_command(oss.oss_command)

10 changes: 10 additions & 0 deletions src/cf_support/commands/gitops.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import click

@click.command(name='gitops') # Use @click.command() directly
@click.option('-n','--namespace', help='The namespace where the GitOps Runtime is installed')
def gitops_command(namespace):
"""Collect data for the Codefresh GitOps Runtime"""

click.echo(f"Executing pipelines command with filter: {filter if filter else 'none'}")
# Add your core logic for the 'pipelines' command here.
# This might involve calling functions from 'utils.py' or directly performing actions.
10 changes: 10 additions & 0 deletions src/cf_support/commands/onprem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import click

@click.command(name='onprem') # Use @click.command() directly
@click.option('-n','--namespace', help='The namespace where Codefresh OnPrem is installed')
def onprem_command(namespace):
"""Collect data for the Codefresh OnPrem Installation"""

click.echo(f"Executing pipelines command with filter: {filter if filter else 'none'}")
# Add your core logic for the 'pipelines' command here.
# This might involve calling functions from 'utils.py' or directly performing actions.
10 changes: 10 additions & 0 deletions src/cf_support/commands/oss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import click

@click.command(name='oss') # Use @click.command() directly
@click.option('-n','--namespace', help='The namespace where the OSS ArgoCD is installed')
def oss_command(namespace):
"""Collect data for the Open Source ArgoCD"""

click.echo(f"Executing pipelines command with filter: {filter if filter else 'none'}")
# Add your core logic for the 'pipelines' command here.
# This might involve calling functions from 'utils.py' or directly performing actions.
11 changes: 11 additions & 0 deletions src/cf_support/commands/pipelines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import click

@click.command(name='pipelines') # Use @click.command() directly
@click.option('-n','--namespace', help='The namespace where the Pipelines Runtime is installed')
@click.option('-r','--runtime', help='The name of the Pipelines Runtime')
def pipelines_command(namespace, runtime):
"""Collect data for the Codefresh Pipelines Runtime"""

click.echo(f"Executing pipelines command with filter: {filter if filter else 'none'}")
# Add your core logic for the 'pipelines' command here.
# This might involve calling functions from 'utils.py' or directly performing actions.
58 changes: 58 additions & 0 deletions src/cf_support/logic/codefresh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from dotenv import load_dotenv
import requests
import yaml
import sys
import os


load_dotenv()


# TODO: Add this when we break out the main function
# required_env_vars: list[str] = ["CF_API_KEY", "CF_URL"]

# for var in required_env_vars:
# if not var:
# sys.exit(f"Environment variable {var} is not defined")



def get_runtime_spec(cf_creds, runtime):
response = requests.get(
f"{cf_creds['base_url']}/runtime-environments/{runtime}",
headers=cf_creds["headers"],
)
return response.json()


def get_all_accounts(cf_creds):
response = requests.get(
f"{cf_creds['base_url']}/admin/accounts",
headers=cf_creds["headers"],
)
return response.json()


def get_all_runtimes(cf_creds):
response = requests.get(
f"{cf_creds['base_url']}/admin/runtime-environments",
headers=cf_creds["headers"],
)
return response.json()


def get_total_users(cf_creds):
response = requests.get(
f"{cf_creds['base_url']}/admin/user?limit=1&page=1",
headers=cf_creds["headers"],
)
users = response.json()
return {"totalUsers": users["total"]}


def get_system_feature_flags(cf_creds):
response = requests.get(
f"{cf_creds['base_url']}/admin/features",
headers=cf_creds["headers"],
)
return response.json()
14 changes: 14 additions & 0 deletions src/cf_support/logic/controllers/account_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import requests


class AccountController:
def __init__(self, cf_creds: dict[str, dict[str, str]]) -> None:
self.base_url = cf_creds["base_url"]
self.auth_headers = cf_creds["headers"]

def get_runtimes(self):
response = requests.get(
f"{self.base_url}/runtime-environments",
headers=self.auth_headers["headers"], # type: ignore
)
return response.json()
Loading