Skip to content

Commit

Permalink
Merge pull request #698 from ystia/feature/GH-697-ecdsa-rsa-keys
Browse files Browse the repository at this point in the history
Fixed the parsing of KEY=VALUE pairs
  • Loading branch information
laurentganne committed Oct 15, 2020
2 parents 10ac6a8 + dd85449 commit 8260512
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

### ENHANCEMENTS

* Should be able to specify edcsa or rsa ssh keys in gcloud compute instances metadata ([GH-697](https://github.com/ystia/yorc/issues/697))
* Add the ability to define OpenStack Compute Instance metadata ([GH-687](https://github.com/ystia/yorc/issues/687))
* Support Alien4Cloud 3.0 ([GH-689](https://github.com/ystia/yorc/issues/689))
* Upgrade Ansible version from 2.7.9 to 2.10.0 ([GH-648](https://github.com/ystia/yorc/issues/648))
Expand Down
2 changes: 1 addition & 1 deletion deployments/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func GetKeyValuePairsNodeProperty(ctx context.Context, deploymentID, nodeName, p
values := strings.Split(strValue.RawString(), ",")
result = make(map[string]string, len(values))
for _, val := range values {
keyValuePair := strings.Split(val, "=")
keyValuePair := strings.SplitN(val, "=", 2)
if len(keyValuePair) != 2 {
return result, errors.Errorf("Expected KEY=VALUE format, got %s for property %s on %s",
val, propertyName, nodeName)
Expand Down
9 changes: 6 additions & 3 deletions prov/terraform/google/compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ package google
import (
"context"
"fmt"
"github.com/ystia/yorc/v4/storage"
"github.com/ystia/yorc/v4/storage/types"
"github.com/ystia/yorc/v4/tosca"
"io/ioutil"
"path"
"testing"

"github.com/ystia/yorc/v4/storage"
"github.com/ystia/yorc/v4/storage/types"
"github.com/ystia/yorc/v4/tosca"

"github.com/hashicorp/consul/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -85,6 +86,8 @@ func testSimpleComputeInstance(t *testing.T, cfg config.Configuration) {
assert.Equal(t, []string{"tag1", "tag2"}, compute.Tags)
assert.Equal(t, map[string]string{"key1": "value1", "key2": "value2"}, compute.Labels)

assert.Equal(t, map[string]string{"enable-oslogin": "false", "ssh-keys": "testuser:ecdsa-sha2-nistp256 AAAAE2VjZH/LlTXfXIr+N= test.user@name.org"}, compute.Metadata)

require.Contains(t, infrastructure.Resource, "null_resource")
require.Len(t, infrastructure.Resource["null_resource"], 1)
nullResources := infrastructure.Resource["null_resource"].(map[string]interface{})
Expand Down
1 change: 1 addition & 0 deletions prov/terraform/google/testdata/simpleComputeInstance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ topology_template:
service_account: "yorc@yorc.net"
tags: "tag1, tag2"
labels: "key1=value1, key2=value2"
metadata: "enable-oslogin=false,ssh-keys=testuser:ecdsa-sha2-nistp256 AAAAE2VjZH/LlTXfXIr+N= test.user@name.org"
scratch_disks:
- interface: SCSI
- interface: NVME
Expand Down

0 comments on commit 8260512

Please sign in to comment.