This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Takes data from github and returns the value as string | |
func TakeDataFromgithub(URL string, FileName string) billy.File { | |
log.Printf(" Started to fetch data from Github") | |
fs := memfs.New() | |
//Authenticate and clone the repository | |
repo, err := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{ | |
URL: URL, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For reading files that are bytes | |
func ParseData(file billy.File) string { | |
log.Printf("%v Started to parse file data to string", APINAME) | |
buf := make([]byte, 1) | |
var data string | |
for { | |
n, err := file.Read(buf) | |
if err == io.EOF { | |
break | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main(){ | |
jsonBody := TakeDataFromgithub("https://"+GetEnv("UserName")+":"+GetEnv("GithubToken")+GetEnv("Path"), GetEnv("FileName2")) | |
} | |
// Takes data from github and returns the value as string | |
func TakeDataFromgithub(URL string, FileName string) string { | |
log.Printf("%v Started to fetch data from Github", APINAME) | |
fs := memfs.New() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controller | |
import ( | |
model "Read-From-Github/model" | |
"bytes" | |
"encoding/json" | |
"io" | |
"log" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model | |
type VMs struct { | |
Provider string `json:"provider,omitempty" ` //AWS , Azure: | |
ProjectID string `json:"projectId,omitempty"` //AWS: Account, Azure: Subscription | |
Location string `json:"location,omitempty"` //AWS: Region, Azure: Resporce Group | |
VMName string `json:"vmName,omitempty"` //Virtual Machine Name | |
VMStartAt string `json:"startsAt,omitempty"` //Virtual Machine start time | |
VMStopAt string `json:"stopsAt,omitempty"` //Virtual Machine stop time | |
Credential interface{} `json:"credential,omitempty"` //VirtualMachine's credential information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package routes | |
import ( | |
controller "Github/controller" | |
"github.com/gofiber/fiber/v2" | |
) | |
func VMRoute(app *fiber.App) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"Github/controller" | |
"Github/routes" | |
"log" | |
"github.com/gofiber/fiber/v2" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
type MyStruct struct { | |
Message string `json:"message"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VMware vRealize Orchestrator action sample | |
// vRA 8.8.0 | |
//input type : hostname [string] | |
//return type: VC:VirtualMachine | |
var vmSearch = VcPlugin.getAllVirtualMachines(null, hostname); | |
if (vmSearch.length > 1) { | |
for each (var vmObj in vmSearch) { | |
if (vmObj.summary.guest) { | |
System.log("Matched ## " + vmObj.summary.guest.hostName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VMware vRealize Orchestrator action sample | |
// vRA 8.7.0 | |
// input types: categoryPath [string] | |
configName [string] | |
// return type: ConfigurationElement | |
var category = Server.getConfigurationElementCategoryWithPath(categoryPath); | |
for each (var c in category.configurationElements){ | |
if (c.name == configName){ | |
return c; |
NewerOlder