Categorygithub.com/StackGuardian/sg-sdk-go
modulepackage
1.0.0
Repository: https://github.com/stackguardian/sg-sdk-go.git
Documentation: pkg.go.dev

# README

StackGuardian logo

StackGuardian SDK For Go (sg-sdk-go)

sg-sdk-go is the StackGuardian SDK for the Go Programming language.

The SG SDK requires a minimum version of Go 1.19.

Check out the notes in the release for information about the latest bug fixes, updates and features added to the SDK.

Getting started

It's recommended to store your API token and base URL in environment variables:

SG_BASE_URL (default: https://api.app.stackguardian.io)
SG_API_TOKEN

Install the SDK: To get started working with the SDK, setup your project for Go modules and retrieve the SDK dependencies using go get.

go get github.com/StackGuardian/[email protected]

Sample Usage

import (
	"context"
	"fmt"
	"os"

	sggosdk "github.com/StackGuardian/sg-sdk-go"
	client "github.com/StackGuardian/sg-sdk-go/client"
	option "github.com/StackGuardian/sg-sdk-go/option"
)

func main() {

	// Define the API key, base URL, org and workflow details
	API_KEY := "apikey " + os.Getenv("SG_API_TOKEN")
	SG_ORG := "demo-org"
	SG_WF_GROUP := "sg-sdk-go-test"
	SG_WF := "2aumphefkejtj3bv4q3wo"
	SG_BASE_URL := os.Getenv("SG_BASE_URL")

	// Create a new client using the API key and base URL
	c := client.NewClient(
		option.WithApiKey(API_KEY),
		option.WithBaseURL(SG_BASE_URL),
	)

	// Create a new WorkflowRun request
	createWorkflowRunRequest := sggosdk.WorkflowRun{
		DeploymentPlatformConfig: []*sggosdk.DeploymentPlatformConfig{{
			Kind: sggosdk.DeploymentPlatformConfigKindEnumAwsRbac,
			Config: map[string]interface{}{
				"profileName":   "testAWSConnector",
				"integrationId": "/integrations/testAWSConnector"}}},
		WfType: sggosdk.WfTypeEnumTerraform.Ptr(),
		EnvironmentVariables: []*sggosdk.EnvVars{{Kind: sggosdk.EnvVarsKindEnumPlainText,
			Config: &sggosdk.EnvVarConfig{VarName: "test", TextValue: sggosdk.String("testValue")}}},
		VcsConfig: &sggosdk.VcsConfig{
			IacVcsConfig: &sggosdk.IacvcsConfig{
				IacTemplateId:          sggosdk.String("/stackguardian/aws-s3-demo-website:16"),
				UseMarketplaceTemplate: true,
			},
			IacInputData: &sggosdk.IacInputData{
				SchemaType: sggosdk.IacInputDataSchemaTypeEnumFormJsonschema,
				Data: map[string]interface{}{
					"bucket_region": "eu-central-1",
				},
			},
		},
		UserJobCpu:    sggosdk.Int(512),
		UserJobMemory: sggosdk.Int(1024),
		RunnerConstraints: &sggosdk.RunnerConstraints{
			Type: "shared",
		},
	}

	// Create a new WorkflowRun using the client and request from above
	response, err := c.WorkflowRuns.CreateWorkflowRun(context.Background(),
		SG_ORG, SG_WF, SG_WF_GROUP, &createWorkflowRunRequest)
	if err != nil {
		fmt.Println(err)
	}
	// Get the resource name of the newly created WF run from the response
	var wfRunResourceName string = response.Data.GetExtraProperties()["ResourceName"].(string)

	// Get the status of the newly created WF run
	wfRunResponse, err := c.WorkflowRuns.ReadWorkflowRun(context.Background(), SG_ORG, SG_WF, SG_WF_GROUP, wfRunResourceName)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(wfRunResponse.Msg.Statuses["pre_0_step"][0].Name)

}

Reporting bugs

If you encounter a bug with the SG SDK for Go we would like to hear about it. Please search the existing issues and see if others are experiencing the same issue before opening a new one.

Please include the version of the SG SDK for Go, the Go version and the OS you are using along with steps to replicate the issue when appropriate.

# Packages

No description provided by the author
For creation of Cloud connector groups please refer to the documentation.
No description provided by the author
No description provided by the author
Organizations.
Policies.
Runner Groups.
Stacks.
Workflow Run Facts.
Stack Workflow Runs.
Stack Workflows.
Templates.
No description provided by the author
Users & Role.
Workflow Groups.
Workflow Run Facts.
Workflow Runs.
Workflows.

# Functions

Bool returns a pointer to the given bool value.
Byte returns a pointer to the given byte value.
Complex128 returns a pointer to the given complex128 value.
Complex64 returns a pointer to the given complex64 value.
Float32 returns a pointer to the given float32 value.
Float64 returns a pointer to the given float64 value.
Int returns a pointer to the given int value.
Int16 returns a pointer to the given int16 value.
Int32 returns a pointer to the given int32 value.
Int64 returns a pointer to the given int64 value.
Int8 returns a pointer to the given int8 value.
MustParseDate attempts to parse the given string as a date time.Time, and panics upon failure.
MustParseDateTime attempts to parse the given string as a datetime time.Time, and panics upon failure.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Null initializes an optional field that will be sent as an explicit null value.
Optional initializes an optional field.
Rune returns a pointer to the given rune value.
String returns a pointer to the given string value.
Time returns a pointer to the given time.Time value.
Uint returns a pointer to the given uint value.
Uint16 returns a pointer to the given uint16 value.
Uint32 returns a pointer to the given uint32 value.
Uint64 returns a pointer to the given uint64 value.
Uint8 returns a pointer to the given uint8 value.
Uintptr returns a pointer to the given uintptr value.
UUID returns a pointer to the given uuid.UUID value.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

Environments defines all of the API environments.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

- `apply` - apply - `destroy` - destroy - `plan` - plan - `plan-destroy` - plan-destroy - `plan-without-policy` - plan-without-policy - `refresh` - refresh.
- `apply` - apply - `destroy` - destroy.
- `GITHUB_COM` - GITHUB_COM - `GITHUB_APP_CUSTOM` - GITHUB_APP_CUSTOM - `GIT_OTHER` - GIT_OTHER - `INLINE` - INLINE - `BITBUCKET_ORG` - BITBUCKET_ORG - `GITLAB_COM` - GITLAB_COM - `AZURE_DEVOPS` - AZURE_DEVOPS.
- `GITHUB_COM` - GITHUB_COM - `GITHUB_APP_CUSTOM` - GITHUB_APP_CUSTOM - `GIT_OTHER` - GIT_OTHER - `BITBUCKET_ORG` - BITBUCKET_ORG - `GITLAB_COM` - GITLAB_COM - `AZURE_DEVOPS` - AZURE_DEVOPS.
- `AWS_STATIC` - AWS_STATIC - `AWS_RBAC` - AWS_RBAC - `AWS_OIDC` - AWS_OIDC - `AZURE_STATIC` - AZURE_STATIC - `AZURE_OIDC` - AZURE_OIDC - `GCP_STATIC` - GCP_STATIC - `GCP_OIDC` - GCP_OIDC.
- `EMAIL` - EMAIL - `GROUP` - GROUP.
- `PLAIN_TEXT` - PLAIN_TEXT - `VAULT_SECRET` - VAULT_SECRET.
- `FORM_JSONSCHEMA` - FORM_JSONSCHEMA - `RAW_HCL` - RAW_HCL - `RAW_JSON` - RAW_JSON - `NONE` - NONE.
- `FORM_JSONSCHEMA` - FORM_JSONSCHEMA - `RAW_JSON` - RAW_JSON - `TIRITH_JSON` - TIRITH_JSON - `NONE` - NONE.
- `FORM_JSONSCHEMA` - FORM_JSONSCHEMA - `RAW_JSON` - RAW_JSON - `TIRITH_JSON` - TIRITH_JSON.
- `0` - 0 - `1` - 1.
No description provided by the author
- `FAIL` - FAIL - `WARN` - WARN - `PASS` - PASS - `APPROVAL_REQUIRED` - APPROVAL_REQUIRED.
- `FAIL` - FAIL - `WARN` - WARN - `PASS` - PASS - `APPROVAL_REQUIRED` - APPROVAL_REQUIRED.
- `PULL_PUSH` - PULL_PUSH - `PULL` - PULL - `PUSH` - PUSH.
No description provided by the author
- `private` - private - `shared` - shared.
- `GITHUB_COM` - GITHUB_COM - `GITHUB_APP_CUSTOM` - GITHUB_APP_CUSTOM - `GIT_OTHER` - GIT_OTHER - `BITBUCKET_ORG` - BITBUCKET_ORG - `GITLAB_COM` - GITLAB_COM - `AZURE_DEVOPS` - AZURE_DEVOPS - `INLINE` - INLINE - `EXTERNAL` - EXTERNAL - `CONTAINER_REGISTRY` - CONTAINER_REGISTRY.
- `GITHUB_COM` - GITHUB_COM - `GITHUB_APP_CUSTOM` - GITHUB_APP_CUSTOM - `AWS_STATIC` - AWS_STATIC - `GCP_STATIC` - GCP_STATIC - `GCP_OIDC` - GCP_OIDC - `AWS_RBAC` - AWS_RBAC - `AWS_OIDC` - AWS_OIDC - `AZURE_STATIC` - AZURE_STATIC - `AZURE_OIDC` - AZURE_OIDC - `BITBUCKET_ORG` - BITBUCKET_ORG - `GITLAB_COM` - GITLAB_COM - `AZURE_DEVOPS` - AZURE_DEVOPS.
- `OPA_REGO` - OPA_REGO - `SG_POLICY_FRAMEWORK` - SG_POLICY_FRAMEWORK.
- `ENABLED` - ENABLED - `DISABLED` - DISABLED.
- `ACTIVE` - ACTIVE - `DRAINING` - DRAINING.
- `IAC` - IAC - `IAC_GROUP` - IAC_GROUP - `WORKFLOW_STEP` - WORKFLOW_STEP - `IAC_POLICY` - IAC_POLICY - `WORKFLOW_STEP_POLICY` - WORKFLOW_STEP_POLICY - `REACTIVE_POLICY` - REACTIVE_POLICY.
- `GITHUB_COM` - GITHUB_COM - `GITHUB_APP_CUSTOM` - GITHUB_APP_CUSTOM - `GITLAB_OAUTH_SSH` - GITLAB_OAUTH_SSH - `BITBUCKET_ORG` - BITBUCKET_ORG - `GITLAB_COM` - GITLAB_COM - `AZURE_DEVOPS` - AZURE_DEVOPS.
- `FORM_JSONSCHEMA` - FORM_JSONSCHEMA.
- `TERRAFORM` - TERRAFORM - `CUSTOM` - CUSTOM.