Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: harbor operator #124

Merged
merged 2 commits into from
Oct 30, 2024
Merged
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
67 changes: 30 additions & 37 deletions src/operator/harbor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,17 @@ async function processNamespace(namespace: string) {
*/
async function ensureTeamPullRobotAccountSecret(namespace: string, projectName): Promise<void> {
const k8sSecret = await getSecret(projectPullSecretName, namespace)
if (k8sSecret) {
console.debug(`Deleting pull secret/${projectPullSecretName} from ${namespace} namespace`)
await k8sApi.deleteNamespacedSecret(projectPullSecretName, namespace)
if (!k8sSecret) {
const robotPullAccount = await createTeamPullRobotAccount(projectName)
console.debug(`Creating pull secret/${projectPullSecretName} at ${namespace} namespace`)
await createK8sSecret({
namespace,
name: projectPullSecretName,
server: `${env.harborBaseRepoUrl}`,
username: robotPullAccount.name!,
password: robotPullAccount.secret!,
})
}

const robotPullAccount = await createTeamPullRobotAccount(projectName)
console.debug(`Creating pull secret/${projectPullSecretName} at ${namespace} namespace`)
await createK8sSecret({
namespace,
name: projectPullSecretName,
server: `${env.harborBaseRepoUrl}`,
username: robotPullAccount.name!,
password: robotPullAccount.secret!,
})
}

/**
Expand Down Expand Up @@ -470,19 +467,17 @@ async function createTeamPullRobotAccount(projectName: string): Promise<RobotCre
*/
async function ensureTeamPushRobotAccountSecret(namespace: string, projectName): Promise<void> {
const k8sSecret = await getSecret(projectPushSecretName, namespace)
if (k8sSecret) {
console.debug(`Deleting push secret/${projectPushSecretName} from ${namespace} namespace`)
await k8sApi.deleteNamespacedSecret(projectPushSecretName, namespace)
if (!k8sSecret) {
const robotPushAccount = await ensureTeamPushRobotAccount(projectName)
console.debug(`Creating push secret/${projectPushSecretName} at ${namespace} namespace`)
await createK8sSecret({
namespace,
name: projectPushSecretName,
server: `${env.harborBaseRepoUrl}`,
username: robotPushAccount.name!,
password: robotPushAccount.secret!,
})
}
const robotPushAccount = await ensureTeamPushRobotAccount(projectName)
console.debug(`Creating push secret/${projectPushSecretName} at ${namespace} namespace`)
await createK8sSecret({
namespace,
name: projectPushSecretName,
server: `${env.harborBaseRepoUrl}`,
username: robotPushAccount.name!,
password: robotPushAccount.secret!,
})
}

/**
Expand Down Expand Up @@ -544,19 +539,17 @@ async function ensureTeamPushRobotAccount(projectName: string): Promise<any> {
*/
async function ensureTeamBuildPushRobotAccountSecret(namespace: string, projectName): Promise<void> {
const k8sSecret = await getSecret(projectBuildPushSecretName, namespace)
if (k8sSecret) {
console.debug(`Deleting build push secret/${projectBuildPushSecretName} from ${namespace} namespace`)
await k8sApi.deleteNamespacedSecret(projectBuildPushSecretName, namespace)
if (!k8sSecret) {
const robotBuildsPushAccount = await ensureTeamBuildsPushRobotAccount(projectName)
console.debug(`Creating build push secret/${projectBuildPushSecretName} at ${namespace} namespace`)
await createBuildsK8sSecret({
namespace,
name: projectBuildPushSecretName,
server: `${env.harborBaseRepoUrl}`,
username: robotBuildsPushAccount.name!,
password: robotBuildsPushAccount.secret!,
})
}
const robotBuildsPushAccount = await ensureTeamBuildsPushRobotAccount(projectName)
console.debug(`Creating build push secret/${projectBuildPushSecretName} at ${namespace} namespace`)
await createBuildsK8sSecret({
namespace,
name: projectBuildPushSecretName,
server: `${env.harborBaseRepoUrl}`,
username: robotBuildsPushAccount.name!,
password: robotBuildsPushAccount.secret!,
})
}

/**
Expand Down