Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into rediscache-roll-a…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
jpflueger committed May 26, 2020
2 parents 423ff13 + 1a428b1 commit a80963e
Show file tree
Hide file tree
Showing 23 changed files with 5,187 additions and 56 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ RUN apt-get update \
golang.org/x/lint/golint \
github.com/alecthomas/gometalinter \
honnef.co/go/tools/... \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/mgechev/revive \
github.com/derekparker/delve/cmd/dlv 2>&1 \
#
Expand Down Expand Up @@ -93,7 +92,7 @@ COPY ./Makefile ./
RUN make install-kind
RUN make install-kubebuilder
RUN make install-kustomize
RUN make install-test-dependency
RUN make install-test-dependencies

# Set the default shell to bash instead of sh
ENV SHELL /bin/bash
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ testlogs.txt
# Generated CRDS
config/crd/bases/*
config/rbac/role.yaml
api/*/zz_generated.*

# Kubernetes Generated files - skip generated files, except for vendored files

Expand Down
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ resources:
- group: azure
version: v1alpha1
kind: RedisCacheAction
- group: azure
kind: AzureVirtualMachineExtension
version: v1alpha1
55 changes: 55 additions & 0 deletions api/v1alpha1/azurevirtualmachineextension_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// AzureVirtualMachineExtensionSpec defines the desired state of AzureVirtualMachineExtension
type AzureVirtualMachineExtensionSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Location string `json:"location"`
ResourceGroup string `json:"resourceGroup"`
VMName string `json:"vmName"`
AutoUpgradeMinorVersion bool `json:"autoUpgradeMinorVersion"`
ForceUpdateTag string `json:"forceUpdateTag"`
Publisher string `json:"publisher"`
TypeName string `json:"typeName"`
TypeHandlerVersion string `json:"typeHandlerVersion"`
Settings string `json:"settings,omitempty"`
ProtectedSettings string `json:"protectedSettings,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// AzureVirtualMachineExtension is the Schema for the azurevirtualmachineextensions API
// +kubebuilder:resource:shortName=vmext,path=azurevirtualmachineextensions
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message"
type AzureVirtualMachineExtension struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AzureVirtualMachineExtensionSpec `json:"spec,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// AzureVirtualMachineExtensionList contains a list of AzureVirtualMachineExtension
type AzureVirtualMachineExtensionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AzureVirtualMachineExtension `json:"items"`
}

func init() {
SchemeBuilder.Register(&AzureVirtualMachineExtension{}, &AzureVirtualMachineExtensionList{})
}
76 changes: 76 additions & 0 deletions api/v1alpha1/azurevirtualmachineextension_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package v1alpha1

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// These tests are written in BDD-style using Ginkgo framework. Refer to
// http://onsi.github.io/ginkgo to learn more.

var _ = Describe("AzureVirtualMachineExtension", func() {
var (
key types.NamespacedName
created, fetched *AzureVirtualMachineExtension
)

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
})

AfterEach(func() {
// Add any teardown steps that needs to be executed after each test
})

// Add Tests for OpenAPI validation (or additonal CRD features) specified in
// your API definition.
// Avoid adding tests for vanilla CRUD operations because they would
// test Kubernetes API server, which isn't the goal here.
Context("Create API", func() {

It("should create an object successfully", func() {

key = types.NamespacedName{
Name: "foo",
Namespace: "default",
}
created = &AzureVirtualMachineExtension{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: AzureVirtualMachineExtensionSpec{
Location: "westus",
ResourceGroup: "foo-rg",
VMName: "foo-vm",
AutoUpgradeMinorVersion: true,
ForceUpdateTag: "test",
Publisher: "test",
TypeName: "test",
TypeHandlerVersion: "test",
Settings: "test",
ProtectedSettings: "test",
}}

By("creating an API obj")
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed())

fetched = &AzureVirtualMachineExtension{}
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed())
Expect(fetched).To(Equal(created))

By("deleting the created object")
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed())
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed())
})

})

})
Loading

0 comments on commit a80963e

Please sign in to comment.