From ed3ba2f1bfa348d2b424083e028557f8610c7ea2 Mon Sep 17 00:00:00 2001 From: nagendraOpsmx Date: Mon, 21 Oct 2024 10:28:18 +0530 Subject: [PATCH 1/2] noOperation clouddriver if Spinnaker services disabled --- .../spinnaker/gate/config/GateConfig.groovy | 11 +- .../gate/services/NoOpClouddriverService.java | 436 ++++++++++++++++++ 2 files changed, 446 insertions(+), 1 deletion(-) create mode 100644 gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpClouddriverService.java diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy index b7442984f2..0b4e35782e 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy @@ -50,6 +50,7 @@ import com.netflix.spinnaker.kork.web.selector.SelectableService import com.netflix.spinnaker.kork.web.selector.ServiceSelector import com.netflix.spinnaker.okhttp.OkHttp3MetricsInterceptor import com.netflix.spinnaker.okhttp.OkHttpClientConfigurationProperties +import com.opsmx.spinnaker.gate.services.NoOpClouddriverService import com.opsmx.spinnaker.gate.services.OpsmxAuditClientService import com.opsmx.spinnaker.gate.services.OpsmxAuditService import groovy.transform.CompileStatic @@ -104,6 +105,9 @@ class GateConfig extends RedisHttpSessionConfiguration { @Autowired RequestInterceptor spinnakerRequestInterceptor + @Value('${services.clouddriver.enabled}') + boolean cloudDriverStatus + @Autowired void setServiceClientProvider(ServiceClientProvider serviceClientProvider) { this.serviceClientProvider = serviceClientProvider @@ -213,7 +217,12 @@ class GateConfig extends RedisHttpSessionConfiguration { @Bean ClouddriverService clouddriverService() { - createClient "clouddriver", ClouddriverService + if(cloudDriverStatus) { + createClient "clouddriver", ClouddriverService + } + else { + return new NoOpClouddriverService() + } } @Bean diff --git a/gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpClouddriverService.java b/gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpClouddriverService.java new file mode 100644 index 0000000000..b3005f7aac --- /dev/null +++ b/gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpClouddriverService.java @@ -0,0 +1,436 @@ +/* + * Copyright 2024 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.opsmx.spinnaker.gate.services; + +import com.netflix.spinnaker.gate.services.internal.ClouddriverService; +import com.netflix.spinnaker.kork.plugins.SpinnakerPluginDescriptor; +import java.util.List; +import java.util.Map; +import retrofit.client.Response; + +public class NoOpClouddriverService implements ClouddriverService { + @Override + public List getAccounts() { + return List.of(); + } + + @Override + public List getAccountDetails() { + return List.of(); + } + + @Override + public AccountDetails getAccount(String account) { + return null; + } + + @Override + public List getAccountDefinitionsByType( + String type, Integer limit, String startingAccountName) { + return List.of(); + } + + @Override + public AccountDefinition createAccountDefinition(AccountDefinition accountDefinition) { + return null; + } + + @Override + public AccountDefinition updateAccountDefinition(AccountDefinition accountDefinition) { + return null; + } + + @Override + public Response deleteAccountDefinition(String account) { + return null; + } + + @Override + public Map getTaskDetails(String taskDetailsId) { + return Map.of(); + } + + @Override + public List getApplications(boolean expand) { + return List.of(); + } + + @Override + public List getAllApplicationsUnrestricted(boolean expand) { + return List.of(); + } + + @Override + public Map getApplication(String name) { + return Map.of(); + } + + @Override + public Map getClusters(String name) { + return Map.of(); + } + + @Override + public List getClustersForAccount(String name, String account) { + return List.of(); + } + + @Override + public List getCluster(String name, String account, String cluster) { + return List.of(); + } + + @Override + public List getScalingActivities( + String application, + String account, + String cluster, + String provider, + String serverGroupName, + String region) { + return List.of(); + } + + @Override + public Map getClusterByType(String name, String account, String cluster, String type) { + return Map.of(); + } + + @Override + public List getServerGroup( + String name, String account, String cluster, String type, String serverGroupName) { + return List.of(); + } + + @Override + public Map getTargetServerGroup( + String application, + String account, + String cluster, + String type, + String scope, + String target, + Boolean onlyEnabled, + Boolean validateOldest) { + return Map.of(); + } + + @Override + public List> getApplicationRawResources(String appName) { + return List.of(); + } + + @Override + public List getServerGroups(String name, String expand, String cloudProvider, String clusters) { + return List.of(); + } + + @Override + public List getServerGroups(List applications, List ids, String cloudProvider) { + return List.of(); + } + + @Override + public Map getJobDetails( + String name, String account, String region, String jobName, String emptyStringForRetrofit) { + return Map.of(); + } + + @Override + public Map getServerGroupDetails( + String appName, + String account, + String region, + String serverGroupName, + String includeDetails) { + return Map.of(); + } + + @Override + public List getClusterLoadBalancers(String appName, String account, String cluster, String type) { + return List.of(); + } + + @Override + public List getLoadBalancers(String provider) { + return List.of(); + } + + @Override + public List getApplicationLoadBalancers(String appName) { + return List.of(); + } + + @Override + public Map getLoadBalancer(String provider, String name) { + return Map.of(); + } + + @Override + public List getLoadBalancerDetails( + String provider, String account, String region, String name) { + return List.of(); + } + + @Override + public Map getInstanceDetails(String account, String region, String instanceId) { + return Map.of(); + } + + @Override + public Map getConsoleOutput(String account, String region, String instanceId, String provider) { + return Map.of(); + } + + @Override + public List getImageDetails(String provider, String account, String region, String imageId) { + return List.of(); + } + + @Override + public List getProjectClusters(String project) { + return List.of(); + } + + @Override + public List getReservationReports(Map filters) { + return List.of(); + } + + @Override + public List getReservationReports(String name, Map filters) { + return List.of(); + } + + @Override + public List findImages( + String provider, + String query, + String region, + String account, + Integer count, + Map additionalFilters) { + return List.of(); + } + + @Override + public List findTags(String provider, String account, String repository) { + return List.of(); + } + + @Override + public List search( + String query, String type, String platform, Integer size, Integer offset, Map filters) { + return List.of(); + } + + @Override + public Map getSecurityGroups() { + return Map.of(); + } + + @Override + public Map getSecurityGroups(String account, String type) { + return Map.of(); + } + + @Override + public List getSecurityGroupsForRegion(String account, String type, String region) { + return List.of(); + } + + @Override + public Map getSecurityGroup( + String account, String type, String name, String region, String vpcId) { + return Map.of(); + } + + @Override + public List getServerGroupManagersForApplication(String application) { + return List.of(); + } + + @Override + public List getInstanceTypes() { + return List.of(); + } + + @Override + public List getKeyPairs() { + return List.of(); + } + + @Override + public List getSubnets() { + return List.of(); + } + + @Override + public List getSubnets(String cloudProvider) { + return List.of(); + } + + @Override + public Map getNetworks() { + return Map.of(); + } + + @Override + public List getNetworks(String cloudProvider) { + return List.of(); + } + + @Override + public List findAllCloudMetrics( + String cloudProvider, String account, String region, Map filters) { + return List.of(); + } + + @Override + public Map getCloudMetricStatistics( + String cloudProvider, + String account, + String region, + String metricName, + Long startTime, + Long endTime, + Map filters) { + return Map.of(); + } + + @Override + public List listEntityTags(Map allParameters) { + return List.of(); + } + + @Override + public Map getEntityTags(String id) { + return Map.of(); + } + + @Override + public List getCertificates() { + return List.of(); + } + + @Override + public List getCertificates(String cloudProvider) { + return List.of(); + } + + @Override + public Response getStaticData(String id, Map filters) { + return null; + } + + @Override + public Response getAdhocData(String groupId, String bucketId, String objectId) { + return null; + } + + @Override + public List getStorageAccounts() { + return List.of(); + } + + @Override + public List getArtifactCredentials() { + return List.of(); + } + + @Override + public Response getArtifactContent(Map artifact) { + return null; + } + + @Override + public List getArtifactNames(String accountName, String type) { + return List.of(); + } + + @Override + public List getArtifactVersions(String accountName, String type, String artifactName) { + return List.of(); + } + + @Override + public List getRoles(String cloudProvider) { + return List.of(); + } + + @Override + public List getAllEcsClusters() { + return List.of(); + } + + @Override + public List getEcsAllMetricAlarms() { + return List.of(); + } + + @Override + public List getAllEcsSecrets() { + return List.of(); + } + + @Override + public List getEcsClusterDescriptions(String account, String region) { + return List.of(); + } + + @Override + public List getAllEcsServiceDiscoveryRegistries() { + return List.of(); + } + + @Override + public Map getManifest(String account, String location, String name) { + return Map.of(); + } + + @Override + public List getServerGroupEvents( + String application, String account, String serverGroupName, String region, String provider) { + return List.of(); + } + + @Override + public List listServices(String cloudProvider, String region, String account) { + return List.of(); + } + + @Override + public Map getServiceInstance( + String account, String cloudProvider, String region, String serviceInstanceName) { + return Map.of(); + } + + @Override + public List getFunctions(String functionName, String region, String account) { + return List.of(); + } + + @Override + public List getApplicationFunctions(String appName) { + return List.of(); + } + + @Override + public List getInstalledPlugins() { + return List.of(); + } +} From 7054d1cd250772018b2eb338288d047a97101521 Mon Sep 17 00:00:00 2001 From: nagendraOpsmx Date: Mon, 21 Oct 2024 10:50:03 +0530 Subject: [PATCH 2/2] noOperation front50service if Spinnaker services disabled --- .../spinnaker/gate/config/GateConfig.groovy | 11 +- .../gate/services/NoOpFront50Service.java | 212 ++++++++++++++++++ 2 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpFront50Service.java diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy index 0b4e35782e..09b0bdb207 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy @@ -51,6 +51,7 @@ import com.netflix.spinnaker.kork.web.selector.ServiceSelector import com.netflix.spinnaker.okhttp.OkHttp3MetricsInterceptor import com.netflix.spinnaker.okhttp.OkHttpClientConfigurationProperties import com.opsmx.spinnaker.gate.services.NoOpClouddriverService +import com.opsmx.spinnaker.gate.services.NoOpFront50Service import com.opsmx.spinnaker.gate.services.OpsmxAuditClientService import com.opsmx.spinnaker.gate.services.OpsmxAuditService import groovy.transform.CompileStatic @@ -108,6 +109,9 @@ class GateConfig extends RedisHttpSessionConfiguration { @Value('${services.clouddriver.enabled}') boolean cloudDriverStatus + @Value('${services.front50.enabled}') + boolean front50Status + @Autowired void setServiceClientProvider(ServiceClientProvider serviceClientProvider) { this.serviceClientProvider = serviceClientProvider @@ -212,7 +216,12 @@ class GateConfig extends RedisHttpSessionConfiguration { @Bean Front50Service front50Service() { - createClient "front50", Front50Service + if(front50Status) { + createClient "front50", Front50Service + } + else { + return new NoOpFront50Service() + } } @Bean diff --git a/gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpFront50Service.java b/gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpFront50Service.java new file mode 100644 index 0000000000..1a6f4609ab --- /dev/null +++ b/gate-web/src/main/groovy/com/opsmx/spinnaker/gate/services/NoOpFront50Service.java @@ -0,0 +1,212 @@ +/* + * Copyright 2024 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.opsmx.spinnaker.gate.services; + +import com.netflix.spinnaker.fiat.model.resources.ServiceAccount; +import com.netflix.spinnaker.gate.services.internal.Front50Service; +import com.netflix.spinnaker.kork.plugins.SpinnakerPluginDescriptor; +import java.util.List; +import java.util.Map; +import retrofit.client.Response; + +public class NoOpFront50Service implements Front50Service { + @Override + public List getCredentials() { + return List.of(); + } + + @Override + public List getAllApplicationsUnrestricted() { + return List.of(); + } + + @Override + public Map getApplication(String applicationName) { + return Map.of(); + } + + @Override + public List getApplicationHistory(String applicationName, int limit) { + return List.of(); + } + + @Override + public List getAllPipelineConfigs() { + return List.of(); + } + + @Override + public List getPipelineConfigsForApplication(String app, boolean refresh) { + return List.of(); + } + + @Override + public Response deletePipelineConfig(String app, String name) { + return null; + } + + @Override + public Response savePipelineConfig(Map pipelineConfig) { + return null; + } + + @Override + public Response movePipelineConfig(Map moveCommand) { + return null; + } + + @Override + public List getPipelineConfigHistory(String pipelineConfigId, int limit) { + return List.of(); + } + + @Override + public Map updatePipeline(String pipelineId, Map pipeline) { + return Map.of(); + } + + @Override + public List getAllStrategyConfigs() { + return List.of(); + } + + @Override + public List getStrategyConfigs(String app) { + return List.of(); + } + + @Override + public Response deleteStrategyConfig(String app, String name) { + return null; + } + + @Override + public Response saveStrategyConfig(Map strategyConfig) { + return null; + } + + @Override + public Response moveStrategyConfig(Map moveCommand) { + return null; + } + + @Override + public List getStrategyConfigHistory(String strategyConfigId, int limit) { + return List.of(); + } + + @Override + public Map updateStrategy(String strategyId, Map strategy) { + return Map.of(); + } + + @Override + public List getPipelineTemplates(String... scopes) { + return List.of(); + } + + @Override + public Map getPipelineTemplate(String pipelineTemplateId) { + return Map.of(); + } + + @Override + public List> getPipelineTemplateDependents( + String pipelineTemplateId, boolean recursive) { + return List.of(); + } + + @Override + public Map getV2PipelineTemplate(String pipelineTemplateId, String tag, String digest) { + return Map.of(); + } + + @Override + public List getV2PipelineTemplates(String... scopes) { + return List.of(); + } + + @Override + public Map> getV2PipelineTemplatesVersions(String... scopes) { + return Map.of(); + } + + @Override + public List> getV2PipelineTemplateDependents(String pipelineTemplateId) { + return List.of(); + } + + @Override + public Map getNotificationConfigs(String type, String app) { + return Map.of(); + } + + @Override + public Response deleteNotificationConfig(String type, String app) { + return null; + } + + @Override + public Response saveNotificationConfig(String type, String app, Map notificationConfig) { + return null; + } + + @Override + public List getAllProjects() { + return List.of(); + } + + @Override + public Map getProject(String projectId) { + return Map.of(); + } + + @Override + public Map getCurrentSnapshot(String id) { + return Map.of(); + } + + @Override + public List getSnapshotHistory(String id, int limit) { + return List.of(); + } + + @Override + public List getServiceAccounts() { + return List.of(); + } + + @Override + public List getDeliveries() { + return List.of(); + } + + @Override + public Map getDelivery(String id) { + return Map.of(); + } + + @Override + public List getPluginInfo(String service) { + return List.of(); + } + + @Override + public List getInstalledPlugins() { + return List.of(); + } +}