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

Backend Skeleton for SDLC Server #683

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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: []