This file contains hidden or 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
| def upsert_secret(path, value): | |
| settings.VAULT_CLIENT.secrets.kv.v2.create_or_update_secret( | |
| path=path, | |
| secret=value, | |
| mount_point=settings.VAULT_MOUNTPOINT | |
| ) | |
| def read_secret(path): | |
| return settings.VAULT_CLIENT.secrets.kv.v2.read_secret_version( |
This file contains hidden or 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
| import hvac | |
| VAULT_HOSTNAME = 'http://0.0.0.0' | |
| VAULT_PORT = 8200 | |
| VAULT_TOKEN = 'xxx' | |
| VAULT_CLIENT = hvac.Client( | |
| url=f'{VAULT_HOSTNAME}:{VAULT_PORT}', | |
| token=VAULT_TOKEN, |
This file contains hidden or 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 job | |
| import ( | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| func Job() (error) { | |
| resp, err := http.Get("http://example.com/api/v1/examples") | |
| if err != nil { |
This file contains hidden or 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 job | |
| type Job struct { | |
| client ApiClient | |
| } | |
| func NewJob(client ApiClient) FetchJob { | |
| return Job{client: client} | |
| } |
This file contains hidden or 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 yourpackage | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "net/http/httptest" | |
| "net/url" | |
| "testing" | |
| "time" |
This file contains hidden or 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 yourpackage | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| type ApiClient struct { | |
| protocol string |
This file contains hidden or 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 yourpackage | |
| import ( | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| func GetData() ([]byte, error) { | |
| resp, err := http.Get("http://example.com/api/v1/examples") | |
| if err != nil { |
This file contains hidden or 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 yourpackage | |
| import "testing" | |
| func setup(t *testing.T) { | |
| t.Log("setup") | |
| } | |
| func teardown(t *testing.T) { | |
| t.Log("teardown") |
This file contains hidden or 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
| kind: pipeline | |
| name: python27 | |
| steps: | |
| - name: test | |
| image: python:2.7-alpine3.9 | |
| commands: | |
| - pip install -e . | |
| - pip install -e .[tests] | |
| - pytest |
This file contains hidden or 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
| // a & b & c are exactly the same | |
| // a is shorthand written | |
| // b is the long version | |
| // c is the type infered version | |
| var a: [Int] = [1, 2, 3, 4, 5] | |
| var b: Array<Int> = [1, 2, 3, 4, 5] | |
| var c: = [1, 2, 3, 4, 5] | |
| var a: [String: Int] = ["a": 1, "b": 2] |