Skip to content

Commit

Permalink
refactor(kubernetes): Convert all V2 code in clouddriver-kubernetes t…
Browse files Browse the repository at this point in the history
…o Java (#3947)

* fix(appengine): Fix package name of MutableCacheData

At some point the MutableCacheData class was moved to the appengine
provider, but the package name still references kubernetes. Update
the package name in the class, and all of the references.

* refactor(kubernetes): Move shared logic out of V1 provider

KubernetesAtomicOperationConverterHelper is used by both the V1 and V2
providers, so should not live in the V1 directory tree; move it up to
the base level.

KubernetesApiClientConfig is only used by the V1 provider, so it should
be moved into the v1 directory tree.

* refactor(kubernetes): Convert ConfigurationProperties to Java

Also, move the top-level classes in that file to their own files
as part of the Java conversion.

In order to make this work better with Lombok-generated accessors,
change calls to the accessors: booleans should use isXXX instead of
getXXX, and change the capialization of getoAuthScopes.

* refactor(kubernetes): Convert a few more classes to Java

Also, as part of this conversion update
KubernetesAtomicOperationConverterHelper to use generics, which
avoids a lot of necessary casting and provides extra type safety.
This extra type safety surfaced a bug in the resize server group
converter where we were incorrectly converting the description to a
deploy manifest description which compiled before but no longer does.

* refactor(kubernetes): Convert KubernetesCloudProvider to Java

Also standardize static access to the ID to just use the public
static final field instead of mixing use of the field and the
auto-generated static accessor.

* refactor(kubernetes): Convert configuration to Java

This is the last non-test class in clouddriver-kubernetes that is
still in groovy (excluding classes used exclusively by the V1 provider).

* refactor(kubernetes): Remove unused Getter annotation
  • Loading branch information
ezimanyi authored Aug 15, 2019
1 parent fe186a2 commit 09e0c13
Show file tree
Hide file tree
Showing 70 changed files with 536 additions and 503 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import com.netflix.spinnaker.cats.provider.ProviderCache
import com.netflix.spinnaker.clouddriver.appengine.AppengineCloudProvider
import com.netflix.spinnaker.clouddriver.appengine.cache.Keys
import com.netflix.spinnaker.clouddriver.appengine.model.AppengineLoadBalancer
import com.netflix.spinnaker.clouddriver.appengine.provider.view.MutableCacheData
import com.netflix.spinnaker.clouddriver.appengine.security.AppengineNamedAccountCredentials
import com.netflix.spinnaker.clouddriver.cache.OnDemandAgent
import com.netflix.spinnaker.clouddriver.cache.OnDemandAgent.OnDemandResult
import com.netflix.spinnaker.clouddriver.cache.OnDemandMetricsSupport
import com.netflix.spinnaker.clouddriver.kubernetes.v1.provider.view.MutableCacheData
import groovy.util.logging.Slf4j

import java.util.concurrent.TimeUnit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import com.netflix.spinnaker.cats.agent.DefaultCacheResult
import com.netflix.spinnaker.cats.provider.ProviderCache
import com.netflix.spinnaker.clouddriver.appengine.cache.Keys
import com.netflix.spinnaker.clouddriver.appengine.model.AppenginePlatformApplication
import com.netflix.spinnaker.clouddriver.appengine.provider.view.MutableCacheData
import com.netflix.spinnaker.clouddriver.appengine.security.AppengineNamedAccountCredentials
import com.netflix.spinnaker.clouddriver.kubernetes.v1.provider.view.MutableCacheData
import groovy.util.logging.Slf4j

import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import com.netflix.spinnaker.clouddriver.appengine.model.AppengineInstance
import com.netflix.spinnaker.clouddriver.appengine.model.AppengineLoadBalancer
import com.netflix.spinnaker.clouddriver.appengine.model.AppengineServerGroup
import com.netflix.spinnaker.clouddriver.appengine.provider.callbacks.AppengineCallback
import com.netflix.spinnaker.clouddriver.appengine.provider.view.MutableCacheData
import com.netflix.spinnaker.clouddriver.appengine.security.AppengineNamedAccountCredentials
import com.netflix.spinnaker.clouddriver.cache.OnDemandAgent
import com.netflix.spinnaker.clouddriver.cache.OnDemandMetricsSupport
import com.netflix.spinnaker.clouddriver.kubernetes.v1.provider.view.MutableCacheData
import groovy.util.logging.Slf4j

import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.clouddriver.kubernetes.v1.provider.view
package com.netflix.spinnaker.clouddriver.appengine.provider.view

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2015 Google, 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.clouddriver.kubernetes;

import com.netflix.spinnaker.clouddriver.core.CloudProvider;
import java.lang.annotation.Annotation;
import org.springframework.stereotype.Component;

/** Kubernetes declaration as a {@link CloudProvider}. */
@Component
public class KubernetesCloudProvider implements CloudProvider {
public static final String ID = "kubernetes";

@Override
public String getId() {
return ID;
}

@Override
public String getDisplayName() {
return "Kubernetes";
}

@Override
public Class<? extends Annotation> getOperationAnnotationType() {
return KubernetesOperation.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.clouddriver.kubernetes;

package com.netflix.spinnaker.clouddriver.kubernetes

import java.lang.annotation.ElementType
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* {@code KubernetesOperation}s specify implementation classes of Spinnaker AtomicOperations for Kubernetes.
* {@code KubernetesOperation}s specify implementation classes of Spinnaker AtomicOperations for
* Kubernetes.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@interface KubernetesOperation {
String value()
public @interface KubernetesOperation {
String value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2019 Google, 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.clouddriver.kubernetes.config;

import com.netflix.spinnaker.clouddriver.kubernetes.v2.description.KubernetesSpinnakerKindMap;
import lombok.Data;

@Data
public class CustomKubernetesResource {
private String kubernetesKind;
private String spinnakerKind = KubernetesSpinnakerKindMap.SpinnakerKind.UNCLASSIFIED.toString();
private String deployPriority = "100";
private boolean versioned = false;
private boolean namespaced = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2019 Google, 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.clouddriver.kubernetes.config;

import lombok.Data;

@Data
public class KubernetesCachingPolicy {
private String kubernetesKind;
private int maxEntriesPerAgent;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2019 Google, 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.clouddriver.kubernetes.config;

import com.netflix.spinnaker.clouddriver.security.ProviderVersion;
import com.netflix.spinnaker.fiat.model.resources.Permissions;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;

@Data
public class KubernetesConfigurationProperties {
private static final int DEFAULT_CACHE_THREADS = 1;
private List<ManagedAccount> accounts = new ArrayList<>();

@Data
public static class ManagedAccount {
private String name;
private ProviderVersion providerVersion = ProviderVersion.v1;
private String environment;
private String accountType;
private String context;
private String cluster;
private String oAuthServiceAccount;
private List<String> oAuthScopes;
private String user;
private String kubeconfigFile;
private String kubeconfigContents;
private String kubectlExecutable;
private Integer kubectlRequestTimeoutSeconds;
private boolean serviceAccount = false;
private boolean configureImagePullSecrets = true;
private List<String> namespaces = new ArrayList<>();
private List<String> omitNamespaces = new ArrayList<>();
private String skin;
private int cacheThreads = DEFAULT_CACHE_THREADS;
private List<LinkedDockerRegistryConfiguration> dockerRegistries;
private List<String> requiredGroupMembership = new ArrayList<>();
private Permissions.Builder permissions = new Permissions.Builder();
private String namingStrategy = "kubernetesAnnotations";
private boolean debug = false;
private boolean metrics = true;
private boolean checkPermissionsOnStartup = true;
private List<CustomKubernetesResource> customResources = new ArrayList<>();
private List<KubernetesCachingPolicy> cachingPolicies = new ArrayList<>();
private List<String> kinds = new ArrayList<>();
private List<String> omitKinds = new ArrayList<>();
private boolean onlySpinnakerManaged = false;
private boolean liveManifestCalls = false;
private Long cacheIntervalSeconds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2019 Google, 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.clouddriver.kubernetes.config;

import java.util.List;
import lombok.Data;

@Data
public class LinkedDockerRegistryConfiguration {
private String accountName;
private List<String> namespaces;
}
Loading

0 comments on commit 09e0c13

Please sign in to comment.