Remove kubeconfig from config struct

Change-Id: I5ab8722dd151d9e652e0b20e1d82988cd98505af
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
This commit is contained in:
Ruslan Aliev 2020-09-15 15:05:52 -05:00
parent 10620da2cc
commit fc33287204
69 changed files with 157 additions and 359 deletions

View File

@ -18,7 +18,6 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/k8s/client"
) )
const ( const (
@ -39,7 +38,7 @@ func NewClusterCommand(cfgFactory config.Factory) *cobra.Command {
clusterRootCmd.AddCommand(NewInitCommand(cfgFactory)) clusterRootCmd.AddCommand(NewInitCommand(cfgFactory))
clusterRootCmd.AddCommand(NewMoveCommand(cfgFactory)) clusterRootCmd.AddCommand(NewMoveCommand(cfgFactory))
clusterRootCmd.AddCommand(NewStatusCommand(cfgFactory, client.DefaultClient)) clusterRootCmd.AddCommand(NewStatusCommand(cfgFactory))
return clusterRootCmd return clusterRootCmd
} }

View File

@ -70,18 +70,26 @@ airshipctl cluster init
// NewInitCommand creates a command to deploy cluster-api // NewInitCommand creates a command to deploy cluster-api
func NewInitCommand(cfgFactory config.Factory) *cobra.Command { func NewInitCommand(cfgFactory config.Factory) *cobra.Command {
var kubeconfig string
initCmd := &cobra.Command{ initCmd := &cobra.Command{
Use: "init", Use: "init",
Short: "Deploy cluster-api provider components", Short: "Deploy cluster-api provider components",
Long: initLong, Long: initLong,
Example: initExample, Example: initExample,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
command, err := clusterctlcmd.NewCommand(cfgFactory) command, err := clusterctlcmd.NewCommand(cfgFactory, kubeconfig)
if err != nil { if err != nil {
return err return err
} }
return command.Init() return command.Init()
}, },
} }
initCmd.Flags().StringVar(
&kubeconfig,
"kubeconfig",
"",
"Path to kubeconfig associated with cluster being managed")
return initCmd return initCmd
} }

View File

@ -37,14 +37,14 @@ Move Cluster API objects, provider specific objects and all dependencies to the
// NewMoveCommand creates a command to move capi and bmo resources to the target cluster // NewMoveCommand creates a command to move capi and bmo resources to the target cluster
func NewMoveCommand(cfgFactory config.Factory) *cobra.Command { func NewMoveCommand(cfgFactory config.Factory) *cobra.Command {
var toKubeconfigContext string var toKubeconfigContext, kubeconfig string
moveCmd := &cobra.Command{ moveCmd := &cobra.Command{
Use: "move", Use: "move",
Short: "Move Cluster API objects, provider specific objects and all dependencies to the target cluster", Short: "Move Cluster API objects, provider specific objects and all dependencies to the target cluster",
Long: moveLong[1:], Long: moveLong[1:],
Example: moveExample, Example: moveExample,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
command, err := clusterctlcmd.NewCommand(cfgFactory) command, err := clusterctlcmd.NewCommand(cfgFactory, kubeconfig)
if err != nil { if err != nil {
return err return err
} }
@ -52,6 +52,11 @@ func NewMoveCommand(cfgFactory config.Factory) *cobra.Command {
}, },
} }
moveCmd.Flags().StringVar(
&kubeconfig,
"kubeconfig",
"",
"Path to kubeconfig associated with cluster being managed")
moveCmd.Flags().StringVar(&toKubeconfigContext, "target-context", "", moveCmd.Flags().StringVar(&toKubeconfigContext, "target-context", "",
"Context to be used within the kubeconfig file for the target cluster. If empty, current context will be used.") "Context to be used within the kubeconfig file for the target cluster. If empty, current context will be used.")
return moveCmd return moveCmd

View File

@ -23,18 +23,25 @@ import (
) )
// NewStatusCommand creates a command which reports the statuses of a cluster's deployed components. // NewStatusCommand creates a command which reports the statuses of a cluster's deployed components.
func NewStatusCommand(cfgFactory config.Factory, factory client.Factory) *cobra.Command { func NewStatusCommand(cfgFactory config.Factory) *cobra.Command {
o := cluster.NewStatusOptions(cfgFactory, factory) var kubeconfig string
cmd := &cobra.Command{ statusCmd := &cobra.Command{
Use: "status", Use: "status",
Short: "Retrieve statuses of deployed cluster components", Short: "Retrieve statuses of deployed cluster components",
RunE: clusterStatusRunE(o), RunE: clusterStatusRunE(cfgFactory, kubeconfig),
} }
return cmd
statusCmd.Flags().StringVar(
&kubeconfig,
"kubeconfig",
"",
"Path to kubeconfig associated with cluster being managed")
return statusCmd
} }
func clusterStatusRunE(o cluster.StatusOptions) func(cmd *cobra.Command, args []string) error { func clusterStatusRunE(cfgFactory config.Factory, kubeconfig string) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error { return func(cmd *cobra.Command, args []string) error {
return cluster.StatusRunner(o, cmd.OutOrStdout()) return cluster.StatusRunner(cluster.NewStatusOptions(cfgFactory, client.DefaultClient, kubeconfig), cmd.OutOrStdout())
} }
} }

View File

@ -26,7 +26,7 @@ func TestNewClusterStatusCmd(t *testing.T) {
{ {
Name: "cluster-status-cmd-with-help", Name: "cluster-status-cmd-with-help",
CmdLine: "--help", CmdLine: "--help",
Cmd: cluster.NewStatusCommand(nil, nil), Cmd: cluster.NewStatusCommand(nil),
}, },
} }
for _, testcase := range tests { for _, testcase := range tests {

View File

@ -47,4 +47,5 @@ airshipctl cluster init
Flags: Flags:
-h, --help help for init -h, --help help for init
--kubeconfig string Path to kubeconfig associated with cluster being managed

View File

@ -14,4 +14,5 @@ Move Cluster API objects, provider specific objects and all dependencies to the
Flags: Flags:
-h, --help help for move -h, --help help for move
--kubeconfig string Path to kubeconfig associated with cluster being managed
--target-context string Context to be used within the kubeconfig file for the target cluster. If empty, current context will be used. --target-context string Context to be used within the kubeconfig file for the target cluster. If empty, current context will be used.

View File

@ -4,4 +4,5 @@ Usage:
status [flags] status [flags]
Flags: Flags:
-h, --help help for status -h, --help help for status
--kubeconfig string Path to kubeconfig associated with cluster being managed

View File

@ -47,11 +47,7 @@ func NewInitCommand() *cobra.Command {
airshipConfigPath = "" airshipConfigPath = ""
} }
kubeConfigPath, err := cmd.Flags().GetString("kubeconfig") return config.CreateConfig(airshipConfigPath)
if err != nil {
kubeConfigPath = ""
}
return config.CreateConfig(airshipConfigPath, kubeConfigPath)
}, },
} }

View File

@ -92,11 +92,7 @@ func NewSetManagementConfigCommand(cfgFactory config.Factory) *cobra.Command {
return nil return nil
} }
if err = cfg.PersistConfig(true); err != nil { return cfg.PersistConfig()
return err
}
return nil
}, },
} }

View File

@ -34,8 +34,8 @@ airshipctl phase run ephemeral-control-plane
// NewRunCommand creates a command to run specific phase // NewRunCommand creates a command to run specific phase
func NewRunCommand(cfgFactory config.Factory) *cobra.Command { func NewRunCommand(cfgFactory config.Factory) *cobra.Command {
p := &phase.RunCommand{ p := &phase.RunCommand{
Options: phase.RunFlags{},
Factory: cfgFactory, Factory: cfgFactory,
Options: phase.RunFlags{},
} }
runCmd := &cobra.Command{ runCmd := &cobra.Command{
@ -60,5 +60,10 @@ func NewRunCommand(cfgFactory config.Factory) *cobra.Command {
"wait-timeout", "wait-timeout",
0, 0,
"wait timeout") "wait timeout")
flags.StringVar(
&p.Options.Kubeconfig,
"kubeconfig",
"",
"Path to kubeconfig associated with site being managed")
return runCmd return runCmd
} }

View File

@ -12,4 +12,5 @@ airshipctl phase run ephemeral-control-plane
Flags: Flags:
--dry-run simulate phase execution --dry-run simulate phase execution
-h, --help help for run -h, --help help for run
--kubeconfig string Path to kubeconfig associated with site being managed
--wait-timeout duration wait timeout --wait-timeout duration wait timeout

View File

@ -19,8 +19,6 @@ import (
"path/filepath" "path/filepath"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
// Import to initialize client auth plugins. // Import to initialize client auth plugins.
_ "k8s.io/client-go/plugin/pkg/client/auth" _ "k8s.io/client-go/plugin/pkg/client/auth"
@ -40,14 +38,13 @@ import (
type RootOptions struct { type RootOptions struct {
Debug bool Debug bool
AirshipConfigPath string AirshipConfigPath string
KubeConfigPath string
} }
// NewAirshipCTLCommand creates a root `airshipctl` command with the default commands attached // NewAirshipCTLCommand creates a root `airshipctl` command with the default commands attached
func NewAirshipCTLCommand(out io.Writer) *cobra.Command { func NewAirshipCTLCommand(out io.Writer) *cobra.Command {
rootCmd, settings := NewRootCommand(out) rootCmd, settings := NewRootCommand(out)
return AddDefaultAirshipCTLCommands(rootCmd, return AddDefaultAirshipCTLCommands(rootCmd,
cfg.CreateFactory(&settings.AirshipConfigPath, &settings.KubeConfigPath)) cfg.CreateFactory(&settings.AirshipConfigPath))
} }
// NewRootCommand creates the root `airshipctl` command. All other commands are // NewRootCommand creates the root `airshipctl` command. All other commands are
@ -97,11 +94,4 @@ func initFlags(options *RootOptions, cmd *cobra.Command) {
"airshipconf", "airshipconf",
"", "",
`Path to file for airshipctl configuration. (default "`+defaultAirshipConfigPath+`")`) `Path to file for airshipctl configuration. (default "`+defaultAirshipConfigPath+`")`)
defaultKubeConfigPath := filepath.Join(defaultAirshipConfigDir, cfg.AirshipKubeConfig)
flags.StringVar(
&options.KubeConfigPath,
clientcmd.RecommendedConfigPathFlag,
"",
`Path to kubeconfig associated with airshipctl configuration. (default "`+defaultKubeConfigPath+`")`)
} }

View File

@ -19,6 +19,5 @@ Flags:
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
-h, --help help for airshipctl -h, --help help for airshipctl
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
Use "airshipctl [command] --help" for more information about a command. Use "airshipctl [command] --help" for more information about a command.

View File

@ -11,6 +11,5 @@ Flags:
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
-h, --help help for airshipctl -h, --help help for airshipctl
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
Use "airshipctl [command] --help" for more information about a command. Use "airshipctl [command] --help" for more information about a command.

View File

@ -12,7 +12,6 @@ A unified entrypoint to various airship components
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
-h, --help help for airshipctl -h, --help help for airshipctl
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -17,7 +17,6 @@ Perform actions on baremetal hosts
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,7 +24,6 @@ airshipctl baremetal ejectmedia [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,7 +24,6 @@ airshipctl baremetal poweroff [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,7 +24,6 @@ airshipctl baremetal poweron [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,7 +24,6 @@ airshipctl baremetal powerstatus [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,7 +24,6 @@ airshipctl baremetal reboot [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -21,7 +21,6 @@ airshipctl baremetal remotedirect [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -19,7 +19,6 @@ such as getting status and deploying initial infrastructure.
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -60,7 +60,8 @@ airshipctl cluster init
### Options ### Options
``` ```
-h, --help help for init -h, --help help for init
--kubeconfig string Path to kubeconfig associated with cluster being managed
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
@ -68,7 +69,6 @@ airshipctl cluster init
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -27,6 +27,7 @@ Move Cluster API objects, provider specific objects and all dependencies to the
``` ```
-h, --help help for move -h, --help help for move
--kubeconfig string Path to kubeconfig associated with cluster being managed
--target-context string Context to be used within the kubeconfig file for the target cluster. If empty, current context will be used. --target-context string Context to be used within the kubeconfig file for the target cluster. If empty, current context will be used.
``` ```
@ -35,7 +36,6 @@ Move Cluster API objects, provider specific objects and all dependencies to the
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -13,7 +13,8 @@ airshipctl cluster status [flags]
### Options ### Options
``` ```
-h, --help help for status -h, --help help for status
--kubeconfig string Path to kubeconfig associated with cluster being managed
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
@ -21,7 +22,6 @@ airshipctl cluster status [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -34,7 +34,6 @@ source <(airshipctl completion bash)
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -17,7 +17,6 @@ Manage the airshipctl config file
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -38,7 +38,6 @@ airshipctl config get-context exampleContext
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -34,7 +34,6 @@ airshipctl config get-encryption-config exampleConfig
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -33,7 +33,6 @@ airshipctl config get-management-config default
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -34,7 +34,6 @@ airshipctl config get-manifest e2e
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -26,7 +26,6 @@ airshipctl config init [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -42,7 +42,6 @@ airshipctl config set-context \
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -44,7 +44,6 @@ airshipctl config set-encryption-config exampleConfig \
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,7 +24,6 @@ airshipctl config set-management-config NAME [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -60,7 +60,6 @@ airshipctl config set-manifest e2e \
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -32,7 +32,6 @@ airshipctl config use-context exampleContext
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -17,7 +17,6 @@ Manage deployment documents
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -55,7 +55,6 @@ airshipctl document plugin /tmp/replacement.yaml
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -22,7 +22,6 @@ airshipctl document pull [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -17,7 +17,6 @@ Manage ISO image creation
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -22,7 +22,6 @@ airshipctl image build [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -19,7 +19,6 @@ such as getting list and applying specific one.
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,7 +24,6 @@ airshipctl phase plan [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -39,7 +39,6 @@ airshipctl phase render initinfra -l app=helm,service=tiller -k Deployment
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -24,6 +24,7 @@ airshipctl phase run ephemeral-control-plane
``` ```
--dry-run simulate phase execution --dry-run simulate phase execution
-h, --help help for run -h, --help help for run
--kubeconfig string Path to kubeconfig associated with site being managed
--wait-timeout duration wait timeout --wait-timeout duration wait timeout
``` ```
@ -32,7 +33,6 @@ airshipctl phase run ephemeral-control-plane
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -17,7 +17,6 @@ Manage secrets
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -17,7 +17,6 @@ Generate various secrets
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -21,7 +21,6 @@ airshipctl secret generate masterpassphrase [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

View File

@ -21,7 +21,6 @@ airshipctl version [flags]
``` ```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output --debug enable verbose output
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
``` ```
### SEE ALSO ### SEE ALSO

2
go.sum
View File

@ -723,6 +723,7 @@ golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMx
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
@ -842,6 +843,7 @@ golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDq
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190930201159-7c411dea38b0/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190930201159-7c411dea38b0/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff h1:XdBG6es/oFDr1HwaxkxgVve7NB281QhxgK/i4voubFs=
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -256,10 +256,9 @@ func TestVerifyInputs(t *testing.T) {
func TestGenerateBootstrapIso(t *testing.T) { func TestGenerateBootstrapIso(t *testing.T) {
airshipConfigPath := "testdata/config/config" airshipConfigPath := "testdata/config/config"
kubeConfigPath := "testdata/config/kubeconfig"
t.Run("ContextEntryPointError", func(t *testing.T) { t.Run("ContextEntryPointError", func(t *testing.T) {
cfg, err := config.CreateFactory(&airshipConfigPath, &kubeConfigPath)() cfg, err := config.CreateFactory(&airshipConfigPath)()
require.NoError(t, err) require.NoError(t, err)
cfg.Manifests["default"].Repositories = make(map[string]*config.Repository) cfg.Manifests["default"].Repositories = make(map[string]*config.Repository)
settings := func() (*config.Config, error) { settings := func() (*config.Config, error) {
@ -271,7 +270,7 @@ func TestGenerateBootstrapIso(t *testing.T) {
}) })
t.Run("NewBundleByPathError", func(t *testing.T) { t.Run("NewBundleByPathError", func(t *testing.T) {
cfg, err := config.CreateFactory(&airshipConfigPath, &kubeConfigPath)() cfg, err := config.CreateFactory(&airshipConfigPath)()
require.NoError(t, err) require.NoError(t, err)
cfg.Manifests["default"].TargetPath = "/nonexistent" cfg.Manifests["default"].TargetPath = "/nonexistent"
settings := func() (*config.Config, error) { settings := func() (*config.Config, error) {
@ -283,7 +282,7 @@ func TestGenerateBootstrapIso(t *testing.T) {
}) })
t.Run("SelectOneError", func(t *testing.T) { t.Run("SelectOneError", func(t *testing.T) {
cfg, err := config.CreateFactory(&airshipConfigPath, &kubeConfigPath)() cfg, err := config.CreateFactory(&airshipConfigPath)()
require.NoError(t, err) require.NoError(t, err)
cfg.Manifests["default"].SubPath = "missingkinddoc/site/test-site" cfg.Manifests["default"].SubPath = "missingkinddoc/site/test-site"
settings := func() (*config.Config, error) { settings := func() (*config.Config, error) {
@ -296,7 +295,7 @@ func TestGenerateBootstrapIso(t *testing.T) {
}) })
t.Run("ToObjectError", func(t *testing.T) { t.Run("ToObjectError", func(t *testing.T) {
cfg, err := config.CreateFactory(&airshipConfigPath, &kubeConfigPath)() cfg, err := config.CreateFactory(&airshipConfigPath)()
require.NoError(t, err) require.NoError(t, err)
cfg.Manifests["default"].SubPath = "missingmetadoc/site/test-site" cfg.Manifests["default"].SubPath = "missingmetadoc/site/test-site"
settings := func() (*config.Config, error) { settings := func() (*config.Config, error) {
@ -304,11 +303,12 @@ func TestGenerateBootstrapIso(t *testing.T) {
} }
expectedErrMessage := "missing metadata.name in object" expectedErrMessage := "missing metadata.name in object"
actualErr := GenerateBootstrapIso(settings, false) actualErr := GenerateBootstrapIso(settings, false)
require.NotNil(t, actualErr)
assert.Contains(t, actualErr.Error(), expectedErrMessage) assert.Contains(t, actualErr.Error(), expectedErrMessage)
}) })
t.Run("verifyInputsError", func(t *testing.T) { t.Run("verifyInputsError", func(t *testing.T) {
cfg, err := config.CreateFactory(&airshipConfigPath, &kubeConfigPath)() cfg, err := config.CreateFactory(&airshipConfigPath)()
require.NoError(t, err) require.NoError(t, err)
cfg.Manifests["default"].SubPath = "missingvoldoc/site/test-site" cfg.Manifests["default"].SubPath = "missingvoldoc/site/test-site"
settings := func() (*config.Config, error) { settings := func() (*config.Config, error) {

View File

@ -43,18 +43,19 @@ type StatusOptions interface {
} }
type statusOptions struct { type statusOptions struct {
ConfigFactory config.Factory CfgFactory config.Factory
ClientFactory client.Factory ClientFactory client.Factory
Kubeconfig string
} }
// NewStatusOptions constructs a new StatusOptions interface based on inner struct // NewStatusOptions constructs a new StatusOptions interface based on inner struct
func NewStatusOptions(cfgFactory config.Factory, clientFactory client.Factory) StatusOptions { func NewStatusOptions(cfgFactory config.Factory, clientFactory client.Factory, kubeconfig string) StatusOptions {
return &statusOptions{ConfigFactory: cfgFactory, ClientFactory: clientFactory} return &statusOptions{CfgFactory: cfgFactory, ClientFactory: clientFactory, Kubeconfig: kubeconfig}
} }
// GetStatusMapDocs returns status map within all the documents in the bundle // GetStatusMapDocs returns status map within all the documents in the bundle
func (o *statusOptions) GetStatusMapDocs() (*StatusMap, []document.Document, error) { func (o *statusOptions) GetStatusMapDocs() (*StatusMap, []document.Document, error) {
conf, err := o.ConfigFactory() conf, err := o.CfgFactory()
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -74,7 +75,7 @@ func (o *statusOptions) GetStatusMapDocs() (*StatusMap, []document.Document, err
return nil, nil, err return nil, nil, err
} }
client, err := o.ClientFactory(conf) client, err := o.ClientFactory(conf.LoadedConfigPath(), o.Kubeconfig)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -63,11 +63,12 @@ func TestGetStatusMapDocs(t *testing.T) {
fakeClient := fake.NewClient( fakeClient := fake.NewClient(
fake.WithDynamicObjects(tt.resources...), fake.WithDynamicObjects(tt.resources...),
fake.WithCRDs(tt.CRDs...)) fake.WithCRDs(tt.CRDs...))
clientFactory := func(_ string, _ string) (client.Interface, error) {
return fakeClient, nil
}
statusOptions := cluster.NewStatusOptions(func() (*config.Config, error) { statusOptions := cluster.NewStatusOptions(func() (*config.Config, error) {
return settings, nil return settings, nil
}, func(_ *config.Config) (client.Interface, error) { }, clientFactory, "")
return fakeClient, nil
})
expectedSM, err := cluster.NewStatusMap(fakeClient) expectedSM, err := cluster.NewStatusMap(fakeClient)
require.NoError(t, err) require.NoError(t, err)

View File

@ -32,7 +32,7 @@ type Command struct {
} }
// NewCommand returns instance of Command // NewCommand returns instance of Command
func NewCommand(cfgFactory config.Factory) (*Command, error) { func NewCommand(cfgFactory config.Factory, kubeconfig string) (*Command, error) {
cfg, err := cfgFactory() cfg, err := cfgFactory()
if err != nil { if err != nil {
return nil, err return nil, err
@ -53,10 +53,9 @@ func NewCommand(cfgFactory config.Factory) (*Command, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
kubeConfigPath := cfg.KubeConfigPath()
return &Command{ return &Command{
kubeconfigPath: kubeConfigPath, kubeconfigPath: kubeconfig,
documentRoot: root, documentRoot: root,
client: client, client: client,
options: options, options: options,

View File

@ -31,8 +31,7 @@ const (
// TODO (kkalynovskyi) expand test cases // TODO (kkalynovskyi) expand test cases
func TestNewCommand(t *testing.T) { func TestNewCommand(t *testing.T) {
airshipConfigPath := "testdata/airshipconfig.yaml" airshipConfigPath := "testdata/airshipconfig.yaml"
kubeConfigPath := "testdata/kubeconfig.yaml" cfg, err := config.CreateFactory(&airshipConfigPath)()
cfg, err := config.CreateFactory(&airshipConfigPath, &kubeConfigPath)()
require.NoError(t, err) require.NoError(t, err)
tests := []struct { tests := []struct {
@ -120,7 +119,7 @@ func TestNewCommand(t *testing.T) {
cfg.CurrentContext = context cfg.CurrentContext = context
command, err := NewCommand(func() (*config.Config, error) { command, err := NewCommand(func() (*config.Config, error) {
return cfg, nil return cfg, nil
}) }, "")
if expectErr { if expectErr {
assert.Error(t, err) assert.Error(t, err)
assert.Nil(t, command) assert.Nil(t, command)

View File

@ -15,7 +15,6 @@ limitations under the License.
package config package config
import ( import (
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -23,8 +22,6 @@ import (
"path/filepath" "path/filepath"
"sort" "sort"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
"opendev.org/airship/airshipctl/pkg/log" "opendev.org/airship/airshipctl/pkg/log"
@ -36,8 +33,7 @@ import (
// Any truly optional piece of config is allowed to be omitted. // Any truly optional piece of config is allowed to be omitted.
// Config holds the information required by airshipctl commands // Config holds the information required by airshipctl commands
// It is somewhat a superset of what a kubeconfig looks like, we allow for this overlaps by providing // It is somewhat a superset of what a kubeconfig looks like
// a mechanism to consume or produce a kubeconfig into / from the airship config.
type Config struct { type Config struct {
// +optional // +optional
Kind string `json:"kind,omitempty"` Kind string `json:"kind,omitempty"`
@ -67,14 +63,6 @@ type Config struct {
// file from which this config was loaded // file from which this config was loaded
// +not persisted in file // +not persisted in file
loadedConfigPath string loadedConfigPath string
// kubeConfigPath is the full path to the the location of the
// kubeconfig file associated with this airship config instance
// +not persisted in file
kubeConfigPath string
// Private instance of Kube Config content as an object
kubeConfig *clientcmdapi.Config
} }
// Permissions has the permissions for file and directory // Permissions has the permissions for file and directory
@ -87,21 +75,17 @@ type Permissions struct {
type Factory func() (*Config, error) type Factory func() (*Config, error)
// CreateFactory returns function which creates ready to use Config object // CreateFactory returns function which creates ready to use Config object
func CreateFactory(airshipConfigPath *string, kubeConfigPath *string) Factory { func CreateFactory(airshipConfigPath *string) Factory {
return func() (*Config, error) { return func() (*Config, error) {
cfg := NewConfig() cfg := NewConfig()
cfg.kubeConfig = NewKubeConfig()
var acp, kcp string var acp string
if airshipConfigPath != nil { if airshipConfigPath != nil {
acp = *airshipConfigPath acp = *airshipConfigPath
} }
if kubeConfigPath != nil {
kcp = *kubeConfigPath
}
cfg.initConfigPath(acp, kcp) cfg.initConfigPath(acp)
err := cfg.LoadConfig(cfg.loadedConfigPath, cfg.kubeConfigPath, false) err := cfg.LoadConfig()
if err != nil { if err != nil {
// Should stop airshipctl // Should stop airshipctl
log.Fatal("Failed to load or initialize config: ", err) log.Fatal("Failed to load or initialize config: ", err)
@ -112,15 +96,14 @@ func CreateFactory(airshipConfigPath *string, kubeConfigPath *string) Factory {
} }
// CreateConfig saves default config to specified paths // CreateConfig saves default config to specified paths
func CreateConfig(airshipConfigPath string, kubeConfigPath string) error { func CreateConfig(airshipConfigPath string) error {
cfg := NewConfig() cfg := NewConfig()
cfg.kubeConfig = NewKubeConfig() cfg.initConfigPath(airshipConfigPath)
cfg.initConfigPath(airshipConfigPath, kubeConfigPath) return cfg.PersistConfig()
return cfg.PersistConfig(true)
} }
// initConfigPath - Initializes loadedConfigPath and kubeConfigPath variable for Config object // initConfigPath - Initializes loadedConfigPath variable for Config object
func (c *Config) initConfigPath(airshipConfigPath string, kubeConfigPath string) { func (c *Config) initConfigPath(airshipConfigPath string) {
switch { switch {
case airshipConfigPath != "": case airshipConfigPath != "":
// The loadedConfigPath may already have been received as a command line argument // The loadedConfigPath may already have been received as a command line argument
@ -132,77 +115,22 @@ func (c *Config) initConfigPath(airshipConfigPath string, kubeConfigPath string)
// Otherwise, we'll try putting it in the home directory // Otherwise, we'll try putting it in the home directory
c.loadedConfigPath = filepath.Join(util.UserHomeDir(), AirshipConfigDir, AirshipConfig) c.loadedConfigPath = filepath.Join(util.UserHomeDir(), AirshipConfigDir, AirshipConfig)
} }
switch {
case kubeConfigPath != "":
// The kubeConfigPath may already have been received as a command line argument
c.kubeConfigPath = kubeConfigPath
case os.Getenv(AirshipKubeConfigEnv) != "":
// Otherwise, we can check if we got the path via ENVIRONMENT variable
c.kubeConfigPath = os.Getenv(AirshipKubeConfigEnv)
default:
// Otherwise, we'll try putting it in the home directory
c.kubeConfigPath = filepath.Join(util.UserHomeDir(), AirshipConfigDir, AirshipKubeConfig)
}
} }
// LoadConfig populates the Config object using the files found at // LoadConfig populates the Config from the file found at airshipConfigPath.
// airshipConfigPath and kubeConfigPath
func (c *Config) LoadConfig(airshipConfigPath, kubeConfigPath string, create bool) error {
err := c.loadFromAirConfig(airshipConfigPath, create)
if err != nil {
return err
}
err = c.loadKubeConfig(kubeConfigPath, create)
if err != nil {
return err
}
return nil
}
// loadFromAirConfig populates the Config from the file found at airshipConfigPath.
// If there is no file at airshipConfigPath, this function does nothing. // If there is no file at airshipConfigPath, this function does nothing.
// An error is returned if: // An error is returned if:
// * airshipConfigPath is the empty string // * airshipConfigPath is the empty string
// * the file at airshipConfigPath is inaccessible // * the file at airshipConfigPath is inaccessible
// * the file at airshipConfigPath cannot be marshaled into Config // * the file at airshipConfigPath cannot be marshaled into Config
func (c *Config) loadFromAirConfig(airshipConfigPath string, create bool) error { func (c *Config) LoadConfig() error {
if airshipConfigPath == "" {
return errors.New("configuration file location was not provided")
}
// Remember where I loaded the Config from
c.loadedConfigPath = airshipConfigPath
// If I can read from the file, load from it // If I can read from the file, load from it
// throw an error otherwise // throw an error otherwise
if _, err := os.Stat(airshipConfigPath); os.IsNotExist(err) && create { if _, err := os.Stat(c.loadedConfigPath); err != nil {
return nil
} else if err != nil {
return err return err
} }
return util.ReadYAMLFile(airshipConfigPath, c) return util.ReadYAMLFile(c.loadedConfigPath, c)
}
func (c *Config) loadKubeConfig(kubeConfigPath string, create bool) error {
// Will need this for persisting the changes
c.kubeConfigPath = kubeConfigPath
// If I can read from the file, load from it
var err error
if _, err = os.Stat(kubeConfigPath); os.IsNotExist(err) && create {
// Default kubeconfig matching Airship target cluster
c.kubeConfig = NewKubeConfig()
return nil
} else if err != nil {
return err
}
c.kubeConfig, err = clientcmd.LoadFromFile(kubeConfigPath)
return err
} }
// EnsureComplete verifies that a Config object is ready to use. // EnsureComplete verifies that a Config object is ready to use.
@ -247,11 +175,11 @@ func (c *Config) EnsureComplete() error {
return nil return nil
} }
// PersistConfig updates the airshipctl config and kubeconfig files to match // PersistConfig updates the airshipctl config file to match
// the current Config and KubeConfig objects. // the current Config object.
// If either file did not previously exist, the file will be created. // If file did not previously exist, the file will be created.
// Otherwise, the file will be overwritten // Otherwise, the file will be overwritten
func (c *Config) PersistConfig(persistKubeConfig bool) error { func (c *Config) PersistConfig() error {
airshipConfigYaml, err := c.ToYaml() airshipConfigYaml, err := c.ToYaml()
if err != nil { if err != nil {
return err return err
@ -282,13 +210,6 @@ func (c *Config) PersistConfig(persistKubeConfig bool) error {
return err return err
} }
if persistKubeConfig {
// Persist the kubeconfig file referenced
if err := clientcmd.WriteToFile(*c.kubeConfig, c.kubeConfigPath); err != nil {
return err
}
}
return nil return nil
} }
@ -319,29 +240,6 @@ func (c *Config) SetLoadedConfigPath(lcp string) {
c.loadedConfigPath = lcp c.loadedConfigPath = lcp
} }
// KubeConfigPath returns the file path of the kube config
// from Config object
func (c *Config) KubeConfigPath() string {
return c.kubeConfigPath
}
// SetKubeConfigPath updates the file path of the kubeconfig
// in Config object
func (c *Config) SetKubeConfigPath(kubeConfigPath string) {
c.kubeConfigPath = kubeConfigPath
}
// KubeConfig returns kube config object from the
// context of current Config object
func (c *Config) KubeConfig() *clientcmdapi.Config {
return c.kubeConfig
}
// SetKubeConfig updates kube config in Config object
func (c *Config) SetKubeConfig(kubeConfig *clientcmdapi.Config) {
c.kubeConfig = kubeConfig
}
// GetContext returns a context instance // GetContext returns a context instance
func (c *Config) GetContext(cName string) (*Context, error) { func (c *Config) GetContext(cName string) (*Context, error) {
context, exists := c.Contexts[cName] context, exists := c.Contexts[cName]

View File

@ -60,7 +60,7 @@ func RunSetContext(o *ContextOptions, airconfig *Config, writeToStorage bool) (b
} }
// Update configuration file just in time persistence approach // Update configuration file just in time persistence approach
if writeToStorage { if writeToStorage {
if err := airconfig.PersistConfig(true); err != nil { if err := airconfig.PersistConfig(); err != nil {
// Error that it didnt persist the changes // Error that it didnt persist the changes
return modified, ErrConfigFailed{} return modified, ErrConfigFailed{}
} }
@ -77,7 +77,7 @@ func RunUseContext(desiredContext string, airconfig *Config) error {
if airconfig.CurrentContext != desiredContext { if airconfig.CurrentContext != desiredContext {
airconfig.CurrentContext = desiredContext airconfig.CurrentContext = desiredContext
if err := airconfig.PersistConfig(false); err != nil { if err := airconfig.PersistConfig(); err != nil {
return err return err
} }
} }
@ -107,7 +107,7 @@ func RunSetManifest(o *ManifestOptions, airconfig *Config, writeToStorage bool)
} }
// Update configuration file just in time persistence approach // Update configuration file just in time persistence approach
if writeToStorage { if writeToStorage {
if err := airconfig.PersistConfig(true); err != nil { if err := airconfig.PersistConfig(); err != nil {
// Error that it didnt persist the changes // Error that it didnt persist the changes
return modified, ErrConfigFailed{} return modified, ErrConfigFailed{}
} }
@ -138,7 +138,7 @@ func RunSetEncryptionConfig(o *EncryptionConfigOptions, airconfig *Config, write
} }
// Update configuration file just in time persistence approach // Update configuration file just in time persistence approach
if writeToStorage { if writeToStorage {
if err := airconfig.PersistConfig(false); err != nil { if err := airconfig.PersistConfig(); err != nil {
// Error that it didnt persist the changes // Error that it didnt persist the changes
return modified, ErrConfigFailed{} return modified, ErrConfigFailed{}
} }

View File

@ -98,16 +98,12 @@ func TestPersistConfig(t *testing.T) {
defer cleanup(t) defer cleanup(t)
conf.SetLoadedConfigPath(conf.LoadedConfigPath() + ".new") conf.SetLoadedConfigPath(conf.LoadedConfigPath() + ".new")
conf.SetKubeConfigPath(conf.KubeConfigPath() + ".new")
err := conf.PersistConfig(true) err := conf.PersistConfig()
require.NoError(t, err) require.NoError(t, err)
// Check that the files were created // Check that the files were created
assert.FileExists(t, conf.LoadedConfigPath()) assert.FileExists(t, conf.LoadedConfigPath())
assert.FileExists(t, conf.KubeConfigPath())
// Check that the invalid name was changed to a valid one
assert.Contains(t, conf.KubeConfig().Clusters, "def_ephemeral")
} }
func TestEnsureComplete(t *testing.T) { func TestEnsureComplete(t *testing.T) {
@ -208,7 +204,7 @@ func TestPurge(t *testing.T) {
defer cleanup(t) defer cleanup(t)
// Store it // Store it
err := conf.PersistConfig(true) err := conf.PersistConfig()
assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", conf.LoadedConfigPath()) assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", conf.LoadedConfigPath())
// Verify that the file is there // Verify that the file is there
@ -236,17 +232,6 @@ func TestSetLoadedConfigPath(t *testing.T) {
assert.Equal(t, testPath, conf.LoadedConfigPath()) assert.Equal(t, testPath, conf.LoadedConfigPath())
} }
func TestSetKubeConfigPath(t *testing.T) {
conf, cleanup := testutil.InitConfig(t)
defer cleanup(t)
testPath := "/tmp/kubeconfig"
assert.NotEqual(t, testPath, conf.KubeConfigPath())
conf.SetKubeConfigPath(testPath)
assert.Equal(t, testPath, conf.KubeConfigPath())
}
func TestGetContexts(t *testing.T) { func TestGetContexts(t *testing.T) {
conf, cleanup := testutil.InitConfig(t) conf, cleanup := testutil.InitConfig(t)
defer cleanup(t) defer cleanup(t)
@ -297,14 +282,10 @@ func TestGetCurrentContext(t *testing.T) {
conf, cleanup := testutil.InitConfig(t) conf, cleanup := testutil.InitConfig(t)
defer cleanup(t) defer cleanup(t)
context, err := conf.GetCurrentContext()
require.Error(t, err)
assert.Nil(t, context)
conf.CurrentContext = currentContextName conf.CurrentContext = currentContextName
conf.Contexts[currentContextName].Manifest = defaultString conf.Contexts[currentContextName].Manifest = defaultString
context, err = conf.GetCurrentContext() context, err := conf.GetCurrentContext()
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, conf.Contexts[currentContextName], context) assert.Equal(t, conf.Contexts[currentContextName], context)
}) })
@ -314,14 +295,10 @@ func TestCurrentContextManifest(t *testing.T) {
conf, cleanup := testutil.InitConfig(t) conf, cleanup := testutil.InitConfig(t)
defer cleanup(t) defer cleanup(t)
manifest, err := conf.CurrentContextManifest()
require.Error(t, err)
assert.Nil(t, manifest)
conf.CurrentContext = currentContextName conf.CurrentContext = currentContextName
conf.Contexts[currentContextName].Manifest = defaultString conf.Contexts[currentContextName].Manifest = defaultString
manifest, err = conf.CurrentContextManifest() manifest, err := conf.CurrentContextManifest()
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, conf.Manifests[defaultString], manifest) assert.Equal(t, conf.Manifests[defaultString], manifest)
} }
@ -330,10 +307,6 @@ func TestCurrentTargetPath(t *testing.T) {
conf, cleanup := testutil.InitConfig(t) conf, cleanup := testutil.InitConfig(t)
defer cleanup(t) defer cleanup(t)
manifest, err := conf.CurrentContextManifest()
require.Error(t, err)
assert.Nil(t, manifest)
conf.CurrentContext = currentContextName conf.CurrentContext = currentContextName
conf.Contexts[currentContextName].Manifest = defaultString conf.Contexts[currentContextName].Manifest = defaultString
@ -364,10 +337,6 @@ func TestCurrentContextClusterType(t *testing.T) {
expectedClusterType := "ephemeral" expectedClusterType := "ephemeral"
clusterTypeEmpty, err := conf.CurrentContextClusterType()
require.Error(t, err)
assert.Equal(t, "", clusterTypeEmpty)
conf.CurrentContext = currentContextName conf.CurrentContext = currentContextName
conf.Contexts[currentContextName].Manifest = defaultString conf.Contexts[currentContextName].Manifest = defaultString
@ -382,10 +351,6 @@ func TestCurrentContextClusterName(t *testing.T) {
expectedClusterName := "def" expectedClusterName := "def"
clusterNameEmpty, err := conf.CurrentContextClusterName()
require.Error(t, err)
assert.Equal(t, "", clusterNameEmpty)
conf.CurrentContext = currentContextName conf.CurrentContext = currentContextName
conf.Contexts[currentContextName].Manifest = defaultString conf.Contexts[currentContextName].Manifest = defaultString

View File

@ -22,7 +22,6 @@ import (
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
"opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/k8s/kubectl" "opendev.org/airship/airshipctl/pkg/k8s/kubectl"
k8sutils "opendev.org/airship/airshipctl/pkg/k8s/utils" k8sutils "opendev.org/airship/airshipctl/pkg/k8s/utils"
) )
@ -55,20 +54,20 @@ type Client struct {
var _ Interface = &Client{} var _ Interface = &Client{}
// Factory is a function which creates Interfaces // Factory is a function which creates Interfaces
type Factory func(*config.Config) (Interface, error) type Factory func(airshipConfigPath string, kubeconfig string) (Interface, error)
// DefaultClient is a factory which generates a default client // DefaultClient is a factory which generates a default client
var DefaultClient Factory = NewClient var DefaultClient Factory = NewClient
// NewClient creates a Client initialized from the passed in settings // NewClient creates a Client initialized from the passed in settings
func NewClient(cfg *config.Config) (Interface, error) { func NewClient(airshipConfigPath string, kubeconfig string) (Interface, error) {
client := new(Client) client := new(Client)
var err error var err error
// TODO add support for kubeconfig context, for now use current context // TODO add support for kubeconfig context, for now use current context
f := k8sutils.FactoryFromKubeConfig(cfg.KubeConfigPath(), "") f := k8sutils.FactoryFromKubeConfig(kubeconfig, "")
pathToBufferDir := filepath.Dir(cfg.LoadedConfigPath()) pathToBufferDir := filepath.Dir(airshipConfigPath)
client.kubectl = kubectl.NewKubectl(f).WithBufferDir(pathToBufferDir) client.kubectl = kubectl.NewKubectl(f).WithBufferDir(pathToBufferDir)
client.clientSet, err = f.KubernetesClientSet() client.clientSet, err = f.KubernetesClientSet()
@ -82,7 +81,7 @@ func NewClient(cfg *config.Config) (Interface, error) {
} }
// kubectl factories can't create CRD clients... // kubectl factories can't create CRD clients...
kubeConfig, err := clientcmd.BuildConfigFromFlags("", cfg.KubeConfigPath()) kubeConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -41,9 +41,8 @@ func TestNewClient(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
conf.SetLoadedConfigPath(adir) conf.SetLoadedConfigPath(adir)
conf.SetKubeConfigPath(akp)
client, err := client.NewClient(conf) client, err := client.NewClient(conf.LoadedConfigPath(), akp)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, client) assert.NotNil(t, client)
assert.NotNil(t, client.ClientSet()) assert.NotNil(t, client.ClientSet())

View File

@ -55,10 +55,11 @@ var _ ifc.Phase = &phase{}
// Phase implements phase interface // Phase implements phase interface
type phase struct { type phase struct {
helper ifc.Helper helper ifc.Helper
apiObj *v1alpha1.Phase apiObj *v1alpha1.Phase
registry ExecutorRegistry registry ExecutorRegistry
processor events.EventProcessor processor events.EventProcessor
kubeconfig string
} }
// Executor returns executor interface associated with the phase // Executor returns executor interface associated with the phase
@ -96,6 +97,7 @@ func (p *phase) Executor() (ifc.Executor, error) {
WithBundle(p.helper.PhaseRoot()). WithBundle(p.helper.PhaseRoot()).
WithClusterMap(cMap). WithClusterMap(cMap).
WithClusterName(p.apiObj.ClusterName). WithClusterName(p.apiObj.ClusterName).
WithPath(p.kubeconfig).
WithTempRoot(wd). WithTempRoot(wd).
Build() Build()
@ -169,6 +171,7 @@ type client struct {
registry ExecutorRegistry registry ExecutorRegistry
processorFunc ProcessorFunc processorFunc ProcessorFunc
kubeconfig string
} }
// ProcessorFunc that returns processor interface // ProcessorFunc that returns processor interface
@ -191,6 +194,13 @@ func InjectRegistry(registry ExecutorRegistry) Option {
} }
} }
// InjectKubeconfigPath is an option that allows to inject path to kubeconfig into phase client
func InjectKubeconfigPath(path string) Option {
return func(c *client) {
c.kubeconfig = path
}
}
// NewClient returns implementation of phase Client interface // NewClient returns implementation of phase Client interface
func NewClient(helper ifc.Helper, opts ...Option) ifc.Client { func NewClient(helper ifc.Helper, opts ...Option) ifc.Client {
c := &client{Helper: helper} c := &client{Helper: helper}

View File

@ -24,9 +24,10 @@ import (
// RunFlags options for phase run command // RunFlags options for phase run command
type RunFlags struct { type RunFlags struct {
DryRun bool DryRun bool
Timeout time.Duration Timeout time.Duration
PhaseID ifc.ID PhaseID ifc.ID
Kubeconfig string
} }
// RunCommand phase run command // RunCommand phase run command
@ -47,7 +48,8 @@ func (c *RunCommand) RunE() error {
return err return err
} }
client := NewClient(helper) kubeconfigOption := InjectKubeconfigPath(c.Options.Kubeconfig)
client := NewClient(helper, kubeconfigOption)
phase, err := client.PhaseByID(c.Options.PhaseID) phase, err := client.PhaseByID(c.Options.PhaseID)
if err != nil { if err != nil {

View File

@ -34,7 +34,6 @@ type Executor interface {
// RunOptions holds options for run method // RunOptions holds options for run method
type RunOptions struct { type RunOptions struct {
Debug bool
DryRun bool DryRun bool
Timeout time.Duration Timeout time.Duration

View File

@ -1,17 +1,15 @@
/* /*
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
Licensed under the Apache License, Version 2.0 (the "License"); https://www.apache.org/licenses/LICENSE-2.0
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,
Unless required by applicable law or agreed to in writing, software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. limitations under the License.
See the License for the specific language governing permissions and
limitations under the License.
*/ */
package testutil package testutil
@ -21,8 +19,6 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
kubeconfig "k8s.io/client-go/tools/clientcmd/api"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
@ -54,7 +50,6 @@ func DummyConfig() *config.Config {
}, },
CurrentContext: "dummy_context", CurrentContext: "dummy_context",
} }
conf.SetKubeConfig(kubeconfig.NewConfig())
return conf return conf
} }
@ -124,16 +119,12 @@ func InitConfig(t *testing.T) (conf *config.Config, cleanup func(*testing.T)) {
err := ioutil.WriteFile(configPath, []byte(testConfigYAML), 0600) err := ioutil.WriteFile(configPath, []byte(testConfigYAML), 0600)
require.NoError(t, err) require.NoError(t, err)
kubeConfigPath := filepath.Join(testDir, "kubeconfig")
err = ioutil.WriteFile(kubeConfigPath, []byte(testKubeConfigYAML), 0600)
require.NoError(t, err)
conf = config.NewConfig() conf = config.NewConfig()
err = conf.LoadConfig(configPath, kubeConfigPath, false) cfg, err := config.CreateFactory(&configPath)()
require.NoError(t, err) require.NoError(t, err)
return conf, cleanup return cfg, cleanup
} }
// DummyContextOptions creates ContextOptions config object // DummyContextOptions creates ContextOptions config object
@ -197,70 +188,14 @@ const (
contexts: contexts:
def_ephemeral: def_ephemeral:
contextKubeconf: def_ephemeral contextKubeconf: def_ephemeral
manifest: dummy_manifest
def_target: def_target:
contextKubeconf: def_target contextKubeconf: def_target
onlyink: onlyink:
contextKubeconf: onlyinkubeconf_target contextKubeconf: onlyinkubeconf_target
encryptionConfigs: {} encryptionConfigs: {}
currentContext: "" currentContext: def_ephemeral
kind: Config kind: Config
manifests: {}` manifests:
dummy_manifest: {}`
//nolint:lll
testKubeConfigYAML = `apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: http://5.6.7.8
name: def_ephemeral
- cluster:
insecure-skip-tls-verify: true
server: http://1.2.3.4
name: def_target
- cluster:
insecure-skip-tls-verify: true
server: http://9.10.11.12
name: onlyinkubeconf_target
- cluster:
certificate-authority: cert_file
server: ""
name: wrongonlyinkubeconf_target
- cluster:
insecure-skip-tls-verify: true
server: http://9.10.11.12
name: invalidName
- cluster:
insecure-skip-tls-verify: true
server: http://9.10.11.12
name: clustertypenil_target
contexts:
- context:
cluster: def_ephemeral
user: k-admin
name: def_ephemeral
- context:
cluster: def_target
user: k-admin
name: def_target
- context:
cluster: onlyinkubeconf_target
user: k-other
name: onlyink
current-context: ""
kind: Config
preferences: {}
users:
users:
- name: def-user
user:
username: dummy_username
password: ZHVtbXlfcGFzc3dvcmQK
- name: k-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdXb1RXRXlGOEVWN3JyLwo0K0hoSEdpcTVQbXF1SUZ5enpuNi9JWmM4alU5eEVmenZpa2NpckxmVTR2UlhKUXdWd2dBU05sMkFXQUloMmRECmRUcmpCQ2ZpS1dNSHlqMFJiSGFsc0J6T3BnVC9IVHYzR1F6blVRekZLdjJkajVWMU5rUy9ESGp5UlJKK0VMNlEKQlltR3NlZzVQNE5iQzllYnVpcG1NVEFxL0p1bU9vb2QrRmpMMm5acUw2Zkk2ZkJ0RjVPR2xwQ0IxWUo4ZnpDdApHUVFaN0hUSWJkYjJ0cDQzRlZPaHlRYlZjSHFUQTA0UEoxNSswV0F5bVVKVXo4WEE1NDRyL2J2NzRKY0pVUkZoCmFyWmlRd0lEQVFBQm95Y3dKVEFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUgKQXdJd0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFMMmh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REdHckdpbzZmTQp5aXB3Q2tZVGVxRThpZ1J6UkI5QkdFUGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=`
) )

View File

@ -1,3 +1,17 @@
/*
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 testutil package testutil
import ( import (

View File

@ -115,7 +115,7 @@ for cluster in ephemeral target; do
# step 1: actually apply all crds in the phase # step 1: actually apply all crds in the phase
# TODO: will need to loop through phases in order, eventually # TODO: will need to loop through phases in order, eventually
# e.g., load CRDs from initinfra first, so they're present when validating later phases # e.g., load CRDs from initinfra first, so they're present when validating later phases
${ACTL} phase render ${phase} -k CustomResourceDefinition > ${TMP}/${phase}-crds.yaml ${AIRSHIPCTL} --airshipconf ${AIRSHIPCONFIG} phase render ${phase} -k CustomResourceDefinition > ${TMP}/${phase}-crds.yaml
if [ -s ${TMP}/${phase}-crds.yaml ]; then if [ -s ${TMP}/${phase}-crds.yaml ]; then
${KUBECTL} --context ${CONTEXT} --kubeconfig ${KUBECONFIG} apply -f ${TMP}/${phase}-crds.yaml ${KUBECTL} --context ${CONTEXT} --kubeconfig ${KUBECONFIG} apply -f ${TMP}/${phase}-crds.yaml
fi fi