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

adding ability to have teams with cluster access #19

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ spec:
envFrom:
- configMapRef:
name: public-repos
- configMapRef:
name: cluster-scoped-teams
SadeghTb marked this conversation as resolved.
Show resolved Hide resolved
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
32 changes: 25 additions & 7 deletions controllers/namespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ func (r *NamespaceReconciler) createAppProj(team string) (*argov1alpha1.AppProje
repo_env := os.Getenv("PUBLIC_REPOS")
repo_list := strings.Split(repo_env, ",")

// Get cluster scoped teams
team_env := os.Getenv("TEAMS")
SadeghTb marked this conversation as resolved.
Show resolved Hide resolved
team_list := strings.Split(team_env, ",")

includeAllGroupKind := []metav1.GroupKind{
{
Group: "*",
Kind: "*",
},
}

appProj := &argov1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{
Name: team,
Expand All @@ -300,12 +311,6 @@ func (r *NamespaceReconciler) createAppProj(team string) (*argov1alpha1.AppProje
Spec: argov1alpha1.AppProjectSpec{
SourceRepos: repo_list,
Destinations: destList,
ClusterResourceBlacklist: []metav1.GroupKind{
{
Group: "*",
Kind: "*",
},
},
NamespaceResourceBlacklist: []metav1.GroupKind{
{
Group: "",
Expand All @@ -330,7 +335,11 @@ func (r *NamespaceReconciler) createAppProj(team string) (*argov1alpha1.AppProje
},
},
}

if isTeamClusterScoped(team, team_list) {
appProj.Spec.ClusterResourceWhitelist = includeAllGroupKind
SadeghTb marked this conversation as resolved.
Show resolved Hide resolved
} else {
appProj.Spec.ClusterResourceBlacklist = includeAllGroupKind
}
return appProj, nil

}
Expand Down Expand Up @@ -371,3 +380,12 @@ func convertLabelToAppProjectNameset(l string) AppProjectNameset {
}
return result
}

func isTeamClusterScoped(team string, clusterScopedList []string) bool {
SadeghTb marked this conversation as resolved.
Show resolved Hide resolved
for _, tm := range clusterScopedList {
if team == tm {
return true
}
}
return false
}
Loading