Skip to content

Commit

Permalink
New scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Sauthier <[email protected]>
  • Loading branch information
huats committed Jan 24, 2025
1 parent bdfb2ea commit b147c64
Show file tree
Hide file tree
Showing 17 changed files with 381 additions and 133 deletions.
32 changes: 21 additions & 11 deletions Ambassadors/CNCF-Project-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ Argo
Armada
Artifact Hub
Athenz
Atlantis
Backstage
Bank-Vaults
BFE
bpfman
Brigade
Buildpacks
Capsule
Carina
Cartography
Carvel
CDK for Kubernetes (CDK8s)
cert-manager
Expand All @@ -37,7 +41,6 @@ CubeFS
Curiefense
Curve
Dapr
Dapr (Serverless)
Devfile
DevSpace
DevStream
Expand All @@ -52,11 +55,13 @@ etcd
external-secrets
FabEdge
Falco
Flatcar Container Linux
Fluentd
Fluid
Flux
Fonio
gRPC
hami
Harbor
Headlamp
Helm
Expand All @@ -77,20 +82,20 @@ Karmada
KCL
kcp
KEDA
KEDA (Serverless)
Kepler
Keptn
Keycloak
Keylime
Kmesh
Knative
Knative (Serverless)
ko
Konveyor
Koordinator
kpt
Krator
Krkn
Krustlet
Krustlet (Wasm)
Kuadrant
Kuasar
Kube-burner
Kube-OVN
Expand All @@ -104,7 +109,6 @@ KubeEdge
Kubeflow
Kuberhealthy
Kubernetes
Kubernetes
Kubescape
KubeSlice
KubeStellar
Expand All @@ -114,12 +118,14 @@ Kubewarden
KUDO
Kuma
Kured
KusionStack
Kyverno
Lima
Linkerd
Litmus
Logging Operator (Kube Logging)
Longhorn
LoxiLB
Merbridge
Meshery
MetalLB
Expand All @@ -128,7 +134,7 @@ Microcks
NATS
Network Service Mesh
Nocalhost
Notary
Notary Project
Open Cluster Management
Open Policy Agent (OPA)
Open Policy Containers
Expand All @@ -139,7 +145,7 @@ OpenELB
OpenFeature
OpenFGA
OpenFunction
OpenFunction (Serverless)
openGemini
OpenGitOps
OpenKruise
OpenMetrics
Expand All @@ -148,30 +154,36 @@ OpenTracing
OpenYurt
Operator Framework
ORAS
OSCAL-COMPASS
Paralus
Parsec
Perses
PipeCD
Piraeus Datastore
Pixie
Porter
Pravega
Prometheus
Radius
Ratify
rkt
Rook
SchemaHero
Score
sealer
Sermant
Serverless Devs
Serverless Devs (Serverless)
Serverless Workflow
Service Mesh Interface (SMI)
Service Mesh Performance
Shipwright
Skooner
SlimToolkit
SOPS
Spiderpool
SPIFFE
SPIRE
Stacker
Strimzi
Submariner
SuperEdge
Expand All @@ -185,14 +197,12 @@ Tremor
Trickster
Vineyard
Virtual Kubelet
Virtual Kubelet (Serverless)
Visual Studio Code Kubernetes Tools
Vitess
Volcano
wasmCloud
WasmEdge (Wasm)
WasmEdge Runtime
WasmEdge Runtime
werf
Xline
youki
zot
22 changes: 14 additions & 8 deletions Ambassadors/CNCFInsertAmbassadorInPeople_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseDownload
from google.auth.transport.requests import Request
from dotenv import load_dotenv


# Constants
GDRIVE_URL = "https://drive.google.com/drive/folders/XXXXXXXX"
load_dotenv()
GDRIVE_URL= os.getenv('GDRIVE_URL')
PROJECT_LIST_PATH = 'CNCF-Project-list.txt'
PEOPLE_JSON_PATH = '../../people/people.json'
SUGGESTIONS_FILE = 'suggestions.json'
Expand Down Expand Up @@ -158,14 +161,15 @@ def download_file_from_drive(folder_url, filename, outputname):
print(f'Download complete for {filename}')

class People:
def __init__(self, firstName, lastName, bio, company, pronouns, location, twitter, github, projects, image):
def __init__(self, firstName, lastName, bio, company, pronouns, location, twitter, github, projects, image, slack):
self.name = f"{firstName} {lastName}"
self.bio = f"<p>{bio.replace(' ', '<p/><p>')}</p>" if bio else ""
self.company = company if company != "Individual - No Account" else ""
self.pronouns = pronouns if pronouns != "Prefer not to answer" else ""
self.location = location
self.twitter = self.format_twitter(twitter)
self.github = self.format_github(github)
self.slack_id = slack
self.category = ["Ambassadors"]
self.projects = self.parse_and_confirm_projects(projects)
self.image = self.handle_image(image, firstName, lastName)
Expand All @@ -190,14 +194,14 @@ def handle_image(self, image, firstName, lastName):
download_file_from_drive(GDRIVE_URL, image, "imageTemp" + file_extension)
return f"{firstName.lower().replace(' ', '-')}-{lastName.lower().replace(' ', '-')}{file_extension}"
else:
shutil.copy("phippy.jpg", "imageTemp.jpg")
shutil.copy("../../people/images/phippy.jpg", "imageTemp.jpg")
return "phippy.jpg"

def parse_and_confirm_projects(self, raw_string):
project_names = load_project_names(PROJECT_LIST_PATH)
project_dict = {project.lower(): project for project in project_names}
identified_projects = parse_projects(raw_string, project_names)

# Confirm and add any missing projects interactively
remaining_words = raw_string.lower()
for project in identified_projects:
Expand Down Expand Up @@ -235,7 +239,7 @@ def parse_and_confirm_projects(self, raw_string):
else:
suggestions[word_sequence] = None
save_suggestions(suggestions)

remaining_words = [word for word in remaining_words if word]

for word in remaining_words:
Expand Down Expand Up @@ -263,8 +267,10 @@ def process_entries(firstLine, lastLine):
csv_reader = csv.reader(csv_file, delimiter='\t')
for lineCount, row in enumerate(csv_reader, start=1):
if firstLine <= lineCount <= lastLine:
newPerson = People(firstName=row[0], lastName=row[1], bio=row[7], company=row[3], pronouns=row[4],
location=row[2], twitter=row[6], github=row[5], projects=row[8], image=row[9])
# newPerson = People(firstName=row[0], lastName=row[1], bio=row[7], company=row[3], pronouns=row[4],
# location=row[2], twitter=row[6], github=row[5], projects=row[8], image=row[9])
newPerson = People(firstName=row[0], lastName=row[1], bio=row[9], company=row[3], pronouns=row[4],
location=row[2], twitter=row[7], github=row[5], projects=row[8], image=row[10], slack=row[6])
print(newPerson.toJSON())

# Load existing data
Expand All @@ -283,7 +289,7 @@ def process_entries(firstLine, lastLine):
else:
data.insert(indexPeople, json.JSONDecoder(object_pairs_hook=OrderedDict).decode(newPerson.toJSON()))
split_tup = os.path.splitext(newPerson.image)
os.rename("imageTemp" + split_tup[1], "people/images/" + newPerson.image)
os.rename("imageTemp" + split_tup[1], "../../people/images/" + newPerson.image)
break

# Write updated data back to file
Expand Down
5 changes: 5 additions & 0 deletions Ambassadors/README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Projects list
wget https://landscape.cncf.io/api/projects/all.json
jq '.[] | select(.accepted_at) | .name' all.json | cut -d'"' -f2 > CNCF-Project-list.txt


# Get the secrets from https://console.cloud.google.com/auth/clients/, store it under credentials.json and run the script
python3 CNCFInsertAmbassadorInPeople_json.py -fl 2 -ll 45
# You will be prompted to login
6 changes: 6 additions & 0 deletions Ambassadors/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pygsheets
gdown
pandas
urllib3==1.26.6
pygsheets==2.0.6
python-dotenv
6 changes: 5 additions & 1 deletion Ambassadors/suggestions.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@
"gloo": null,
"- open policy agent": "Open Policy Agent (OPA)",
"ceph": null,
"rollouts": "Argo"
"rollouts": "Argo",
"notary": "Notary Project",
"litmusery": "Litmus",
"ery": null,
"tensorflow": null
}
69 changes: 69 additions & 0 deletions Kubestronaut/AddNewWeeklyyKubestronautsInReceivers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import pygsheets
import os
from dotenv import load_dotenv

# Authenticate with your Google Sheets API credentials
gc = pygsheets.authorize(service_file='kubestronauts-handling-service-file.json')

# Load environment variables
load_dotenv()
KUBESTRONAUT_RECEIVERS = os.getenv('KUBESTRONAUT_RECEIVERS')
KUBESTRONAUTS_WEEKLY_TEMP = os.getenv('KUBESTRONAUTS_WEEKLY_TEMP')
KUBESTRONAUTS_WELCOME = os.getenv('KUBESTRONAUTS_WELCOME')

# Open the sheets
receivers_sheet = gc.open_by_key(KUBESTRONAUT_RECEIVERS)
weekly_temp_sheet = gc.open_by_key(KUBESTRONAUTS_WEEKLY_TEMP)
welcome_sheet = gc.open_by_key(KUBESTRONAUTS_WELCOME)

# Select the first worksheet in both spreadsheets
weekly_temp_worksheet = weekly_temp_sheet.sheet1
receivers_worksheet = receivers_sheet.sheet1
welcome_worksheet = welcome_sheet.sheet1

# Get emails from column C in the weekly temp sheet
emails_to_check = weekly_temp_worksheet.get_col(3, include_tailing_empty=False)

# Get first names (column A) and last names (column B) from the weekly temp sheet
first_names = weekly_temp_worksheet.get_col(1, include_tailing_empty=False)
last_names = weekly_temp_worksheet.get_col(2, include_tailing_empty=False)

# Get emails from column B in the receivers sheet
existing_emails = receivers_worksheet.get_col(2, include_tailing_empty=False)

# Iterate through emails to check
for idx, email in enumerate(emails_to_check):
if email not in existing_emails:
print(f"Adding Kubestronaut: {email}")
# Find the next row index after the last value in column B
next_row = len(existing_emails) + 1

# Insert a blank row before the next row
receivers_worksheet.insert_rows(next_row - 1, number=1)

# Add the email to column B in the newly inserted row
receivers_worksheet.update_value(f"B{next_row}", email)

# Add the first name to column C and last name to column D
receivers_worksheet.update_value(f"C{next_row}", first_names[idx])
receivers_worksheet.update_value(f"D{next_row}", last_names[idx])

# Set the background color of column F to red
receivers_worksheet.cell(f"F{next_row}").color = (1.0, 0.0, 0.0) # RGB for red

# Add value `1` in column G
receivers_worksheet.update_value(f"G{next_row}", "1")

# Update the local list to include the newly added email
existing_emails.append(email)

# Add this Kubestronaut to the WelcomeEmail Google Sheet Mailer
welcome_worksheet.insert_rows(1, number=1, values=[email])
#welcome_worksheet.update_value(f"A2", email)
else:
# Mention that the email is already in the file
print(f"Kubestronaut already exists: {email}")

print("Completed processing emails!")
print("Go to https://docs.google.com/spreadsheets/d/"+KUBESTRONAUTS_WELCOME)
print("And use the mail merger with the draft name \"Welcome to the Kubestronaut program !\"")
2 changes: 1 addition & 1 deletion Kubestronaut/AnnotateKubestronautAsJacketSent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

load_dotenv()
# Store credentials
pwd = os.getenv('KUBESTRONAUTS_INFOS')
KUBESTRONAUTS_INFOS = os.getenv('KUBESTRONAUTS_INFOS')

# Let's open the GoogleSheet to write Kubestronaut info + coupons
#authorization
Expand Down
Loading

0 comments on commit b147c64

Please sign in to comment.