Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows-based image and IPv6 network #38

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions builder/yandex/cloud_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func MergeCloudUserMetaData(usersData ...string) (string, error) {
return "", err
}

close := false
for i, userData := range usersData {
if len(userData) != 0 {
w, err := data.CreatePart(textproto.MIMEHeader{
Expand All @@ -46,8 +47,18 @@ func MergeCloudUserMetaData(usersData ...string) (string, error) {
if err != nil {
return "", err
}

close = true
}
}

if close {
err = data.Close()
if err != nil {
return "", err
}
}

return buff.String(), nil
}

Expand Down
24 changes: 2 additions & 22 deletions builder/yandex/driver_yc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,7 @@ func (d *driverYC) GetImage(imageID string) (*Image, error) {
return nil, err
}

return &Image{
ID: image.Id,
Labels: image.Labels,
Licenses: image.ProductIds,
Name: image.Name,
Family: image.Family,
Description: image.Description,
FolderID: image.FolderId,
MinDiskSizeGb: toGigabytes(image.MinDiskSize),
SizeGb: toGigabytes(image.StorageSize),
}, nil
return convert(image), nil
}

func (d *driverYC) GetImageFromFolder(ctx context.Context, folderID string, family string) (*Image, error) {
Expand All @@ -133,17 +123,7 @@ func (d *driverYC) GetImageFromFolder(ctx context.Context, folderID string, fami
return nil, err
}

return &Image{
ID: image.Id,
Labels: image.Labels,
Licenses: image.ProductIds,
Name: image.Name,
Description: image.Description,
FolderID: image.FolderId,
Family: image.Family,
MinDiskSizeGb: toGigabytes(image.MinDiskSize),
SizeGb: toGigabytes(image.StorageSize),
}, nil
return convert(image), nil
}

func (d *driverYC) GetImageFromFolderByName(ctx context.Context, folderID string, imageName string) (*Image, error) {
Expand Down
20 changes: 20 additions & 0 deletions builder/yandex/image.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package yandex

import (
"github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1"
)

type Image struct {
ID string
FolderID string
Expand All @@ -10,4 +14,20 @@ type Image struct {
Description string
Family string
SizeGb int
Os *compute.Os
}

func convert(image *compute.Image) *Image {
return &Image{
ID: image.Id,
Labels: image.Labels,
Licenses: image.ProductIds,
Name: image.Name,
Family: image.Family,
Description: image.Description,
FolderID: image.FolderId,
MinDiskSizeGb: toGigabytes(image.MinDiskSize),
SizeGb: toGigabytes(image.StorageSize),
Os: image.Os,
}
}
18 changes: 11 additions & 7 deletions builder/yandex/step_create_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,17 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
if config.UseIPv6 {
ui.Say("Prepare user-data...")

oldUserData, ok := instanceMetadata["user-data"]
if !ok {
oldUserData = ""
}
instanceMetadata["user-data"], err = MergeCloudUserMetaData(cloudInitIPv6Config, oldUserData)
if err != nil {
return StepHaltWithError(state, fmt.Errorf("Error merge user data configs: %s", err))
if sourceImage.Os.Type == compute.Os_WINDOWS {
ui.Say("Windows OS detected, no additional IPv6 configuration required")
} else {
oldUserData, ok := instanceMetadata["user-data"]
if !ok {
oldUserData = ""
}
instanceMetadata["user-data"], err = MergeCloudUserMetaData(cloudInitIPv6Config, oldUserData)
if err != nil {
return StepHaltWithError(state, fmt.Errorf("Error merge user data configs: %s", err))
}
}
}

Expand Down