From 2f5402ae8093da6ec8747afd4e15e8b0cdbd4d25 Mon Sep 17 00:00:00 2001
From: Ruslan Aliev <raliev@mirantis.com>
Date: Wed, 23 Sep 2020 00:30:34 -0500
Subject: [PATCH] Remove phase apply command

Command phase run will be used instead, so phase apply became no
longer needed.

Change-Id: I8bdbd6bcad7efbb03632978d8952700fc39d55ba
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
---
 cmd/phase/apply.go                            |  81 ------------
 cmd/phase/apply_test.go                       |  35 -----
 cmd/phase/phase.go                            |   1 -
 cmd/phase/run.go                              |   2 -
 .../phase-apply-cmd-with-help.golden          |  16 ---
 .../phase-cmd-with-help.golden                |   1 -
 docs/source/architecture.md                   |   2 +-
 docs/source/cli/airshipctl_phase.md           |   1 -
 docs/source/cli/airshipctl_phase_apply.md     |  43 ------
 docs/source/providers/cluster_api_docker.md   |  16 +--
 pkg/phase/apply/apply.go                      |  88 -------------
 pkg/phase/apply/apply_test.go                 | 124 ------------------
 pkg/phase/apply/testdata/config.yaml          |  23 ----
 pkg/phase/apply/testdata/kubeconfig.yaml      |  19 ---
 .../ephemeral/initinfra/kustomization.yaml    |   2 -
 .../initinfra/replicationcontroller.yaml      |  19 ---
 .../test-site/ephemeral/kustomization.yaml    |   2 -
 tools/document/validate_site_docs.sh          |   2 +-
 18 files changed, 10 insertions(+), 467 deletions(-)
 delete mode 100644 cmd/phase/apply.go
 delete mode 100644 cmd/phase/apply_test.go
 delete mode 100644 cmd/phase/testdata/TestNewApplyCommandGoldenOutput/phase-apply-cmd-with-help.golden
 delete mode 100644 docs/source/cli/airshipctl_phase_apply.md
 delete mode 100644 pkg/phase/apply/apply.go
 delete mode 100644 pkg/phase/apply/apply_test.go
 delete mode 100644 pkg/phase/apply/testdata/config.yaml
 delete mode 100644 pkg/phase/apply/testdata/kubeconfig.yaml
 delete mode 100644 pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/kustomization.yaml
 delete mode 100644 pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/replicationcontroller.yaml
 delete mode 100644 pkg/phase/apply/testdata/primary/site/test-site/ephemeral/kustomization.yaml

diff --git a/cmd/phase/apply.go b/cmd/phase/apply.go
deleted file mode 100644
index 274d0cc77..000000000
--- a/cmd/phase/apply.go
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package phase
-
-import (
-	"time"
-
-	"github.com/spf13/cobra"
-
-	"opendev.org/airship/airshipctl/pkg/config"
-	"opendev.org/airship/airshipctl/pkg/phase/apply"
-)
-
-const (
-	applyLong = `
-Apply specific phase to kubernetes cluster such as control-plane, workloads, initinfra
-`
-	applyExample = `
-# Apply initinfra phase to a cluster
-airshipctl phase apply initinfra
-`
-)
-
-// NewApplyCommand creates a command to apply phase to k8s cluster.
-func NewApplyCommand(cfgFactory config.Factory) *cobra.Command {
-	i := &apply.Options{}
-	applyCmd := &cobra.Command{
-		Use:     "apply PHASE_NAME",
-		Short:   "Apply phase to a cluster",
-		Long:    applyLong[1:],
-		Args:    cobra.ExactArgs(1),
-		Example: applyExample,
-		RunE: func(cmd *cobra.Command, args []string) error {
-			i.PhaseName = args[0]
-			cfg, err := cfgFactory()
-			if err != nil {
-				return err
-			}
-			i.Initialize(cfg.KubeConfigPath())
-			return i.Run(cfg)
-		},
-	}
-	addApplyFlags(i, applyCmd)
-	return applyCmd
-}
-
-func addApplyFlags(i *apply.Options, cmd *cobra.Command) {
-	flags := cmd.Flags()
-	flags.BoolVar(
-		&i.DryRun,
-		"dry-run",
-		false,
-		"don't deliver documents to the cluster, simulate the changes instead")
-
-	flags.BoolVar(
-		&i.Prune,
-		"prune",
-		false,
-		`if set to true, command will delete all kubernetes resources that are not`+
-			` defined in airship documents and have airshipit.org/deployed=apply label`)
-
-	flags.DurationVar(
-		&i.WaitTimeout,
-		"wait-timeout",
-		time.Second*120,
-		`number of seconds to wait for resources to become ready, if set to 0 will not wait`)
-}
diff --git a/cmd/phase/apply_test.go b/cmd/phase/apply_test.go
deleted file mode 100644
index 88c255e72..000000000
--- a/cmd/phase/apply_test.go
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-     https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package phase_test
-
-import (
-	"testing"
-
-	"opendev.org/airship/airshipctl/cmd/phase"
-	"opendev.org/airship/airshipctl/testutil"
-)
-
-func TestNewApplyCommand(t *testing.T) {
-	tests := []*testutil.CmdTest{
-		{
-			Name:    "phase-apply-cmd-with-help",
-			CmdLine: "--help",
-			Cmd:     phase.NewApplyCommand(nil),
-		},
-	}
-	for _, testcase := range tests {
-		testutil.RunTest(t, testcase)
-	}
-}
diff --git a/cmd/phase/phase.go b/cmd/phase/phase.go
index 325fa0772..8d9f66902 100644
--- a/cmd/phase/phase.go
+++ b/cmd/phase/phase.go
@@ -35,7 +35,6 @@ func NewPhaseCommand(cfgFactory config.Factory) *cobra.Command {
 		Long:  clusterLong[1:],
 	}
 
-	phaseRootCmd.AddCommand(NewApplyCommand(cfgFactory))
 	phaseRootCmd.AddCommand(NewRenderCommand(cfgFactory))
 	phaseRootCmd.AddCommand(NewPlanCommand(cfgFactory))
 	phaseRootCmd.AddCommand(NewRunCommand(cfgFactory))
diff --git a/cmd/phase/run.go b/cmd/phase/run.go
index 83ebc0b63..697607f09 100644
--- a/cmd/phase/run.go
+++ b/cmd/phase/run.go
@@ -24,8 +24,6 @@ import (
 const (
 	// TODO (kkalynovskyi) when different phase executors will be implemented, and their description is more clear,
 	// add documentation here. also consider adding dynamic phase descriptions based on executors.
-	// TODO (kkalynovskyi) when this command is fully functional and phase executors are developed
-	// remove phase apply command
 	runLong    = `Run specific life-cycle phase such as ephemeral-control-plane, target-initinfra etc...`
 	runExample = `
 # Run initinfra phase
diff --git a/cmd/phase/testdata/TestNewApplyCommandGoldenOutput/phase-apply-cmd-with-help.golden b/cmd/phase/testdata/TestNewApplyCommandGoldenOutput/phase-apply-cmd-with-help.golden
deleted file mode 100644
index f94a59179..000000000
--- a/cmd/phase/testdata/TestNewApplyCommandGoldenOutput/phase-apply-cmd-with-help.golden
+++ /dev/null
@@ -1,16 +0,0 @@
-Apply specific phase to kubernetes cluster such as control-plane, workloads, initinfra
-
-Usage:
-  apply PHASE_NAME [flags]
-
-Examples:
-
-# Apply initinfra phase to a cluster
-airshipctl phase apply initinfra
-
-
-Flags:
-      --dry-run                 don't deliver documents to the cluster, simulate the changes instead
-  -h, --help                    help for apply
-      --prune                   if set to true, command will delete all kubernetes resources that are not defined in airship documents and have airshipit.org/deployed=apply label
-      --wait-timeout duration   number of seconds to wait for resources to become ready, if set to 0 will not wait (default 2m0s)
diff --git a/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden b/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden
index 5c624e522..3e52eec10 100644
--- a/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden
+++ b/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden
@@ -5,7 +5,6 @@ Usage:
   phase [command]
 
 Available Commands:
-  apply       Apply phase to a cluster
   help        Help about any command
   plan        List phases
   render      Render phase documents from model
diff --git a/docs/source/architecture.md b/docs/source/architecture.md
index 2b44652bd..53cff1385 100644
--- a/docs/source/architecture.md
+++ b/docs/source/architecture.md
@@ -25,7 +25,7 @@ In a nutshell, users of `airshipctl` should be able to do the following:
    instance that `airshipctl` can communicate with for subsequent steps. This
    ephemeral host provides a foothold in the target environment so we can follow
    the standard cluster-api bootstrap flow.
-6. Run `airshipctl phase apply initinfra` to bootstrap the new ephemeral cluster
+6. Run `airshipctl phase run initinfra-ephemeral` to bootstrap the new ephemeral cluster
    with enough of the chosen cluster-api provider components to provision the
    target cluster.
 7. Run `airshipctl clusterctl` to use the ephemeral Kubernetes host to provision
diff --git a/docs/source/cli/airshipctl_phase.md b/docs/source/cli/airshipctl_phase.md
index db50d6c43..c58e47caf 100644
--- a/docs/source/cli/airshipctl_phase.md
+++ b/docs/source/cli/airshipctl_phase.md
@@ -25,7 +25,6 @@ such as getting list and applying specific one.
 ### SEE ALSO
 
 * [airshipctl](airshipctl.md)	 - A unified entrypoint to various airship components
-* [airshipctl phase apply](airshipctl_phase_apply.md)	 - Apply phase to a cluster
 * [airshipctl phase plan](airshipctl_phase_plan.md)	 - List phases
 * [airshipctl phase render](airshipctl_phase_render.md)	 - Render phase documents from model
 * [airshipctl phase run](airshipctl_phase_run.md)	 - Run phase
diff --git a/docs/source/cli/airshipctl_phase_apply.md b/docs/source/cli/airshipctl_phase_apply.md
deleted file mode 100644
index 314795a3a..000000000
--- a/docs/source/cli/airshipctl_phase_apply.md
+++ /dev/null
@@ -1,43 +0,0 @@
-## airshipctl phase apply
-
-Apply phase to a cluster
-
-### Synopsis
-
-Apply specific phase to kubernetes cluster such as control-plane, workloads, initinfra
-
-
-```
-airshipctl phase apply PHASE_NAME [flags]
-```
-
-### Examples
-
-```
-
-# Apply initinfra phase to a cluster
-airshipctl phase apply initinfra
-
-```
-
-### Options
-
-```
-      --dry-run                 don't deliver documents to the cluster, simulate the changes instead
-  -h, --help                    help for apply
-      --prune                   if set to true, command will delete all kubernetes resources that are not defined in airship documents and have airshipit.org/deployed=apply label
-      --wait-timeout duration   number of seconds to wait for resources to become ready, if set to 0 will not wait (default 2m0s)
-```
-
-### Options inherited from parent commands
-
-```
-      --airshipconf string   Path to file for airshipctl configuration. (default "$HOME/.airship/config")
-      --debug                enable verbose output
-      --kubeconfig string    Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
-```
-
-### SEE ALSO
-
-* [airshipctl phase](airshipctl_phase.md)	 - Manage phases
-
diff --git a/docs/source/providers/cluster_api_docker.md b/docs/source/providers/cluster_api_docker.md
index 0af34df25..9a076508f 100755
--- a/docs/source/providers/cluster_api_docker.md
+++ b/docs/source/providers/cluster_api_docker.md
@@ -15,11 +15,11 @@ components**
 
 **Create a workload cluster, with control plane and worker nodes**
 
-> airshipctl phase apply controlplane
+> airshipctl phase run controlplane
 
-> airshipctl phase apply workers
+> airshipctl phase run workers
 
-Note: `airshipctl phase apply initinfra` is not used because all the provider
+Note: `airshipctl phase run initinfra-ephemeral` is not used because all the provider
 components are initialized  using `airshipctl cluster init`
 
 The phase `initinfra` is included just to get `validate docs` to
@@ -378,7 +378,7 @@ b9690cecdcf2        kindest/node:v1.18.2           "/usr/local/bin/entr…"   14
 
 ## Create your first workload cluster
 
-$ airshipctl phase apply controlplane --debug
+$ airshipctl phase run controlplane --debug
 
 ```
 [airshipctl] 2020/08/12 14:10:12 building bundle from kustomize path /tmp/airship/airshipctl/manifests/site/docker-test-site/target/controlplane
@@ -452,7 +452,7 @@ NAME                      PROVIDERID                               PHASE
 dtc-control-plane-p4fsx   docker:////dtc-dtc-control-plane-p4fsx   Running
 ```
 
-$ airshipctl phase apply workers --debug
+$ airshipctl phase run workers --debug
 
 ```
 [airshipctl] 2020/08/12 14:11:55 building bundle from kustomize path /tmp/airship/airshipctl/manifests/site/docker-test-site/target/worker
@@ -678,7 +678,7 @@ There are 3 phases currently available in `docker-test-site/target`.
 
 Note: `airshipctl cluster init` initializes all the provider components
 including the docker infrastructure provider component. As a result, `airshipctl
-phase apply initinfra` is not used.
+phase run initinfra-ephemeral` is not used.
 
 At the moment, `phase initinfra` is only present for two reasons:
 - `airshipctl` complains if the phase is not found
@@ -687,11 +687,11 @@ At the moment, `phase initinfra` is only present for two reasons:
 #### Patch Merge Strategy
 
 Json patch to patch `control plane machine count` is applied on templates in `manifests/function/k8scontrol-capd`
-from `airshipctl/manifests/site/docker-test-site/target/controlplane` when `airshipctl phase apply
+from `airshipctl/manifests/site/docker-test-site/target/controlplane` when `airshipctl phase run
 controlplane` is executed
 
 Json patch to patch `workers machine count` is applied on templates in `manifests/function/workers-capd`
-from `airshipctl/manifests/site/docker-test-site/target/workers` when `airshipctl phase apply
+from `airshipctl/manifests/site/docker-test-site/target/workers` when `airshipctl phase run
 workers` is executed.
 
 | Patch Name | Purpose  |
diff --git a/pkg/phase/apply/apply.go b/pkg/phase/apply/apply.go
deleted file mode 100644
index 8ef8f834a..000000000
--- a/pkg/phase/apply/apply.go
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-     https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package apply
-
-import (
-	"fmt"
-	"time"
-
-	"sigs.k8s.io/cli-utils/pkg/common"
-
-	"opendev.org/airship/airshipctl/pkg/config"
-	"opendev.org/airship/airshipctl/pkg/document"
-	"opendev.org/airship/airshipctl/pkg/events"
-	"opendev.org/airship/airshipctl/pkg/k8s/applier"
-	"opendev.org/airship/airshipctl/pkg/k8s/utils"
-	"opendev.org/airship/airshipctl/pkg/log"
-)
-
-// Options is an abstraction used to apply the phase
-type Options struct {
-	DryRun      bool
-	Prune       bool
-	PhaseName   string
-	WaitTimeout time.Duration
-
-	Applier      *applier.Applier
-	Processor    events.EventProcessor
-	EventChannel chan events.Event
-}
-
-// Initialize Options with required field, such as Applier
-func (o *Options) Initialize(kubeConfigPath string) {
-	f := utils.FactoryFromKubeConfig(kubeConfigPath, "")
-	streams := utils.Streams()
-	o.EventChannel = make(chan events.Event)
-	o.Applier = applier.NewApplier(o.EventChannel, f, streams)
-	o.Processor = events.NewDefaultProcessor(streams)
-}
-
-// Run apply subcommand logic
-func (o *Options) Run(cfg *config.Config) error {
-	ao := applier.ApplyOptions{
-		DryRunStrategy: common.DryRunNone,
-		Prune:          o.Prune,
-		WaitTimeout:    o.WaitTimeout,
-	}
-	if o.DryRun {
-		ao.DryRunStrategy = common.DryRunClient
-	}
-
-	clusterName, err := cfg.CurrentContextClusterName()
-	if err != nil {
-		return err
-	}
-	clusterType, err := cfg.CurrentContextClusterType()
-	if err != nil {
-		return err
-	}
-	ao.BundleName = fmt.Sprintf("%s-%s-%s", clusterName, clusterType, o.PhaseName)
-	kustomizePath, err := cfg.CurrentContextEntryPoint(o.PhaseName)
-	if err != nil {
-		return err
-	}
-	log.Debugf("building bundle from kustomize path %s", kustomizePath)
-	b, err := document.NewBundleByPath(kustomizePath)
-	if err != nil {
-		return err
-	}
-	// Returns all documents for this phase
-	bundle, err := b.SelectBundle(document.NewDeployToK8sSelector())
-	if err != nil {
-		return err
-	}
-	go o.Applier.ApplyBundle(bundle, ao)
-	return o.Processor.Process(o.EventChannel)
-}
diff --git a/pkg/phase/apply/apply_test.go b/pkg/phase/apply/apply_test.go
deleted file mode 100644
index 218b5fe35..000000000
--- a/pkg/phase/apply/apply_test.go
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-     https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package apply_test
-
-import (
-	"os"
-	"path/filepath"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-	corev1 "k8s.io/api/core/v1"
-	"k8s.io/cli-runtime/pkg/genericclioptions"
-	applyevent "sigs.k8s.io/cli-utils/pkg/apply/event"
-
-	"opendev.org/airship/airshipctl/pkg/config"
-	"opendev.org/airship/airshipctl/pkg/document"
-	"opendev.org/airship/airshipctl/pkg/events"
-	"opendev.org/airship/airshipctl/pkg/k8s/applier"
-	"opendev.org/airship/airshipctl/pkg/phase/apply"
-	"opendev.org/airship/airshipctl/testutil"
-	"opendev.org/airship/airshipctl/testutil/k8sutils"
-)
-
-const (
-	kubeconfigPath    = "testdata/kubeconfig.yaml"
-	airshipConfigFile = "testdata/config.yaml"
-)
-
-func TestDeploy(t *testing.T) {
-	bundle := testutil.NewTestBundle(t, "testdata/primary/site/test-site/ephemeral/initinfra")
-	replicationController, err := bundle.SelectOne(document.NewSelector().ByKind("ReplicationController"))
-	require.NoError(t, err)
-	b, err := replicationController.AsYAML()
-	require.NoError(t, err)
-	f := k8sutils.FakeFactory(t,
-		[]k8sutils.ClientHandler{
-			&k8sutils.InventoryObjectHandler{},
-			&k8sutils.NamespaceHandler{},
-			&k8sutils.GenericHandler{
-				Obj:       &corev1.ReplicationController{},
-				Bytes:     b,
-				URLPath:   "/namespaces/%s/replicationcontrollers",
-				Namespace: replicationController.GetNamespace(),
-			},
-		})
-	defer f.Cleanup()
-	tests := []struct {
-		name                string
-		expectedErrorString string
-		phaseName           string
-		events              []applyevent.Event
-	}{
-		{
-			name:                "success",
-			expectedErrorString: "",
-			events:              k8sutils.SuccessEvents(),
-		},
-		{
-			name:                "missing phase",
-			expectedErrorString: "Phase document 'missingPhase' was not found",
-			phaseName:           "missingPhase",
-		},
-	}
-
-	for _, tt := range tests {
-		tt := tt
-		t.Run(tt.name, func(t *testing.T) {
-			rs := makeNewFakeRootSettings(t, kubeconfigPath, airshipConfigFile)
-			ao := &apply.Options{PhaseName: "initinfra", DryRun: true}
-			ao.Initialize(rs.KubeConfigPath())
-
-			if tt.events != nil {
-				ch := make(chan events.Event)
-				cliApplier := applier.NewFakeApplier(
-					ch,
-					genericclioptions.IOStreams{
-						In:     os.Stdin,
-						Out:    os.Stdout,
-						ErrOut: os.Stderr,
-					}, k8sutils.SuccessEvents(), f)
-				ao.Applier = cliApplier
-				ao.EventChannel = ch
-			}
-			if tt.phaseName != "" {
-				ao.PhaseName = tt.phaseName
-			}
-			actualErr := ao.Run(rs)
-			if tt.expectedErrorString != "" {
-				require.Error(t, actualErr)
-				assert.Contains(t, actualErr.Error(), tt.expectedErrorString)
-			} else {
-				assert.NoError(t, actualErr)
-			}
-		})
-	}
-}
-
-// makeNewFakeRootSettings takes kubeconfig path and directory path to fixture dir as argument.
-func makeNewFakeRootSettings(t *testing.T, kp string, dir string) *config.Config {
-	t.Helper()
-	akp, err := filepath.Abs(kp)
-	require.NoError(t, err)
-
-	adir, err := filepath.Abs(dir)
-	require.NoError(t, err)
-
-	settings, err := config.CreateFactory(&adir, &akp)()
-	require.NoError(t, err)
-
-	return settings
-}
diff --git a/pkg/phase/apply/testdata/config.yaml b/pkg/phase/apply/testdata/config.yaml
deleted file mode 100644
index 44e60e15b..000000000
--- a/pkg/phase/apply/testdata/config.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-apiVersion: airshipit.org/v1alpha1
-contexts:
-  dummy_cluster:
-    contextKubeconf: dummycluster_ephemeral
-    manifest: dummy_manifest
-currentContext: dummy_cluster
-kind: Config
-manifests:
-  dummy_manifest:
-    primaryRepositoryName: primary
-    repositories:
-      primary:
-        auth:
-          sshKey: testdata/test-key.pem
-          type: ssh-key
-        checkout:
-          branch: ""
-          force: false
-          remoteRef: ""
-          tag: v1.0.1
-        url: http://dummy.url.com/primary.git
-    subPath: primary/site/test-site
-    targetPath: testdata
diff --git a/pkg/phase/apply/testdata/kubeconfig.yaml b/pkg/phase/apply/testdata/kubeconfig.yaml
deleted file mode 100644
index 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1SXF6UTZDNmJaSk9SMDMvVEl5ejh6NDJnaitDVApjWUZXZkltM2RKTnpRL08xWkdySXZZNWdtcWJtWDlpV0JaU24rRytEOGxubzd2aGMvY0tBRFR5OTMvVU92MThuCkdhMnIrRGJJcHcyTWVBVEl2elpxRS9RWlVSQ25DMmdjUFhTVzFqN2h4R3o1a3ZNcGVDZTdQYVUvdVFvblVHSWsKZ2t6ZzI4NHQvREhUUzc4N1V1SUg5cXBaV09yTFNMOGFBeUxQUHhWSXBteGZmbWRETE9TS2VUemRlTmxoSitUMwowQlBVaHBQTlJBNTNJN0hRQjhVUDR2elNONTkzZ1VFbVlFQ2Jic2RYSzB6ZVR6SDdWWHR2Zmd5WTVWWT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
-      server: https://127.0.0.1:6443
-    name: dummycluster_ephemeral
-contexts:
-  - context:
-      cluster: dummycluster_ephemeral
-      user: kubernetes-admin
-    name: dummy_cluster
-current-context: dummy_cluster
-kind: Config
-preferences: {}
-users:
-  - name: kubernetes-admin
-    user:
-      client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdXb1RXRXlGOEVWN3JyLwo0K0hoSEdpcTVQbXF1S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emNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
diff --git a/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/kustomization.yaml b/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/kustomization.yaml
deleted file mode 100644
index 72ab8548e..000000000
--- a/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/kustomization.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-resources:
-  - replicationcontroller.yaml
diff --git a/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/replicationcontroller.yaml b/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/replicationcontroller.yaml
deleted file mode 100644
index 83aca9454..000000000
--- a/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/initinfra/replicationcontroller.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-apiVersion: v1
-kind: ReplicationController
-metadata:
-  name: test-rc
-  namespace: test
-  labels:
-    airshipit.org/phase: "initinfra"
-spec:
-  replicas: 1
-  template:
-    metadata:
-      labels:
-        name: test-rc
-    spec:
-      containers:
-        - name: test-rc
-          image: nginx
-          ports:
-          - containerPort: 80
diff --git a/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/kustomization.yaml b/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/kustomization.yaml
deleted file mode 100644
index 3789004c6..000000000
--- a/pkg/phase/apply/testdata/primary/site/test-site/ephemeral/kustomization.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-resources:
-  - initinfra
diff --git a/tools/document/validate_site_docs.sh b/tools/document/validate_site_docs.sh
index a823aac8c..5c2c73497 100755
--- a/tools/document/validate_site_docs.sh
+++ b/tools/document/validate_site_docs.sh
@@ -125,7 +125,7 @@ for cluster in ephemeral target; do
                 fi
 
                 # step 2: dry-run the entire phase
-                ${ACTL} phase apply --dry-run ${phase}
+                ${ACTL} phase run --dry-run ${phase}
             fi
         done