diff --git a/docs/sdks/languages/go.mdx b/docs/sdks/languages/go.mdx index 18fabf64e..834a759a2 100644 --- a/docs/sdks/languages/go.mdx +++ b/docs/sdks/languages/go.mdx @@ -4,8 +4,6 @@ sidebarTitle: "Go" icon: "golang" --- - - If you're working with Go Lang, the official [Infisical Go SDK](https://github.com/infisical/go-sdk) package is the easiest way to fetch and work with secrets for your application. - [Package](https://pkg.go.dev/github.com/infisical/go-sdk) @@ -57,7 +55,9 @@ func main() { This example demonstrates how to use the Infisical Go SDK in a simple Go application. The application retrieves a secret named `API_KEY` from the `dev` environment of the `YOUR_PROJECT_ID` project. - We do not recommend hardcoding your [Machine Identity Tokens](/platform/identities/overview). Setting it as an environment variable would be best. + We do not recommend hardcoding your [Machine Identity + Tokens](/platform/identities/overview). Setting it as an environment variable + would be best. # Installation @@ -95,6 +95,10 @@ client := infisical.NewInfisicalClient(context.Background(), infisical.Config{ Whether or not to suppress logs such as warnings from the token refreshing process. Defaults to false if not specified. + + + Defines how long certain responses should be cached in memory, in seconds. When set to a positive value, responses from specific methods (like secret fetching) will be cached for this duration. Set to 0 to disable caching. + @@ -140,6 +144,7 @@ Call `.Auth().UniversalAuthLogin()` with empty arguments to use the following en - `INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET` - Your machine identity client secret. **Using the SDK directly** + ```go _, err := client.Auth().UniversalAuthLogin("CLIENT_ID", "CLIENT_SECRET") @@ -150,9 +155,12 @@ if err != nil { ``` #### GCP ID Token Auth + - Please note that this authentication method will only work if you're running your application on Google Cloud Platform. - Please [read more](/documentation/platform/identities/gcp-auth) about this authentication method. + Please note that this authentication method will only work if you're running + your application on Google Cloud Platform. Please [read + more](/documentation/platform/identities/gcp-auth) about this authentication + method. **Using environment variables** @@ -162,6 +170,7 @@ Call `.Auth().GcpIdTokenAuthLogin()` with empty arguments to use the following e - `INFISICAL_GCP_AUTH_IDENTITY_ID` - Your Infisical Machine Identity ID. **Using the SDK directly** + ```go _, err := client.Auth().GcpIdTokenAuthLogin("YOUR_MACHINE_IDENTITY_ID") @@ -181,6 +190,7 @@ Call `.Auth().GcpIamAuthLogin()` with empty arguments to use the following envir - `INFISICAL_GCP_IAM_SERVICE_ACCOUNT_KEY_FILE_PATH` - The path to your GCP service account key file. **Using the SDK directly** + ```go _, err = client.Auth().GcpIamAuthLogin("MACHINE_IDENTITY_ID", "SERVICE_ACCOUNT_KEY_FILE_PATH") @@ -191,9 +201,12 @@ if err != nil { ``` #### AWS IAM Auth + - Please note that this authentication method will only work if you're running your application on AWS. - Please [read more](/documentation/platform/identities/aws-auth) about this authentication method. + Please note that this authentication method will only work if you're running + your application on AWS. Please [read + more](/documentation/platform/identities/aws-auth) about this authentication + method. **Using environment variables** @@ -203,6 +216,7 @@ Call `.Auth().AwsIamAuthLogin()` with empty arguments to use the following envir - `INFISICAL_AWS_IAM_AUTH_IDENTITY_ID` - Your Infisical Machine Identity ID. **Using the SDK directly** + ```go _, err = client.Auth().AwsIamAuthLogin("MACHINE_IDENTITY_ID") @@ -212,11 +226,13 @@ if err != nil { } ``` - #### Azure Auth + - Please note that this authentication method will only work if you're running your application on Azure. - Please [read more](/documentation/platform/identities/azure-auth) about this authentication method. + Please note that this authentication method will only work if you're running + your application on Azure. Please [read + more](/documentation/platform/identities/azure-auth) about this authentication + method. **Using environment variables** @@ -226,6 +242,7 @@ Call `.Auth().AzureAuthLogin()` with empty arguments to use the following enviro - `INFISICAL_AZURE_AUTH_IDENTITY_ID` - Your Infisical Machine Identity ID. **Using the SDK directly** + ```go _, err = client.Auth().AzureAuthLogin("MACHINE_IDENTITY_ID") @@ -236,9 +253,12 @@ if err != nil { ``` #### Kubernetes Auth + - Please note that this authentication method will only work if you're running your application on Kubernetes. - Please [read more](/documentation/platform/identities/kubernetes-auth) about this authentication method. + Please note that this authentication method will only work if you're running + your application on Kubernetes. Please [read + more](/documentation/platform/identities/kubernetes-auth) about this + authentication method. **Using environment variables** @@ -249,6 +269,7 @@ Call `.Auth().KubernetesAuthLogin()` with empty arguments to use the following e - `INFISICAL_KUBERNETES_SERVICE_ACCOUNT_TOKEN_PATH_ENV_NAME` - The environment variable name that contains the path to the service account token. This is optional and will default to `/var/run/secrets/kubernetes.io/serviceaccount/token`. **Using the SDK directly** + ```go // Service account token path will default to /var/run/secrets/kubernetes.io/serviceaccount/token if empty value is passed _, err = client.Auth().KubernetesAuthLogin("MACHINE_IDENTITY_ID", "SERVICE_ACCOUNT_TOKEN_PATH") @@ -262,6 +283,7 @@ if err != nil { ## Working With Secrets ### List Secrets + `client.Secrets().List(options)` Retrieve all secrets within the Infisical project and environment that client is connected to. @@ -311,7 +333,9 @@ secrets, err := client.Secrets().List(infisical.ListSecretsOptions{ ### + ### Retrieve Secret + `client.Secrets().Retrieve(options)` Retrieve a secret from Infisical. By default `Secrets().Retrieve()` fetches and returns a shared secret. @@ -327,27 +351,31 @@ secret, err := client.Secrets().Retrieve(infisical.RetrieveSecretOptions{ ### Parameters - - - The key of the secret to retrieve. - - - The project ID where the secret lives in. - - - The slug name (dev, prod, etc) of the environment from where secrets should be fetched from. - - - The path from where secret should be fetched from. - - - The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared". - - + + + The key of the secret to retrieve. + + + The project ID where the secret lives in. + + + The slug name (dev, prod, etc) of the environment from where secrets + should be fetched from. + + + The path from where secret should be fetched from. + + + The type of the secret. Valid options are "shared" or "personal". If not + specified, the default value is "shared". + + ### + ### Create Secret + `client.Secrets().Create(options)` Create a new secret in Infisical. @@ -363,36 +391,38 @@ secret, err := client.Secrets().Create(infisical.CreateSecretOptions{ }) ``` - ### Parameters - - - The key of the secret to create. - - - The value of the secret. - - - A comment for the secret. - - - The project ID where the secret lives in. - - - The slug name (dev, prod, etc) of the environment from where secrets should be fetched from. - - - The path from where secret should be created. - - - The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared". - - + + + The key of the secret to create. + + + The value of the secret. + + + A comment for the secret. + + + The project ID where the secret lives in. + + + The slug name (dev, prod, etc) of the environment from where secrets + should be fetched from. + + + The path from where secret should be created. + + + The type of the secret. Valid options are "shared" or "personal". If not + specified, the default value is "shared". + + ### + ### Update Secret `client.Secrets().Update(options)` @@ -412,33 +442,42 @@ secret, err := client.Secrets().Update(infisical.UpdateSecretOptions{ ### Parameters - - - The key of the secret to update. - - - The new value of the secret. - - - Whether or not to skip multiline encoding for the new secret value. - - - The project ID where the secret lives in. - - - The slug name (dev, prod, etc) of the environment from where secrets should be fetched from. - - - The path from where secret should be updated. - - - The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared". - - + + + The key of the secret to update. + + + The new value of the secret. + + + Whether or not to skip multiline encoding for the new secret value. + + + The project ID where the secret lives in. + + + The slug name (dev, prod, etc) of the environment from where secrets + should be fetched from. + + + The path from where secret should be updated. + + + The type of the secret. Valid options are "shared" or "personal". If not + specified, the default value is "shared". + + ### + ### Delete Secret + `client.Secrets().Delete(options)` Delete a secret in Infisical. @@ -454,30 +493,33 @@ secret, err := client.Secrets().Delete(infisical.DeleteSecretOptions{ ### Parameters - - - The key of the secret to update. - - - The project ID where the secret lives in. - - - The slug name (dev, prod, etc) of the environment from where secrets should be fetched from. - - - The path from where secret should be deleted. - - - The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared". - - + + + The key of the secret to update. + + + The project ID where the secret lives in. + + + The slug name (dev, prod, etc) of the environment from where secrets + should be fetched from. + + + The path from where secret should be deleted. + + + The type of the secret. Valid options are "shared" or "personal". If not + specified, the default value is "shared". + + ## Working With folders - ### + ### List Folders + `client.Folders().List(options)` Retrieve all within the Infisical project and environment that client is connected to. @@ -510,7 +552,9 @@ folders, err := client.Folders().List(infisical.ListFoldersOptions{ ### + ### Create Folder + `client.Folders().Create(options)` Create a new folder in Infisical. @@ -527,25 +571,27 @@ folder, err := client.Folders().Create(infisical.CreateFolderOptions{ ### Parameters - - - The ID of the project where the folder will be created. - - - The slug name (dev, prod, etc) of the environment where the folder will be created. - - - The path to create the folder in. The root path is `/`. - - - The name of the folder to create. - - + + + The ID of the project where the folder will be created. + + + The slug name (dev, prod, etc) of the environment where the folder will be + created. + + + The path to create the folder in. The root path is `/`. + + + The name of the folder to create. + + - ### + ### Update Folder + `client.Folders().Update(options)` Update an existing folder in Infisical. @@ -563,27 +609,30 @@ folder, err := client.Folders().Update(infisical.UpdateFolderOptions{ ### Parameters - - - The ID of the project where the folder will be updated. - - - The slug name (dev, prod, etc) of the environment from where the folder lives in. - - - The path from where the folder should be updated. - - - The ID of the folder to update. - - - The new name of the folder. - - + + + The ID of the project where the folder will be updated. + + + The slug name (dev, prod, etc) of the environment from where the folder + lives in. + + + The path from where the folder should be updated. + + + The ID of the folder to update. + + + The new name of the folder. + + ### + ### Delete Folder + `client.Folders().Delete(options)` Delete a folder in Infisical. @@ -620,6 +669,5 @@ deletedFolder, err := client.Folders().Delete(infisical.DeleteFolderOptions{ The path from where the folder should be deleted. + - -