Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Add client config option + registry auth e2e tests #844

Merged
merged 8 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ blocks:
task:
env_vars:
- name: GIMME_GO_VERSION
value: "1.14.2"
value: "1.16.3"
jobs:
- name: Tests
commands:
Expand All @@ -32,4 +32,5 @@ blocks:
- make ignite ignite-spawn ignited bin/amd64/Dockerfile GO_MAKE_TARGET=local
- make test
- make root-test
- bash e2e/util/setup-private-registry.sh # This is required for registry auth e2e tests.
- make e2e-nobuild # this depends on Semaphore CI's support for nested virtualization
4 changes: 4 additions & 0 deletions cmd/ignite/cmd/cmdutil/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ func AddSSHFlags(fs *pflag.FlagSet, identityFile *string, timeout *uint32) {
fs.StringVarP(identityFile, "identity", "i", "", "Override the vm's default identity file")
fs.Uint32Var(timeout, "timeout", constants.SSH_DEFAULT_TIMEOUT_SECONDS, "Timeout waiting for connection in seconds")
}

func AddClientConfigDirFlag(fs *pflag.FlagSet, dir *string) {
fs.StringVar(dir, "client-config-dir", "", "Directory containing the client configuration (default ~/.docker/)")
}
22 changes: 22 additions & 0 deletions cmd/ignite/cmd/cmdutil/providers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmdutil

import (
log "github.com/sirupsen/logrus"

"github.com/weaveworks/ignite/pkg/providers"
)

// ResolveClientConfigDir reads various configuration to resolve the client
// configuration directory.
func ResolveClientConfigDir() {
if providers.ComponentConfig != nil {
// Set the providers client config dir from ignite configuration if
// it's empty. When it's set in the providers and in the ignite
// configuration, log about the override.
if providers.ClientConfigDir == "" {
providers.ClientConfigDir = providers.ComponentConfig.Spec.ClientConfigDir
} else if providers.ComponentConfig.Spec.ClientConfigDir != "" {
log.Debug("client-config-dir flag overriding the ignite configuration")
}
}
}
1 change: 1 addition & 0 deletions cmd/ignite/cmd/imgcmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ func NewCmdImport(out io.Writer) *cobra.Command {

func addImportFlags(fs *pflag.FlagSet) {
runtimeflag.RuntimeVar(fs, &providers.RuntimeName)
cmdutil.AddClientConfigDirFlag(fs, &providers.ClientConfigDir)
}
1 change: 1 addition & 0 deletions cmd/ignite/cmd/kerncmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ func NewCmdImport(out io.Writer) *cobra.Command {

func addImportFlags(fs *pflag.FlagSet) {
runtimeflag.RuntimeVar(fs, &providers.RuntimeName)
cmdutil.AddClientConfigDirFlag(fs, &providers.ClientConfigDir)
}
1 change: 1 addition & 0 deletions cmd/ignite/cmd/vmcmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@ func addCreateFlags(fs *pflag.FlagSet, cf *run.CreateFlags) {
runtimeflag.RuntimeVar(fs, &providers.RuntimeName)
networkflag.NetworkPluginVar(fs, &providers.NetworkPluginName)
cmdutil.AddIDPrefixFlag(fs, &providers.IDPrefix)
cmdutil.AddClientConfigDirFlag(fs, &providers.ClientConfigDir)
}
4 changes: 4 additions & 0 deletions cmd/ignite/run/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path"
"strings"

"github.com/weaveworks/ignite/cmd/ignite/cmd/cmdutil"
api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/apis/ignite/scheme"
"github.com/weaveworks/ignite/pkg/apis/ignite/validation"
Expand Down Expand Up @@ -58,6 +59,9 @@ func (cf *CreateFlags) NewCreateOptions(args []string, fs *flag.FlagSet) (*Creat
baseVM.Spec = providers.ComponentConfig.Spec.VMDefaults
}

// Resolve client configuration used for pulling image if required.
cmdutil.ResolveClientConfigDir()

// Initialize the VM's Prefixer
baseVM.Status.IDPrefix = providers.IDPrefix
// Set the runtime and network-plugin on the VM, then override the global config.
Expand Down
5 changes: 5 additions & 0 deletions cmd/ignite/run/import.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package run

import (
"github.com/weaveworks/ignite/cmd/ignite/cmd/cmdutil"
api "github.com/weaveworks/ignite/pkg/apis/ignite"
meta "github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1"
"github.com/weaveworks/ignite/pkg/config"
Expand All @@ -16,6 +17,8 @@ func ImportImage(source string) (image *api.Image, err error) {
return nil, err
}

cmdutil.ResolveClientConfigDir()

ociRef, err := meta.NewOCIImageRef(source)
if err != nil {
return
Expand All @@ -38,6 +41,8 @@ func ImportKernel(source string) (kernel *api.Kernel, err error) {
return nil, err
}

cmdutil.ResolveClientConfigDir()

ociRef, err := meta.NewOCIImageRef(source)
if err != nil {
return
Expand Down
16 changes: 16 additions & 0 deletions docs/api/ignite_v1alpha3.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

- [Constants](#pkg-constants)
- [Variables](#pkg-variables)
- [func
Convert\_ignite\_ConfigurationSpec\_To\_v1alpha3\_ConfigurationSpec(in
*ignite.ConfigurationSpec, out *ConfigurationSpec, s
conversion.Scope)
error](#Convert_ignite_ConfigurationSpec_To_v1alpha3_ConfigurationSpec)
- [func SetDefaults\_ConfigurationSpec(obj
\*ConfigurationSpec)](#SetDefaults_ConfigurationSpec)
- [func SetDefaults\_PoolSpec(obj \*PoolSpec)](#SetDefaults_PoolSpec)
Expand Down Expand Up @@ -60,6 +65,7 @@

#### <a name="pkg-files">Package files</a>

[conversion.go](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha3/conversion.go)
[defaults.go](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha3/defaults.go)
[doc.go](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha3/doc.go)
[json.go](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha3/json.go)
Expand Down Expand Up @@ -106,6 +112,16 @@ var SchemeGroupVersion = schema.GroupVersion{

SchemeGroupVersion is group version used to register these objects

## <a name="Convert_ignite_ConfigurationSpec_To_v1alpha3_ConfigurationSpec">func</a> [Convert\_ignite\_ConfigurationSpec\_To\_v1alpha3\_ConfigurationSpec](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha3/conversion.go?s=261:408#L9)

``` go
func Convert_ignite_ConfigurationSpec_To_v1alpha3_ConfigurationSpec(in *ignite.ConfigurationSpec, out *ConfigurationSpec, s conversion.Scope) error
```

Convert\_ignite\_ConfigurationSpec\_To\_v1alpha3\_ConfigurationSpec
calls the autogenerated conversion function along with custom conversion
logic

## <a name="SetDefaults_ConfigurationSpec">func</a> [SetDefaults\_ConfigurationSpec](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha3/defaults.go?s=1785:1843#L71)

``` go
Expand Down
11 changes: 6 additions & 5 deletions docs/api/ignite_v1alpha4.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ type Configuration struct {
Configuration represents the ignite runtime configuration.
+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

## <a name="ConfigurationSpec">type</a> [ConfigurationSpec](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha4/types.go?s=9475:9786#L261)
## <a name="ConfigurationSpec">type</a> [ConfigurationSpec](https://github.com/weaveworks/ignite/tree/main/pkg/apis/ignite/v1alpha4/types.go?s=9475:9871#L261)

``` go
type ConfigurationSpec struct {
Runtime igniteRuntime.Name `json:"runtime,omitempty"`
NetworkPlugin igniteNetwork.PluginName `json:"networkPlugin,omitempty"`
VMDefaults VMSpec `json:"vmDefaults,omitempty"`
IDPrefix string `json:"idPrefix,omitempty"`
Runtime igniteRuntime.Name `json:"runtime,omitempty"`
NetworkPlugin igniteNetwork.PluginName `json:"networkPlugin,omitempty"`
VMDefaults VMSpec `json:"vmDefaults,omitempty"`
IDPrefix string `json:"idPrefix,omitempty"`
ClientConfigDir string `json:"clientConfigDir,omitempty"`
}
```

Expand Down
37 changes: 19 additions & 18 deletions docs/cli/ignite/ignite_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,25 @@ ignite create <OCI image> [flags]
### Options

```
--config string Specify a path to a file with the API resources you want to pass
-f, --copy-files strings Copy files/directories from the host to the created VM
--cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1)
-h, --help help for create
--id-prefix string Prefix string for system identifiers (default ignite)
--kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp")
-k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:5.4.108)
-l, --label stringArray Set a label (foo=bar)
--memory size Amount of RAM to allocate for the VM (default 512.0 MB)
-n, --name string Specify the name
--network-plugin plugin Network plugin to use. Available options are: [cni docker-bridge] (default cni)
-p, --ports strings Map host ports to VM ports
--require-name Require VM name to be passed, no name generation
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
--sandbox-image oci-image Specify an OCI image for the VM sandbox (default weaveworks/ignite:dev)
-s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB)
--ssh[=<path>] Enable SSH for the VM. If <path> is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM)
-v, --volumes volume Expose block devices from the host inside the VM
--client-config-dir string Directory containing the client configuration (default ~/.docker/)
--config string Specify a path to a file with the API resources you want to pass
-f, --copy-files strings Copy files/directories from the host to the created VM
--cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1)
-h, --help help for create
--id-prefix string Prefix string for system identifiers (default ignite)
--kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp")
-k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:5.4.108)
-l, --label stringArray Set a label (foo=bar)
--memory size Amount of RAM to allocate for the VM (default 512.0 MB)
-n, --name string Specify the name
--network-plugin plugin Network plugin to use. Available options are: [cni docker-bridge] (default cni)
-p, --ports strings Map host ports to VM ports
--require-name Require VM name to be passed, no name generation
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
--sandbox-image oci-image Specify an OCI image for the VM sandbox (default weaveworks/ignite:dev)
-s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB)
--ssh[=<path>] Enable SSH for the VM. If <path> is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM)
-v, --volumes volume Expose block devices from the host inside the VM
```

### Options inherited from parent commands
Expand Down
5 changes: 3 additions & 2 deletions docs/cli/ignite/ignite_image_import.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ ignite image import <OCI image> [flags]
### Options

```
-h, --help help for import
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
--client-config-dir string Directory containing the client configuration (default ~/.docker/)
-h, --help help for import
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
```

### Options inherited from parent commands
Expand Down
5 changes: 3 additions & 2 deletions docs/cli/ignite/ignite_kernel_import.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ ignite kernel import <OCI image> [flags]
### Options

```
-h, --help help for import
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
--client-config-dir string Directory containing the client configuration (default ~/.docker/)
-h, --help help for import
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions docs/cli/ignite/ignite_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ignite run <OCI image> [flags]
### Options

```
--client-config-dir string Directory containing the client configuration (default ~/.docker/)
--config string Specify a path to a file with the API resources you want to pass
-f, --copy-files strings Copy files/directories from the host to the created VM
--cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1)
Expand Down
37 changes: 19 additions & 18 deletions docs/cli/ignite/ignite_vm_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,25 @@ ignite vm create <OCI image> [flags]
### Options

```
--config string Specify a path to a file with the API resources you want to pass
-f, --copy-files strings Copy files/directories from the host to the created VM
--cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1)
-h, --help help for create
--id-prefix string Prefix string for system identifiers (default ignite)
--kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp")
-k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:5.4.108)
-l, --label stringArray Set a label (foo=bar)
--memory size Amount of RAM to allocate for the VM (default 512.0 MB)
-n, --name string Specify the name
--network-plugin plugin Network plugin to use. Available options are: [cni docker-bridge] (default cni)
-p, --ports strings Map host ports to VM ports
--require-name Require VM name to be passed, no name generation
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
--sandbox-image oci-image Specify an OCI image for the VM sandbox (default weaveworks/ignite:dev)
-s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB)
--ssh[=<path>] Enable SSH for the VM. If <path> is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM)
-v, --volumes volume Expose block devices from the host inside the VM
--client-config-dir string Directory containing the client configuration (default ~/.docker/)
--config string Specify a path to a file with the API resources you want to pass
-f, --copy-files strings Copy files/directories from the host to the created VM
--cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1)
-h, --help help for create
--id-prefix string Prefix string for system identifiers (default ignite)
--kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp")
-k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:5.4.108)
-l, --label stringArray Set a label (foo=bar)
--memory size Amount of RAM to allocate for the VM (default 512.0 MB)
-n, --name string Specify the name
--network-plugin plugin Network plugin to use. Available options are: [cni docker-bridge] (default cni)
-p, --ports strings Map host ports to VM ports
--require-name Require VM name to be passed, no name generation
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
--sandbox-image oci-image Specify an OCI image for the VM sandbox (default weaveworks/ignite:dev)
-s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB)
--ssh[=<path>] Enable SSH for the VM. If <path> is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM)
-v, --volumes volume Expose block devices from the host inside the VM
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions docs/cli/ignite/ignite_vm_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ignite vm run <OCI image> [flags]
### Options

```
--client-config-dir string Directory containing the client configuration (default ~/.docker/)
--config string Specify a path to a file with the API resources you want to pass
-f, --copy-files strings Copy files/directories from the host to the created VM
--cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1)
Expand Down
Loading