func (tc *testContext) createPrivateKeySecret(useKnownKey bool) error {
	if err := tc.ensurePrivateKeyDeleted(); err != nil {
		return errors.Wrap(err, "error ensuring any existing private key is removed")
	}
	var keyData []byte
	var err error
	if useKnownKey {
		keyData, err = ioutil.ReadFile(gc.privateKeyPath)
		if err != nil {
			return errors.Wrapf(err, "unable to read private key data from file %s", gc.privateKeyPath)
		}
	} else {
		keyData, err = generatePrivateKey()
		if err != nil {
			return errors.Wrap(err, "error generating private key")
		}
	}

	privateKeySecret := core.Secret{
		Data: map[string][]byte{secrets.PrivateKeySecretKey: keyData},
		ObjectMeta: meta.ObjectMeta{
			Name: secrets.PrivateKeySecret,
		},
	}

	// Create the private key secret in both the operator's namespace, and the test namespace. This is needed to make it
	// possible to SSH into the Windows nodes from pods spun up in the test namespace.
	for _, ns := range []string{tc.namespace, tc.workloadNamespace} {
		_, err := tc.client.K8s.CoreV1().Secrets(ns).Create(context.TODO(), &privateKeySecret, meta.CreateOptions{})
		if err != nil {
			return errors.Wrapf(err, "could not create private key secret in namespace %s", ns)
		}
	}
	return nil
}
// createPrivateKeySecret ensures that a private key secret exists with the correct data in both the operator and test
// namespaces
createPrivateKeySecret ensures that a private key secret exists with the correct data in both the operator and test
namespaces
// createPrivateKeySecret ensures that a private key secret exists with the correct data in both the operator and test // namespaces
func (tc *testContext) createPrivateKeySecret(useKnownKey bool) error {
	if err := tc.ensurePrivateKeyDeleted(); err != nil {
		return errors.Wrap(err, "error ensuring any existing private key is removed")
	}
	var keyData []byte
	var err error
	if useKnownKey {
		keyData, err = ioutil.ReadFile(gc.privateKeyPath)
		if err != nil {
			return errors.Wrapf(err, "unable to read private key data from file %s", gc.privateKeyPath)
		}
	} else {
		keyData, err = generatePrivateKey()
		if err != nil {
			return errors.Wrap(err, "error generating private key")
		}
	}
	privateKeySecret := core.Secret{
		Data: map[string][]byte{secrets.PrivateKeySecretKey: keyData},
		ObjectMeta: meta.ObjectMeta{
			Name: secrets.PrivateKeySecret,
		},
	}
	for _, ns := range []string{tc.namespace, tc.workloadNamespace} {
		_, err := tc.client.K8s.CoreV1().Secrets(ns).Create(context.TODO(), &privateKeySecret, meta.CreateOptions{})
		if err != nil {
			return errors.Wrapf(err, "could not create private key secret in namespace %s", ns)
		}
	}
	return nil
}
func ( tc * testContext ) createPrivateKeySecret ( useKnownKey bool ) error { if err := tc . ensurePrivateKeyDeleted ( ) ; err != nil { return errors . Wrap ( err , " " ) } var keyData [ ] byte var err error if useKnownKey { keyData , err = ioutil . ReadFile ( gc . privateKeyPath ) if err != nil { return errors . Wrapf ( err , " " , gc . privateKeyPath ) } } else { keyData , err = generatePrivateKey ( ) if err != nil { return errors . Wrap ( err , " " ) } } privateKeySecret := core . Secret { Data : map [ string ] [ ] byte { secrets . PrivateKeySecretKey : keyData } , ObjectMeta : meta . ObjectMeta { Name : secrets . PrivateKeySecret , } , } for _ , ns := range [ ] string { tc . namespace , tc . workloadNamespace } { _ , err := tc . client . K8s . CoreV1 ( ) . Secrets ( ns ) . Create ( context . TODO ( ) , & privateKeySecret , meta . CreateOptions { } ) if err != nil { return errors . Wrapf ( err , " " , ns ) } } return nil }
createPrivateKeySecret ensures that a private key secret exists with the correct data in both the operator and test
namespaces
createPrivateKeySecret ensures that a private key secret exists with the correct data in both the operator and test namespaces
// Create the private key secret in both the operator's namespace, and the test namespace. This is needed to make it // possible to SSH into the Windows nodes from pods spun up in the test namespace.