Skip to content

Commit

Permalink
Merge pull request #26 from previousnext/v1-apiservice
Browse files Browse the repository at this point in the history
Bump APIService to v1
  • Loading branch information
nickschuch authored Jul 5, 2023
2 parents 95f2d3b + 43e1fc9 commit e812578
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia
return diag.FromErr(err)
}

out, err := conn.APIRegistration().ApiregistrationV1beta1().APIServices().Create(ctx, &service, metav1.CreateOptions{})
out, err := conn.APIRegistration().ApiregistrationV1().APIServices().Create(ctx, &service, metav1.CreateOptions{})
if err != nil {
return diag.FromErr(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia
return diag.FromErr(err)
}

err = conn.APIRegistration().ApiregistrationV1beta1().APIServices().Delete(ctx, name, metav1.DeleteOptions{})
err = conn.APIRegistration().ApiregistrationV1().APIServices().Delete(ctx, name, metav1.DeleteOptions{})
if err != nil {
return diag.FromErr(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package apiservice
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"

"github.com/previousnext/terraform-provider-k8s/internal/interfaceutils"
)

// Generate the APIService.
func Generate(d *schema.ResourceData) (apiregistrationv1beta1.APIService, error) {
func Generate(d *schema.ResourceData) (apiregistrationv1.APIService, error) {
var (
name = d.Get(FieldName).(string)
rawLabels = d.Get(FieldLabels).(map[string]interface{})
Expand All @@ -22,13 +22,13 @@ func Generate(d *schema.ResourceData) (apiregistrationv1beta1.APIService, error)
versionPriority = d.Get(FieldVersionPriority).(int)
)

crd := apiregistrationv1beta1.APIService{
crd := apiregistrationv1.APIService{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: interfaceutils.ExpandMap(rawLabels),
},
Spec: apiregistrationv1beta1.APIServiceSpec{
Service: &apiregistrationv1beta1.ServiceReference{
Spec: apiregistrationv1.APIServiceSpec{
Service: &apiregistrationv1.ServiceReference{
Name: serviceName,
Namespace: serviceNamespace,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn
return diag.FromErr(err)
}

service, err := conn.APIRegistration().ApiregistrationV1beta1().APIServices().Get(ctx, name, metav1.GetOptions{})
service, err := conn.APIRegistration().ApiregistrationV1().APIServices().Get(ctx, name, metav1.GetOptions{})
if kerrors.IsNotFound(err) {
// This is how we tell Terraform that the resource does not exist.
d.SetId("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia
return diag.FromErr(err)
}

_, err = conn.APIRegistration().ApiregistrationV1beta1().APIServices().Update(ctx, &service, metav1.UpdateOptions{})
_, err = conn.APIRegistration().ApiregistrationV1().APIServices().Update(ctx, &service, metav1.UpdateOptions{})
if err != nil {
return diag.FromErr(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (
FieldCustomtResourceDefinition = "k8s_apiextensions_v1beta1_customresourcedefinition"

// FieldAPIService identifier for the Kubernetes APIService.
FieldAPIService = "k8s_apiregistration_v1beta1_apiservice"
FieldAPIService = "k8s_apiregistration_v1_apiservice"

// FieldPodDisruptionBudget identifier for the Kubernetes PodDisruptionBudget.
FieldPodDisruptionBudget = "k8s_policy_v1beta1_poddisruptionbudget"
Expand Down

0 comments on commit e812578

Please sign in to comment.