This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func TestInsertSortGenericInt(t *testing.T) { | |
| items := []int{3, 55, 4, 9, 8, 7, 67, 51} | |
| InsertSort(items) | |
| assert.Equal(t, items, []int{3, 4, 7, 8, 9, 51, 55, 67}) | |
| } | |
| func TestInsertSortGenericString(t *testing.T) { | |
| items := []string{"mike", "john", "adil", "aaron", "julia"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func TestInsertInt(t *testing.T) { | |
| items := []int{6, 55, 4, 9, 8, 7, 67, 51} | |
| InsertSortInt(items) | |
| assert.Equal(t, items, []int{4, 6, 7, 8, 9, 51, 55, 67}) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func InsertSort[T constraints.Ordered](items []T) { | |
| for i := 1; i < len(items); i++ { | |
| // loop through subslices | |
| for j := i; j > 0; j-- { | |
| if items[j] < items[j-1] { | |
| // swap elements if not ordered | |
| items[j], items[j-1] = items[j-1], items[j] | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func InsertSortAny[T any](items []T) { | |
| for i := 1; i < len(items); i++ { | |
| // loop through subslices | |
| for j := i; j > 0; j-- { | |
| if items[j] < items[j-1] { | |
| // swap elements if not ordered | |
| items[j], items[j-1] = items[j-1], items[j] | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func InsertSortInt(items []int) { | |
| for i := 1; i < len(items); i++ { | |
| // loop through subslices | |
| for j := i; j > 0; j-- { | |
| if items[j] < items[j-1] { | |
| // swap elements if not ordered | |
| items[j], items[j-1] = items[j-1], items[j] | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Context("When creating a deployment", func() { | |
| var deployment *appsv1.Deployment | |
| var bucket *abv1.Bucket | |
| It("Should create the bucket crd", func() { | |
| ctx := context.Background() | |
| gcpSvc.On("CreateBucket", mock.AnythingOfType("*context.emptyCtx"), BucketFullName).Return(nil) | |
| deployment = &appsv1.Deployment{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (r *BucketReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { | |
| ctx := context.Background() | |
| log := r.Log.WithValues("bucket", req.NamespacedName) | |
| bucket := &abv1.Bucket{} | |
| err := r.Get(ctx, req.NamespacedName, bucket) | |
| if err != nil { | |
| if errors.IsNotFound(err) { | |
| // Request object not found, could have been deleted after reconcile request. | |
| // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (r *DeploymentReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { | |
| ctx := context.Background() | |
| log := r.Log.WithValues("deployment", req.NamespacedName) | |
| dep := &appsv1.Deployment{} | |
| err := r.Get(ctx, req.NamespacedName, dep) | |
| if err != nil { | |
| if errors.IsNotFound(err) { | |
| // Request object not found, could have been deleted after reconcile request. | |
| // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: bucket-text-api | |
| labels: | |
| app: bucket-text-api | |
| annotations: | |
| ## Custom Annotations start here | |
| ab.leclouddev.com/cloud: gcp | |
| ab.leclouddev.com/name-prefix: ab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: ab.leclouddev.com/v1 | |
| kind: Bucket | |
| metadata: | |
| name: my-app | |
| spec: | |
| cloud: gcp | |
| fullName: ab-default-my-app | |
| onDeletePolicy: destroy |
NewerOlder