Skip to content

Commit

Permalink
update go and nodejs examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan committed Nov 26, 2024
1 parent 4768ffa commit b771e20
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 26 deletions.
17 changes: 12 additions & 5 deletions examples/go/kubernetes/main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package main

import (
"crypto/rand"
"encoding/base64"
"math/rand"
"os"
"strings"

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/threefoldtech/pulumi-threefold/sdk/go/threefold"
)

func randomString() string {
bytes := make([]byte, 8)
rand.Read(bytes)
return base64.URLEncoding.EncodeToString(bytes)[:8]
var alphabet []rune = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")

var sb strings.Builder

for i := 0; i < 8; i++ {
ch := alphabet[rand.Intn(len(alphabet))]
sb.WriteRune(ch)
}

return sb.String()
}

func main() {
Expand Down
18 changes: 13 additions & 5 deletions examples/go/network/main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package main

import (
"encoding/base64"
"os"
"strings"

"math/rand"

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/threefoldtech/pulumi-threefold/sdk/go/threefold"
"golang.org/x/exp/rand"
)

func randomString() string {
bytes := make([]byte, 8)
rand.Read(bytes)
return base64.URLEncoding.EncodeToString(bytes)[:8]
var alphabet []rune = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")

var sb strings.Builder

for i := 0; i < 8; i++ {
ch := alphabet[rand.Intn(len(alphabet))]
sb.WriteRune(ch)
}

return sb.String()
}

func main() {
Expand Down
17 changes: 12 additions & 5 deletions examples/go/virtual_machine/main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package main

import (
"crypto/rand"
"encoding/base64"
"math/rand"
"os"
"strings"

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/threefoldtech/pulumi-threefold/sdk/go/threefold"
)

func randomString() string {
bytes := make([]byte, 8)
rand.Read(bytes)
return base64.URLEncoding.EncodeToString(bytes)[:8]
var alphabet []rune = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")

var sb strings.Builder

for i := 0; i < 8; i++ {
ch := alphabet[rand.Intn(len(alphabet))]
sb.WriteRune(ch)
}

return sb.String()
}

func main() {
Expand Down
17 changes: 12 additions & 5 deletions examples/go/zdb/main.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
package main

import (
"crypto/rand"
"encoding/base64"
"fmt"
"math/rand"
"os"
"strings"

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/threefoldtech/pulumi-threefold/sdk/go/threefold"
)

func randomString() string {
bytes := make([]byte, 8)
rand.Read(bytes)
return base64.URLEncoding.EncodeToString(bytes)[:8]
var alphabet []rune = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")

var sb strings.Builder

for i := 0; i < 8; i++ {
ch := alphabet[rand.Intn(len(alphabet))]
sb.WriteRune(ch)
}

return sb.String()
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/gateway_fqdn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"@threefold/pulumi": "^0.7.2",
"@threefold/pulumi": "^0.8.1",
"typescript": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/nodejs/gateway_name/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"@threefold/pulumi": "^0.7.2",
"@threefold/pulumi": "^0.8.1",
"typescript": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/nodejs/kubernetes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"@threefold/pulumi": "^0.7.2",
"@threefold/pulumi": "^0.8.1",
"typescript": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/nodejs/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"@threefold/pulumi": "^0.7.2",
"@threefold/pulumi": "^0.8.1",
"typescript": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/nodejs/virtual_machine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"dependencies": {
"@pulumi/pulumi": "^3.131.0",
"@threefold/pulumi": "^0.7.2",
"@threefold/pulumi": "^0.8.1",
"typescript": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/nodejs/zdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"@threefold/pulumi": "^0.7.2",
"@threefold/pulumi": "^0.8.1",
"typescript": "^4.0.0"
}
}

0 comments on commit b771e20

Please sign in to comment.