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 deprecation warnings and docs #918

Merged
merged 1 commit into from
Dec 12, 2019
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## HEAD (Unreleased)

### Bug fixes

- Fix deprecation warnings and docs. (https://github.com/pulumi/pulumi-kubernetes/pull/918).

## 1.4.0 (December 9, 2019)

### Important
Expand Down
5 changes: 3 additions & 2 deletions pkg/gen/additionalComments.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ func PulumiComment(kind string) string {
}

func ApiVersionComment(gvk schema.GroupVersionKind) string {
const template = `%s is not supported by Kubernetes 1.16+ clusters. Use %s instead.
const template = `%s is deprecated by %s and not supported by Kubernetes v%v+ clusters.

`
gvkStr := gvk.GroupVersion().String() + "/" + gvk.Kind
return fmt.Sprintf(template, gvkStr, kinds.SuggestedApiVersion(gvk))
removedIn := kinds.RemovedInVersion(gvk)
return fmt.Sprintf(template, gvkStr, kinds.SuggestedApiVersion(gvk), removedIn)
}
28 changes: 22 additions & 6 deletions pkg/kinds/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,37 @@ func DeprecatedApiVersion(gvk schema.GroupVersionKind) bool {
return SuggestedApiVersion(gvk) != gvkStr(gvk)
}

// RemovedApiVersion returns true if the given GVK has been removed in the given k8s version, and the corresponding
// ServerVersion where the GVK was removed.
func RemovedApiVersion(gvk schema.GroupVersionKind, version cluster.ServerVersion) (bool, *cluster.ServerVersion) {
// RemovedInVersion returns the ServerVersion of k8s that a GVK is removed in. The return value is
// nil if the GVK is not scheduled for removal.
func RemovedInVersion(gvk schema.GroupVersionKind) *cluster.ServerVersion {
var removedIn cluster.ServerVersion

switch gvk.GroupVersion() {
case schema.GroupVersion{Group: "extensions", Version: "v1beta1"},
schema.GroupVersion{Group: "apps", Version: "v1beta1"},
schema.GroupVersion{Group: "apps", Version: "v1beta2"}:
removedIn = cluster.ServerVersion{Major: 1, Minor: 16}

if gvk.Kind == "Ingress" {
removedIn = cluster.ServerVersion{Major: 1, Minor: 20}
} else {
removedIn = cluster.ServerVersion{Major: 1, Minor: 16}
}
default:
return false, nil
return nil
}

return version.Compare(removedIn) >= 0, &removedIn
return &removedIn
}

// RemovedApiVersion returns true if the given GVK has been removed in the given k8s version, and the corresponding
// ServerVersion where the GVK was removed.
func RemovedApiVersion(gvk schema.GroupVersionKind, version cluster.ServerVersion) (bool, *cluster.ServerVersion) {
removedIn := RemovedInVersion(gvk)

if removedIn == nil {
return false, nil
}
return version.Compare(*removedIn) >= 0, removedIn
}

// SuggestedApiVersion returns a string with the suggested apiVersion for a given GVK.
Expand Down
26 changes: 26 additions & 0 deletions pkg/kinds/deprecated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@ func TestSuggestedApiVersion(t *testing.T) {
}
}

func TestRemovedInVersion(t *testing.T) {
type args struct {
gvk GroupVersionKind
}
tests := []struct {
name string
args args
wantVersion *cluster.ServerVersion
}{
{"extensions/v1beta1:Deployment", args{
GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "Deployment"},
}, &cluster.ServerVersion{Major: 1, Minor: 16}},
{"extensions/v1beta1:Ingress", args{
GroupVersionKind{Group: "extensions", Version: "v1beta1", Kind: "Ingress"},
}, &cluster.ServerVersion{Major: 1, Minor: 20}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := RemovedInVersion(tt.args.gvk)
if !reflect.DeepEqual(got, tt.wantVersion) {
t.Errorf("RemovedInVersion() got = %v, want %v", got, tt.wantVersion)
}
})
}
}

func TestRemovedApiVersion(t *testing.T) {
type args struct {
gvk GroupVersionKind
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta1/ControllerRevision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta1
{
/// <summary>
/// DEPRECATED - apps/v1beta1/ControllerRevision is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/ControllerRevision instead.
/// DEPRECATED - apps/v1beta1/ControllerRevision is deprecated by apps/v1/ControllerRevision and
/// not supported by Kubernetes v1.16+ clusters.
///
/// ControllerRevision implements an immutable snapshot of state data. Clients are responsible
/// for serializing and deserializing the objects that contain their internal state. Once a
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta1/Deployment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta1
{
/// <summary>
/// DEPRECATED - apps/v1beta1/Deployment is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/Deployment instead.
/// DEPRECATED - apps/v1beta1/Deployment is deprecated by apps/v1/Deployment and not supported
/// by Kubernetes v1.16+ clusters.
///
/// Deployment enables declarative updates for Pods and ReplicaSets.
///
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta1/StatefulSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta1
{
/// <summary>
/// DEPRECATED - apps/v1beta1/StatefulSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/StatefulSet instead.
/// DEPRECATED - apps/v1beta1/StatefulSet is deprecated by apps/v1/StatefulSet and not supported
/// by Kubernetes v1.16+ clusters.
///
/// StatefulSet represents a set of pods with consistent identities. Identities are defined as:
/// - Network: A single stable DNS and hostname.
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta2/ControllerRevision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta2
{
/// <summary>
/// DEPRECATED - apps/v1beta2/ControllerRevision is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/ControllerRevision instead.
/// DEPRECATED - apps/v1beta2/ControllerRevision is deprecated by apps/v1/ControllerRevision and
/// not supported by Kubernetes v1.16+ clusters.
///
/// ControllerRevision implements an immutable snapshot of state data. Clients are responsible
/// for serializing and deserializing the objects that contain their internal state. Once a
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta2/DaemonSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta2
{
/// <summary>
/// DEPRECATED - apps/v1beta2/DaemonSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/DaemonSet instead.
/// DEPRECATED - apps/v1beta2/DaemonSet is deprecated by apps/v1/DaemonSet and not supported by
/// Kubernetes v1.16+ clusters.
///
/// DaemonSet represents the configuration of a daemon set.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta2/Deployment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta2
{
/// <summary>
/// DEPRECATED - apps/v1beta2/Deployment is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/Deployment instead.
/// DEPRECATED - apps/v1beta2/Deployment is deprecated by apps/v1/Deployment and not supported
/// by Kubernetes v1.16+ clusters.
///
/// Deployment enables declarative updates for Pods and ReplicaSets.
///
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta2/ReplicaSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta2
{
/// <summary>
/// DEPRECATED - apps/v1beta2/ReplicaSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/ReplicaSet instead.
/// DEPRECATED - apps/v1beta2/ReplicaSet is deprecated by apps/v1/ReplicaSet and not supported
/// by Kubernetes v1.16+ clusters.
///
/// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Apps/V1Beta2/StatefulSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Apps.V1Beta2
{
/// <summary>
/// DEPRECATED - apps/v1beta2/StatefulSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/StatefulSet instead.
/// DEPRECATED - apps/v1beta2/StatefulSet is deprecated by apps/v1/StatefulSet and not supported
/// by Kubernetes v1.16+ clusters.
///
/// StatefulSet represents a set of pods with consistent identities. Identities are defined as:
/// - Network: A single stable DNS and hostname.
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Extensions/V1Beta1/DaemonSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Extensions.V1Beta1
{
/// <summary>
/// DEPRECATED - extensions/v1beta1/DaemonSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/DaemonSet instead.
/// DEPRECATED - extensions/v1beta1/DaemonSet is deprecated by apps/v1/DaemonSet and not
/// supported by Kubernetes v1.16+ clusters.
///
/// DaemonSet represents the configuration of a daemon set.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Extensions/V1Beta1/Deployment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Extensions.V1Beta1
{
/// <summary>
/// DEPRECATED - extensions/v1beta1/Deployment is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/Deployment instead.
/// DEPRECATED - extensions/v1beta1/Deployment is deprecated by apps/v1/Deployment and not
/// supported by Kubernetes v1.16+ clusters.
///
/// Deployment enables declarative updates for Pods and ReplicaSets.
///
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Extensions/V1Beta1/Ingress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Extensions.V1Beta1
{
/// <summary>
/// DEPRECATED - extensions/v1beta1/Ingress is not supported by Kubernetes 1.16+ clusters. Use
/// networking/v1beta1/Ingress instead.
/// DEPRECATED - extensions/v1beta1/Ingress is deprecated by networking/v1beta1/Ingress and not
/// supported by Kubernetes v1.20+ clusters.
///
/// Ingress is a collection of rules that allow inbound connections to reach the endpoints
/// defined by a backend. An Ingress can be configured to give services externally-reachable
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Extensions/V1Beta1/ReplicaSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Extensions.V1Beta1
{
/// <summary>
/// DEPRECATED - extensions/v1beta1/ReplicaSet is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/ReplicaSet instead.
/// DEPRECATED - extensions/v1beta1/ReplicaSet is deprecated by apps/v1/ReplicaSet and not
/// supported by Kubernetes v1.16+ clusters.
///
/// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Storage/V1Beta1/CSINode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Pulumi.Kubernetes.Storage.V1Beta1
{
/// <summary>
/// DEPRECATED - storage/v1beta1/CSINode is not supported by Kubernetes 1.16+ clusters. Use
/// storage/v1beta1/CSINode instead.
/// DEPRECATED - storage/v1beta1/CSINode is deprecated by storage/v1beta1/CSINode and not
/// supported by Kubernetes v&amp;lt;nil&amp;gt;+ clusters.
///
/// CSINode holds information about all CSI drivers installed on a node. CSI drivers do not need
/// to create the CSINode object directly. As long as they use the node-driver-registrar sidecar
Expand Down
52 changes: 26 additions & 26 deletions sdk/dotnet/Types/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5012,8 +5012,8 @@ public class StatefulSetUpdateStrategyArgs : Pulumi.ResourceArgs
namespace V1Beta1
{
/// <summary>
/// DEPRECATED - apps/v1beta1/ControllerRevision is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/ControllerRevision instead.
/// DEPRECATED - apps/v1beta1/ControllerRevision is deprecated by apps/v1/ControllerRevision and
/// not supported by Kubernetes v1.16+ clusters.
///
/// ControllerRevision implements an immutable snapshot of state data. Clients are responsible
/// for serializing and deserializing the objects that contain their internal state. Once a
Expand Down Expand Up @@ -5110,8 +5110,8 @@ public InputList<Apps.V1Beta1.ControllerRevisionArgs> Items
}

/// <summary>
/// DEPRECATED - apps/v1beta1/Deployment is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/Deployment instead.
/// DEPRECATED - apps/v1beta1/Deployment is deprecated by apps/v1/Deployment and not supported
/// by Kubernetes v1.16+ clusters.
///
/// Deployment enables declarative updates for Pods and ReplicaSets.
/// </summary>
Expand Down Expand Up @@ -5593,8 +5593,8 @@ public InputMap<string> Selector
}

/// <summary>
/// DEPRECATED - apps/v1beta1/StatefulSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/StatefulSet instead.
/// DEPRECATED - apps/v1beta1/StatefulSet is deprecated by apps/v1/StatefulSet and not supported
/// by Kubernetes v1.16+ clusters.
///
/// StatefulSet represents a set of pods with consistent identities. Identities are defined as:
/// - Network: A single stable DNS and hostname.
Expand Down Expand Up @@ -5897,8 +5897,8 @@ public class StatefulSetUpdateStrategyArgs : Pulumi.ResourceArgs
namespace V1Beta2
{
/// <summary>
/// DEPRECATED - apps/v1beta2/ControllerRevision is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/ControllerRevision instead.
/// DEPRECATED - apps/v1beta2/ControllerRevision is deprecated by apps/v1/ControllerRevision and
/// not supported by Kubernetes v1.16+ clusters.
///
/// ControllerRevision implements an immutable snapshot of state data. Clients are responsible
/// for serializing and deserializing the objects that contain their internal state. Once a
Expand Down Expand Up @@ -5995,8 +5995,8 @@ public InputList<Apps.V1Beta2.ControllerRevisionArgs> Items
}

/// <summary>
/// DEPRECATED - apps/v1beta2/DaemonSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/DaemonSet instead.
/// DEPRECATED - apps/v1beta2/DaemonSet is deprecated by apps/v1/DaemonSet and not supported by
/// Kubernetes v1.16+ clusters.
///
/// DaemonSet represents the configuration of a daemon set.
/// </summary>
Expand Down Expand Up @@ -6267,8 +6267,8 @@ public class DaemonSetUpdateStrategyArgs : Pulumi.ResourceArgs
}

/// <summary>
/// DEPRECATED - apps/v1beta2/Deployment is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/Deployment instead.
/// DEPRECATED - apps/v1beta2/Deployment is deprecated by apps/v1/Deployment and not supported
/// by Kubernetes v1.16+ clusters.
///
/// Deployment enables declarative updates for Pods and ReplicaSets.
/// </summary>
Expand Down Expand Up @@ -6545,8 +6545,8 @@ public class DeploymentStrategyArgs : Pulumi.ResourceArgs
}

/// <summary>
/// DEPRECATED - apps/v1beta2/ReplicaSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/ReplicaSet instead.
/// DEPRECATED - apps/v1beta2/ReplicaSet is deprecated by apps/v1/ReplicaSet and not supported
/// by Kubernetes v1.16+ clusters.
///
/// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
/// </summary>
Expand Down Expand Up @@ -6921,8 +6921,8 @@ public InputMap<string> Selector
}

/// <summary>
/// DEPRECATED - apps/v1beta2/StatefulSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/StatefulSet instead.
/// DEPRECATED - apps/v1beta2/StatefulSet is deprecated by apps/v1/StatefulSet and not supported
/// by Kubernetes v1.16+ clusters.
///
/// StatefulSet represents a set of pods with consistent identities. Identities are defined as:
/// - Network: A single stable DNS and hostname.
Expand Down Expand Up @@ -20600,8 +20600,8 @@ public class AllowedHostPathArgs : Pulumi.ResourceArgs
}

/// <summary>
/// DEPRECATED - extensions/v1beta1/DaemonSet is not supported by Kubernetes 1.16+ clusters. Use
/// apps/v1/DaemonSet instead.
/// DEPRECATED - extensions/v1beta1/DaemonSet is deprecated by apps/v1/DaemonSet and not
/// supported by Kubernetes v1.16+ clusters.
///
/// DaemonSet represents the configuration of a daemon set.
/// </summary>
Expand Down Expand Up @@ -20878,8 +20878,8 @@ public class DaemonSetUpdateStrategyArgs : Pulumi.ResourceArgs
}

/// <summary>
/// DEPRECATED - extensions/v1beta1/Deployment is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/Deployment instead.
/// DEPRECATED - extensions/v1beta1/Deployment is deprecated by apps/v1/Deployment and not
/// supported by Kubernetes v1.16+ clusters.
///
/// Deployment enables declarative updates for Pods and ReplicaSets.
/// </summary>
Expand Down Expand Up @@ -21359,8 +21359,8 @@ public InputList<string> Except
}

/// <summary>
/// DEPRECATED - extensions/v1beta1/Ingress is not supported by Kubernetes 1.16+ clusters. Use
/// networking/v1beta1/Ingress instead.
/// DEPRECATED - extensions/v1beta1/Ingress is deprecated by networking/v1beta1/Ingress and not
/// supported by Kubernetes v1.20+ clusters.
///
/// Ingress is a collection of rules that allow inbound connections to reach the endpoints
/// defined by a backend. An Ingress can be configured to give services externally-reachable
Expand Down Expand Up @@ -22219,8 +22219,8 @@ public InputList<string> Volumes
}

/// <summary>
/// DEPRECATED - extensions/v1beta1/ReplicaSet is not supported by Kubernetes 1.16+ clusters.
/// Use apps/v1/ReplicaSet instead.
/// DEPRECATED - extensions/v1beta1/ReplicaSet is deprecated by apps/v1/ReplicaSet and not
/// supported by Kubernetes v1.16+ clusters.
///
/// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
/// </summary>
Expand Down Expand Up @@ -29351,8 +29351,8 @@ public InputList<string> VolumeLifecycleModes
}

/// <summary>
/// DEPRECATED - storage/v1beta1/CSINode is not supported by Kubernetes 1.16+ clusters. Use
/// storage/v1beta1/CSINode instead.
/// DEPRECATED - storage/v1beta1/CSINode is deprecated by storage/v1beta1/CSINode and not
/// supported by Kubernetes v&amp;lt;nil&amp;gt;+ clusters.
///
/// CSINode holds information about all CSI drivers installed on a node. CSI drivers do not need
/// to create the CSINode object directly. As long as they use the node-driver-registrar sidecar
Expand Down
Loading