@ Override public void enrich ( PlatformMode platformMode , KubernetesListBuilder builder ) { builder . accept ( new TypedVisitor < ObjectMetaBuilder > ( ) { private String getNamespaceName ( ) { String name = null ; if ( config . getNamespace ( ) != null && ! config . getNamespace ( ) . isEmpty ( ) ) { name = config . getNamespace ( ) ; } name = builder . getItems ( ) . stream ( ) . filter ( item -> Arrays . asList ( NAMESPACE_KINDS ) . contains ( item . getKind ( ) ) ) . findFirst ( ) . get ( ) . getMetadata ( ) . getName ( ) ; return name ; } @ Override public void visit ( ObjectMetaBuilder metaBuilder ) { if ( ! KubernetesResourceUtil . checkForKind ( builder , NAMESPACE_KINDS ) ) { return ; } String name = getNamespaceName ( ) ; if ( name == null || name . isEmpty ( ) ) { return ; } metaBuilder . withNamespace ( name ) . build ( ) ; } } ) ; // Removing namespace annotation from the namespace and project objects being generated. // to avoid unncessary trouble while applying these resources. builder . accept ( new TypedVisitor < NamespaceBuilder > ( ) { @ Override public void visit ( NamespaceBuilder builder ) { builder . withNewStatus ( "active" ) . editMetadata ( ) . withNamespace ( null ) . endMetadata ( ) . build ( ) ; } } ) ; builder . accept ( new TypedVisitor < ProjectBuilder > ( ) { @ Override public void visit ( ProjectBuilder builder ) { builder . withNewStatus ( "active" ) . editMetadata ( ) . withNamespace ( null ) . endMetadata ( ) . build ( ) ; } } ) ; }
This method will annotate all the items in the KubernetesListBuilder with the created new namespace or project .