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

fix(plugins): fix plugins-manifest.json #1564

Merged
merged 6 commits into from
Mar 26, 2020
Merged
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 @@ -7,39 +7,48 @@
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.Profile;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.StringBackedProfileFactory;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PluginManifestProfileFactory extends StringBackedProfileFactory {
@Autowired PluginService pluginService;

private static String PLUGIN_ENTRY = "{id: \"%s\", version: \"%s\", url: \"%s\"}";
private static String PLUGIN_ENTRY = "{\"id\": \"%s\", \"version\": \"%s\", \"url\": \"%s\"}";

@Override
protected boolean showEditWarning() {
return false;
}

@Override
protected void setProfile(
Profile profile,
DeploymentConfiguration deploymentConfiguration,
SpinnakerRuntimeSettings endpoints) {
profile.appendContents("plugins = [");
profile.appendContents("[");

Map<String, Plugin> plugins = pluginService.getPlugins(deploymentConfiguration.getName());
plugins.entrySet().stream()
.filter(
v -> {
Plugin p = v.getValue();
return p.getEnabled()
&& p.getUiResourceLocation() != null
&& p.getUiResourceLocation() != "";
})
.forEach(
v -> {
Plugin p = v.getValue();
profile.appendContents(
String.format(
PLUGIN_ENTRY, p.getId(), p.getVersion(), p.getUiResourceLocation()));
});
List<String> contents =
plugins.entrySet().stream()
.filter(
v -> {
Plugin p = v.getValue();
return p.getEnabled()
&& p.getUiResourceLocation() != null
&& p.getUiResourceLocation() != "";
})
.map(
v -> {
Plugin p = v.getValue();
return String.format(
PLUGIN_ENTRY, p.getId(), p.getVersion(), p.getUiResourceLocation());
})
.collect(Collectors.toList());
profile.appendContents(String.join(",", contents));
profile.appendContents("]");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<Profile> getProfiles(
result.add(
deckDockerProfileFactory.getProfile(settingsJs, path, deploymentConfiguration, endpoints));

String filename = "plugin-manifest.js";
String filename = "plugin-manifest.json";
path = Paths.get(settingsPath, filename).toString();
result.add(
pluginManifestProfileFactory.getProfile(
Expand Down