Skip to content

Commit

Permalink
remove extra
Browse files Browse the repository at this point in the history
  • Loading branch information
frostyfan109 committed May 30, 2024
1 parent d5e5075 commit 0a320a6
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions appstore/api/v1/k8s_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import base64
import os
from kubernetes import client, config
from app.models.user import UserType

class KubernetesService:
def __init__(self):
Expand Down Expand Up @@ -29,45 +28,6 @@ def get_current_namespace(self):
except KeyError:
return "default"

def create_credential_secret(self, course_name: str, onyen: str, password: str, user_type: UserType):
current_namespace = self.get_current_namespace()

secret_name = self._compute_credential_secret_name(course_name, onyen)
secret_data = {
"onyen": onyen,
"password": password,
"class": course_name,
"user_type": user_type.value,
}
encoded_secret_data = {
key: base64.b64encode(value.encode()).decode() for (key, value) in secret_data.items()
}

secret = client.V1Secret(
api_version="v1",
kind="Secret",
metadata=client.V1ObjectMeta(
name=secret_name,
namespace=current_namespace
),
type="Opaque",
data=encoded_secret_data
)

self.api_instance.create_namespaced_secret(
namespace=current_namespace,
body=secret
)

def delete_credential_secret(self, course_name: str, onyen: str):
current_namespace = self.get_current_namespace()

secret_name = self._compute_credential_secret_name(course_name, onyen)
self.api_instance.delete_namespaced_secret(
namespace=current_namespace,
name=secret_name
)

def get_autogen_password(self, course_name: str, onyen: str) -> str:
current_namespace = self.get_current_namespace()
secret_name = self._compute_credential_secret_name(course_name, onyen)
Expand Down

0 comments on commit 0a320a6

Please sign in to comment.