Skip to content

Commit

Permalink
Backend Skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
mrudula-gs committed Jul 12, 2023
1 parent 0ea0955 commit ee115df
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.dropwizard.lifecycle.setup.LifecycleEnvironment;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.eclipse.collections.impl.block.factory.Functions;
import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory;
import org.finos.legend.sdlc.server.config.LegendSDLCServerConfiguration;
import org.finos.legend.sdlc.server.depot.DepotConfiguration;
Expand All @@ -27,6 +28,7 @@
import org.finos.legend.sdlc.server.guice.AbstractBaseModule;
import org.finos.legend.sdlc.server.guice.BaseModule;
import org.finos.legend.sdlc.server.project.config.ProjectStructureConfiguration;
import org.finos.legend.sdlc.server.backend.BackendConfiguration;
import org.finos.legend.sdlc.server.tools.BackgroundTaskProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -72,7 +74,7 @@ protected void configureApis(Bootstrap<T> bootstrap)
if (GITLAB_MODE.equals(this.mode))
{
// Add GitLab bundle
bootstrap.addBundle(new GitLabBundle<>(LegendSDLCServerConfiguration::getGitLabConfiguration));
bootstrap.addBundle(new GitLabBundle<>(Functions.chain(LegendSDLCServerConfiguration::getBackendConfiguration, BackendConfiguration::getGitLabConfiguration)));
}

// Guice bootstrapping..
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2023 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.finos.legend.sdlc.server.backend;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.finos.legend.sdlc.server.gitlab.GitLabConfiguration;

public class BackendConfiguration
{
private final GitLabConfiguration gitLabConfig;

private BackendConfiguration(GitLabConfiguration gitLabConfig)
{
this.gitLabConfig = gitLabConfig;
}

public GitLabConfiguration getGitLabConfiguration()
{
return this.gitLabConfig;
}

@JsonCreator
public static BackendConfiguration newBackendConfiguration(@JsonProperty("gitLab") GitLabConfiguration gitLabConfig)
{
return new BackendConfiguration(gitLabConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import org.finos.legend.sdlc.server.depot.DepotConfiguration;
import org.finos.legend.sdlc.server.gitlab.GitLabConfiguration;
import org.finos.legend.sdlc.server.project.config.ProjectStructureConfiguration;
import org.finos.legend.sdlc.server.backend.BackendConfiguration;

public class LegendSDLCServerConfiguration extends ServerConfiguration
{
@JsonProperty("gitLab")
private GitLabConfiguration gitLabConfig;
@JsonProperty("backend")
private BackendConfiguration backendConfig;

@JsonProperty("projectStructure")
private ProjectStructureConfiguration projectStructureConfiguration;
Expand All @@ -33,9 +33,9 @@ public class LegendSDLCServerConfiguration extends ServerConfiguration
@JsonProperty("features")
private LegendSDLCServerFeaturesConfiguration featuresConfiguration;

public GitLabConfiguration getGitLabConfiguration()
public BackendConfiguration getBackendConfiguration()
{
return this.gitLabConfig;
return this.backendConfig;
}

public ProjectStructureConfiguration getProjectStructureConfiguration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ protected void configureApis(Binder binder)
binder.bind(GitLabUserContext.class);
binder.bind(GitLabAuthResource.class);
binder.bind(GitLabAuthCheckResource.class);
binder.bind(GitLabConfiguration.class).toProvider(() -> getConfiguration().getGitLabConfiguration());
binder.bind(GitLabAppInfo.class).toProvider(() -> GitLabAppInfo.newAppInfo(getConfiguration().getGitLabConfiguration()));
binder.bind(GitLabConfiguration.class).toProvider(() -> getConfiguration().getBackendConfiguration().getGitLabConfiguration());
binder.bind(GitLabAppInfo.class).toProvider(() -> GitLabAppInfo.newAppInfo(getConfiguration().getBackendConfiguration().getGitLabConfiguration()));
binder.bind(GitLabAuthorizerManager.class).toProvider(() -> this.provideGitLabAuthorizerManager(getConfiguration())).in(Scopes.SINGLETON);
}
configureMetadataApi(binder);
Expand All @@ -108,7 +108,7 @@ protected void configureMetadataApi(Binder binder)

private GitLabAuthorizerManager provideGitLabAuthorizerManager(LegendSDLCServerConfiguration configuration)
{
List<GitLabAuthorizer> gitLabAuthorizers = configuration.getGitLabConfiguration().getGitLabAuthorizers();
List<GitLabAuthorizer> gitLabAuthorizers = configuration.getBackendConfiguration().getGitLabConfiguration().getGitLabAuthorizers();
if (gitLabAuthorizers == null)
{
return GitLabAuthorizerManager.newManager(Collections.emptyList());
Expand Down
29 changes: 18 additions & 11 deletions legend-sdlc-server/src/test/resources/config-sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,24 @@ pac4j:
- /api/server/platforms
- /api/auth/authorized

gitLab:
newProjectVisibility: public
projectIdPrefix: SAMPLE
projectTag: legend
server:
scheme: https
host: $GITLAB_HOST
app:
id: $APP_ID
secret: $APP_SECRET
redirectURI: http://$SDLC_SERVER_HOST/api/auth/callback
backend:
inMemory:
# engineConfig:
# inMemorySizeGB: 256MB
fileSystem:
# rootDirectory: /location/to/drive
# maxThreads: 100
gitLab:
newProjectVisibility: public
projectIdPrefix: SAMPLE
projectTag: legend
server:
scheme: https
host: $GITLAB_HOST
app:
id: $APP_ID
secret: $APP_SECRET
redirectURI: http://$SDLC_SERVER_HOST/api/auth/callback

projectStructure:
extensionProvider:
Expand Down
29 changes: 18 additions & 11 deletions legend-sdlc-server/src/test/resources/config-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,23 @@ projectStructure:
projectCreation:
groupIdPattern: ^org\.finos\.legend\..+

gitLab:
projectTag: legendtest
projectIdPrefix: PROTOTYPE
server:
scheme: na
host: na-uat
app:
id: na
secret: na
redirectURI: na
backend:
inMemory:
# engineConfig:
# inMemorySizeGB: 256MB
fileSystem:
# rootDirectory: /location/to/drive
# maxThreads: 100
gitLab:
projectTag: legendtest
projectIdPrefix: PROTOTYPE
server:
scheme: na
host: na-uat
app:
id: na
secret: na
redirectURI: na

logging:
# Change this to affect library class logging
Expand All @@ -74,4 +81,4 @@ swagger:
resourcePackage: org.finos.legend.sdlc.server.resources
title: Legend SDLC
version: local-snapshot
schemes: []
schemes: []

0 comments on commit ee115df

Please sign in to comment.