Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions cmd/mapt/cmd/aws/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const (
MACDHID string = "dedicated-host-id"
MACDHIDDesc string = "id for the dedicated host"

Spot string = "spot"
SpotDesc string = "if spot is set the spot prices across all regions will be checked and machine will be started on best spot option (price / eviction)"
Spot string = "spot"
SpotDesc string = "if spot is set the spot prices across all regions will be checked and machine will be started on best spot option (price / eviction)"
)

func MACArchAsCirrusArch(arch string) *cirrus.Arch {
Expand Down
2 changes: 2 additions & 0 deletions cmd/mapt/cmd/azure/hosts/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func getCreateLinux(ostype data.OSType, defaultOSVersion string) *cobra.Command
OSType: ostype,
Username: viper.GetString(paramUsername),
Spot: viper.IsSet(azparams.ParamSpot),
Timeout: viper.GetString(params.Timeout),
SpotTolerance: spotToleranceValue}); err != nil {
logging.Error(err)
}
Expand All @@ -112,6 +113,7 @@ func getCreateLinux(ostype data.OSType, defaultOSVersion string) *cobra.Command
flagSet.Bool(azparams.ParamSpot, false, azparams.ParamSpotDesc)
flagSet.StringP(azparams.ParamSpotTolerance, "", azparams.DefaultSpotTolerance, azparams.ParamSpotToleranceDesc)
flagSet.StringSliceP(azparams.ParamSpotExcludedRegions, "", []string{}, azparams.ParamSpotExcludedRegionsDesc)
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
flagSet.AddFlagSet(params.GetCpusAndMemoryFlagset())
c.PersistentFlags().AddFlagSet(flagSet)
return c
Expand Down
2 changes: 2 additions & 0 deletions cmd/mapt/cmd/azure/hosts/rhel.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func getCreateRHEL() *cobra.Command {
ProfileSNC: viper.IsSet(params.ProfileSNC),
Username: viper.GetString(paramUsername),
Spot: viper.IsSet(azparams.ParamSpot),
Timeout: viper.GetString(params.Timeout),
SpotTolerance: spotToleranceValue,
SpotExcludedRegions: viper.GetStringSlice(azparams.ParamSpotExcludedRegions),
}); err != nil {
Expand All @@ -130,6 +131,7 @@ func getCreateRHEL() *cobra.Command {
flagSet.Bool(azparams.ParamSpot, false, azparams.ParamSpotDesc)
flagSet.StringP(azparams.ParamSpotTolerance, "", azparams.DefaultSpotTolerance, azparams.ParamSpotToleranceDesc)
flagSet.StringSliceP(azparams.ParamSpotExcludedRegions, "", []string{}, azparams.ParamSpotExcludedRegionsDesc)
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
flagSet.AddFlagSet(params.GetGHActionsFlagset())
params.AddCirrusFlags(flagSet)
flagSet.AddFlagSet(params.GetCpusAndMemoryFlagset())
Expand Down
2 changes: 2 additions & 0 deletions cmd/mapt/cmd/azure/hosts/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func getCreateWindowsDesktop() *cobra.Command {
AdminUsername: viper.GetString(paramAdminUsername),
Profiles: viper.GetStringSlice(paramProfile),
Spot: viper.IsSet(azparams.ParamSpot),
Timeout: viper.GetString(params.Timeout),
SpotTolerance: spotToleranceValue,
SpotExcludedRegions: viper.GetStringSlice(azparams.ParamSpotExcludedRegions)}); err != nil {
logging.Error(err)
Expand All @@ -139,6 +140,7 @@ func getCreateWindowsDesktop() *cobra.Command {
flagSet.StringSliceP(azparams.ParamSpotExcludedRegions, "", []string{}, azparams.ParamSpotExcludedRegionsDesc)
flagSet.AddFlagSet(params.GetGHActionsFlagset())
params.AddCirrusFlags(flagSet)
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
flagSet.AddFlagSet(params.GetCpusAndMemoryFlagset())
c.PersistentFlags().AddFlagSet(flagSet)
return c
Expand Down
15 changes: 9 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ require (
github.com/pulumi/pulumi-aws-native/sdk v1.29.0
github.com/pulumi/pulumi-aws/sdk/v6 v6.82.1
github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.90.0
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.90.0
github.com/pulumi/pulumi-azure-native-sdk/app/v3 v3.5.1
github.com/pulumi/pulumi-azure-native-sdk/authorization/v3 v3.5.1
github.com/pulumi/pulumi-azure-native-sdk/compute/v3 v3.5.1
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.90.0
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.90.0
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.90.0
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.90.0
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3 v3.5.1
github.com/pulumi/pulumi-azure-native-sdk/network/v3 v3.5.1
github.com/pulumi/pulumi-azure-native-sdk/operationalinsights/v3 v3.5.1
github.com/pulumi/pulumi-azure-native-sdk/resources/v3 v3.5.1
github.com/pulumi/pulumi-azure-native-sdk/storage/v3 v3.5.1
github.com/pulumi/pulumi-tls/sdk/v5 v5.2.0
)

Expand All @@ -49,6 +52,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pulumi/pulumi-azure-native-sdk/v3 v3.5.1 // indirect
github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild v0.0.3 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
golang.org/x/mod v0.25.0 // indirect
Expand Down Expand Up @@ -151,7 +155,6 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.90.0
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.23.0
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
Expand Down
30 changes: 18 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,28 @@ github.com/pulumi/pulumi-aws/sdk/v6 v6.82.1 h1:OMFesR8LFHKczdjw+1G8D7jWaZfl/j4fx
github.com/pulumi/pulumi-aws/sdk/v6 v6.82.1/go.mod h1:H3ch/vJwSGdwO3Veyu2CJtKcElQmwnLq0XGOX8V/5Kg=
github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1 h1:V0NaeP3Rx5WGysvNz6x13Dnd3visEgQubP/gzQ+X86Q=
github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1/go.mod h1:j8IUGf1uw47bXxHS5H98O3NZIXvVsb7bfv/zby1cVLE=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.90.0 h1:n7CIe1znqhPy/GMnzif6ces7rYJxNSN6mImbveB2Mfg=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.90.0/go.mod h1:E/eRptiP+vN8CHhbqkp62Kl/ce5lc9M2/Jos4YQlSWw=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.90.0 h1:zgHEQ9qYOeLr5ji4RIZIAPp2Y7aely3cKncSbMCmPGE=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.90.0/go.mod h1:ppkY8kpbZNeyNqUu9IOikthVMtPp3QGMfPxpvt4cpXI=
github.com/pulumi/pulumi-azure-native-sdk/app/v3 v3.5.1 h1:LnS0JLndeS5808Fn1mHY74C8hxJn3AesOa/MBX3udLI=
github.com/pulumi/pulumi-azure-native-sdk/app/v3 v3.5.1/go.mod h1:uRkpdKOn5TzOvFEU8ClIg7F0qaP4qnZOIG5uo6te3C0=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v3 v3.5.1 h1:/ZefC2g1pgGLD15UTva15xw6r9n44UesWL+Guzbj4tc=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v3 v3.5.1/go.mod h1:92GeokCKmCPkjgDddtFifp52W7bcX2di5N5UfdAPsNo=
github.com/pulumi/pulumi-azure-native-sdk/compute/v3 v3.5.1 h1:ZRgCfhj/h9oWe9/EJQZGtRPt0wIzlHmZSckKqqEIC/o=
github.com/pulumi/pulumi-azure-native-sdk/compute/v3 v3.5.1/go.mod h1:fpZ9m+mUwFJYYbUhmynux5MhgkPr0XNoajswNVNWKFo=
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.90.0 h1:hAeeWNwun6IsPynn+DmfDTdZf8yUDA/iSxWKYCGSras=
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.90.0/go.mod h1:9gxE6h4R/cKQ7Wuje0g7vvqu0RSVI8GC6NEVqwlorMs=
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.90.0 h1:al+yi/DLRIh5QD1ly6nmKEhLwsX4MJf/pSAkhgWDsyU=
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.90.0/go.mod h1:XtnP9Glgh7qQORnr0swkSs0Nl2sW7SrbPORH8Bzbsa4=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.90.0 h1:MY1Gsyf/EbnC6cpxTdhAvTPoQ7vYsFRdi6DuK1hQRVs=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.90.0/go.mod h1:vokLPWkqbKuI8d3+apCHrp0BDmqf6tS4UWLRweBVv70=
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.90.0 h1:24gy0uzkWkahHnpv38Cn1tzLmS67QUnF5bGH5dSpVj8=
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.90.0/go.mod h1:vr80rePwLAyiE3YsSUT5yAK7L0TVoA/+nPZ6yXjfRkk=
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.90.0 h1:ZrZ/HhSXEez4XlmFFQAZr8hAQu5z5UPTm/5Kjfx1OXI=
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.90.0/go.mod h1:aYU8LRrKffIqYmA9/B9eqmmsLALkMlwKLPwA0UBPB/U=
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3 v3.5.1 h1:g/3ebg8tuqHXZxiA7/vUL8x53NRhso0pd4AtpMjCCjE=
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3 v3.5.1/go.mod h1:H4pGl/yW8lDlNGAH6PGzQL+bgW+KIctf5wW/sfK/bx4=
github.com/pulumi/pulumi-azure-native-sdk/network/v3 v3.5.1 h1:AlFosM3H5fkxC0ZrmVvO4l4bnEXu9gyw7+6yworm+qg=
github.com/pulumi/pulumi-azure-native-sdk/network/v3 v3.5.1/go.mod h1:KWg3ySLcYAxgIe4+TRAxFcPbEwb/V8KpIHEem1U0RjY=
github.com/pulumi/pulumi-azure-native-sdk/operationalinsights/v3 v3.5.1 h1:FTtY+r9q75gl2Ysh7Ojvx1u2fD53R9GasshtCAw8Uj8=
github.com/pulumi/pulumi-azure-native-sdk/operationalinsights/v3 v3.5.1/go.mod h1:nQjlBmQKy1vNoxH11NEqBsOhiqjmNgixuUyWFenSlj4=
github.com/pulumi/pulumi-azure-native-sdk/resources/v3 v3.5.1 h1:DRJ3WAXo1yhH6YAySjlUnT0eNDV3xlI1MoNrQxxN+d8=
github.com/pulumi/pulumi-azure-native-sdk/resources/v3 v3.5.1/go.mod h1:Ag4JPUH7wO3A4dLispzONEmUcy4YnIna23xiFloQHHo=
github.com/pulumi/pulumi-azure-native-sdk/storage/v3 v3.5.1 h1:WijJymNZw2hYeSQy/eRLZt//7DzQK4Ww81vQ0Irb3so=
github.com/pulumi/pulumi-azure-native-sdk/storage/v3 v3.5.1/go.mod h1:qhiBFlA5N7IBpoN0Eg1yyqM8b43XE+pxYeHJ8f+3K7A=
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.90.0 h1:clO7kyLNEPl6VCwm74/C/yoFemBjVJPompPgkSQgBoI=
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.90.0/go.mod h1:2IvMmB8/M+RXKlMz330M8BFD+7ChBo7mEWhzpgPAkSc=
github.com/pulumi/pulumi-azure-native-sdk/v3 v3.5.1 h1:XHYZFOa7Oad66z/1OpjGJ5KykQVfxrayroZnt6+1uGA=
github.com/pulumi/pulumi-azure-native-sdk/v3 v3.5.1/go.mod h1:xYRok2u4arAE8Q+j67N1V+mUqYf6ph4TFcV8r6uxbOo=
github.com/pulumi/pulumi-command/sdk v1.1.0 h1:CFCa5B825ZVg2VHoNESnPIQU7QhxXthIfe6EVpR5ohE=
github.com/pulumi/pulumi-command/sdk v1.1.0/go.mod h1:DhLf389o85xzbpu59VEZRxBzzBG9Tv3zMxUW+NA2pq4=
github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild v0.0.3 h1:NxCXxRvzhUJP9dIvlpNlZKt/A3NHu3i9pC5XO+i8bR0=
Expand Down
15 changes: 15 additions & 0 deletions pkg/manager/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ package manager

import (
"context"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
"github.com/redhat-developer/mapt/pkg/manager/credentials"
"github.com/redhat-developer/mapt/pkg/util"
"github.com/redhat-developer/mapt/pkg/util/logging"
)

var (
ErrInvalidBackedURLForTimeout = fmt.Errorf("timeout can action can not be set due to backed url pointing to local file. Please use external storage or remote timeout option")
)

// this function gets our stack ready for update/destroy by prepping the workspace, init/selecting the stack
// and doing a refresh to make sure state and cloud resources are in sync
func getStack(ctx context.Context, target Stack) auto.Stack {
Expand Down Expand Up @@ -51,3 +59,10 @@ func postStack(ctx context.Context, target Stack, stack *auto.Stack) (err error)
_, err = stack.Refresh(ctx)
return
}

func CheckBackedURLForServerless() error {
return util.If(
strings.HasPrefix(maptContext.BackedURL(), "file:///"),
ErrInvalidBackedURLForTimeout,
nil)
}
10 changes: 5 additions & 5 deletions pkg/provider/aws/action/eks/eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
infra "github.com/redhat-developer/mapt/pkg/provider"
"github.com/redhat-developer/mapt/pkg/provider/aws"
awsConstants "github.com/redhat-developer/mapt/pkg/provider/aws/constants"
"github.com/redhat-developer/mapt/pkg/provider/aws/data"
"github.com/redhat-developer/mapt/pkg/provider/aws/modules/allocation"
network "github.com/redhat-developer/mapt/pkg/provider/aws/modules/network/standard"
Expand All @@ -31,7 +32,6 @@ import (
"github.com/redhat-developer/mapt/pkg/util"
"github.com/redhat-developer/mapt/pkg/util/logging"
resourcesUtil "github.com/redhat-developer/mapt/pkg/util/resources"
awsConstants "github.com/redhat-developer/mapt/pkg/provider/aws/constants"
)

type EKSRequest struct {
Expand Down Expand Up @@ -82,15 +82,15 @@ func Create(ctx *maptContext.ContextArgs, r *EKSRequest) (err error) {
r.AvailabilityZones = data.GetAvailabilityZones(*r.AllocationData.Region)

cs := manager.Stack{
StackName: maptContext.StackNameByProject(stackName),
ProjectName: maptContext.ProjectName(),
BackedURL: maptContext.BackedURL(),
StackName: maptContext.StackNameByProject(stackName),
ProjectName: maptContext.ProjectName(),
BackedURL: maptContext.BackedURL(),
ProviderCredentials: aws.GetClouProviderCredentials(
map[string]string{
awsConstants.CONFIG_AWS_REGION: *r.AllocationData.Region,
awsConstants.CONFIG_AWS_NATIVE_REGION: *r.AllocationData.Region,
}),
DeployFunc: r.deployer,
DeployFunc: r.deployer,
}

sr, _ := manager.UpStack(cs)
Expand Down
15 changes: 2 additions & 13 deletions pkg/provider/aws/modules/serverless/serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@ import (
"github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/awsx"
awsxecs "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/redhat-developer/mapt/pkg/manager"
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
"github.com/redhat-developer/mapt/pkg/provider/aws/data"
"github.com/redhat-developer/mapt/pkg/util"

resourcesUtil "github.com/redhat-developer/mapt/pkg/util/resources"
)

var (
ErrInvalidBackedURLForTimeout = fmt.Errorf("timeout can action can not be set due to backed url pointing to local file. Please use external storage or remote timeout option")
)

func OneTimeDelayedTask(ctx *pulumi.Context,
region, prefix, componentID string,
cmd string,
delay string) error {
if err := checkBackedURLForServerless(); err != nil {
if err := manager.CheckBackedURLForServerless(); err != nil {
return err
}
se, err := generateOneTimeScheduleExpression(region, delay)
Expand All @@ -48,13 +44,6 @@ func OneTimeDelayedTask(ctx *pulumi.Context,
return r.deploy(ctx)
}

func checkBackedURLForServerless() error {
return util.If(
strings.HasPrefix(maptContext.BackedURL(), "file:///"),
ErrInvalidBackedURLForTimeout,
nil)
}

func (a *serverlessRequestArgs) deploy(ctx *pulumi.Context) error {
// Get the pre configured cluster to handle serverless exectucions
clusterArn, err := getClusterArn(ctx,
Expand Down
8 changes: 4 additions & 4 deletions pkg/provider/azure/action/aks/aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"encoding/base64"
"fmt"

"github.com/pulumi/pulumi-azure-native-sdk/authorization/v2"
"github.com/pulumi/pulumi-azure-native-sdk/authorization/v3"
containerservice "github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2/v20240801"
"github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
"github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v3"
"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
Expand Down Expand Up @@ -198,7 +198,7 @@ func (r *AKSRequest) deployer(ctx *pulumi.Context) error {
// grant the 'contributor' role to the identity on the resource group
_, err = authorization.NewRoleAssignment(ctx, "roleAssignment", &authorization.RoleAssignmentArgs{
PrincipalId: identity.PrincipalId,
PrincipalType: pulumi.String("ServicePrincipal"),
PrincipalType: pulumi.String(authorization.PrincipalTypeServicePrincipal),
RoleDefinitionId: pulumi.String("/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"),
Scope: rg.ID(),
})
Expand Down
3 changes: 2 additions & 1 deletion pkg/provider/azure/action/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package linux
import (
"fmt"

"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v3"
"github.com/pulumi/pulumi-command/sdk/go/command/remote"
"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
Expand Down Expand Up @@ -48,6 +48,7 @@ type LinuxRequest struct {
SpotExcludedRegions []string
GetUserdata func() (string, error)
ReadinessCommand string
Timeout string
}

func Create(ctx *maptContext.ContextArgs, r *LinuxRequest) (err error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/azure/action/rhel/rhel.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Request struct {
Spot bool
SpotTolerance spotAzure.EvictionRate
SpotExcludedRegions []string
Timeout string
}

func Create(ctx *maptContext.ContextArgs, r *Request) (err error) {
Expand Down
20 changes: 17 additions & 3 deletions pkg/provider/azure/action/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"strings"

"github.com/pulumi/pulumi-azure-native-sdk/compute/v2"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
"github.com/pulumi/pulumi-azure-native-sdk/storage/v2"
"github.com/pulumi/pulumi-azure-native-sdk/compute/v3"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v3"
"github.com/pulumi/pulumi-azure-native-sdk/storage/v3"
"github.com/pulumi/pulumi-command/sdk/go/command/remote"
"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
Expand All @@ -20,6 +20,7 @@ import (
"github.com/redhat-developer/mapt/pkg/provider/azure"
"github.com/redhat-developer/mapt/pkg/provider/azure/data"
"github.com/redhat-developer/mapt/pkg/provider/azure/module/network"
"github.com/redhat-developer/mapt/pkg/provider/azure/module/serverless"
virtualmachine "github.com/redhat-developer/mapt/pkg/provider/azure/module/virtual-machine"
"github.com/redhat-developer/mapt/pkg/provider/util/command"
"github.com/redhat-developer/mapt/pkg/provider/util/instancetypes"
Expand Down Expand Up @@ -49,6 +50,7 @@ type WindowsRequest struct {
SpotTolerance spotAzure.EvictionRate
SpotExcludedRegions []string
Profiles []string
Timeout string
}

type ghActionsRunnerData struct {
Expand Down Expand Up @@ -156,6 +158,18 @@ func (r *WindowsRequest) deployer(ctx *pulumi.Context) error {
}
ctx.Export(fmt.Sprintf("%s-%s", r.Prefix, outputAdminUsername), pulumi.String(r.AdminUsername))
ctx.Export(fmt.Sprintf("%s-%s", r.Prefix, outputAdminUserPassword), adminPasswd.Result)
// schedule destroy if Timeout is provided
if len(r.Timeout) > 0 {
if err = serverless.CreateScheduledJob(ctx, rg,
r.Prefix, azureWindowsDesktopID,
fmt.Sprintf("azure %s destroy --project-name %s --backed-url %s --serverless --force-destroy",
"windows",
maptContext.ProjectName(),
maptContext.BackedURL()),
r.Timeout); err != nil {
return err
}
}
// Setup machine on post init (may move too to virtual-machine pkg)
pk, vme, err := r.postInitSetup(ctx, rg, vm, *location)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/azure/module/network/network.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package network

import (
"github.com/pulumi/pulumi-azure-native-sdk/network/v2"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
"github.com/pulumi/pulumi-azure-native-sdk/network/v3"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
resourcesUtil "github.com/redhat-developer/mapt/pkg/util/resources"
Expand Down
Loading