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

feat(md): created a new endpoint for passing the http request as is without parsing the body #1470

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
@@ -0,0 +1,27 @@
/*
* Copyright 2019 Netflix, Inc.
*
* 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 com.netflix.spinnaker.gate.model.manageddelivery;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NonNull;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class RawDeliveryConfig {
@NonNull String content;
}
Expand Up @@ -24,6 +24,7 @@
import com.netflix.spinnaker.gate.model.manageddelivery.EnvironmentArtifactVeto;
import com.netflix.spinnaker.gate.model.manageddelivery.GraphQLRequest;
import com.netflix.spinnaker.gate.model.manageddelivery.OverrideVerificationRequest;
import com.netflix.spinnaker.gate.model.manageddelivery.RawDeliveryConfig;
import com.netflix.spinnaker.gate.model.manageddelivery.Resource;
import com.netflix.spinnaker.gate.model.manageddelivery.RetryVerificationRequest;
import com.netflix.spinnaker.kork.plugins.SpinnakerPluginDescriptor;
Expand Down Expand Up @@ -79,9 +80,9 @@ List<Map<String, Object>> getResourceEvents(
@GET("/delivery-configs/{name}/artifacts")
List<Map<String, Object>> getManifestArtifacts(@Path("name") String name);

@POST("/delivery-configs")
@POST("/delivery-configs/upsertGate")
@Headers("Accept: application/json")
DeliveryConfig upsertManifest(@Body DeliveryConfig manifest);
DeliveryConfig upsertManifest(@Body RawDeliveryConfig req);

@DELETE("/delivery-configs/{name}")
DeliveryConfig deleteManifest(@Path("name") String name);
Expand Down
Expand Up @@ -10,6 +10,7 @@
import com.netflix.spinnaker.gate.model.manageddelivery.EnvironmentArtifactVeto;
import com.netflix.spinnaker.gate.model.manageddelivery.GraphQLRequest;
import com.netflix.spinnaker.gate.model.manageddelivery.OverrideVerificationRequest;
import com.netflix.spinnaker.gate.model.manageddelivery.RawDeliveryConfig;
import com.netflix.spinnaker.gate.model.manageddelivery.Resource;
import com.netflix.spinnaker.gate.model.manageddelivery.RetryVerificationRequest;
import com.netflix.spinnaker.gate.services.NotificationService;
Expand All @@ -20,13 +21,17 @@
import io.github.resilience4j.retry.RetryRegistry;
import io.swagger.annotations.ApiOperation;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -194,16 +199,19 @@ List<Map<String, Object>> getManifestArtifacts(@PathVariable("name") String name

@SneakyThrows
@ApiOperation(
value = "Create or update a delivery config manifest",
response = DeliveryConfig.class)
value = "Create or update a delivery config manifest",
response = DeliveryConfig.class)
@PostMapping(
path = "/delivery-configs",
consumes = {APPLICATION_JSON_VALUE, APPLICATION_YAML_VALUE},
produces = {APPLICATION_JSON_VALUE})
DeliveryConfig upsertManifest(@RequestBody DeliveryConfig manifest) {
path = "/delivery-configs",
consumes = {APPLICATION_JSON_VALUE, APPLICATION_YAML_VALUE},
produces = {APPLICATION_JSON_VALUE})
DeliveryConfig upsertManifestRaw(InputStream body) {
StringWriter writer = new StringWriter();
IOUtils.copy(body, writer, StandardCharsets.UTF_8);
RawDeliveryConfig config = new RawDeliveryConfig(writer.toString());
return retryRegistry
.retry("managed-write")
.executeCallable(() -> keelService.upsertManifest(manifest));
.retry("managed-write")
.executeCallable(() -> keelService.upsertManifest(config));
}

@ApiOperation(value = "Delete a delivery config manifest", response = DeliveryConfig.class)
Expand Down