Skip to content

Commit

Permalink
fix: check for user already created
Browse files Browse the repository at this point in the history
  • Loading branch information
ElderMatt committed Jan 15, 2025
1 parent 1cb052f commit 4c9b9b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/operator/gitea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Repository,
RepositoryApi,
Team,
User,
} from '@linode/gitea-client-node'
import { isEmpty, keys } from 'lodash'
import { doApiCall } from '../utils'
Expand Down Expand Up @@ -151,13 +152,16 @@ const secretsAndConfigmapsCallback = async (e: any) => {
}

const createOperatorAccount = async (adminApi: AdminApi) => {
const users: User[] = await doApiCall(errors, `Getting all users"`, () => adminApi.adminGetAllUsers())
if (users.some((user) => user.login === giteaOperatorUsername)) return
const userOption = {
...new CreateUserOption(),
loginName: giteaOperatorUsername,
username: giteaOperatorUsername,
fullName: giteaOperatorUsername,
password: giteaOperatorPassword,
email: giteaOperatorEmail,
isAdmin: true,
restricted: false,
mustChangePassword: false,
repoAdminChangeTeamAccess: true,
Expand Down Expand Up @@ -463,7 +467,7 @@ async function setupGitea() {

const adminUser = createOperatorAccount(adminApi)
console.log('adminuser: ', adminUser)
const users = adminApi.adminGetAllUsers()
const users: User[] = await doApiCall(errors, `Getting all users"`, () => adminApi.adminGetAllUsers())
console.log('users: ', users)
const existingOrganizations = await doApiCall(errors, 'Getting all organizations', () => orgApi.orgGetAll())

Expand Down

0 comments on commit 4c9b9b8

Please sign in to comment.