@@ -49,10 +49,11 @@ private async Task Write(IKubernetesObject obj)
4949 private static V1CustomResourceDefinition CreateCustomResourceDefinition ( IEventWatcher item )
5050 {
5151 var group = item . Metadata . OfType < KubernetesEntityAttribute > ( ) . First ( ) ;
52- var scope = item . Metadata . OfType < IEntityScopeMetadata > ( ) . First ( ) ;
52+ var scope = item . Metadata . OfType < INamespaceMetadata > ( ) . FirstOrDefault ( ) ;
5353
5454 var crdBuilder = new CustomResourceDefinitionBuilder ( ) ;
55- crdBuilder . WithName ( $ "{ group . PluralName } .{ group . Group } ")
55+ crdBuilder
56+ . WithName ( $ "{ group . PluralName } .{ group . Group } ")
5657 . WithSpec ( )
5758 . WithGroup ( group . Group )
5859 . WithNames (
@@ -61,7 +62,7 @@ private static V1CustomResourceDefinition CreateCustomResourceDefinition(IEventW
6162 plural : group . PluralName ,
6263 singular : group . Kind . ToLower ( )
6364 )
64- . WithScope ( scope . Scope )
65+ . WithScope ( scope == null ? EntityScope . Cluster : EntityScope . Namespaced )
6566 . WithVersion (
6667 group . ApiVersion ,
6768 schema =>
@@ -76,12 +77,15 @@ private static V1CustomResourceDefinition CreateCustomResourceDefinition(IEventW
7677
7778 private static V1Deployment CreateDeployment ( IReadOnlyList < object > metadata )
7879 {
79- var name = metadata . TryGetValue < IOperatorNameMetadata , string > ( x => x . Name ) ! ;
80+ var name = metadata . TryGetValue < IOperatorNameMetadata , string > ( x => x . OperatorName ) ! ;
8081 var image = metadata . TryGetValue < IImageMetadata , string > ( x => x . GetImage ( ) ) ! ;
82+ var ns = metadata . TryGetValue < INamespaceMetadata , string > ( x => x . Namespace ) ;
8183
8284 var deployment = DeploymentBuilder . Create ( ) ;
8385
84- deployment . WithName ( $ "{ name } -deployment")
86+ deployment
87+ . WithName ( $ "{ name } -deployment")
88+ . WithNamespace ( ns )
8589 . WithLabel ( "operator-deployment" , name )
8690 . WithSpec ( )
8791 . WithReplicas ( 1 )
@@ -134,7 +138,7 @@ private static V1Deployment CreateDeployment(IReadOnlyList<object> metadata)
134138
135139 private static V1ClusterRoleBinding CreateClusterRoleBinding ( IReadOnlyList < object > metadata )
136140 {
137- var name = metadata . TryGetValue < IOperatorNameMetadata , string > ( x => x . Name ) ;
141+ var name = metadata . TryGetValue < IOperatorNameMetadata , string > ( x => x . OperatorName ) ;
138142
139143 var clusterrolebinding = new ClusterRoleBindingBuilder ( )
140144 . WithName ( $ "{ name } -role-binding")
@@ -146,7 +150,7 @@ private static V1ClusterRoleBinding CreateClusterRoleBinding(IReadOnlyList<objec
146150
147151 private static V1ClusterRole CreateClusterRole ( IReadOnlyList < object > metadata , IEnumerable < IEventWatcher > watchers )
148152 {
149- var name = metadata . TryGetValue < IOperatorNameMetadata , string > ( x => x . Name ) ;
153+ var name = metadata . TryGetValue < IOperatorNameMetadata , string > ( x => x . OperatorName ) ;
150154
151155 var clusterrole = new ClusterRoleBuilder ( )
152156 . WithName ( $ "{ name } -role") ;
0 commit comments