Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
anibmurthy committed Oct 13, 2023
1 parent 0640f3d commit 951e2e7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PLUGIN_SCOPE_ASSOCIATION_FILE ?= ""
all: test build ## Prepare and run the project tests

.PHONY: install
install: test## Install the plugin binaries to the local machine
install: ## Install the plugin binaries to the local machine
@# TODO avoid deleting an existing plugin once in place reinstalls are working again
@tanzu plugin delete apps > /dev/null 2>&1 || true
$(BUILDER_PLUGIN) plugin build --path $(PLUGIN_DIR) --binary-artifacts $(PLUGIN_BINARY_ARTIFACTS_DIR) --version $(PLUGIN_BUILD_VERSION) --ldflags "$(PLUGIN_LD_FLAGS)" --os-arch local
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/cartographer/v1alpha1/workload_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io"
"reflect"
"time"

corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -560,6 +561,18 @@ func WorkloadReadyConditionFunc(target client.Object) (bool, error) {
return false, nil
}

func TestDelay(delay time.Duration) func(client.Object) (bool, error) {
return func(target client.Object) (bool, error) {
ok, err := WorkloadReadyConditionFunc(target)

if ok && err == nil {
time.Sleep(delay)
return WorkloadReadyConditionFunc(target)
}
return ok, err
}
}

func (w *Workload) DeprecationWarnings() []string {
warnings := []string{}
var serviceClaimDeprecationWarningMsg = "Cross namespace service claims are deprecated. Please use `tanzu service claim create` instead."
Expand Down
5 changes: 4 additions & 1 deletion pkg/commands/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type WorkloadOptions struct {

Wait bool
WaitTimeout time.Duration
Delay time.Duration
Tail bool
TailTimestamps bool
DryRun bool
Expand Down Expand Up @@ -907,7 +908,7 @@ func getReadyConditionWorker(c *cli.Config, workload *cartov1alpha1.Workload) wa
if err != nil {
return err
}
return wait.UntilCondition(ctx, clientWithWatch, types.NamespacedName{Name: workload.Name, Namespace: workload.Namespace}, &cartov1alpha1.WorkloadList{}, cartov1alpha1.WorkloadReadyConditionFunc)
return wait.UntilCondition(ctx, clientWithWatch, types.NamespacedName{Name: workload.Name, Namespace: workload.Namespace}, &cartov1alpha1.WorkloadList{}, cartov1alpha1.TestDelay(30*time.Second))
})

return worker
Expand Down Expand Up @@ -1018,6 +1019,8 @@ func (opts *WorkloadOptions) DefineFlags(ctx context.Context, c *cli.Config, cmd
cmd.MarkFlagFilename(cli.StripDash(flags.FilePathFlagName), ".yaml", ".yml")
cmd.Flags().BoolVar(&opts.DryRun, cli.StripDash(flags.DryRunFlagName), false, "print kubernetes resources to stdout rather than apply them to the cluster, messages normally on stdout will be sent to stderr")
cmd.Flags().BoolVarP(&opts.Yes, cli.StripDash(flags.YesFlagName), "y", false, "accept all prompts")

cmd.Flags().DurationVar(&opts.Delay, cli.StripDash(flags.DelayFlagName), 10*time.Second, "Delay for workload to become ready when waiting")
}

func (opts *WorkloadOptions) DefineEnvVars(ctx context.Context, c *cli.Config, cmd *cobra.Command) {
Expand Down
1 change: 1 addition & 0 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ const (
WaitFlagName = "--wait"
WaitTimeoutFlagName = "--wait-timeout"
YesFlagName = "--yes"
DelayFlagName = "--delay"
)

0 comments on commit 951e2e7

Please sign in to comment.