From 75158065ec1a4baa5ef1fff375fc628d4f11939e Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Fri, 10 Jan 2020 12:45:17 -0500 Subject: [PATCH 1/8] Update test to use newer field names. Remove obsolete test invalidated by #4798. Properly handle case where an error was expected and didn't occur. --- builtin/credential/okta/backend_test.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/builtin/credential/okta/backend_test.go b/builtin/credential/okta/backend_test.go index 1a32a86dfb682..e40962298e042 100644 --- a/builtin/credential/okta/backend_test.go +++ b/builtin/credential/okta/backend_test.go @@ -36,24 +36,23 @@ func TestBackend_Config(t *testing.T) { token := os.Getenv("OKTA_API_TOKEN") configData := map[string]interface{}{ - "organization": os.Getenv("OKTA_ORG"), - "base_url": "oktapreview.com", + "org_name": os.Getenv("OKTA_ORG"), + "base_url": "oktapreview.com", } updatedDuration := time.Hour * 1 configDataToken := map[string]interface{}{ - "token": token, - "ttl": "1h", + "api_token": token, + "token_ttl": "1h", } logicaltest.Test(t, logicaltest.TestCase{ - AcceptanceTest: true, - PreCheck: func() { testAccPreCheck(t) }, - LogicalBackend: b, + AcceptanceTest: true, + PreCheck: func() { testAccPreCheck(t) }, + CredentialBackend: b, Steps: []logicaltest.TestStep{ testConfigCreate(t, configData), testLoginWrite(t, username, "wrong", "E0000004", 0, nil), - testLoginWrite(t, username, password, "user is not a member of any authorized policy", 0, nil), testAccUserGroups(t, username, "local_grouP,lOcal_group2", []string{"user_policy"}), testAccGroups(t, "local_groUp", "loCal_group_policy"), testLoginWrite(t, username, password, "", defaultLeaseTTLVal, []string{"local_group_policy", "user_policy"}), @@ -81,6 +80,9 @@ func testLoginWrite(t *testing.T, username, password, reason string, expectedTTL if reason == "" || !strings.Contains(resp.Error().Error(), reason) { return resp.Error() } + } else if reason != "" { + return fmt.Errorf("expected error containing %q, got no error", reason) + } if resp.Auth != nil { @@ -124,7 +126,7 @@ func testConfigRead(t *testing.T, token string, d map[string]interface{}) logica return resp.Error() } - if resp.Data["organization"] != d["organization"] { + if resp.Data["org_name"] != d["org_name"] { return fmt.Errorf("org mismatch expected %s but got %s", d["organization"], resp.Data["Org"]) } From 0dbb81cf4754b4e9735fb3d42ffdd05212bcf42b Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Mon, 13 Jan 2020 09:51:44 -0500 Subject: [PATCH 2/8] Upgrade to new official Okta sdk lib. Unfortunately it doesn't support logging in without an API token, so using my fork of it while waiting to see if they accept a PR. --- api/go.sum | 1 + builtin/credential/okta/backend.go | 33 +++++++++++---------- builtin/credential/okta/backend_test.go | 20 ++++++++++--- builtin/credential/okta/path_config.go | 39 +++++++++++++++++++++---- go.mod | 7 +++-- go.sum | 12 ++++++-- sdk/go.mod | 1 + 7 files changed, 84 insertions(+), 29 deletions(-) diff --git a/api/go.sum b/api/go.sum index 24a91133430ab..b85da99ce0ffd 100644 --- a/api/go.sum +++ b/api/go.sum @@ -48,6 +48,7 @@ github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0S github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= diff --git a/builtin/credential/okta/backend.go b/builtin/credential/okta/backend.go index 8b75d1097cc64..5b40578bb1dc1 100644 --- a/builtin/credential/okta/backend.go +++ b/builtin/credential/okta/backend.go @@ -5,11 +5,11 @@ import ( "fmt" "time" - "github.com/chrismalek/oktasdk-go/okta" "github.com/hashicorp/vault/helper/mfa" "github.com/hashicorp/vault/sdk/framework" "github.com/hashicorp/vault/sdk/helper/cidrutil" "github.com/hashicorp/vault/sdk/logical" + "github.com/okta/okta-sdk-golang/okta" ) func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) { @@ -77,7 +77,10 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri } } - client := cfg.OktaClient() + client, reqExec, err := cfg.OktaClient() + if err != nil { + return nil, nil, nil, err + } type mfaFactor struct { Id string `json:"id"` @@ -97,7 +100,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri StateToken string `json:"stateToken"` } - authReq, err := client.NewRequest("POST", "authn", map[string]interface{}{ + authReq, err := reqExec.NewRequest("POST", "/api/v1/authn", map[string]interface{}{ "username": username, "password": password, }) @@ -106,8 +109,11 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri } var result authResult - rsp, err := client.Do(authReq, &result) + rsp, err := reqExec.Do(authReq, &result) if err != nil { + if oe, ok := err.(*okta.Error); ok { + return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed: %v (code=%v)", err, oe.ErrorCode)), nil, nil + } return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed: %v", err)), nil, nil } if rsp == nil { @@ -178,12 +184,12 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri payload := map[string]interface{}{ "stateToken": result.StateToken, } - verifyReq, err := client.NewRequest("POST", requestPath, payload) + verifyReq, err := reqExec.NewRequest("POST", requestPath, payload) if err != nil { return nil, nil, nil, err } - rsp, err := client.Do(verifyReq, &result) + rsp, err := reqExec.Do(verifyReq, &result) if err != nil { return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed: %v", err)), nil, nil } @@ -193,11 +199,11 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri for result.Status == "MFA_CHALLENGE" { switch result.FactorResult { case "WAITING": - verifyReq, err := client.NewRequest("POST", requestPath, payload) + verifyReq, err := reqExec.NewRequest("POST", requestPath, payload) if err != nil { return nil, logical.ErrorResponse(fmt.Sprintf("okta auth failed creating verify request: %v", err)), nil, nil } - rsp, err := client.Do(verifyReq, &result) + rsp, err := reqExec.Do(verifyReq, &result) if err != nil { return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed checking loop: %v", err)), nil, nil } @@ -252,7 +258,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri var allGroups []string // Only query the Okta API for group membership if we have a token - if cfg.Token != "" { + if client != nil { oktaGroups, err := b.getOktaGroups(client, &result.Embedded.User) if err != nil { return nil, logical.ErrorResponse(fmt.Sprintf("okta failure retrieving groups: %v", err)), nil, nil @@ -302,15 +308,12 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri } func (b *backend) getOktaGroups(client *okta.Client, user *okta.User) ([]string, error) { - rsp, err := client.Users.PopulateGroups(user) + groups, _, err := client.User.ListUserGroups(user.Id, nil) if err != nil { return nil, err } - if rsp == nil { - return nil, fmt.Errorf("okta auth method unexpected failure") - } - oktaGroups := make([]string, 0, len(user.Groups)) - for _, group := range user.Groups { + oktaGroups := make([]string, 0, len(groups)) + for _, group := range groups { oktaGroups = append(oktaGroups, group.Profile.Name) } if b.Logger().IsDebug() { diff --git a/builtin/credential/okta/backend_test.go b/builtin/credential/okta/backend_test.go index e40962298e042..9a6b20d9e130f 100644 --- a/builtin/credential/okta/backend_test.go +++ b/builtin/credential/okta/backend_test.go @@ -6,14 +6,12 @@ import ( "os" "strings" "testing" + "time" log "github.com/hashicorp/go-hclog" + logicaltest "github.com/hashicorp/vault/helper/testhelpers/logical" "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/helper/policyutil" - - "time" - - logicaltest "github.com/hashicorp/vault/helper/testhelpers/logical" "github.com/hashicorp/vault/sdk/logical" ) @@ -52,14 +50,28 @@ func TestBackend_Config(t *testing.T) { CredentialBackend: b, Steps: []logicaltest.TestStep{ testConfigCreate(t, configData), + // 2. Login with bad password, expect failure (E0000004=okta auth failure). testLoginWrite(t, username, "wrong", "E0000004", 0, nil), + // 3. Make our user belong to two groups and have one user-specific policy. testAccUserGroups(t, username, "local_grouP,lOcal_group2", []string{"user_policy"}), + // 4. Create the group local_group, assign it a single policy. testAccGroups(t, "local_groUp", "loCal_group_policy"), + // 5. Login with good password, expect user to have their user-specific + // policy and the policy of the one valid group they belong to. testLoginWrite(t, username, password, "", defaultLeaseTTLVal, []string{"local_group_policy", "user_policy"}), + // 6. Create the group everyone, assign it two policies. This is a + // magic group name in okta that always exists and which every + // user automatically belongs to. testAccGroups(t, "everyoNe", "everyone_grouP_policy,eveRy_group_policy2"), + // 7. Login as before, expect same result testLoginWrite(t, username, password, "", defaultLeaseTTLVal, []string{"local_group_policy", "user_policy"}), + // 8. Add API token so we can lookup groups testConfigUpdate(t, configDataToken), testConfigRead(t, token, configData), + // 10. Login should now lookup okta groups; since all okta users are + // in the "everyone" group, that should be returned; since we + // defined policies attached to the everyone group, we should now + // see those policies attached to returned vault token. testLoginWrite(t, username, password, "", updatedDuration, []string{"everyone_group_policy", "every_group_policy2", "local_group_policy", "user_policy"}), testAccGroups(t, "locAl_group2", "testgroup_group_policy"), testLoginWrite(t, username, password, "", updatedDuration, []string{"everyone_group_policy", "every_group_policy2", "local_group_policy", "testgroup_group_policy", "user_policy"}), diff --git a/builtin/credential/okta/path_config.go b/builtin/credential/okta/path_config.go index 5c5dd3a68cf55..5e5dc9f7294e5 100644 --- a/builtin/credential/okta/path_config.go +++ b/builtin/credential/okta/path_config.go @@ -4,14 +4,12 @@ import ( "context" "fmt" "net/url" - "time" - "github.com/chrismalek/oktasdk-go/okta" - cleanhttp "github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/vault/sdk/framework" "github.com/hashicorp/vault/sdk/helper/tokenutil" "github.com/hashicorp/vault/sdk/logical" + okta "github.com/okta/okta-sdk-golang/okta" ) const ( @@ -267,7 +265,7 @@ func (b *backend) pathConfigExistenceCheck(ctx context.Context, req *logical.Req } // OktaClient creates a basic okta client connection -func (c *ConfigEntry) OktaClient() *okta.Client { +func (c *ConfigEntry) OktaClient() (*okta.Client, *okta.RequestExecutor, error) { baseURL := defaultBaseURL if c.Production != nil { if !*c.Production { @@ -278,9 +276,38 @@ func (c *ConfigEntry) OktaClient() *okta.Client { baseURL = c.BaseURL } + oktaURL := "https://" + c.Org + "." + baseURL // We validate config on input and errors are only returned when parsing URLs - client, _ := okta.NewClientWithDomain(cleanhttp.DefaultClient(), c.Org, baseURL, c.Token) - return client + conf := []okta.ConfigSetter{okta.WithOrgUrl(oktaURL)} + if c.Token != "" { + conf = append(conf, okta.WithToken(c.Token)) + client, err := okta.NewClient(context.Background(), conf...) + if err != nil { + return nil, nil, err + } + return client, client.GetRequestExecutor(), nil + } + + conf = append(conf, okta.WithConnectionTimeout(30), + okta.WithCache(true), + okta.WithCacheTtl(300), + okta.WithCacheTti(300), + okta.WithUserAgentExtra("")) + + config, err := okta.NewConfig(conf...) + if err != nil { + return nil, nil, err + } + err = okta.ValidateOktaDomain(config) + if err != nil { + return nil, nil, err + } + cache, err := okta.NewCache(config) + if err != nil { + return nil, nil, err + } + + return nil, okta.NewRequestExecutor(&config.HttpClient, cache, config), nil } // ConfigEntry for Okta diff --git a/go.mod b/go.mod index c1b814ecd0df8..b1924b5310d88 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,8 @@ replace github.com/hashicorp/vault/api => ./api replace github.com/hashicorp/vault/sdk => ./sdk +replace github.com/okta/okta-sdk-golang => github.com/ncabatoff/okta-sdk-golang v1.0.2-0.20200113143729-b3ae90a98438 + require ( cloud.google.com/go v0.39.0 github.com/Azure/azure-sdk-for-go v29.0.0+incompatible @@ -24,7 +26,6 @@ require ( github.com/aws/aws-sdk-go v1.25.41 github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect - github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0 github.com/cockroachdb/apd v1.1.0 // indirect github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c github.com/coreos/go-semver v0.2.0 @@ -62,7 +63,8 @@ require ( github.com/hashicorp/go-rootcerts v1.0.1 github.com/hashicorp/go-sockaddr v1.0.2 github.com/hashicorp/go-syslog v1.0.0 - github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8 + github.com/hashicorp/go-uuid v1.0.2 + github.com/hashicorp/gokrb5 v7.3.1-0.20191209171754-1a6fa9886ec3+incompatible github.com/hashicorp/golang-lru v0.5.3 github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/nomad/api v0.0.0-20190412184103-1c38ced33adf @@ -109,6 +111,7 @@ require ( github.com/ncw/swift v1.0.47 github.com/nwaples/rardecode v1.0.0 // indirect github.com/oklog/run v1.0.0 + github.com/okta/okta-sdk-golang v1.0.1 github.com/oracle/oci-go-sdk v7.0.0+incompatible github.com/ory/dockertest v3.3.5+incompatible github.com/patrickmn/go-cache v2.1.0+incompatible diff --git a/go.sum b/go.sum index 21961d4da1045..da5b52a8a5e82 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.0 h1:LzQXZOgg4CQfE6bFvXG github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f h1:gJzxrodnNd/CtPXjO3WYiakyNzHg3rtAi7rO74ejHYU= github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE= -github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0 h1:CWU8piLyqoi9qXEUwzOh5KFKGgmSU5ZhktJyYcq6ryQ= -github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0/go.mod h1:5d8DqS60xkj9k3aXfL3+mXBH0DPYO0FQjcKosxl+b/Q= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj7ug5D7I/orNUA= @@ -194,6 +192,8 @@ github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31 h1:28FVBuwkwowZMjbA github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o= +github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df h1:fwXmhM0OqixzJDOGgTSyNH9eEDij9uGTXwsyWXvyR0A= github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM= @@ -334,6 +334,8 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8 h1:PKbxRbsOP7R3f/TpdqcgXrO69T3yd9nLoR+RMRUxSxA= github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= @@ -413,6 +415,7 @@ github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGU github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= github.com/jackc/pgx v3.3.0+incompatible h1:Wa90/+qsITBAPkAZjiByeIGHFcj3Ztu+VzrrIpHjL90= github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= +github.com/jarcoal/httpmock v1.0.4/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jeffchao/backoff v0.0.0-20140404060208-9d7fd7aa17f2 h1:mex1izRBCD+7WjieGgRdy7e651vD/lvB1bD9vNE/3K4= @@ -437,6 +440,8 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM= +github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f h1:Gsc9mVHLRqBjMgdQCghN9NObCcRncDqxJvBvEaIIQEo= github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -514,6 +519,8 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/ncabatoff/okta-sdk-golang v1.0.2-0.20200113143729-b3ae90a98438 h1:6YwWNKjkGAwq2r1h5zBPEwN/IbF8pZxyVFn+c1C5ULw= +github.com/ncabatoff/okta-sdk-golang v1.0.2-0.20200113143729-b3ae90a98438/go.mod h1:/XIqyXYm5Mht0ksFDgBJOvJOoTiII7uk8QMbsPfURME= github.com/ncw/swift v1.0.47 h1:4DQRPj35Y41WogBxyhOXlrI37nzGlyEcsforeudyYPQ= github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs= @@ -553,6 +560,7 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v0.0.0-20180815053127-5633e0862627/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= diff --git a/sdk/go.mod b/sdk/go.mod index 5589866850435..e3ccf6a030317 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -30,6 +30,7 @@ require ( golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect golang.org/x/sys v0.0.0-20191008105621-543471e840be golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db // indirect + google.golang.org/appengine v1.4.0 // indirect google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 // indirect google.golang.org/grpc v1.22.0 ) From 7e97157ff43b91437886474c5468ee876d5ead12 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Mon, 13 Jan 2020 09:57:06 -0500 Subject: [PATCH 3/8] go mod vendor --- .../chrismalek/oktasdk-go/okta/apps.go | 315 -- .../chrismalek/oktasdk-go/okta/factors.go | 8 - .../chrismalek/oktasdk-go/okta/groups.go | 359 --- .../chrismalek/oktasdk-go/okta/sdk.go | 523 ---- .../chrismalek/oktasdk-go/okta/users.go | 625 ---- .../go-cfclient/gen_error.go | 115 + .../compress/bzip2/internal/sais/sais_gen.go | 703 +++++ vendor/github.com/go-yaml/yaml/.travis.yml | 12 + vendor/github.com/go-yaml/yaml/LICENSE | 201 ++ .../github.com/go-yaml/yaml/LICENSE.libyaml | 31 + vendor/github.com/go-yaml/yaml/NOTICE | 13 + vendor/github.com/go-yaml/yaml/README.md | 135 + vendor/github.com/go-yaml/yaml/apic.go | 739 +++++ vendor/github.com/go-yaml/yaml/decode.go | 764 +++++ vendor/github.com/go-yaml/yaml/emitterc.go | 1685 ++++++++++ vendor/github.com/go-yaml/yaml/encode.go | 358 +++ vendor/github.com/go-yaml/yaml/parserc.go | 1095 +++++++ vendor/github.com/go-yaml/yaml/readerc.go | 394 +++ vendor/github.com/go-yaml/yaml/resolve.go | 245 ++ vendor/github.com/go-yaml/yaml/scannerc.go | 2702 +++++++++++++++++ vendor/github.com/go-yaml/yaml/sorter.go | 104 + vendor/github.com/go-yaml/yaml/writerc.go | 26 + vendor/github.com/go-yaml/yaml/yaml.go | 466 +++ vendor/github.com/go-yaml/yaml/yamlh.go | 738 +++++ .../github.com/go-yaml/yaml/yamlprivateh.go | 173 ++ .../google/go-github/github/gen-accessors.go | 332 ++ .../github.com/hashicorp/vault/api/client.go | 6 +- vendor/github.com/hashicorp/vault/api/go.sum | 1 + .../kelseyhightower/envconfig/.travis.yml | 7 + .../envconfig/LICENSE} | 18 +- .../kelseyhightower/envconfig/MAINTAINERS | 2 + .../kelseyhightower/envconfig/README.md | 188 ++ .../kelseyhightower/envconfig/doc.go | 8 + .../kelseyhightower/envconfig/env_os.go | 7 + .../kelseyhightower/envconfig/env_syscall.go | 7 + .../kelseyhightower/envconfig/envconfig.go | 319 ++ .../kelseyhightower/envconfig/usage.go | 158 + vendor/github.com/lib/pq/oid/gen.go | 93 + .../okta/okta-sdk-golang/LICENSE.md | 194 ++ .../github.com/okta/okta-sdk-golang/NOTICE.md | 5 + .../okta/okta-sdk-golang/okta/appLink.go | 34 + .../okta/okta-sdk-golang/okta/appUser.go | 83 + .../okta/appUserCredentials.go | 34 + .../okta/appUserPasswordCredential.go | 33 + .../okta/okta-sdk-golang/okta/application.go | 347 +++ .../okta/applicationAccessibility.go | 35 + .../okta/applicationCredentials.go | 34 + .../okta/applicationCredentialsOAuthClient.go | 36 + .../okta/applicationCredentialsScheme.go | 32 + .../okta/applicationCredentialsSigning.go | 38 + .../applicationCredentialsUsernameTemplate.go | 35 + .../okta/applicationGroupAssignment.go | 57 + .../okta/applicationLicensing.go | 33 + .../okta/applicationSettings.go | 36 + .../okta/applicationSettingsApplication.go | 31 + .../okta/applicationSettingsNotifications.go | 33 + .../applicationSettingsNotificationsVpn.go | 35 + ...licationSettingsNotificationsVpnNetwork.go | 35 + .../okta/applicationSignOnMode.go | 32 + .../okta/applicationVisibility.go | 35 + .../okta/applicationVisibilityHide.go | 34 + .../okta/authenticationProvider.go | 26 + .../okta/authenticationProviderType.go | 24 + .../okta/autoLoginApplication.go | 52 + .../okta/autoLoginApplicationSettings.go | 37 + .../autoLoginApplicationSettingsSignOn.go | 34 + .../okta/basicApplicationSettings.go | 36 + .../basicApplicationSettingsApplication.go | 34 + .../okta/basicAuthApplication.go | 53 + .../okta/bookmarkApplication.go | 53 + .../okta/bookmarkApplicationSettings.go | 36 + .../bookmarkApplicationSettingsApplication.go | 34 + .../okta/browserPluginApplication.go | 52 + .../okta/okta-sdk-golang/okta/cache/cache.go | 48 + .../okta-sdk-golang/okta/cache/goCache.go | 69 + .../okta-sdk-golang/okta/cache/noopCache.go | 46 + .../okta/okta-sdk-golang/okta/callFactor.go | 49 + .../okta-sdk-golang/okta/callFactorProfile.go | 34 + .../okta/changePasswordRequest.go | 26 + .../okta/okta-sdk-golang/okta/config.go | 177 ++ .../okta/createSessionRequest.go | 25 + .../okta/okta-sdk-golang/okta/emailAddress.go | 27 + .../okta/okta-sdk-golang/okta/emailFactor.go | 49 + .../okta/emailFactorProfile.go | 33 + .../okta/okta-sdk-golang/okta/emailStatus.go | 24 + .../okta/okta-sdk-golang/okta/emailType.go | 24 + .../okta/okta-sdk-golang/okta/error.go | 47 + .../okta/okta-sdk-golang/okta/factor.go | 174 ++ .../okta-sdk-golang/okta/factorProfile.go | 32 + .../okta-sdk-golang/okta/factorProvider.go | 32 + .../okta-sdk-golang/okta/factorResultType.go | 32 + .../okta/okta-sdk-golang/okta/factorStatus.go | 32 + .../okta/okta-sdk-golang/okta/factorType.go | 32 + .../okta/forgotPasswordResponse.go | 25 + .../okta/okta-sdk-golang/okta/group.go | 262 ++ .../okta-sdk-golang/okta/groupCondition.go | 26 + .../okta/okta-sdk-golang/okta/groupProfile.go | 26 + .../okta/okta-sdk-golang/okta/groupRule.go | 71 + .../okta-sdk-golang/okta/groupRuleAction.go | 25 + .../okta/groupRuleConditions.go | 26 + .../okta/groupRuleExpression.go | 26 + .../okta/groupRuleGroupAssignment.go | 25 + .../okta/groupRuleGroupCondition.go | 26 + .../okta/groupRulePeopleCondition.go | 26 + .../okta-sdk-golang/okta/groupRuleStatus.go | 24 + .../okta/groupRuleUserCondition.go | 26 + .../okta-sdk-golang/okta/hardwareFactor.go | 49 + .../okta/hardwareFactorProfile.go | 33 + .../okta/okta-sdk-golang/okta/jsonWebKey.go | 50 + .../okta/okta-sdk-golang/okta/logActor.go | 29 + .../okta/logAuthenticationContext.go | 31 + .../okta/logAuthenticationProvider.go | 24 + .../okta/okta-sdk-golang/okta/logClient.go | 30 + .../okta/logCredentialProvider.go | 24 + .../okta-sdk-golang/okta/logCredentialType.go | 24 + .../okta-sdk-golang/okta/logDebugContext.go | 25 + .../okta/okta-sdk-golang/okta/logEvent.go | 64 + .../okta/logGeographicalContext.go | 29 + .../okta-sdk-golang/okta/logGeolocation.go | 26 + .../okta/okta-sdk-golang/okta/logIpAddress.go | 28 + .../okta/okta-sdk-golang/okta/logIssuer.go | 26 + .../okta/okta-sdk-golang/okta/logOutcome.go | 26 + .../okta/okta-sdk-golang/okta/logRequest.go | 25 + .../okta/logSecurityContext.go | 29 + .../okta/okta-sdk-golang/okta/logSeverity.go | 24 + .../okta/okta-sdk-golang/okta/logTarget.go | 29 + .../okta-sdk-golang/okta/logTransaction.go | 27 + .../okta/okta-sdk-golang/okta/logUserAgent.go | 27 + .../okta/oAuthApplicationCredentials.go | 35 + .../okta/oAuthEndpointAuthenticationMethod.go | 32 + .../okta-sdk-golang/okta/oAuthGrantType.go | 32 + .../okta-sdk-golang/okta/oAuthResponseType.go | 32 + .../okta/okta-sdk-golang/okta/okta.go | 164 + .../okta-sdk-golang/okta/oktaSignOnPolicy.go | 38 + .../okta/oktaSignOnPolicyConditions.go | 25 + .../okta/oktaSignOnPolicyRule.go | 36 + .../okta/oktaSignOnPolicyRuleActions.go | 25 + .../okta/oktaSignOnPolicyRuleConditions.go | 27 + .../okta/oktaSignOnPolicyRuleSignonActions.go | 30 + ...ktaSignOnPolicyRuleSignonSessionActions.go | 27 + .../okta/openIdConnectApplication.go | 53 + .../openIdConnectApplicationConsentMethod.go | 32 + .../okta/openIdConnectApplicationSettings.go | 37 + .../openIdConnectApplicationSettingsClient.go | 42 + .../okta/openIdConnectApplicationType.go | 32 + .../okta/passwordCredential.go | 25 + .../okta/passwordDictionary.go | 25 + .../okta/passwordDictionaryCommon.go | 25 + .../okta-sdk-golang/okta/passwordPolicy.go | 39 + ...rdPolicyAuthenticationProviderCondition.go | 26 + .../okta/passwordPolicyConditions.go | 26 + .../okta/passwordPolicyDelegationSettings.go | 25 + ...passwordPolicyDelegationSettingsOptions.go | 25 + .../okta/passwordPolicyPasswordSettings.go | 27 + .../okta/passwordPolicyPasswordSettingsAge.go | 28 + ...asswordPolicyPasswordSettingsComplexity.go | 32 + .../passwordPolicyPasswordSettingsLockout.go | 28 + .../okta/passwordPolicyRecoveryEmail.go | 26 + .../passwordPolicyRecoveryEmailProperties.go | 25 + ...asswordPolicyRecoveryEmailRecoveryToken.go | 25 + .../passwordPolicyRecoveryFactorSettings.go | 25 + .../okta/passwordPolicyRecoveryFactors.go | 28 + .../okta/passwordPolicyRecoveryQuestion.go | 26 + ...asswordPolicyRecoveryQuestionComplexity.go | 25 + ...asswordPolicyRecoveryQuestionProperties.go | 25 + .../okta/passwordPolicyRecoverySettings.go | 25 + .../okta/passwordPolicyRule.go | 36 + .../okta/passwordPolicyRuleAction.go | 25 + .../okta/passwordPolicyRuleActions.go | 27 + .../okta/passwordPolicyRuleConditions.go | 26 + .../okta/passwordPolicySettings.go | 27 + .../okta/okta-sdk-golang/okta/policy.go | 244 ++ .../okta/policyNetworkCondition.go | 27 + .../okta/policyPeopleCondition.go | 26 + .../okta/okta-sdk-golang/okta/policyRule.go | 64 + .../okta/policyRuleAuthContextCondition.go | 25 + .../okta/okta-sdk-golang/okta/policyType.go | 24 + .../okta/okta-sdk-golang/okta/pushFactor.go | 49 + .../okta-sdk-golang/okta/pushFactorProfile.go | 37 + .../okta/okta-sdk-golang/okta/query/query.go | 320 ++ .../okta/recoveryQuestionCredential.go | 26 + .../okta-sdk-golang/okta/requestExecutor.go | 253 ++ .../okta/resetPasswordToken.go | 25 + .../okta/okta-sdk-golang/okta/role.go | 36 + .../okta/okta-sdk-golang/okta/roleStatus.go | 24 + .../okta-sdk-golang/okta/samlApplication.go | 52 + .../okta/samlApplicationSettings.go | 37 + .../okta/samlApplicationSettingsSignOn.go | 53 + .../okta/samlAttributeStatement.go | 36 + .../okta/schemeApplicationCredentials.go | 38 + .../okta/securePasswordStoreApplication.go | 53 + .../securePasswordStoreApplicationSettings.go | 36 + ...wordStoreApplicationSettingsApplication.go | 41 + .../okta-sdk-golang/okta/securityQuestion.go | 35 + .../okta/securityQuestionFactor.go | 49 + .../okta/securityQuestionFactorProfile.go | 35 + .../okta/okta-sdk-golang/okta/session.go | 96 + .../okta/sessionAuthenticationMethod.go | 24 + .../okta/sessionIdentityProvider.go | 26 + .../okta/sessionIdentityProviderType.go | 24 + .../okta-sdk-golang/okta/sessionStatus.go | 24 + .../okta/okta-sdk-golang/okta/smsFactor.go | 49 + .../okta-sdk-golang/okta/smsFactorProfile.go | 33 + .../okta-sdk-golang/okta/swaApplication.go | 53 + .../okta/swaApplicationSettings.go | 36 + .../okta/swaApplicationSettingsApplication.go | 37 + .../okta/swaThreeFieldApplication.go | 53 + .../okta/swaThreeFieldApplicationSettings.go | 36 + ...hreeFieldApplicationSettingsApplication.go | 39 + .../okta/okta-sdk-golang/okta/tempPassword.go | 25 + .../okta/okta-sdk-golang/okta/tokenFactor.go | 49 + .../okta/tokenFactorProfile.go | 33 + .../okta/okta-sdk-golang/okta/totpFactor.go | 49 + .../okta-sdk-golang/okta/totpFactorProfile.go | 33 + .../okta/okta-sdk-golang/okta/u2fFactor.go | 49 + .../okta-sdk-golang/okta/u2fFactorProfile.go | 32 + .../okta/okta-sdk-golang/okta/user.go | 429 +++ .../okta/userActivationToken.go | 26 + .../okta/okta-sdk-golang/okta/userAgent.go | 52 + .../okta-sdk-golang/okta/userCondition.go | 26 + .../okta-sdk-golang/okta/userCredentials.go | 28 + .../okta-sdk-golang/okta/userNextLogin.go | 24 + .../okta/okta-sdk-golang/okta/userProfile.go | 21 + .../okta/okta-sdk-golang/okta/userStatus.go | 24 + .../okta/okta-sdk-golang/okta/validator.go | 60 + .../okta/verifyFactorRequest.go | 37 + .../okta/verifyFactorResponse.go | 39 + .../okta/okta-sdk-golang/okta/webFactor.go | 49 + .../okta-sdk-golang/okta/webFactorProfile.go | 33 + .../okta/wsFederationApplication.go | 53 + .../okta/wsFederationApplicationSettings.go | 36 + ...ederationApplicationSettingsApplication.go | 44 + .../docker/pkg/archive/example_changes.go | 97 + .../shirou/gopsutil/disk/types_freebsd.go | 88 + .../shirou/gopsutil/disk/types_openbsd.go | 70 + .../shirou/gopsutil/host/types_darwin.go | 17 + .../shirou/gopsutil/host/types_freebsd.go | 44 + .../shirou/gopsutil/host/types_linux.go | 42 + .../shirou/gopsutil/host/types_openbsd.go | 43 + .../shirou/gopsutil/mem/types_openbsd.go | 34 + .../shirou/gopsutil/process/types_darwin.go | 160 + .../shirou/gopsutil/process/types_freebsd.go | 95 + .../shirou/gopsutil/process/types_openbsd.go | 103 + vendor/github.com/ugorji/go/codec/xml.go | 508 ++++ vendor/github.com/ulikunitz/xz/example.go | 40 + vendor/golang.org/x/sys/unix/mkasm_darwin.go | 78 + vendor/golang.org/x/sys/unix/mkpost.go | 122 + vendor/golang.org/x/sys/unix/mksyscall.go | 402 +++ .../x/sys/unix/mksyscall_aix_ppc.go | 415 +++ .../x/sys/unix/mksyscall_aix_ppc64.go | 614 ++++ .../x/sys/unix/mksyscall_solaris.go | 335 ++ .../golang.org/x/sys/unix/mksysctl_openbsd.go | 355 +++ vendor/golang.org/x/sys/unix/mksysnum.go | 190 ++ vendor/golang.org/x/sys/unix/types_aix.go | 237 ++ vendor/golang.org/x/sys/unix/types_darwin.go | 283 ++ .../golang.org/x/sys/unix/types_dragonfly.go | 263 ++ vendor/golang.org/x/sys/unix/types_freebsd.go | 400 +++ vendor/golang.org/x/sys/unix/types_netbsd.go | 290 ++ vendor/golang.org/x/sys/unix/types_openbsd.go | 283 ++ vendor/golang.org/x/sys/unix/types_solaris.go | 266 ++ .../text/encoding/internal/identifier/gen.go | 142 + vendor/golang.org/x/text/unicode/bidi/gen.go | 133 + .../x/text/unicode/bidi/gen_ranges.go | 57 + .../x/text/unicode/bidi/gen_trieval.go | 64 + .../x/text/unicode/norm/maketables.go | 986 ++++++ .../golang.org/x/text/unicode/norm/triegen.go | 117 + vendor/modules.txt | 518 ++-- 267 files changed, 28371 insertions(+), 2099 deletions(-) delete mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/apps.go delete mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/factors.go delete mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/groups.go delete mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go delete mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/users.go create mode 100644 vendor/github.com/cloudfoundry-community/go-cfclient/gen_error.go create mode 100644 vendor/github.com/dsnet/compress/bzip2/internal/sais/sais_gen.go create mode 100644 vendor/github.com/go-yaml/yaml/.travis.yml create mode 100644 vendor/github.com/go-yaml/yaml/LICENSE create mode 100644 vendor/github.com/go-yaml/yaml/LICENSE.libyaml create mode 100644 vendor/github.com/go-yaml/yaml/NOTICE create mode 100644 vendor/github.com/go-yaml/yaml/README.md create mode 100644 vendor/github.com/go-yaml/yaml/apic.go create mode 100644 vendor/github.com/go-yaml/yaml/decode.go create mode 100644 vendor/github.com/go-yaml/yaml/emitterc.go create mode 100644 vendor/github.com/go-yaml/yaml/encode.go create mode 100644 vendor/github.com/go-yaml/yaml/parserc.go create mode 100644 vendor/github.com/go-yaml/yaml/readerc.go create mode 100644 vendor/github.com/go-yaml/yaml/resolve.go create mode 100644 vendor/github.com/go-yaml/yaml/scannerc.go create mode 100644 vendor/github.com/go-yaml/yaml/sorter.go create mode 100644 vendor/github.com/go-yaml/yaml/writerc.go create mode 100644 vendor/github.com/go-yaml/yaml/yaml.go create mode 100644 vendor/github.com/go-yaml/yaml/yamlh.go create mode 100644 vendor/github.com/go-yaml/yaml/yamlprivateh.go create mode 100644 vendor/github.com/google/go-github/github/gen-accessors.go create mode 100644 vendor/github.com/kelseyhightower/envconfig/.travis.yml rename vendor/github.com/{chrismalek/oktasdk-go/LICENSE.txt => kelseyhightower/envconfig/LICENSE} (60%) create mode 100644 vendor/github.com/kelseyhightower/envconfig/MAINTAINERS create mode 100644 vendor/github.com/kelseyhightower/envconfig/README.md create mode 100644 vendor/github.com/kelseyhightower/envconfig/doc.go create mode 100644 vendor/github.com/kelseyhightower/envconfig/env_os.go create mode 100644 vendor/github.com/kelseyhightower/envconfig/env_syscall.go create mode 100644 vendor/github.com/kelseyhightower/envconfig/envconfig.go create mode 100644 vendor/github.com/kelseyhightower/envconfig/usage.go create mode 100644 vendor/github.com/lib/pq/oid/gen.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/LICENSE.md create mode 100644 vendor/github.com/okta/okta-sdk-golang/NOTICE.md create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/appLink.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/appUser.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/appUserCredentials.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/appUserPasswordCredential.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/application.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationAccessibility.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentials.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsOAuthClient.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsScheme.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsSigning.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsUsernameTemplate.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationGroupAssignment.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationLicensing.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotifications.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpn.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpnNetwork.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationSignOnMode.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibility.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibilityHide.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/authenticationProvider.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/authenticationProviderType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettingsSignOn.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettingsApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/basicAuthApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettingsApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/browserPluginApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/cache/cache.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/cache/goCache.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/cache/noopCache.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/callFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/callFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/changePasswordRequest.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/config.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/createSessionRequest.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/emailAddress.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/emailFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/emailFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/emailStatus.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/emailType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/error.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/factor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/factorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/factorProvider.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/factorResultType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/factorStatus.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/factorType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/forgotPasswordResponse.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/group.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRule.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRuleAction.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRuleConditions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRuleExpression.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupAssignment.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRulePeopleCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRuleStatus.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/groupRuleUserCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/jsonWebKey.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logActor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationContext.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationProvider.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logClient.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logCredentialProvider.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logCredentialType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logDebugContext.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logEvent.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logGeographicalContext.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logGeolocation.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logIpAddress.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logIssuer.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logOutcome.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logRequest.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logSecurityContext.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logSeverity.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logTarget.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logTransaction.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/logUserAgent.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oAuthApplicationCredentials.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oAuthEndpointAuthenticationMethod.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oAuthGrantType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oAuthResponseType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/okta.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicy.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyConditions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRule.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleActions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleConditions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonActions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonSessionActions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationConsentMethod.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettingsClient.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordCredential.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionary.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionaryCommon.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicy.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyAuthenticationProviderCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyConditions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettingsOptions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsAge.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsComplexity.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsLockout.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmail.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailProperties.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailRecoveryToken.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactorSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactors.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestion.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionComplexity.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionProperties.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoverySettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRule.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleAction.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleActions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleConditions.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicySettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/policy.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/policyNetworkCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/policyPeopleCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/policyRule.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/policyRuleAuthContextCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/policyType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/pushFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/pushFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/query/query.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/recoveryQuestionCredential.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/resetPasswordToken.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/role.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/roleStatus.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/samlApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettingsSignOn.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/samlAttributeStatement.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/schemeApplicationCredentials.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettingsApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/securityQuestion.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/session.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/sessionAuthenticationMethod.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProvider.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProviderType.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/sessionStatus.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/smsFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/smsFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/swaApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettingsApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettingsApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/tempPassword.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/tokenFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/tokenFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/totpFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/totpFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/u2fFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/u2fFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/user.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/userActivationToken.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/userAgent.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/userCondition.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/userCredentials.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/userNextLogin.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/userProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/userStatus.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/validator.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorRequest.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorResponse.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/webFactor.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/webFactorProfile.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplication.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettings.go create mode 100644 vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettingsApplication.go create mode 100644 vendor/github.com/ory/dockertest/docker/pkg/archive/example_changes.go create mode 100644 vendor/github.com/shirou/gopsutil/disk/types_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/disk/types_openbsd.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_openbsd.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/types_openbsd.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_openbsd.go create mode 100644 vendor/github.com/ugorji/go/codec/xml.go create mode 100644 vendor/github.com/ulikunitz/xz/example.go create mode 100644 vendor/golang.org/x/sys/unix/mkasm_darwin.go create mode 100644 vendor/golang.org/x/sys/unix/mkpost.go create mode 100644 vendor/golang.org/x/sys/unix/mksyscall.go create mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go create mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/mksyscall_solaris.go create mode 100644 vendor/golang.org/x/sys/unix/mksysctl_openbsd.go create mode 100644 vendor/golang.org/x/sys/unix/mksysnum.go create mode 100644 vendor/golang.org/x/sys/unix/types_aix.go create mode 100644 vendor/golang.org/x/sys/unix/types_darwin.go create mode 100644 vendor/golang.org/x/sys/unix/types_dragonfly.go create mode 100644 vendor/golang.org/x/sys/unix/types_freebsd.go create mode 100644 vendor/golang.org/x/sys/unix/types_netbsd.go create mode 100644 vendor/golang.org/x/sys/unix/types_openbsd.go create mode 100644 vendor/golang.org/x/sys/unix/types_solaris.go create mode 100644 vendor/golang.org/x/text/encoding/internal/identifier/gen.go create mode 100644 vendor/golang.org/x/text/unicode/bidi/gen.go create mode 100644 vendor/golang.org/x/text/unicode/bidi/gen_ranges.go create mode 100644 vendor/golang.org/x/text/unicode/bidi/gen_trieval.go create mode 100644 vendor/golang.org/x/text/unicode/norm/maketables.go create mode 100644 vendor/golang.org/x/text/unicode/norm/triegen.go diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/apps.go b/vendor/github.com/chrismalek/oktasdk-go/okta/apps.go deleted file mode 100644 index 1fe8007bca8f1..0000000000000 --- a/vendor/github.com/chrismalek/oktasdk-go/okta/apps.go +++ /dev/null @@ -1,315 +0,0 @@ -package okta - -import ( - "fmt" - "net/url" - "time" -) - -// AppsService is a service to retreives applications from OKTA. -type AppsService service - -// AppFilterOptions is used to generate a "Filter" to search for different Apps -// The values here coorelate to API Search paramgters on the group API -type AppFilterOptions struct { - NextURL *url.URL `url:"-"` - GetAllPages bool `url:"-"` - NumberOfPages int `url:"-"` - Limit int `url:"limit,omitempty"` -} - -// App is the Model for an OKTA Application -type App struct { - ID string `json:"id"` - Name string `json:"name"` - Label string `json:"label"` - Status string `json:"status"` - LastUpdated time.Time `json:"lastUpdated"` - Created time.Time `json:"created"` - Accessibility struct { - SelfService bool `json:"selfService"` - ErrorRedirectURL interface{} `json:"errorRedirectUrl"` - LoginRedirectURL interface{} `json:"loginRedirectUrl"` - } `json:"accessibility"` - Visibility struct { - AutoSubmitToolbar bool `json:"autoSubmitToolbar"` - Hide struct { - IOS bool `json:"iOS"` - Web bool `json:"web"` - } `json:"hide"` - AppLinks struct { - TestorgoneCustomsaml20App1Link bool `json:"testorgone_customsaml20app_1_link"` - } `json:"appLinks"` - } `json:"visibility"` - Features []interface{} `json:"features"` - SignOnMode string `json:"signOnMode"` - Credentials struct { - UserNameTemplate struct { - Template string `json:"template"` - Type string `json:"type"` - } `json:"userNameTemplate"` - Signing struct { - } `json:"signing"` - } `json:"credentials"` - Settings struct { - App struct { - } `json:"app"` - Notifications struct { - Vpn struct { - Network struct { - Connection string `json:"connection"` - } `json:"network"` - Message interface{} `json:"message"` - HelpURL interface{} `json:"helpUrl"` - } `json:"vpn"` - } `json:"notifications"` - SignOn struct { - DefaultRelayState string `json:"defaultRelayState"` - SsoAcsURL string `json:"ssoAcsUrl"` - IdpIssuer string `json:"idpIssuer"` - Audience string `json:"audience"` - Recipient string `json:"recipient"` - Destination string `json:"destination"` - SubjectNameIDTemplate string `json:"subjectNameIdTemplate"` - SubjectNameIDFormat string `json:"subjectNameIdFormat"` - ResponseSigned bool `json:"responseSigned"` - AssertionSigned bool `json:"assertionSigned"` - SignatureAlgorithm string `json:"signatureAlgorithm"` - DigestAlgorithm string `json:"digestAlgorithm"` - HonorForceAuthn bool `json:"honorForceAuthn"` - AuthnContextClassRef string `json:"authnContextClassRef"` - SpIssuer interface{} `json:"spIssuer"` - RequestCompressed bool `json:"requestCompressed"` - AttributeStatements []interface{} `json:"attributeStatements"` - } `json:"signOn"` - } `json:"settings"` - Links struct { - Logo []struct { - Name string `json:"name"` - Href string `json:"href"` - Type string `json:"type"` - } `json:"logo"` - AppLinks []struct { - Name string `json:"name"` - Href string `json:"href"` - Type string `json:"type"` - } `json:"appLinks"` - Help struct { - Href string `json:"href"` - Type string `json:"type"` - } `json:"help"` - Users struct { - Href string `json:"href"` - } `json:"users"` - Deactivate struct { - Href string `json:"href"` - } `json:"deactivate"` - Groups struct { - Href string `json:"href"` - } `json:"groups"` - Metadata struct { - Href string `json:"href"` - Type string `json:"type"` - } `json:"metadata"` - } `json:"_links"` -} - -func (a App) String() string { - // return Stringify(g) - return fmt.Sprintf("App:(ID: {%v} - Name: {%v})\n", a.ID, a.Name) -} - -// GetByID gets a group from OKTA by the Gropu ID. An error is returned if the group is not found -func (a *AppsService) GetByID(appID string) (*App, *Response, error) { - - u := fmt.Sprintf("apps/%v", appID) - req, err := a.client.NewRequest("GET", u, nil) - - if err != nil { - return nil, nil, err - } - - app := new(App) - - resp, err := a.client.Do(req, app) - - if err != nil { - return nil, resp, err - } - - return app, resp, err -} - -// AppUser is the model for a user of an OKTA App -type AppUser struct { - ID string `json:"id"` - ExternalID string `json:"externalId"` - Created time.Time `json:"created"` - LastUpdated time.Time `json:"lastUpdated"` - Scope string `json:"scope"` - Status string `json:"status"` - StatusChanged *time.Time `json:"statusChanged"` - PasswordChanged *time.Time `json:"passwordChanged"` - SyncState string `json:"syncState"` - LastSync *time.Time `json:"lastSync"` - Credentials struct { - UserName string `json:"userName"` - Password struct { - } `json:"password"` - } `json:"credentials"` - Profile struct { - SecondEmail interface{} `json:"secondEmail"` - LastName string `json:"lastName"` - MobilePhone interface{} `json:"mobilePhone"` - Email string `json:"email"` - SalesforceGroups []string `json:"salesforceGroups"` - Role string `json:"role"` - FirstName string `json:"firstName"` - Profile string `json:"profile"` - } `json:"profile"` - Links struct { - App struct { - Href string `json:"href"` - } `json:"app"` - User struct { - Href string `json:"href"` - } `json:"user"` - } `json:"_links"` -} - -// GetUsers returns the members in an App -// Pass in an optional AppFilterOptions struct to filter the results -// The Users in the app are returned -func (a *AppsService) GetUsers(appID string, opt *AppFilterOptions) (appUsers []AppUser, resp *Response, err error) { - - pagesRetreived := 0 - var u string - if opt.NextURL != nil { - u = opt.NextURL.String() - } else { - u = fmt.Sprintf("apps/%v/users", appID) - - if opt.Limit == 0 { - opt.Limit = defaultLimit - } - - u, _ = addOptions(u, opt) - } - - req, err := a.client.NewRequest("GET", u, nil) - - if err != nil { - // fmt.Printf("____ERROR HERE\n") - return nil, nil, err - } - resp, err = a.client.Do(req, &appUsers) - - if err != nil { - // fmt.Printf("____ERROR HERE 2\n") - return nil, resp, err - } - - pagesRetreived++ - - if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { - - for { - - if pagesRetreived == opt.NumberOfPages { - break - } - if resp.NextURL != nil { - - var userPage []AppUser - pageOpts := new(AppFilterOptions) - pageOpts.NextURL = resp.NextURL - pageOpts.Limit = opt.Limit - pageOpts.NumberOfPages = 1 - - userPage, resp, err = a.GetUsers(appID, pageOpts) - - if err != nil { - return appUsers, resp, err - } - appUsers = append(appUsers, userPage...) - pagesRetreived++ - } else { - break - } - - } - } - - return appUsers, resp, err -} - -// AppGroups - Groups assigned to Application -type AppGroups struct { - ID string `json:"id"` - LastUpdated time.Time `json:"lastUpdated"` - Priority int `json:"priority"` - Links struct { - User struct { - Href string `json:"href"` - } `json:"user"` - } `json:"_links"` -} - -// GetGroups returns groups assigned to the application - Input appID is the Application GUID -func (a *AppsService) GetGroups(appID string) (appGroups []AppGroups, resp *Response, err error) { - - var u string - u = fmt.Sprintf("apps/%v/groups", appID) - - req, err := a.client.NewRequest("GET", u, nil) - - if err != nil { - return nil, nil, err - } - resp, err = a.client.Do(req, &appGroups) - - if err != nil { - return nil, resp, err - } - - for { - - if resp.NextURL != nil { - - var appGroupPage []AppGroups - - appGroupPage, resp, err = a.GetGroups(appID) - - if err != nil { - return appGroups, resp, err - } else { - appGroups = append(appGroups, appGroupPage...) - - } - } else { - break - } - - } - - return appGroups, resp, err -} - -// GetUser returns the AppUser model for one app users -func (a *AppsService) GetUser(appID string, userID string) (appUser AppUser, resp *Response, err error) { - - var u string - u = fmt.Sprintf("apps/%v/users/%v", appID, userID) - - req, err := a.client.NewRequest("GET", u, nil) - - if err != nil { - return appUser, nil, err - } - resp, err = a.client.Do(req, &appUser) - - if err != nil { - return appUser, resp, err - } - return appUser, resp, nil -} diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/factors.go b/vendor/github.com/chrismalek/oktasdk-go/okta/factors.go deleted file mode 100644 index fc926f91aa387..0000000000000 --- a/vendor/github.com/chrismalek/oktasdk-go/okta/factors.go +++ /dev/null @@ -1,8 +0,0 @@ -package okta - -const ( - // MFAStatusActive is a constant to represent OKTA User State returned by the API - MFAStatusActive = "ACTIVE" - // MFAStatusPending is a user MFA Status of NOT Active - MFAStatusPending = "PENDING_ACTIVATION" -) diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/groups.go b/vendor/github.com/chrismalek/oktasdk-go/okta/groups.go deleted file mode 100644 index 34584d6eb69ee..0000000000000 --- a/vendor/github.com/chrismalek/oktasdk-go/okta/groups.go +++ /dev/null @@ -1,359 +0,0 @@ -package okta - -import ( - "errors" - "fmt" - "net/url" - "time" -) - -const ( - // GroupTypeOKTA - group type constant for an OKTA Mastered Group - GroupTypeOKTA = "OKTA_GROUP" - // GroupTypeBuiltIn - group type constant for a Built in OKTA groups - GroupTypeBuiltIn = "BUILT_IN" - // GroupTypeApp -- group type constant for app mastered group - GroupTypeApp = "APP_GROUP" - - groupTypeFilter = "type" - groupNameFilter = "q" - groupLastMembershipUpdatedFilter = "lastMembershipUpdated" - groupLastUpdatedFilter = "lastUpdated" -) - -// GroupsService handles communication with the Groups data related -// methods of the OKTA API. -type GroupsService service - -// Group represents the Group Object from the OKTA API -type Group struct { - ID string `json:"id"` - Created time.Time `json:"created"` - LastUpdated time.Time `json:"lastUpdated"` - LastMembershipUpdated time.Time `json:"lastMembershipUpdated"` - ObjectClass []string `json:"objectClass"` - Type string `json:"type"` - Profile struct { - Name string `json:"name"` - Description string `json:"description"` - SamAccountName string `json:"samAccountName"` - Dn string `json:"dn"` - WindowsDomainQualifiedName string `json:"windowsDomainQualifiedName"` - ExternalID string `json:"externalId"` - } `json:"profile"` - Links struct { - Logo []struct { - Name string `json:"name"` - Href string `json:"href"` - Type string `json:"type"` - } `json:"logo"` - Users struct { - Href string `json:"href"` - } `json:"users"` - Apps struct { - Href string `json:"href"` - } `json:"apps"` - } `json:"_links"` -} - -// GroupFilterOptions is used to generate a "Filter" to search for different groups -// The values here coorelate to API Search paramgters on the group API -type GroupFilterOptions struct { - // This will be built by internal - may not need to export - FilterString string `url:"filter,omitempty"` - NextURL *url.URL `url:"-"` - GetAllPages bool `url:"-"` - NumberOfPages int `url:"-"` - Limit int `url:"limit,omitempty"` - - NameStartsWith string `url:"q,omitempty"` - GroupTypeEqual string `url:"-"` - - LastUpdated dateFilter `url:"-"` - LastMembershipUpdated dateFilter `url:"-"` -} - -func (g Group) String() string { - // return Stringify(g) - return fmt.Sprintf("Group:(ID: {%v} - Type: {%v} - Group Name: {%v})\n", g.ID, g.Type, g.Profile.Name) -} - -// ListWithFilter - Method to list groups with different filter options. -// Pass in a GroupFilterOptions to specify filters. Values in that struct will turn into Query parameters -func (g *GroupsService) ListWithFilter(opt *GroupFilterOptions) ([]Group, *Response, error) { - - var u string - var err error - - pagesRetreived := 0 - if opt.NextURL != nil { - u = opt.NextURL.String() - } else { - if opt.GroupTypeEqual != "" { - opt.FilterString = appendToFilterString(opt.FilterString, groupTypeFilter, FilterEqualOperator, opt.GroupTypeEqual) - } - - // if opt.NameStartsWith != "" { - // opt.FilterString = appendToFilterString(opt.FilterString, groupNameFilter, filterEqualOperator, opt.NameStartsWith) - // } - if (!opt.LastMembershipUpdated.Value.IsZero()) && (opt.LastMembershipUpdated.Operator != "") { - opt.FilterString = appendToFilterString(opt.FilterString, groupLastMembershipUpdatedFilter, opt.LastMembershipUpdated.Operator, opt.LastMembershipUpdated.Value.UTC().Format(oktaFilterTimeFormat)) - } - - if (!opt.LastUpdated.Value.IsZero()) && (opt.LastUpdated.Operator != "") { - opt.FilterString = appendToFilterString(opt.FilterString, groupLastUpdatedFilter, opt.LastUpdated.Operator, opt.LastUpdated.Value.UTC().Format(oktaFilterTimeFormat)) - } - - if opt.Limit == 0 { - opt.Limit = defaultLimit - } - u, err = addOptions("groups", opt) - if err != nil { - return nil, nil, err - } - } - - req, err := g.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - groups := make([]Group, 1) - resp, err := g.client.Do(req, &groups) - if err != nil { - return nil, resp, err - } - pagesRetreived++ - - if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { - - for { - - if pagesRetreived == opt.NumberOfPages { - break - } - if resp.NextURL != nil { - var groupPage []Group - pageOption := new(GroupFilterOptions) - pageOption.NextURL = resp.NextURL - pageOption.NumberOfPages = 1 - pageOption.Limit = opt.Limit - - groupPage, resp, err = g.ListWithFilter(pageOption) - if err != nil { - return groups, resp, err - } - groups = append(groups, groupPage...) - pagesRetreived++ - - } else { - break - } - } - } - return groups, resp, err -} - -// GetByID gets a group from OKTA by the Gropu ID. An error is returned if the group is not found -func (g *GroupsService) GetByID(groupID string) (*Group, *Response, error) { - - u := fmt.Sprintf("groups/%v", groupID) - req, err := g.client.NewRequest("GET", u, nil) - - if err != nil { - return nil, nil, err - } - - group := new(Group) - - resp, err := g.client.Do(req, group) - - if err != nil { - return nil, resp, err - } - - return group, resp, err -} - -// GetUsers returns the members in a group -// Pass in an optional GroupFilterOptions struct to filter the results -// The Users in the group are returned -func (g *GroupsService) GetUsers(groupID string, opt *GroupUserFilterOptions) (users []User, resp *Response, err error) { - pagesRetreived := 0 - var u string - if opt.NextURL != nil { - u = opt.NextURL.String() - } else { - u = fmt.Sprintf("groups/%v/users", groupID) - - if opt.Limit == 0 { - opt.Limit = defaultLimit - } - - u, _ = addOptions(u, opt) - } - - req, err := g.client.NewRequest("GET", u, nil) - - if err != nil { - return nil, nil, err - } - resp, err = g.client.Do(req, &users) - - if err != nil { - return nil, resp, err - } - - pagesRetreived++ - if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { - - for { - - if pagesRetreived == opt.NumberOfPages { - break - } - if resp.NextURL != nil { - - var userPage []User - pageOpts := new(GroupUserFilterOptions) - pageOpts.NextURL = resp.NextURL - pageOpts.Limit = opt.Limit - pageOpts.NumberOfPages = 1 - - userPage, resp, err = g.GetUsers(groupID, pageOpts) - if err != nil { - return users, resp, err - } - users = append(users, userPage...) - pagesRetreived++ - } else { - break - } - - } - } - - return users, resp, err -} - -// Add - Adds an OKTA Mastered Group with name and description. GroupName is required. -func (g *GroupsService) Add(groupName string, groupDescription string) (*Group, *Response, error) { - - if groupName == "" { - return nil, nil, errors.New("groupName parameter is required for ADD") - } - - newGroup := newGroup{} - newGroup.Profile.Name = groupName - newGroup.Profile.Description = groupDescription - - u := fmt.Sprintf("groups") - - req, err := g.client.NewRequest("POST", u, newGroup) - - if err != nil { - return nil, nil, err - } - - group := new(Group) - - resp, err := g.client.Do(req, group) - - if err != nil { - return nil, resp, err - } - - return group, resp, err -} - -// Delete - Deletes an OKTA Mastered Group with ID -func (g *GroupsService) Delete(groupID string) (*Response, error) { - - if groupID == "" { - return nil, errors.New("groupID parameter is required for Delete") - } - u := fmt.Sprintf("groups/%v", groupID) - - req, err := g.client.NewRequest("DELETE", u, nil) - - if err != nil { - return nil, err - } - - resp, err := g.client.Do(req, nil) - - if err != nil { - return resp, err - } - - return resp, err -} - -// AddUserToGroup - Adds a user to a group. -func (g *GroupsService) AddUserToGroup(groupID string, userID string) (*Response, error) { - - if groupID == "" { - return nil, errors.New("groupID parameter is required for Delete") - } - if userID == "" { - return nil, errors.New("groupID parameter is required for Delete") - } - - u := fmt.Sprintf("groups/%v/users/%v", groupID, userID) - - req, err := g.client.NewRequest("PUT", u, nil) - - if err != nil { - return nil, err - } - - resp, err := g.client.Do(req, nil) - - if err != nil { - return resp, err - } - - return resp, err -} - -// RemoveUserFromGroup - Removes a user to a group. -func (g *GroupsService) RemoveUserFromGroup(groupID string, userID string) (*Response, error) { - - if groupID == "" { - return nil, errors.New("groupID parameter is required for Delete") - } - if userID == "" { - return nil, errors.New("groupID parameter is required for Delete") - } - - u := fmt.Sprintf("groups/%v/users/%v", groupID, userID) - - req, err := g.client.NewRequest("DELETE", u, nil) - - if err != nil { - return nil, err - } - - resp, err := g.client.Do(req, nil) - - if err != nil { - return resp, err - } - - return resp, err -} - -// GroupUserFilterOptions is a struct that you populate which will limit or control group fetches and searches -// The values here will coorelate to the search filtering allowed in the OKTA API. These values are turned into Query Parameters -type GroupUserFilterOptions struct { - Limit int `url:"limit,omitempty"` - NextURL *url.URL `url:"-"` - GetAllPages bool `url:"-"` - NumberOfPages int `url:"-"` -} - -type newGroup struct { - Profile struct { - Name string `json:"name"` - Description string `json:"description"` - } `json:"profile"` -} diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go b/vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go deleted file mode 100644 index ddfc250669b09..0000000000000 --- a/vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go +++ /dev/null @@ -1,523 +0,0 @@ -package okta - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "regexp" - "strconv" - "sync" - "time" - - "github.com/google/go-querystring/query" - - "reflect" -) - -const ( - libraryVersion = "1" - userAgent = "oktasdk-go/" + libraryVersion - productionDomain = "okta.com" - previewDomain = "oktapreview.com" - urlFormat = "https://%s.%s/api/v1/" - headerRateLimit = "X-Rate-Limit-Limit" - headerRateRemaining = "X-Rate-Limit-Remaining" - headerRateReset = "X-Rate-Limit-Reset" - headerOKTARequestID = "X-Okta-Request-Id" - headerAuthorization = "Authorization" - headerAuthorizationFormat = "SSWS %v" - mediaTypeJSON = "application/json" - defaultLimit = 50 - // FilterEqualOperator Filter Operatorid for "equal" - FilterEqualOperator = "eq" - // FilterStartsWithOperator - filter operator for "starts with" - FilterStartsWithOperator = "sw" - // FilterGreaterThanOperator - filter operator for "greater than" - FilterGreaterThanOperator = "gt" - // FilterLessThanOperator - filter operator for "less than" - FilterLessThanOperator = "lt" - - // If the API returns a "X-Rate-Limit-Remaining" header less than this the SDK will either pause - // Or throw RateLimitError depending on the client.PauseOnRateLimit value - defaultRateRemainingFloor = 100 -) - -// A Client manages communication with the API. -type Client struct { - clientMu sync.Mutex // clientMu protects the client during calls that modify the CheckRedirect func. - client *http.Client // HTTP client used to communicate with the API. - - // Base URL for API requests. - // This will be built automatically based on inputs to NewClient - // If needed you can override this if needed (your URL is not *.okta.com or *.oktapreview.com) - BaseURL *url.URL - - // User agent used when communicating with the GitHub API. - UserAgent string - - apiKey string - authorizationHeaderValue string - PauseOnRateLimit bool - - // RateRemainingFloor - If the API returns a "X-Rate-Limit-Remaining" header less than this the SDK will either pause - // Or throw RateLimitError depending on the client.PauseOnRateLimit value. It defaults to 30 - // One client doing too much work can lock out all API Access for every other client - // We are trying to be a "good API User Citizen" - RateRemainingFloor int - - rateMu sync.Mutex - mostRecentRate Rate - - Limit int - // mostRecent rateLimitCategory - - common service // Reuse a single struct instead of allocating one for each service on the heap. - - // Services used for talking to different parts of the API. - // Service for Working with Users - Users *UsersService - - // Service for Working with Groups - Groups *GroupsService - - // Service for Working with Apps - Apps *AppsService -} - -type service struct { - client *Client -} - -// NewClient returns a new OKTA API client. If a nil httpClient is -// provided, http.DefaultClient will be used. -func NewClient(httpClient *http.Client, orgName string, apiToken string, isProduction bool) *Client { - var baseDomain string - if isProduction { - baseDomain = productionDomain - } else { - baseDomain = previewDomain - } - client, _ := NewClientWithDomain(httpClient, orgName, baseDomain, apiToken) - return client -} - -// NewClientWithDomain creates a client based on the organziation name and -// base domain for requests (okta.com, okta-emea.com, oktapreview.com, etc). -func NewClientWithDomain(httpClient *http.Client, orgName string, domain string, apiToken string) (*Client, error) { - baseURL, err := url.Parse(fmt.Sprintf(urlFormat, orgName, domain)) - if err != nil { - return nil, err - } - return NewClientWithBaseURL(httpClient, baseURL, apiToken), nil -} - -// NewClientWithBaseURL creates a client based on the full base URL and api -// token -func NewClientWithBaseURL(httpClient *http.Client, baseURL *url.URL, apiToken string) *Client { - if httpClient == nil { - httpClient = http.DefaultClient - } - - c := &Client{ - client: httpClient, - BaseURL: baseURL, - UserAgent: userAgent, - } - c.PauseOnRateLimit = true // If rate limit found it will block until that time. If false then Error will be returned - c.authorizationHeaderValue = fmt.Sprintf(headerAuthorizationFormat, apiToken) - c.apiKey = apiToken - c.Limit = defaultLimit - c.RateRemainingFloor = defaultRateRemainingFloor - c.common.client = c - - c.Users = (*UsersService)(&c.common) - c.Groups = (*GroupsService)(&c.common) - c.Apps = (*AppsService)(&c.common) - return c -} - -// Rate represents the rate limit for the current client. -type Rate struct { - // The number of requests per minute the client is currently limited to. - RatePerMinuteLimit int - - // The number of remaining requests the client can make this minute - Remaining int - - // The time at which the current rate limit will reset. - ResetTime time.Time -} - -// Response is a OKTA API response. This wraps the standard http.Response -// returned from OKTA and provides convenient access to things like -// pagination links. -type Response struct { - *http.Response - - // These fields provide the page values for paginating through a set of - // results. - - NextURL *url.URL - // PrevURL *url.URL - SelfURL *url.URL - OKTARequestID string - Rate -} - -// newResponse creates a new Response for the provided http.Response. -func newResponse(r *http.Response) *Response { - response := &Response{Response: r} - - response.OKTARequestID = r.Header.Get(headerOKTARequestID) - - response.populatePaginationURLS() - response.Rate = parseRate(r) - return response -} - -// populatePageValues parses the HTTP Link response headers and populates the -// various pagination link values in the Response. - -// OKTA LINK Header takes this form: -// Link: ; rel="next", -// ; rel="self" - -func (r *Response) populatePaginationURLS() { - - for k, v := range r.Header { - - if k == "Link" { - nextRegex := regexp.MustCompile(`<(.*?)>; rel="next"`) - // prevRegex := regexp.MustCompile(`<(.*?)>; rel="prev"`) - selfRegex := regexp.MustCompile(`<(.*?)>; rel="self"`) - - for _, linkValue := range v { - nextLinkMatch := nextRegex.FindStringSubmatch(linkValue) - if len(nextLinkMatch) != 0 { - r.NextURL, _ = url.Parse(nextLinkMatch[1]) - } - selfLinkMatch := selfRegex.FindStringSubmatch(linkValue) - if len(selfLinkMatch) != 0 { - r.SelfURL, _ = url.Parse(selfLinkMatch[1]) - } - // prevLinkMatch := prevRegex.FindStringSubmatch(linkValue) - // if len(prevLinkMatch) != 0 { - // r.PrevURL, _ = url.Parse(prevLinkMatch[1]) - // } - } - } - } - -} - -// parseRate parses the rate related headers. -func parseRate(r *http.Response) Rate { - var rate Rate - - if limit := r.Header.Get(headerRateLimit); limit != "" { - rate.RatePerMinuteLimit, _ = strconv.Atoi(limit) - } - if remaining := r.Header.Get(headerRateRemaining); remaining != "" { - rate.Remaining, _ = strconv.Atoi(remaining) - } - if reset := r.Header.Get(headerRateReset); reset != "" { - if v, _ := strconv.ParseInt(reset, 10, 64); v != 0 { - rate.ResetTime = time.Unix(v, 0) - } - } - return rate -} - -// Do sends an API request and returns the API response. The API response is -// JSON decoded and stored in the value pointed to by v, or returned as an -// error if an API error has occurred. If v implements the io.Writer -// interface, the raw response body will be written to v, without attempting to -// first decode it. If rate limit is exceeded and reset time is in the future, -// Do returns rate immediately without making a network API call. -func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) { - - // If we've hit rate limit, don't make further requests before Reset time. - if err := c.checkRateLimitBeforeDo(req); err != nil { - return nil, err - } - - resp, err := c.client.Do(req) - if err != nil { - return nil, err - } - - defer func() { - // Drain up to 512 bytes and close the body to let the Transport reuse the connection - io.CopyN(ioutil.Discard, resp.Body, 512) - resp.Body.Close() - }() - - response := newResponse(resp) - - c.rateMu.Lock() - c.mostRecentRate.RatePerMinuteLimit = response.Rate.RatePerMinuteLimit - c.mostRecentRate.Remaining = response.Rate.Remaining - c.mostRecentRate.ResetTime = response.Rate.ResetTime - c.rateMu.Unlock() - - err = CheckResponse(resp) - if err != nil { - // even though there was an error, we still return the response - // in case the caller wants to inspect it further - // fmt.Printf("Error after sdk.Do return\n") - - return response, err - } - - if v != nil { - if w, ok := v.(io.Writer); ok { - io.Copy(w, resp.Body) - } else { - err = json.NewDecoder(resp.Body).Decode(v) - if err == io.EOF { - err = nil // ignore EOF errors caused by empty response body - } - } - } - - return response, err -} - -// checkRateLimitBeforeDo does not make any network calls, but uses existing knowledge from -// current client state in order to quickly check if *RateLimitError can be immediately returned -// from Client.Do, and if so, returns it so that Client.Do can skip making a network API call unnecessarily. -// Otherwise it returns nil, and Client.Do should proceed normally. -// http://developer.okta.com/docs/api/getting_started/design_principles.html#rate-limiting -func (c *Client) checkRateLimitBeforeDo(req *http.Request) error { - - c.rateMu.Lock() - mostRecentRate := c.mostRecentRate - c.rateMu.Unlock() - // fmt.Printf("checkRateLimitBeforeDo: \t Remaining = %d, \t ResetTime = %s\n", mostRecentRate.Remaining, mostRecentRate.ResetTime.String()) - if !mostRecentRate.ResetTime.IsZero() && mostRecentRate.Remaining < c.RateRemainingFloor && time.Now().Before(mostRecentRate.ResetTime) { - - if c.PauseOnRateLimit { - // If rate limit is hitting threshold then pause until the rate limit resets - // This behavior is controlled by the client PauseOnRateLimit value - // fmt.Printf("checkRateLimitBeforeDo: \t ***pause**** \t Time Now = %s \tPause After = %s\n", time.Now().String(), mostRecentRate.ResetTime.Sub(time.Now().Add(2*time.Second)).String()) - <-time.After(mostRecentRate.ResetTime.Sub(time.Now().Add(2 * time.Second))) - } else { - // fmt.Printf("checkRateLimitBeforeDo: \t ***error****\n") - - return &RateLimitError{ - Rate: mostRecentRate, - } - } - - } - - return nil -} - -// CheckResponse checks the API response for errors, and returns them if -// present. A response is considered an error if it has a status code outside -// the 200 range. API error responses are expected to have either no response -// body, or a JSON response body that maps to ErrorResponse. Any other -// response body will be silently ignored. -// -// The error type will be *RateLimitError for rate limit exceeded errors, -// and *TwoFactorAuthError for two-factor authentication errors. -// TODO - check un-authorized -func CheckResponse(r *http.Response) error { - if c := r.StatusCode; 200 <= c && c <= 299 { - return nil - } - - errorResp := &errorResponse{Response: r} - data, err := ioutil.ReadAll(r.Body) - if err == nil && data != nil { - json.Unmarshal(data, &errorResp.ErrorDetail) - } - switch { - case r.StatusCode == http.StatusTooManyRequests: - - return &RateLimitError{ - Rate: parseRate(r), - Response: r, - ErrorDetail: errorResp.ErrorDetail} - - default: - return errorResp - } - -} - -type apiError struct { - ErrorCode string `json:"errorCode"` - ErrorSummary string `json:"errorSummary"` - ErrorLink string `json:"errorLink"` - ErrorID string `json:"errorId"` - ErrorCauses []struct { - ErrorSummary string `json:"errorSummary"` - } `json:"errorCauses"` -} - -type errorResponse struct { - Response *http.Response // - ErrorDetail apiError -} - -func (r *errorResponse) Error() string { - return fmt.Sprintf("HTTP Method: %v - URL: %v: - HTTP Status Code: %d, OKTA Error Code: %v, OKTA Error Summary: %v, OKTA Error Causes: %v", - r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, r.ErrorDetail.ErrorCode, r.ErrorDetail.ErrorSummary, r.ErrorDetail.ErrorCauses) -} - -// RateLimitError occurs when OKTA returns 429 "Too Many Requests" response with a rate limit -// remaining value of 0, and error message starts with "API rate limit exceeded for ". -type RateLimitError struct { - Rate Rate // Rate specifies last known rate limit for the client - ErrorDetail apiError - Response *http.Response // -} - -func (r *RateLimitError) Error() string { - - return fmt.Sprintf("rate reset in %v", r.Rate.ResetTime.Sub(time.Now())) - -} - -// Code stolen from Github api libary -// Stringify attempts to create a reasonable string representation of types in -// the library. It does things like resolve pointers to their values -// and omits struct fields with nil values. -func stringify(message interface{}) string { - var buf bytes.Buffer - v := reflect.ValueOf(message) - stringifyValue(&buf, v) - return buf.String() -} - -// stringifyValue was heavily inspired by the goprotobuf library. - -func stringifyValue(w io.Writer, val reflect.Value) { - if val.Kind() == reflect.Ptr && val.IsNil() { - w.Write([]byte("")) - return - } - - v := reflect.Indirect(val) - - switch v.Kind() { - case reflect.String: - fmt.Fprintf(w, `"%s"`, v) - case reflect.Slice: - w.Write([]byte{'['}) - for i := 0; i < v.Len(); i++ { - if i > 0 { - w.Write([]byte{' '}) - } - - stringifyValue(w, v.Index(i)) - } - - w.Write([]byte{']'}) - return - case reflect.Struct: - if v.Type().Name() != "" { - w.Write([]byte(v.Type().String())) - } - w.Write([]byte{'{'}) - - var sep bool - for i := 0; i < v.NumField(); i++ { - fv := v.Field(i) - if fv.Kind() == reflect.Ptr && fv.IsNil() { - continue - } - if fv.Kind() == reflect.Slice && fv.IsNil() { - continue - } - - if sep { - w.Write([]byte(", ")) - } else { - sep = true - } - - w.Write([]byte(v.Type().Field(i).Name)) - w.Write([]byte{':'}) - stringifyValue(w, fv) - } - - w.Write([]byte{'}'}) - default: - if v.CanInterface() { - fmt.Fprint(w, v.Interface()) - } - } -} - -// NewRequest creates an API request. A relative URL can be provided in urlStr, -// in which case it is resolved relative to the BaseURL of the Client. -// Relative URLs should always be specified without a preceding slash. If -// specified, the value pointed to by body is JSON encoded and included as the -// request body. -func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error) { - rel, err := url.Parse(urlStr) - if err != nil { - return nil, err - } - - u := c.BaseURL.ResolveReference(rel) - - var buf io.ReadWriter - if body != nil { - buf = new(bytes.Buffer) - err := json.NewEncoder(buf).Encode(body) - if err != nil { - return nil, err - } - } - - req, err := http.NewRequest(method, u.String(), buf) - if err != nil { - return nil, err - } - if c.apiKey != "" { - req.Header.Set(headerAuthorization, fmt.Sprintf(headerAuthorizationFormat, c.apiKey)) - } - if body != nil { - req.Header.Set("Content-Type", mediaTypeJSON) - } - - if c.UserAgent != "" { - req.Header.Set("User-Agent", c.UserAgent) - } - return req, nil -} - -// addOptions adds the parameters in opt as URL query parameters to s. opt -// must be a struct whose fields may contain "url" tags. -func addOptions(s string, opt interface{}) (string, error) { - v := reflect.ValueOf(opt) - if v.Kind() == reflect.Ptr && v.IsNil() { - return s, nil - } - - u, err := url.Parse(s) - if err != nil { - return s, err - } - - qs, err := query.Values(opt) - if err != nil { - return s, err - } - - u.RawQuery = qs.Encode() - return u.String(), nil -} - -type dateFilter struct { - Value time.Time - Operator string -} diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/users.go b/vendor/github.com/chrismalek/oktasdk-go/okta/users.go deleted file mode 100644 index 8102a819eece8..0000000000000 --- a/vendor/github.com/chrismalek/oktasdk-go/okta/users.go +++ /dev/null @@ -1,625 +0,0 @@ -package okta - -import ( - "errors" - "fmt" - "net/url" - "time" -) - -const ( - profileEmailFilter = "profile.email" - profileLoginFilter = "profile.login" - profileStatusFilter = "status" - profileIDFilter = "id" - profileFirstNameFilter = "profile.firstName" - profileLastNameFilter = "profile.lastName" - profileLastUpdatedFilter = "lastUpdated" - // UserStatusActive is a constant to represent OKTA User State returned by the API - UserStatusActive = "ACTIVE" - // UserStatusStaged is a constant to represent OKTA User State returned by the API - UserStatusStaged = "STAGED" - // UserStatusProvisioned is a constant to represent OKTA User State returned by the API - UserStatusProvisioned = "PROVISIONED" - // UserStatusRecovery is a constant to represent OKTA User State returned by the API - UserStatusRecovery = "RECOVERY" - // UserStatusLockedOut is a constant to represent OKTA User State returned by the API - UserStatusLockedOut = "LOCKED_OUT" - // UserStatusPasswordExpired is a constant to represent OKTA User State returned by the API - UserStatusPasswordExpired = "PASSWORD_EXPIRED" - // UserStatusSuspended is a constant to represent OKTA User State returned by the API - UserStatusSuspended = "SUSPENDED" - // UserStatusDeprovisioned is a constant to represent OKTA User State returned by the API - UserStatusDeprovisioned = "DEPROVISIONED" - - oktaFilterTimeFormat = "2006-01-02T15:05:05.000Z" -) - -// UsersService handles communication with the User data related -// methods of the OKTA API. -type UsersService service - -// ActivationResponse - Response coming back from a user activation -type ActivationResponse struct { - ActivationURL string `json:"activationUrl"` -} - -type provider struct { - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` -} - -type recoveryQuestion struct { - Question string `json:"question,omitempty"` - Answer string `json:"answer,omitempty"` -} - -type passwordValue struct { - Value string `json:"value,omitempty"` -} -type credentials struct { - Password *passwordValue `json:"password,omitempty"` - Provider *provider `json:"provider,omitempty"` - RecoveryQuestion *recoveryQuestion `json:"recovery_question,omitempty"` -} - -type userProfile struct { - Email string `json:"email"` - FirstName string `json:"firstName"` - LastName string `json:"lastName"` - Login string `json:"login"` - MobilePhone string `json:"mobilePhone,omitempty"` - SecondEmail string `json:"secondEmail,omitempty"` - PsEmplid string `json:"psEmplid,omitempty"` - NickName string `json:"nickname,omitempty"` - DisplayName string `json:"displayName,omitempty"` - - ProfileURL string `json:"profileUrl,omitempty"` - PreferredLanguage string `json:"preferredLanguage,omitempty"` - UserType string `json:"userType,omitempty"` - Organization string `json:"organization,omitempty"` - Title string `json:"title,omitempty"` - Division string `json:"division,omitempty"` - Department string `json:"department,omitempty"` - CostCenter string `json:"costCenter,omitempty"` - EmployeeNumber string `json:"employeeNumber,omitempty"` - PrimaryPhone string `json:"primaryPhone,omitempty"` - StreetAddress string `json:"streetAddress,omitempty"` - City string `json:"city,omitempty"` - State string `json:"state,omitempty"` - ZipCode string `json:"zipCode,omitempty"` - CountryCode string `json:"countryCode,omitempty"` -} - -type userLinks struct { - ChangePassword struct { - Href string `json:"href"` - } `json:"changePassword"` - ChangeRecoveryQuestion struct { - Href string `json:"href"` - } `json:"changeRecoveryQuestion"` - Deactivate struct { - Href string `json:"href"` - } `json:"deactivate"` - ExpirePassword struct { - Href string `json:"href"` - } `json:"expirePassword"` - ForgotPassword struct { - Href string `json:"href"` - } `json:"forgotPassword"` - ResetFactors struct { - Href string `json:"href"` - } `json:"resetFactors"` - ResetPassword struct { - Href string `json:"href"` - } `json:"resetPassword"` -} - -// User is a struct that represents a user object from OKTA. -type User struct { - Activated string `json:"activated,omitempty"` - Created string `json:"created,omitempty"` - Credentials credentials `json:"credentials,omitempty"` - ID string `json:"id,omitempty"` - LastLogin string `json:"lastLogin,omitempty"` - LastUpdated string `json:"lastUpdated,omitempty"` - PasswordChanged string `json:"passwordChanged,omitempty"` - Profile userProfile `json:"profile"` - Status string `json:"status,omitempty"` - StatusChanged string `json:"statusChanged,omitempty"` - Links userLinks `json:"_links,omitempty"` - MFAFactors []userMFAFactor `json:"-,"` - Groups []Group `json:"-"` -} - -type userMFAFactor struct { - ID string `json:"id,omitempty"` - FactorType string `json:"factorType,omitempty"` - Provider string `json:"provider,omitempty"` - VendorName string `json:"vendorName,omitempty"` - Status string `json:"status,omitempty"` - Created time.Time `json:"created,omitempty"` - LastUpdated time.Time `json:"lastUpdated,omitempty"` - Profile struct { - CredentialID string `json:"credentialId,omitempty"` - } `json:"profile,omitempty"` -} - -// NewUser object to create user objects in OKTA -type NewUser struct { - Profile userProfile `json:"profile"` - Credentials *credentials `json:"credentials,omitempty"` -} - -type newPasswordSet struct { - Credentials credentials `json:"credentials"` -} - -// ResetPasswordResponse struct that returns data about the password reset -type ResetPasswordResponse struct { - ResetPasswordURL string `json:"resetPasswordUrl"` -} - -// NewUser - Returns a new user object. This is used to create users in OKTA. It only has the properties that -// OKTA will take as input. The "User" object has more feilds that are OKTA returned like the ID, etc -func (s *UsersService) NewUser() NewUser { - return NewUser{} -} - -// SetPassword Adds a specified password to the new User -func (u *NewUser) SetPassword(passwordIn string) { - - if passwordIn != "" { - - pass := new(passwordValue) - pass.Value = passwordIn - - var cred *credentials - if u.Credentials == nil { - cred = new(credentials) - } else { - cred = u.Credentials - } - - cred.Password = pass - u.Credentials = cred - - } -} - -// SetRecoveryQuestion - Sets a custom security question and answer on a user object -func (u *NewUser) SetRecoveryQuestion(questionIn string, answerIn string) { - - if questionIn != "" && answerIn != "" { - recovery := new(recoveryQuestion) - - recovery.Question = questionIn - recovery.Answer = answerIn - - var cred *credentials - if u.Credentials == nil { - cred = new(credentials) - } else { - cred = u.Credentials - } - cred.RecoveryQuestion = recovery - u.Credentials = cred - - } -} - -func (u User) String() string { - return stringify(u) - // return fmt.Sprintf("ID: %v \tLogin: %v", u.ID, u.Profile.Login) -} - -// GetByID returns a user object for a specific OKTA ID. -// Generally the id input string is the cryptic OKTA key value from User.ID. However, the OKTA API may accept other values like "me", or login shortname -func (s *UsersService) GetByID(id string) (*User, *Response, error) { - u := fmt.Sprintf("users/%v", id) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - user := new(User) - resp, err := s.client.Do(req, user) - if err != nil { - return nil, resp, err - } - - return user, resp, err -} - -// UserListFilterOptions is a struct that you can populate which will "filter" user searches -// the exported struct fields should allow you to do different filters based on what is allowed in the OKTA API. -// The filter OKTA API is limited in the fields it can search -// NOTE: In the current form you can't add parenthesis and ordering -// OKTA API Supports only a limited number of properties: -// status, lastUpdated, id, profile.login, profile.email, profile.firstName, and profile.lastName. -// http://developer.okta.com/docs/api/resources/users.html#list-users-with-a-filter -type UserListFilterOptions struct { - Limit int `url:"limit,omitempty"` - EmailEqualTo string `url:"-"` - LoginEqualTo string `url:"-"` - StatusEqualTo string `url:"-"` - IDEqualTo string `url:"-"` - - FirstNameEqualTo string `url:"-"` - LastNameEqualTo string `url:"-"` - // API documenation says you can search with "starts with" but these don't work - - // FirstNameStartsWith string `url:"-"` - // LastNameStartsWith string `url:"-"` - - // This will be built by internal - may not need to export - FilterString string `url:"filter,omitempty"` - NextURL *url.URL `url:"-"` - GetAllPages bool `url:"-"` - NumberOfPages int `url:"-"` - LastUpdated dateFilter `url:"-"` -} - -// PopulateGroups will populate the groups a user is a member of. You pass in a pointer to an existing users -func (s *UsersService) PopulateGroups(user *User) (*Response, error) { - u := fmt.Sprintf("users/%v/groups", user.ID) - req, err := s.client.NewRequest("GET", u, nil) - - if err != nil { - return nil, err - } - // Get first page of users. - resp, err := s.client.Do(req, &user.Groups) - if err != nil { - return resp, err - } - // Look for any remaining user group pages. - var nextURL string - if resp.NextURL != nil { - nextURL = resp.NextURL.String() - } - for { - - if nextURL != "" { - req, err := s.client.NewRequest("GET", nextURL, nil) - userGroupsPages := []Group{} - - resp, err := s.client.Do(req, &userGroupsPages) - nextURL = "" - if err != nil { - return resp, err - } - user.Groups = append(user.Groups, userGroupsPages...) - if resp.NextURL != nil { - nextURL = resp.NextURL.String() - } - - } else { - return resp, err - } - - } - -} - -// PopulateEnrolledFactors will populate the Enrolled MFA Factors a user is a member of. -// You pass in a pointer to an existing users -// http://developer.okta.com/docs/api/resources/factors.html#list-enrolled-factors -func (s *UsersService) PopulateEnrolledFactors(user *User) (*Response, error) { - u := fmt.Sprintf("users/%v/factors", user.ID) - req, err := s.client.NewRequest("GET", u, nil) - - if err != nil { - return nil, err - } - // TODO: If user has more than 200 groups this will only return those first 200 - resp, err := s.client.Do(req, &user.MFAFactors) - if err != nil { - return resp, err - } - - return resp, err -} - -// List users with status of LOCKED_OUT -// filter=status eq "LOCKED_OUT" -// List users updated after 06/01/2013 but before 01/01/2014 -// filter=lastUpdated gt "2013-06-01T00:00:00.000Z" and lastUpdated lt "2014-01-01T00:00:00.000Z" -// List users updated after 06/01/2013 but before 01/01/2014 with a status of ACTIVE -// filter=lastUpdated gt "2013-06-01T00:00:00.000Z" and lastUpdated lt "2014-01-01T00:00:00.000Z" and status eq "ACTIVE" -// TODO - Currently no way to do parenthesis -// List users updated after 06/01/2013 but with a status of LOCKED_OUT or RECOVERY -// filter=lastUpdated gt "2013-06-01T00:00:00.000Z" and (status eq "LOCKED_OUT" or status eq "RECOVERY") - -// OTKA API docs: http://developer.okta.com/docs/api/resources/users.html#list-users-with-a-filter - -func appendToFilterString(currFilterString string, appendFilterKey string, appendFilterOperator string, appendFilterValue string) (rs string) { - if currFilterString != "" { - rs = fmt.Sprintf("%v and %v %v \"%v\"", currFilterString, appendFilterKey, appendFilterOperator, appendFilterValue) - } else { - rs = fmt.Sprintf("%v %v \"%v\"", appendFilterKey, appendFilterOperator, appendFilterValue) - } - - return rs -} - -// ListWithFilter will use the input UserListFilterOptions to find users and return a paged result set -func (s *UsersService) ListWithFilter(opt *UserListFilterOptions) ([]User, *Response, error) { - var u string - var err error - - pagesRetreived := 0 - - if opt.NextURL != nil { - u = opt.NextURL.String() - } else { - if opt.EmailEqualTo != "" { - opt.FilterString = appendToFilterString(opt.FilterString, profileEmailFilter, FilterEqualOperator, opt.EmailEqualTo) - } - if opt.LoginEqualTo != "" { - opt.FilterString = appendToFilterString(opt.FilterString, profileLoginFilter, FilterEqualOperator, opt.LoginEqualTo) - } - - if opt.StatusEqualTo != "" { - opt.FilterString = appendToFilterString(opt.FilterString, profileStatusFilter, FilterEqualOperator, opt.StatusEqualTo) - } - - if opt.IDEqualTo != "" { - opt.FilterString = appendToFilterString(opt.FilterString, profileIDFilter, FilterEqualOperator, opt.IDEqualTo) - } - - if opt.FirstNameEqualTo != "" { - opt.FilterString = appendToFilterString(opt.FilterString, profileFirstNameFilter, FilterEqualOperator, opt.FirstNameEqualTo) - } - - if opt.LastNameEqualTo != "" { - opt.FilterString = appendToFilterString(opt.FilterString, profileLastNameFilter, FilterEqualOperator, opt.LastNameEqualTo) - } - - // API documenation says you can search with "starts with" but these don't work - // if opt.FirstNameStartsWith != "" { - // opt.FilterString = appendToFilterString(opt.FilterString, profileFirstNameFilter, filterStartsWithOperator, opt.FirstNameStartsWith) - // } - - // if opt.LastNameStartsWith != "" { - // opt.FilterString = appendToFilterString(opt.FilterString, profileLastNameFilter, filterStartsWithOperator, opt.LastNameStartsWith) - // } - - if !opt.LastUpdated.Value.IsZero() { - opt.FilterString = appendToFilterString(opt.FilterString, profileLastUpdatedFilter, opt.LastUpdated.Operator, opt.LastUpdated.Value.UTC().Format(oktaFilterTimeFormat)) - } - - if opt.Limit == 0 { - opt.Limit = defaultLimit - } - - u, err = addOptions("users", opt) - - } - - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - users := make([]User, 1) - resp, err := s.client.Do(req, &users) - if err != nil { - return nil, resp, err - } - - pagesRetreived++ - - if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { - - for { - - if pagesRetreived == opt.NumberOfPages { - break - } - if resp.NextURL != nil { - var userPage []User - pageOption := new(UserListFilterOptions) - pageOption.NextURL = resp.NextURL - pageOption.NumberOfPages = 1 - pageOption.Limit = opt.Limit - - userPage, resp, err = s.ListWithFilter(pageOption) - if err != nil { - return users, resp, err - } - users = append(users, userPage...) - pagesRetreived++ - } else { - break - } - } - } - return users, resp, err -} - -// Create - Creates a new user. You must pass in a "newUser" object created from Users.NewUser() -// There are many differnt reasons that OKTA may reject the request so you have to check the error messages -func (s *UsersService) Create(userIn NewUser, createAsActive bool) (*User, *Response, error) { - - u := fmt.Sprintf("users?activate=%v", createAsActive) - - req, err := s.client.NewRequest("POST", u, userIn) - - if err != nil { - return nil, nil, err - } - - newUser := new(User) - resp, err := s.client.Do(req, newUser) - if err != nil { - return nil, resp, err - } - - return newUser, resp, err -} - -// Activate Activates a user. You can have OKTA send an email by including a "sendEmail=true" -// If you pass in sendEmail=false, then activationResponse.ActivationURL will have a string URL that -// can be sent to the end user. You can discard response if sendEmail=true -func (s *UsersService) Activate(id string, sendEmail bool) (*ActivationResponse, *Response, error) { - u := fmt.Sprintf("users/%v/lifecycle/activate?sendEmail=%v", id, sendEmail) - - req, err := s.client.NewRequest("POST", u, nil) - if err != nil { - return nil, nil, err - } - - activationInfo := new(ActivationResponse) - resp, err := s.client.Do(req, activationInfo) - - if err != nil { - return nil, resp, err - } - - return activationInfo, resp, err -} - -// Deactivate - Deactivates a user -func (s *UsersService) Deactivate(id string) (*Response, error) { - u := fmt.Sprintf("users/%v/lifecycle/deactivate", id) - - req, err := s.client.NewRequest("POST", u, nil) - if err != nil { - return nil, err - } - resp, err := s.client.Do(req, nil) - - if err != nil { - return resp, err - } - - return resp, err -} - -// Suspend - Suspends a user - If user is NOT active an Error will come back based on OKTA API: -// http://developer.okta.com/docs/api/resources/users.html#suspend-user -func (s *UsersService) Suspend(id string) (*Response, error) { - u := fmt.Sprintf("users/%v/lifecycle/suspend", id) - - req, err := s.client.NewRequest("POST", u, nil) - if err != nil { - return nil, err - } - resp, err := s.client.Do(req, nil) - - if err != nil { - return resp, err - } - - return resp, err -} - -// Unsuspend - Unsuspends a user - If user is NOT SUSPENDED, an Error will come back based on OKTA API: -// http://developer.okta.com/docs/api/resources/users.html#unsuspend-user -func (s *UsersService) Unsuspend(id string) (*Response, error) { - u := fmt.Sprintf("users/%v/lifecycle/unsuspend", id) - - req, err := s.client.NewRequest("POST", u, nil) - if err != nil { - return nil, err - } - resp, err := s.client.Do(req, nil) - - if err != nil { - return resp, err - } - - return resp, err -} - -// Unlock - Unlocks a user - Per docs, only for OKTA Mastered Account -// http://developer.okta.com/docs/api/resources/users.html#unlock-user -func (s *UsersService) Unlock(id string) (*Response, error) { - u := fmt.Sprintf("users/%v/lifecycle/unlock", id) - - req, err := s.client.NewRequest("POST", u, nil) - if err != nil { - return nil, err - } - resp, err := s.client.Do(req, nil) - - if err != nil { - return resp, err - } - - return resp, err -} - -// SetPassword - Sets a user password to an Admin provided String -func (s *UsersService) SetPassword(id string, newPassword string) (*User, *Response, error) { - - if id == "" || newPassword == "" { - return nil, nil, errors.New("please provide a User ID and Password") - } - - passwordUpdate := new(newPasswordSet) - - pass := new(passwordValue) - pass.Value = newPassword - - passwordUpdate.Credentials.Password = pass - - u := fmt.Sprintf("users/%v", id) - req, err := s.client.NewRequest("POST", u, passwordUpdate) - if err != nil { - return nil, nil, err - } - - user := new(User) - resp, err := s.client.Do(req, user) - if err != nil { - return nil, resp, err - } - - return user, resp, err -} - -// ResetPassword - Generates a one-time token (OTT) that can be used to reset a user’s password. -// The OTT link can be automatically emailed to the user or returned to the API caller and distributed using a custom flow. -// http://developer.okta.com/docs/api/resources/users.html#reset-password -// If you pass in sendEmail=false, then resetPasswordResponse.resetPasswordUrl will have a string URL that -// can be sent to the end user. You can discard response if sendEmail=true -func (s *UsersService) ResetPassword(id string, sendEmail bool) (*ResetPasswordResponse, *Response, error) { - u := fmt.Sprintf("users/%v/lifecycle/reset_password?sendEmail=%v", id, sendEmail) - - req, err := s.client.NewRequest("POST", u, nil) - if err != nil { - return nil, nil, err - } - - resetInfo := new(ResetPasswordResponse) - resp, err := s.client.Do(req, resetInfo) - - if err != nil { - return nil, resp, err - } - - return resetInfo, resp, err -} - -// PopulateMFAFactors will populate the MFA Factors a user is a member of. You pass in a pointer to an existing users -func (s *UsersService) PopulateMFAFactors(user *User) (*Response, error) { - u := fmt.Sprintf("users/%v/factors", user.ID) - - req, err := s.client.NewRequest("GET", u, nil) - - if err != nil { - return nil, err - } - - resp, err := s.client.Do(req, &user.MFAFactors) - if err != nil { - return resp, err - } - - return resp, err -} diff --git a/vendor/github.com/cloudfoundry-community/go-cfclient/gen_error.go b/vendor/github.com/cloudfoundry-community/go-cfclient/gen_error.go new file mode 100644 index 0000000000000..7405c6f3e7986 --- /dev/null +++ b/vendor/github.com/cloudfoundry-community/go-cfclient/gen_error.go @@ -0,0 +1,115 @@ +// +build ignore + +package main + +import ( + "bytes" + "go/format" + "io/ioutil" + "log" + "net/http" + "sort" + "strings" + "text/template" + "time" + + "gopkg.in/yaml.v2" +) + +type CFCode int +type HTTPCode int + +type Definition struct { + CFCode `yaml:"-"` + Name string `yaml:"name"` + HTTPCode `yaml:"http_code"` + Message string `yaml:"message"` +} + +func main() { + const url = "https://raw.githubusercontent.com/cloudfoundry/cloud_controller_ng/master/vendor/errors/v2.yml" + + resp, err := http.Get(url) + if err != nil { + log.Fatal(err) + } + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + log.Fatal(err) + } + + var m map[CFCode]Definition + + if err := yaml.Unmarshal(body, &m); err != nil { + log.Fatal(err) + } + + var definitions []Definition + + for c, d := range m { + d.CFCode = c + definitions = append(definitions, d) + } + + sort.Slice(definitions, func(i, j int) bool { + return definitions[i].CFCode < definitions[j].CFCode + }) + + buf := &bytes.Buffer{} + + if err := packageTemplate.Execute(buf, struct { + Timestamp time.Time + Definitions []Definition + }{ + Timestamp: time.Now(), + Definitions: definitions, + }); err != nil { + log.Fatal(err) + } + + dst, err := format.Source(buf.Bytes()) + if err != nil { + log.Printf("%s", buf.Bytes()) + log.Fatal(err) + } + + if err := ioutil.WriteFile("cf_error.go", dst, 0600); err != nil { + log.Fatal(err) + } +} + +// destutter ensures that s does not end in "Error". +func destutter(s string) string { + return strings.TrimSuffix(s, "Error") +} + +var packageTemplate = template.Must(template.New("").Funcs(template.FuncMap{ + "destutter": destutter, +}).Parse(` +package cfclient + +// Code generated by go generate. DO NOT EDIT. +// This file was generated by robots at +// {{ .Timestamp }} + +import "github.com/pkg/errors" + +{{- range .Definitions }} +{{$method := printf "Is%sError" (.Name | destutter) }} +// {{ $method }} returns a boolean indicating whether +// the error is known to report the Cloud Foundry error: +// - Cloud Foundry code: {{ .CFCode }} +// - HTTP code: {{ .HTTPCode }} +// - message: {{ printf "%q" .Message }} +func Is{{ .Name | destutter }}Error(err error) bool { + cause := errors.Cause(err) + cferr, ok := cause.(CloudFoundryError) + if !ok { + return false + } + return cferr.Code == {{ .CFCode }} +} +{{- end }} +`)) diff --git a/vendor/github.com/dsnet/compress/bzip2/internal/sais/sais_gen.go b/vendor/github.com/dsnet/compress/bzip2/internal/sais/sais_gen.go new file mode 100644 index 0000000000000..26bf628e142e7 --- /dev/null +++ b/vendor/github.com/dsnet/compress/bzip2/internal/sais/sais_gen.go @@ -0,0 +1,703 @@ +// Copyright 2017, Joe Tsai. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE.md file. + +// +build ignore + +package main + +import ( + "bytes" + "go/format" + "io/ioutil" + "log" + "os" + "text/template" +) + +func main() { + if len(os.Args) != 3 { + log.Fatalf("Usage: %s GO_TYPE OUTPUT_FILE", os.Args[0]) + } + typ := os.Args[1] + path := os.Args[2] + + b := new(bytes.Buffer) + t := template.Must(template.New("source").Parse(source)) + if err := t.Execute(b, struct { + Type, GeneratedMessage string + }{typ, "// Code generated by sais_gen.go. DO NOT EDIT."}); err != nil { + log.Fatalf("Template.Execute error: %v", err) + } + out, err := format.Source(bytes.TrimSpace(b.Bytes())) + if err != nil { + log.Fatalf("format.Source error: %v", err) + } + if err := ioutil.WriteFile(path, out, 0644); err != nil { + log.Fatalf("ioutil.WriteFile error: %v", err) + } +} + +const source = ` +// Copyright 2015, Joe Tsai. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE.md file. + +{{.GeneratedMessage}} + +// ==================================================== +// Copyright (c) 2008-2010 Yuta Mori All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// ==================================================== + +package sais + +func getCounts_{{.Type}}(T []{{.Type}}, C []int, n, k int) { + var i int + for i = 0; i < k; i++ { + C[i] = 0 + } + for i = 0; i < n; i++ { + C[T[i]]++ + } +} + +func getBuckets_{{.Type}}(C, B []int, k int, end bool) { + var i, sum int + if end { + for i = 0; i < k; i++ { + sum += C[i] + B[i] = sum + } + } else { + for i = 0; i < k; i++ { + sum += C[i] + B[i] = sum - C[i] + } + } +} + +func sortLMS1_{{.Type}}(T []{{.Type}}, SA, C, B []int, n, k int) { + var b, i, j int + var c0, c1 int + + // Compute SAl. + if &C[0] == &B[0] { + getCounts_{{.Type}}(T, C, n, k) + } + getBuckets_{{.Type}}(C, B, k, false) // Find starts of buckets + j = n - 1 + c1 = int(T[j]) + b = B[c1] + j-- + if int(T[j]) < c1 { + SA[b] = ^j + } else { + SA[b] = j + } + b++ + for i = 0; i < n; i++ { + if j = SA[i]; j > 0 { + if c0 = int(T[j]); c0 != c1 { + B[c1] = b + c1 = c0 + b = B[c1] + } + j-- + if int(T[j]) < c1 { + SA[b] = ^j + } else { + SA[b] = j + } + b++ + SA[i] = 0 + } else if j < 0 { + SA[i] = ^j + } + } + + // Compute SAs. + if &C[0] == &B[0] { + getCounts_{{.Type}}(T, C, n, k) + } + getBuckets_{{.Type}}(C, B, k, true) // Find ends of buckets + c1 = 0 + b = B[c1] + for i = n - 1; i >= 0; i-- { + if j = SA[i]; j > 0 { + if c0 = int(T[j]); c0 != c1 { + B[c1] = b + c1 = c0 + b = B[c1] + } + j-- + b-- + if int(T[j]) > c1 { + SA[b] = ^(j + 1) + } else { + SA[b] = j + } + SA[i] = 0 + } + } +} + +func postProcLMS1_{{.Type}}(T []{{.Type}}, SA []int, n, m int) int { + var i, j, p, q, plen, qlen, name int + var c0, c1 int + var diff bool + + // Compact all the sorted substrings into the first m items of SA. + // 2*m must be not larger than n (provable). + for i = 0; SA[i] < 0; i++ { + SA[i] = ^SA[i] + } + if i < m { + for j, i = i, i+1; ; i++ { + if p = SA[i]; p < 0 { + SA[j] = ^p + j++ + SA[i] = 0 + if j == m { + break + } + } + } + } + + // Store the length of all substrings. + i = n - 1 + j = n - 1 + c0 = int(T[n-1]) + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 < c1 { + break + } + } + for i >= 0 { + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 > c1 { + break + } + } + if i >= 0 { + SA[m+((i+1)>>1)] = j - i + j = i + 1 + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 < c1 { + break + } + } + } + } + + // Find the lexicographic names of all substrings. + name = 0 + qlen = 0 + for i, q = 0, n; i < m; i++ { + p = SA[i] + plen = SA[m+(p>>1)] + diff = true + if (plen == qlen) && ((q + plen) < n) { + for j = 0; (j < plen) && (T[p+j] == T[q+j]); j++ { + } + if j == plen { + diff = false + } + } + if diff { + name++ + q = p + qlen = plen + } + SA[m+(p>>1)] = name + } + return name +} + +func sortLMS2_{{.Type}}(T []{{.Type}}, SA, C, B, D []int, n, k int) { + var b, i, j, t, d int + var c0, c1 int + + // Compute SAl. + getBuckets_{{.Type}}(C, B, k, false) // Find starts of buckets + j = n - 1 + c1 = int(T[j]) + b = B[c1] + j-- + if int(T[j]) < c1 { + t = 1 + } else { + t = 0 + } + j += n + if t&1 > 0 { + SA[b] = ^j + } else { + SA[b] = j + } + b++ + for i, d = 0, 0; i < n; i++ { + if j = SA[i]; j > 0 { + if n <= j { + d += 1 + j -= n + } + if c0 = int(T[j]); c0 != c1 { + B[c1] = b + c1 = c0 + b = B[c1] + } + j-- + t = int(c0) << 1 + if int(T[j]) < c1 { + t |= 1 + } + if D[t] != d { + j += n + D[t] = d + } + if t&1 > 0 { + SA[b] = ^j + } else { + SA[b] = j + } + b++ + SA[i] = 0 + } else if j < 0 { + SA[i] = ^j + } + } + for i = n - 1; 0 <= i; i-- { + if SA[i] > 0 { + if SA[i] < n { + SA[i] += n + for j = i - 1; SA[j] < n; j-- { + } + SA[j] -= n + i = j + } + } + } + + // Compute SAs. + getBuckets_{{.Type}}(C, B, k, true) // Find ends of buckets + c1 = 0 + b = B[c1] + for i, d = n-1, d+1; i >= 0; i-- { + if j = SA[i]; j > 0 { + if n <= j { + d += 1 + j -= n + } + if c0 = int(T[j]); c0 != c1 { + B[c1] = b + c1 = c0 + b = B[c1] + } + j-- + t = int(c0) << 1 + if int(T[j]) > c1 { + t |= 1 + } + if D[t] != d { + j += n + D[t] = d + } + b-- + if t&1 > 0 { + SA[b] = ^(j + 1) + } else { + SA[b] = j + } + SA[i] = 0 + } + } +} + +func postProcLMS2_{{.Type}}(SA []int, n, m int) int { + var i, j, d, name int + + // Compact all the sorted LMS substrings into the first m items of SA. + name = 0 + for i = 0; SA[i] < 0; i++ { + j = ^SA[i] + if n <= j { + name += 1 + } + SA[i] = j + } + if i < m { + for d, i = i, i+1; ; i++ { + if j = SA[i]; j < 0 { + j = ^j + if n <= j { + name += 1 + } + SA[d] = j + d++ + SA[i] = 0 + if d == m { + break + } + } + } + } + if name < m { + // Store the lexicographic names. + for i, d = m-1, name+1; 0 <= i; i-- { + if j = SA[i]; n <= j { + j -= n + d-- + } + SA[m+(j>>1)] = d + } + } else { + // Unset flags. + for i = 0; i < m; i++ { + if j = SA[i]; n <= j { + j -= n + SA[i] = j + } + } + } + return name +} + +func induceSA_{{.Type}}(T []{{.Type}}, SA, C, B []int, n, k int) { + var b, i, j int + var c0, c1 int + + // Compute SAl. + if &C[0] == &B[0] { + getCounts_{{.Type}}(T, C, n, k) + } + getBuckets_{{.Type}}(C, B, k, false) // Find starts of buckets + j = n - 1 + c1 = int(T[j]) + b = B[c1] + if j > 0 && int(T[j-1]) < c1 { + SA[b] = ^j + } else { + SA[b] = j + } + b++ + for i = 0; i < n; i++ { + j = SA[i] + SA[i] = ^j + if j > 0 { + j-- + if c0 = int(T[j]); c0 != c1 { + B[c1] = b + c1 = c0 + b = B[c1] + } + if j > 0 && int(T[j-1]) < c1 { + SA[b] = ^j + } else { + SA[b] = j + } + b++ + } + } + + // Compute SAs. + if &C[0] == &B[0] { + getCounts_{{.Type}}(T, C, n, k) + } + getBuckets_{{.Type}}(C, B, k, true) // Find ends of buckets + c1 = 0 + b = B[c1] + for i = n - 1; i >= 0; i-- { + if j = SA[i]; j > 0 { + j-- + if c0 = int(T[j]); c0 != c1 { + B[c1] = b + c1 = c0 + b = B[c1] + } + b-- + if (j == 0) || (int(T[j-1]) > c1) { + SA[b] = ^j + } else { + SA[b] = j + } + } else { + SA[i] = ^j + } + } +} + +func computeSA_{{.Type}}(T []{{.Type}}, SA []int, fs, n, k int) { + const ( + minBucketSize = 512 + sortLMS2Limit = 0x3fffffff + ) + + var C, B, D, RA []int + var bo int // Offset of B relative to SA + var b, i, j, m, p, q, name, newfs int + var c0, c1 int + var flags uint + + if k <= minBucketSize { + C = make([]int, k) + if k <= fs { + bo = n + fs - k + B = SA[bo:] + flags = 1 + } else { + B = make([]int, k) + flags = 3 + } + } else if k <= fs { + C = SA[n+fs-k:] + if k <= fs-k { + bo = n + fs - 2*k + B = SA[bo:] + flags = 0 + } else if k <= 4*minBucketSize { + B = make([]int, k) + flags = 2 + } else { + B = C + flags = 8 + } + } else { + C = make([]int, k) + B = C + flags = 4 | 8 + } + if n <= sortLMS2Limit && 2 <= (n/k) { + if flags&1 > 0 { + if 2*k <= fs-k { + flags |= 32 + } else { + flags |= 16 + } + } else if flags == 0 && 2*k <= (fs-2*k) { + flags |= 32 + } + } + + // Stage 1: Reduce the problem by at least 1/2. + // Sort all the LMS-substrings. + getCounts_{{.Type}}(T, C, n, k) + getBuckets_{{.Type}}(C, B, k, true) // Find ends of buckets + for i = 0; i < n; i++ { + SA[i] = 0 + } + b = -1 + i = n - 1 + j = n + m = 0 + c0 = int(T[n-1]) + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 < c1 { + break + } + } + for i >= 0 { + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 > c1 { + break + } + } + if i >= 0 { + if b >= 0 { + SA[b] = j + } + B[c1]-- + b = B[c1] + j = i + m++ + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 < c1 { + break + } + } + } + } + + if m > 1 { + if flags&(16|32) > 0 { + if flags&16 > 0 { + D = make([]int, 2*k) + } else { + D = SA[bo-2*k:] + } + B[T[j+1]]++ + for i, j = 0, 0; i < k; i++ { + j += C[i] + if B[i] != j { + SA[B[i]] += n + } + D[i] = 0 + D[i+k] = 0 + } + sortLMS2_{{.Type}}(T, SA, C, B, D, n, k) + name = postProcLMS2_{{.Type}}(SA, n, m) + } else { + sortLMS1_{{.Type}}(T, SA, C, B, n, k) + name = postProcLMS1_{{.Type}}(T, SA, n, m) + } + } else if m == 1 { + SA[b] = j + 1 + name = 1 + } else { + name = 0 + } + + // Stage 2: Solve the reduced problem. + // Recurse if names are not yet unique. + if name < m { + newfs = n + fs - 2*m + if flags&(1|4|8) == 0 { + if k+name <= newfs { + newfs -= k + } else { + flags |= 8 + } + } + RA = SA[m+newfs:] + for i, j = m+(n>>1)-1, m-1; m <= i; i-- { + if SA[i] != 0 { + RA[j] = SA[i] - 1 + j-- + } + } + computeSA_int(RA, SA, newfs, m, name) + + i = n - 1 + j = m - 1 + c0 = int(T[n-1]) + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 < c1 { + break + } + } + for i >= 0 { + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 > c1 { + break + } + } + if i >= 0 { + RA[j] = i + 1 + j-- + for { + c1 = c0 + if i--; i < 0 { + break + } + if c0 = int(T[i]); c0 < c1 { + break + } + } + } + } + for i = 0; i < m; i++ { + SA[i] = RA[SA[i]] + } + if flags&4 > 0 { + B = make([]int, k) + C = B + } + if flags&2 > 0 { + B = make([]int, k) + } + } + + // Stage 3: Induce the result for the original problem. + if flags&8 > 0 { + getCounts_{{.Type}}(T, C, n, k) + } + // Put all left-most S characters into their buckets. + if m > 1 { + getBuckets_{{.Type}}(C, B, k, true) // Find ends of buckets + i = m - 1 + j = n + p = SA[m-1] + c1 = int(T[p]) + for { + c0 = c1 + q = B[c0] + for q < j { + j-- + SA[j] = 0 + } + for { + j-- + SA[j] = p + if i--; i < 0 { + break + } + p = SA[i] + if c1 = int(T[p]); c1 != c0 { + break + } + } + if i < 0 { + break + } + } + for j > 0 { + j-- + SA[j] = 0 + } + } + induceSA_{{.Type}}(T, SA, C, B, n, k) +} +` diff --git a/vendor/github.com/go-yaml/yaml/.travis.yml b/vendor/github.com/go-yaml/yaml/.travis.yml new file mode 100644 index 0000000000000..9f556934d8b91 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/.travis.yml @@ -0,0 +1,12 @@ +language: go + +go: + - 1.4 + - 1.5 + - 1.6 + - 1.7 + - 1.8 + - 1.9 + - tip + +go_import_path: gopkg.in/yaml.v2 diff --git a/vendor/github.com/go-yaml/yaml/LICENSE b/vendor/github.com/go-yaml/yaml/LICENSE new file mode 100644 index 0000000000000..8dada3edaf50d --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-yaml/yaml/LICENSE.libyaml b/vendor/github.com/go-yaml/yaml/LICENSE.libyaml new file mode 100644 index 0000000000000..8da58fbf6f84a --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/LICENSE.libyaml @@ -0,0 +1,31 @@ +The following files were ported to Go from C files of libyaml, and thus +are still covered by their original copyright and license: + + apic.go + emitterc.go + parserc.go + readerc.go + scannerc.go + writerc.go + yamlh.go + yamlprivateh.go + +Copyright (c) 2006 Kirill Simonov + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/go-yaml/yaml/NOTICE b/vendor/github.com/go-yaml/yaml/NOTICE new file mode 100644 index 0000000000000..866d74a7ad791 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/NOTICE @@ -0,0 +1,13 @@ +Copyright 2011-2016 Canonical Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/github.com/go-yaml/yaml/README.md b/vendor/github.com/go-yaml/yaml/README.md new file mode 100644 index 0000000000000..2ed3314c73934 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/README.md @@ -0,0 +1,135 @@ +# YAML support for the Go language + +Introduction +------------ + +The yaml package enables Go programs to comfortably encode and decode YAML +values. It was developed within [Canonical](https://www.canonical.com) as +part of the [juju](https://juju.ubuntu.com) project, and is based on a +pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) +C library to parse and generate YAML data quickly and reliably. + +Compatibility +------------- + +The yaml package supports most of YAML 1.1 and 1.2, including support for +anchors, tags, map merging, etc. Multi-document unmarshalling is not yet +implemented, and base-60 floats from YAML 1.1 are purposefully not +supported since they're a poor design and are gone in YAML 1.2. + +Installation and usage +---------------------- + +The import path for the package is *gopkg.in/yaml.v2*. + +To install it, run: + + go get gopkg.in/yaml.v2 + +API documentation +----------------- + +If opened in a browser, the import path itself leads to the API documentation: + + * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) + +API stability +------------- + +The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). + + +License +------- + +The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details. + + +Example +------- + +Some more examples can be found in the "examples" folder. + +```Go +package main + +import ( + "fmt" + "log" + + "gopkg.in/yaml.v2" +) + +var data = ` +a: Easy! +b: + c: 2 + d: [3, 4] +` + +// Note: struct fields must be public in order for unmarshal to +// correctly populate the data. +type T struct { + A string + B struct { + RenamedC int `yaml:"c"` + D []int `yaml:",flow"` + } +} + +func main() { + t := T{} + + err := yaml.Unmarshal([]byte(data), &t) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- t:\n%v\n\n", t) + + d, err := yaml.Marshal(&t) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- t dump:\n%s\n\n", string(d)) + + m := make(map[interface{}]interface{}) + + err = yaml.Unmarshal([]byte(data), &m) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- m:\n%v\n\n", m) + + d, err = yaml.Marshal(&m) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- m dump:\n%s\n\n", string(d)) +} +``` + +This example will generate the following output: + +``` +--- t: +{Easy! {2 [3 4]}} + +--- t dump: +a: Easy! +b: + c: 2 + d: [3, 4] + + +--- m: +map[a:Easy! b:map[c:2 d:[3 4]]] + +--- m dump: +a: Easy! +b: + c: 2 + d: + - 3 + - 4 +``` + diff --git a/vendor/github.com/go-yaml/yaml/apic.go b/vendor/github.com/go-yaml/yaml/apic.go new file mode 100644 index 0000000000000..3e24a0d7d27b9 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/apic.go @@ -0,0 +1,739 @@ +package yaml + +import ( + "io" +) + +func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) { + //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens)) + + // Check if we can move the queue at the beginning of the buffer. + if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) { + if parser.tokens_head != len(parser.tokens) { + copy(parser.tokens, parser.tokens[parser.tokens_head:]) + } + parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head] + parser.tokens_head = 0 + } + parser.tokens = append(parser.tokens, *token) + if pos < 0 { + return + } + copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:]) + parser.tokens[parser.tokens_head+pos] = *token +} + +// Create a new parser object. +func yaml_parser_initialize(parser *yaml_parser_t) bool { + *parser = yaml_parser_t{ + raw_buffer: make([]byte, 0, input_raw_buffer_size), + buffer: make([]byte, 0, input_buffer_size), + } + return true +} + +// Destroy a parser object. +func yaml_parser_delete(parser *yaml_parser_t) { + *parser = yaml_parser_t{} +} + +// String read handler. +func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { + if parser.input_pos == len(parser.input) { + return 0, io.EOF + } + n = copy(buffer, parser.input[parser.input_pos:]) + parser.input_pos += n + return n, nil +} + +// Reader read handler. +func yaml_reader_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { + return parser.input_reader.Read(buffer) +} + +// Set a string input. +func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { + if parser.read_handler != nil { + panic("must set the input source only once") + } + parser.read_handler = yaml_string_read_handler + parser.input = input + parser.input_pos = 0 +} + +// Set a file input. +func yaml_parser_set_input_reader(parser *yaml_parser_t, r io.Reader) { + if parser.read_handler != nil { + panic("must set the input source only once") + } + parser.read_handler = yaml_reader_read_handler + parser.input_reader = r +} + +// Set the source encoding. +func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { + if parser.encoding != yaml_ANY_ENCODING { + panic("must set the encoding only once") + } + parser.encoding = encoding +} + +// Create a new emitter object. +func yaml_emitter_initialize(emitter *yaml_emitter_t) { + *emitter = yaml_emitter_t{ + buffer: make([]byte, output_buffer_size), + raw_buffer: make([]byte, 0, output_raw_buffer_size), + states: make([]yaml_emitter_state_t, 0, initial_stack_size), + events: make([]yaml_event_t, 0, initial_queue_size), + } +} + +// Destroy an emitter object. +func yaml_emitter_delete(emitter *yaml_emitter_t) { + *emitter = yaml_emitter_t{} +} + +// String write handler. +func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { + *emitter.output_buffer = append(*emitter.output_buffer, buffer...) + return nil +} + +// yaml_writer_write_handler uses emitter.output_writer to write the +// emitted text. +func yaml_writer_write_handler(emitter *yaml_emitter_t, buffer []byte) error { + _, err := emitter.output_writer.Write(buffer) + return err +} + +// Set a string output. +func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { + if emitter.write_handler != nil { + panic("must set the output target only once") + } + emitter.write_handler = yaml_string_write_handler + emitter.output_buffer = output_buffer +} + +// Set a file output. +func yaml_emitter_set_output_writer(emitter *yaml_emitter_t, w io.Writer) { + if emitter.write_handler != nil { + panic("must set the output target only once") + } + emitter.write_handler = yaml_writer_write_handler + emitter.output_writer = w +} + +// Set the output encoding. +func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { + if emitter.encoding != yaml_ANY_ENCODING { + panic("must set the output encoding only once") + } + emitter.encoding = encoding +} + +// Set the canonical output style. +func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) { + emitter.canonical = canonical +} + +//// Set the indentation increment. +func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) { + if indent < 2 || indent > 9 { + indent = 2 + } + emitter.best_indent = indent +} + +// Set the preferred line width. +func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { + if width < 0 { + width = -1 + } + emitter.best_width = width +} + +// Set if unescaped non-ASCII characters are allowed. +func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) { + emitter.unicode = unicode +} + +// Set the preferred line break character. +func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) { + emitter.line_break = line_break +} + +///* +// * Destroy a token object. +// */ +// +//YAML_DECLARE(void) +//yaml_token_delete(yaml_token_t *token) +//{ +// assert(token); // Non-NULL token object expected. +// +// switch (token.type) +// { +// case YAML_TAG_DIRECTIVE_TOKEN: +// yaml_free(token.data.tag_directive.handle); +// yaml_free(token.data.tag_directive.prefix); +// break; +// +// case YAML_ALIAS_TOKEN: +// yaml_free(token.data.alias.value); +// break; +// +// case YAML_ANCHOR_TOKEN: +// yaml_free(token.data.anchor.value); +// break; +// +// case YAML_TAG_TOKEN: +// yaml_free(token.data.tag.handle); +// yaml_free(token.data.tag.suffix); +// break; +// +// case YAML_SCALAR_TOKEN: +// yaml_free(token.data.scalar.value); +// break; +// +// default: +// break; +// } +// +// memset(token, 0, sizeof(yaml_token_t)); +//} +// +///* +// * Check if a string is a valid UTF-8 sequence. +// * +// * Check 'reader.c' for more details on UTF-8 encoding. +// */ +// +//static int +//yaml_check_utf8(yaml_char_t *start, size_t length) +//{ +// yaml_char_t *end = start+length; +// yaml_char_t *pointer = start; +// +// while (pointer < end) { +// unsigned char octet; +// unsigned int width; +// unsigned int value; +// size_t k; +// +// octet = pointer[0]; +// width = (octet & 0x80) == 0x00 ? 1 : +// (octet & 0xE0) == 0xC0 ? 2 : +// (octet & 0xF0) == 0xE0 ? 3 : +// (octet & 0xF8) == 0xF0 ? 4 : 0; +// value = (octet & 0x80) == 0x00 ? octet & 0x7F : +// (octet & 0xE0) == 0xC0 ? octet & 0x1F : +// (octet & 0xF0) == 0xE0 ? octet & 0x0F : +// (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; +// if (!width) return 0; +// if (pointer+width > end) return 0; +// for (k = 1; k < width; k ++) { +// octet = pointer[k]; +// if ((octet & 0xC0) != 0x80) return 0; +// value = (value << 6) + (octet & 0x3F); +// } +// if (!((width == 1) || +// (width == 2 && value >= 0x80) || +// (width == 3 && value >= 0x800) || +// (width == 4 && value >= 0x10000))) return 0; +// +// pointer += width; +// } +// +// return 1; +//} +// + +// Create STREAM-START. +func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) { + *event = yaml_event_t{ + typ: yaml_STREAM_START_EVENT, + encoding: encoding, + } +} + +// Create STREAM-END. +func yaml_stream_end_event_initialize(event *yaml_event_t) { + *event = yaml_event_t{ + typ: yaml_STREAM_END_EVENT, + } +} + +// Create DOCUMENT-START. +func yaml_document_start_event_initialize( + event *yaml_event_t, + version_directive *yaml_version_directive_t, + tag_directives []yaml_tag_directive_t, + implicit bool, +) { + *event = yaml_event_t{ + typ: yaml_DOCUMENT_START_EVENT, + version_directive: version_directive, + tag_directives: tag_directives, + implicit: implicit, + } +} + +// Create DOCUMENT-END. +func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) { + *event = yaml_event_t{ + typ: yaml_DOCUMENT_END_EVENT, + implicit: implicit, + } +} + +///* +// * Create ALIAS. +// */ +// +//YAML_DECLARE(int) +//yaml_alias_event_initialize(event *yaml_event_t, anchor *yaml_char_t) +//{ +// mark yaml_mark_t = { 0, 0, 0 } +// anchor_copy *yaml_char_t = NULL +// +// assert(event) // Non-NULL event object is expected. +// assert(anchor) // Non-NULL anchor is expected. +// +// if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0 +// +// anchor_copy = yaml_strdup(anchor) +// if (!anchor_copy) +// return 0 +// +// ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark) +// +// return 1 +//} + +// Create SCALAR. +func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool { + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + anchor: anchor, + tag: tag, + value: value, + implicit: plain_implicit, + quoted_implicit: quoted_implicit, + style: yaml_style_t(style), + } + return true +} + +// Create SEQUENCE-START. +func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(style), + } + return true +} + +// Create SEQUENCE-END. +func yaml_sequence_end_event_initialize(event *yaml_event_t) bool { + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + } + return true +} + +// Create MAPPING-START. +func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) { + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(style), + } +} + +// Create MAPPING-END. +func yaml_mapping_end_event_initialize(event *yaml_event_t) { + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + } +} + +// Destroy an event object. +func yaml_event_delete(event *yaml_event_t) { + *event = yaml_event_t{} +} + +///* +// * Create a document object. +// */ +// +//YAML_DECLARE(int) +//yaml_document_initialize(document *yaml_document_t, +// version_directive *yaml_version_directive_t, +// tag_directives_start *yaml_tag_directive_t, +// tag_directives_end *yaml_tag_directive_t, +// start_implicit int, end_implicit int) +//{ +// struct { +// error yaml_error_type_t +// } context +// struct { +// start *yaml_node_t +// end *yaml_node_t +// top *yaml_node_t +// } nodes = { NULL, NULL, NULL } +// version_directive_copy *yaml_version_directive_t = NULL +// struct { +// start *yaml_tag_directive_t +// end *yaml_tag_directive_t +// top *yaml_tag_directive_t +// } tag_directives_copy = { NULL, NULL, NULL } +// value yaml_tag_directive_t = { NULL, NULL } +// mark yaml_mark_t = { 0, 0, 0 } +// +// assert(document) // Non-NULL document object is expected. +// assert((tag_directives_start && tag_directives_end) || +// (tag_directives_start == tag_directives_end)) +// // Valid tag directives are expected. +// +// if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error +// +// if (version_directive) { +// version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)) +// if (!version_directive_copy) goto error +// version_directive_copy.major = version_directive.major +// version_directive_copy.minor = version_directive.minor +// } +// +// if (tag_directives_start != tag_directives_end) { +// tag_directive *yaml_tag_directive_t +// if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) +// goto error +// for (tag_directive = tag_directives_start +// tag_directive != tag_directives_end; tag_directive ++) { +// assert(tag_directive.handle) +// assert(tag_directive.prefix) +// if (!yaml_check_utf8(tag_directive.handle, +// strlen((char *)tag_directive.handle))) +// goto error +// if (!yaml_check_utf8(tag_directive.prefix, +// strlen((char *)tag_directive.prefix))) +// goto error +// value.handle = yaml_strdup(tag_directive.handle) +// value.prefix = yaml_strdup(tag_directive.prefix) +// if (!value.handle || !value.prefix) goto error +// if (!PUSH(&context, tag_directives_copy, value)) +// goto error +// value.handle = NULL +// value.prefix = NULL +// } +// } +// +// DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy, +// tag_directives_copy.start, tag_directives_copy.top, +// start_implicit, end_implicit, mark, mark) +// +// return 1 +// +//error: +// STACK_DEL(&context, nodes) +// yaml_free(version_directive_copy) +// while (!STACK_EMPTY(&context, tag_directives_copy)) { +// value yaml_tag_directive_t = POP(&context, tag_directives_copy) +// yaml_free(value.handle) +// yaml_free(value.prefix) +// } +// STACK_DEL(&context, tag_directives_copy) +// yaml_free(value.handle) +// yaml_free(value.prefix) +// +// return 0 +//} +// +///* +// * Destroy a document object. +// */ +// +//YAML_DECLARE(void) +//yaml_document_delete(document *yaml_document_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// tag_directive *yaml_tag_directive_t +// +// context.error = YAML_NO_ERROR // Eliminate a compliler warning. +// +// assert(document) // Non-NULL document object is expected. +// +// while (!STACK_EMPTY(&context, document.nodes)) { +// node yaml_node_t = POP(&context, document.nodes) +// yaml_free(node.tag) +// switch (node.type) { +// case YAML_SCALAR_NODE: +// yaml_free(node.data.scalar.value) +// break +// case YAML_SEQUENCE_NODE: +// STACK_DEL(&context, node.data.sequence.items) +// break +// case YAML_MAPPING_NODE: +// STACK_DEL(&context, node.data.mapping.pairs) +// break +// default: +// assert(0) // Should not happen. +// } +// } +// STACK_DEL(&context, document.nodes) +// +// yaml_free(document.version_directive) +// for (tag_directive = document.tag_directives.start +// tag_directive != document.tag_directives.end +// tag_directive++) { +// yaml_free(tag_directive.handle) +// yaml_free(tag_directive.prefix) +// } +// yaml_free(document.tag_directives.start) +// +// memset(document, 0, sizeof(yaml_document_t)) +//} +// +///** +// * Get a document node. +// */ +// +//YAML_DECLARE(yaml_node_t *) +//yaml_document_get_node(document *yaml_document_t, index int) +//{ +// assert(document) // Non-NULL document object is expected. +// +// if (index > 0 && document.nodes.start + index <= document.nodes.top) { +// return document.nodes.start + index - 1 +// } +// return NULL +//} +// +///** +// * Get the root object. +// */ +// +//YAML_DECLARE(yaml_node_t *) +//yaml_document_get_root_node(document *yaml_document_t) +//{ +// assert(document) // Non-NULL document object is expected. +// +// if (document.nodes.top != document.nodes.start) { +// return document.nodes.start +// } +// return NULL +//} +// +///* +// * Add a scalar node to a document. +// */ +// +//YAML_DECLARE(int) +//yaml_document_add_scalar(document *yaml_document_t, +// tag *yaml_char_t, value *yaml_char_t, length int, +// style yaml_scalar_style_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// mark yaml_mark_t = { 0, 0, 0 } +// tag_copy *yaml_char_t = NULL +// value_copy *yaml_char_t = NULL +// node yaml_node_t +// +// assert(document) // Non-NULL document object is expected. +// assert(value) // Non-NULL value is expected. +// +// if (!tag) { +// tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG +// } +// +// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error +// tag_copy = yaml_strdup(tag) +// if (!tag_copy) goto error +// +// if (length < 0) { +// length = strlen((char *)value) +// } +// +// if (!yaml_check_utf8(value, length)) goto error +// value_copy = yaml_malloc(length+1) +// if (!value_copy) goto error +// memcpy(value_copy, value, length) +// value_copy[length] = '\0' +// +// SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark) +// if (!PUSH(&context, document.nodes, node)) goto error +// +// return document.nodes.top - document.nodes.start +// +//error: +// yaml_free(tag_copy) +// yaml_free(value_copy) +// +// return 0 +//} +// +///* +// * Add a sequence node to a document. +// */ +// +//YAML_DECLARE(int) +//yaml_document_add_sequence(document *yaml_document_t, +// tag *yaml_char_t, style yaml_sequence_style_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// mark yaml_mark_t = { 0, 0, 0 } +// tag_copy *yaml_char_t = NULL +// struct { +// start *yaml_node_item_t +// end *yaml_node_item_t +// top *yaml_node_item_t +// } items = { NULL, NULL, NULL } +// node yaml_node_t +// +// assert(document) // Non-NULL document object is expected. +// +// if (!tag) { +// tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG +// } +// +// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error +// tag_copy = yaml_strdup(tag) +// if (!tag_copy) goto error +// +// if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error +// +// SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end, +// style, mark, mark) +// if (!PUSH(&context, document.nodes, node)) goto error +// +// return document.nodes.top - document.nodes.start +// +//error: +// STACK_DEL(&context, items) +// yaml_free(tag_copy) +// +// return 0 +//} +// +///* +// * Add a mapping node to a document. +// */ +// +//YAML_DECLARE(int) +//yaml_document_add_mapping(document *yaml_document_t, +// tag *yaml_char_t, style yaml_mapping_style_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// mark yaml_mark_t = { 0, 0, 0 } +// tag_copy *yaml_char_t = NULL +// struct { +// start *yaml_node_pair_t +// end *yaml_node_pair_t +// top *yaml_node_pair_t +// } pairs = { NULL, NULL, NULL } +// node yaml_node_t +// +// assert(document) // Non-NULL document object is expected. +// +// if (!tag) { +// tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG +// } +// +// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error +// tag_copy = yaml_strdup(tag) +// if (!tag_copy) goto error +// +// if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error +// +// MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end, +// style, mark, mark) +// if (!PUSH(&context, document.nodes, node)) goto error +// +// return document.nodes.top - document.nodes.start +// +//error: +// STACK_DEL(&context, pairs) +// yaml_free(tag_copy) +// +// return 0 +//} +// +///* +// * Append an item to a sequence node. +// */ +// +//YAML_DECLARE(int) +//yaml_document_append_sequence_item(document *yaml_document_t, +// sequence int, item int) +//{ +// struct { +// error yaml_error_type_t +// } context +// +// assert(document) // Non-NULL document is required. +// assert(sequence > 0 +// && document.nodes.start + sequence <= document.nodes.top) +// // Valid sequence id is required. +// assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE) +// // A sequence node is required. +// assert(item > 0 && document.nodes.start + item <= document.nodes.top) +// // Valid item id is required. +// +// if (!PUSH(&context, +// document.nodes.start[sequence-1].data.sequence.items, item)) +// return 0 +// +// return 1 +//} +// +///* +// * Append a pair of a key and a value to a mapping node. +// */ +// +//YAML_DECLARE(int) +//yaml_document_append_mapping_pair(document *yaml_document_t, +// mapping int, key int, value int) +//{ +// struct { +// error yaml_error_type_t +// } context +// +// pair yaml_node_pair_t +// +// assert(document) // Non-NULL document is required. +// assert(mapping > 0 +// && document.nodes.start + mapping <= document.nodes.top) +// // Valid mapping id is required. +// assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE) +// // A mapping node is required. +// assert(key > 0 && document.nodes.start + key <= document.nodes.top) +// // Valid key id is required. +// assert(value > 0 && document.nodes.start + value <= document.nodes.top) +// // Valid value id is required. +// +// pair.key = key +// pair.value = value +// +// if (!PUSH(&context, +// document.nodes.start[mapping-1].data.mapping.pairs, pair)) +// return 0 +// +// return 1 +//} +// +// diff --git a/vendor/github.com/go-yaml/yaml/decode.go b/vendor/github.com/go-yaml/yaml/decode.go new file mode 100644 index 0000000000000..c8eac16428703 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/decode.go @@ -0,0 +1,764 @@ +package yaml + +import ( + "encoding" + "encoding/base64" + "fmt" + "io" + "math" + "reflect" + "strconv" + "time" +) + +const ( + documentNode = 1 << iota + mappingNode + sequenceNode + scalarNode + aliasNode +) + +type node struct { + kind int + line, column int + tag string + // For an alias node, alias holds the resolved alias. + alias *node + value string + implicit bool + children []*node + anchors map[string]*node +} + +// ---------------------------------------------------------------------------- +// Parser, produces a node tree out of a libyaml event stream. + +type parser struct { + parser yaml_parser_t + event yaml_event_t + doc *node + doneInit bool +} + +func newParser(b []byte) *parser { + p := parser{} + if !yaml_parser_initialize(&p.parser) { + panic("failed to initialize YAML emitter") + } + if len(b) == 0 { + b = []byte{'\n'} + } + yaml_parser_set_input_string(&p.parser, b) + return &p +} + +func newParserFromReader(r io.Reader) *parser { + p := parser{} + if !yaml_parser_initialize(&p.parser) { + panic("failed to initialize YAML emitter") + } + yaml_parser_set_input_reader(&p.parser, r) + return &p +} + +func (p *parser) init() { + if p.doneInit { + return + } + p.expect(yaml_STREAM_START_EVENT) + p.doneInit = true +} + +func (p *parser) destroy() { + if p.event.typ != yaml_NO_EVENT { + yaml_event_delete(&p.event) + } + yaml_parser_delete(&p.parser) +} + +// expect consumes an event from the event stream and +// checks that it's of the expected type. +func (p *parser) expect(e yaml_event_type_t) { + if p.event.typ == yaml_NO_EVENT { + if !yaml_parser_parse(&p.parser, &p.event) { + p.fail() + } + } + if p.event.typ == yaml_STREAM_END_EVENT { + failf("attempted to go past the end of stream; corrupted value?") + } + if p.event.typ != e { + p.parser.problem = fmt.Sprintf("expected %s event but got %s", e, p.event.typ) + p.fail() + } + yaml_event_delete(&p.event) + p.event.typ = yaml_NO_EVENT +} + +// peek peeks at the next event in the event stream, +// puts the results into p.event and returns the event type. +func (p *parser) peek() yaml_event_type_t { + if p.event.typ != yaml_NO_EVENT { + return p.event.typ + } + if !yaml_parser_parse(&p.parser, &p.event) { + p.fail() + } + return p.event.typ +} + +func (p *parser) fail() { + var where string + var line int + if p.parser.problem_mark.line != 0 { + line = p.parser.problem_mark.line + } else if p.parser.context_mark.line != 0 { + line = p.parser.context_mark.line + } + if line != 0 { + where = "line " + strconv.Itoa(line) + ": " + } + var msg string + if len(p.parser.problem) > 0 { + msg = p.parser.problem + } else { + msg = "unknown problem parsing YAML content" + } + failf("%s%s", where, msg) +} + +func (p *parser) anchor(n *node, anchor []byte) { + if anchor != nil { + p.doc.anchors[string(anchor)] = n + } +} + +func (p *parser) parse() *node { + p.init() + switch p.peek() { + case yaml_SCALAR_EVENT: + return p.scalar() + case yaml_ALIAS_EVENT: + return p.alias() + case yaml_MAPPING_START_EVENT: + return p.mapping() + case yaml_SEQUENCE_START_EVENT: + return p.sequence() + case yaml_DOCUMENT_START_EVENT: + return p.document() + case yaml_STREAM_END_EVENT: + // Happens when attempting to decode an empty buffer. + return nil + default: + panic("attempted to parse unknown event: " + p.event.typ.String()) + } +} + +func (p *parser) node(kind int) *node { + return &node{ + kind: kind, + line: p.event.start_mark.line, + column: p.event.start_mark.column, + } +} + +func (p *parser) document() *node { + n := p.node(documentNode) + n.anchors = make(map[string]*node) + p.doc = n + p.expect(yaml_DOCUMENT_START_EVENT) + n.children = append(n.children, p.parse()) + p.expect(yaml_DOCUMENT_END_EVENT) + return n +} + +func (p *parser) alias() *node { + n := p.node(aliasNode) + n.value = string(p.event.anchor) + n.alias = p.doc.anchors[n.value] + if n.alias == nil { + failf("unknown anchor '%s' referenced", n.value) + } + p.expect(yaml_ALIAS_EVENT) + return n +} + +func (p *parser) scalar() *node { + n := p.node(scalarNode) + n.value = string(p.event.value) + n.tag = string(p.event.tag) + n.implicit = p.event.implicit + p.anchor(n, p.event.anchor) + p.expect(yaml_SCALAR_EVENT) + return n +} + +func (p *parser) sequence() *node { + n := p.node(sequenceNode) + p.anchor(n, p.event.anchor) + p.expect(yaml_SEQUENCE_START_EVENT) + for p.peek() != yaml_SEQUENCE_END_EVENT { + n.children = append(n.children, p.parse()) + } + p.expect(yaml_SEQUENCE_END_EVENT) + return n +} + +func (p *parser) mapping() *node { + n := p.node(mappingNode) + p.anchor(n, p.event.anchor) + p.expect(yaml_MAPPING_START_EVENT) + for p.peek() != yaml_MAPPING_END_EVENT { + n.children = append(n.children, p.parse(), p.parse()) + } + p.expect(yaml_MAPPING_END_EVENT) + return n +} + +// ---------------------------------------------------------------------------- +// Decoder, unmarshals a node into a provided value. + +type decoder struct { + doc *node + aliases map[*node]bool + mapType reflect.Type + terrors []string + strict bool +} + +var ( + mapItemType = reflect.TypeOf(MapItem{}) + durationType = reflect.TypeOf(time.Duration(0)) + defaultMapType = reflect.TypeOf(map[interface{}]interface{}{}) + ifaceType = defaultMapType.Elem() + timeType = reflect.TypeOf(time.Time{}) + ptrTimeType = reflect.TypeOf(&time.Time{}) +) + +func newDecoder(strict bool) *decoder { + d := &decoder{mapType: defaultMapType, strict: strict} + d.aliases = make(map[*node]bool) + return d +} + +func (d *decoder) terror(n *node, tag string, out reflect.Value) { + if n.tag != "" { + tag = n.tag + } + value := n.value + if tag != yaml_SEQ_TAG && tag != yaml_MAP_TAG { + if len(value) > 10 { + value = " `" + value[:7] + "...`" + } else { + value = " `" + value + "`" + } + } + d.terrors = append(d.terrors, fmt.Sprintf("line %d: cannot unmarshal %s%s into %s", n.line+1, shortTag(tag), value, out.Type())) +} + +func (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) { + terrlen := len(d.terrors) + err := u.UnmarshalYAML(func(v interface{}) (err error) { + defer handleErr(&err) + d.unmarshal(n, reflect.ValueOf(v)) + if len(d.terrors) > terrlen { + issues := d.terrors[terrlen:] + d.terrors = d.terrors[:terrlen] + return &TypeError{issues} + } + return nil + }) + if e, ok := err.(*TypeError); ok { + d.terrors = append(d.terrors, e.Errors...) + return false + } + if err != nil { + fail(err) + } + return true +} + +// d.prepare initializes and dereferences pointers and calls UnmarshalYAML +// if a value is found to implement it. +// It returns the initialized and dereferenced out value, whether +// unmarshalling was already done by UnmarshalYAML, and if so whether +// its types unmarshalled appropriately. +// +// If n holds a null value, prepare returns before doing anything. +func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { + if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "~" || n.value == "" && n.implicit) { + return out, false, false + } + again := true + for again { + again = false + if out.Kind() == reflect.Ptr { + if out.IsNil() { + out.Set(reflect.New(out.Type().Elem())) + } + out = out.Elem() + again = true + } + if out.CanAddr() { + if u, ok := out.Addr().Interface().(Unmarshaler); ok { + good = d.callUnmarshaler(n, u) + return out, true, good + } + } + } + return out, false, false +} + +func (d *decoder) unmarshal(n *node, out reflect.Value) (good bool) { + switch n.kind { + case documentNode: + return d.document(n, out) + case aliasNode: + return d.alias(n, out) + } + out, unmarshaled, good := d.prepare(n, out) + if unmarshaled { + return good + } + switch n.kind { + case scalarNode: + good = d.scalar(n, out) + case mappingNode: + good = d.mapping(n, out) + case sequenceNode: + good = d.sequence(n, out) + default: + panic("internal error: unknown node kind: " + strconv.Itoa(n.kind)) + } + return good +} + +func (d *decoder) document(n *node, out reflect.Value) (good bool) { + if len(n.children) == 1 { + d.doc = n + d.unmarshal(n.children[0], out) + return true + } + return false +} + +func (d *decoder) alias(n *node, out reflect.Value) (good bool) { + if d.aliases[n] { + // TODO this could actually be allowed in some circumstances. + failf("anchor '%s' value contains itself", n.value) + } + d.aliases[n] = true + good = d.unmarshal(n.alias, out) + delete(d.aliases, n) + return good +} + +var zeroValue reflect.Value + +func resetMap(out reflect.Value) { + for _, k := range out.MapKeys() { + out.SetMapIndex(k, zeroValue) + } +} + +func (d *decoder) scalar(n *node, out reflect.Value) bool { + var tag string + var resolved interface{} + if n.tag == "" && !n.implicit { + tag = yaml_STR_TAG + resolved = n.value + } else { + tag, resolved = resolve(n.tag, n.value) + if tag == yaml_BINARY_TAG { + data, err := base64.StdEncoding.DecodeString(resolved.(string)) + if err != nil { + failf("!!binary value contains invalid base64 data") + } + resolved = string(data) + } + } + if resolved == nil { + if out.Kind() == reflect.Map && !out.CanAddr() { + resetMap(out) + } else { + out.Set(reflect.Zero(out.Type())) + } + return true + } + if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() { + // We've resolved to exactly the type we want, so use that. + out.Set(resolvedv) + return true + } + // Perhaps we can use the value as a TextUnmarshaler to + // set its value. + if out.CanAddr() { + u, ok := out.Addr().Interface().(encoding.TextUnmarshaler) + if ok { + var text []byte + if tag == yaml_BINARY_TAG { + text = []byte(resolved.(string)) + } else { + // We let any value be unmarshaled into TextUnmarshaler. + // That might be more lax than we'd like, but the + // TextUnmarshaler itself should bowl out any dubious values. + text = []byte(n.value) + } + err := u.UnmarshalText(text) + if err != nil { + fail(err) + } + return true + } + } + switch out.Kind() { + case reflect.String: + if tag == yaml_BINARY_TAG { + out.SetString(resolved.(string)) + return true + } + if resolved != nil { + out.SetString(n.value) + return true + } + case reflect.Interface: + if resolved == nil { + out.Set(reflect.Zero(out.Type())) + } else if tag == yaml_TIMESTAMP_TAG { + // It looks like a timestamp but for backward compatibility + // reasons we set it as a string, so that code that unmarshals + // timestamp-like values into interface{} will continue to + // see a string and not a time.Time. + out.Set(reflect.ValueOf(n.value)) + } else { + out.Set(reflect.ValueOf(resolved)) + } + return true + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + switch resolved := resolved.(type) { + case int: + if !out.OverflowInt(int64(resolved)) { + out.SetInt(int64(resolved)) + return true + } + case int64: + if !out.OverflowInt(resolved) { + out.SetInt(resolved) + return true + } + case uint64: + if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { + out.SetInt(int64(resolved)) + return true + } + case float64: + if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { + out.SetInt(int64(resolved)) + return true + } + case string: + if out.Type() == durationType { + d, err := time.ParseDuration(resolved) + if err == nil { + out.SetInt(int64(d)) + return true + } + } + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + switch resolved := resolved.(type) { + case int: + if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + return true + } + case int64: + if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + return true + } + case uint64: + if !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + return true + } + case float64: + if resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + return true + } + } + case reflect.Bool: + switch resolved := resolved.(type) { + case bool: + out.SetBool(resolved) + return true + } + case reflect.Float32, reflect.Float64: + switch resolved := resolved.(type) { + case int: + out.SetFloat(float64(resolved)) + return true + case int64: + out.SetFloat(float64(resolved)) + return true + case uint64: + out.SetFloat(float64(resolved)) + return true + case float64: + out.SetFloat(resolved) + return true + } + case reflect.Struct: + if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() { + out.Set(resolvedv) + return true + } + case reflect.Ptr: + if out.Type().Elem() == reflect.TypeOf(resolved) { + // TODO DOes this make sense? When is out a Ptr except when decoding a nil value? + elem := reflect.New(out.Type().Elem()) + elem.Elem().Set(reflect.ValueOf(resolved)) + out.Set(elem) + return true + } + } + d.terror(n, tag, out) + return false +} + +func settableValueOf(i interface{}) reflect.Value { + v := reflect.ValueOf(i) + sv := reflect.New(v.Type()).Elem() + sv.Set(v) + return sv +} + +func (d *decoder) sequence(n *node, out reflect.Value) (good bool) { + l := len(n.children) + + var iface reflect.Value + switch out.Kind() { + case reflect.Slice: + out.Set(reflect.MakeSlice(out.Type(), l, l)) + case reflect.Interface: + // No type hints. Will have to use a generic sequence. + iface = out + out = settableValueOf(make([]interface{}, l)) + default: + d.terror(n, yaml_SEQ_TAG, out) + return false + } + et := out.Type().Elem() + + j := 0 + for i := 0; i < l; i++ { + e := reflect.New(et).Elem() + if ok := d.unmarshal(n.children[i], e); ok { + out.Index(j).Set(e) + j++ + } + } + out.Set(out.Slice(0, j)) + if iface.IsValid() { + iface.Set(out) + } + return true +} + +func (d *decoder) mapping(n *node, out reflect.Value) (good bool) { + switch out.Kind() { + case reflect.Struct: + return d.mappingStruct(n, out) + case reflect.Slice: + return d.mappingSlice(n, out) + case reflect.Map: + // okay + case reflect.Interface: + if d.mapType.Kind() == reflect.Map { + iface := out + out = reflect.MakeMap(d.mapType) + iface.Set(out) + } else { + slicev := reflect.New(d.mapType).Elem() + if !d.mappingSlice(n, slicev) { + return false + } + out.Set(slicev) + return true + } + default: + d.terror(n, yaml_MAP_TAG, out) + return false + } + outt := out.Type() + kt := outt.Key() + et := outt.Elem() + + mapType := d.mapType + if outt.Key() == ifaceType && outt.Elem() == ifaceType { + d.mapType = outt + } + + if out.IsNil() { + out.Set(reflect.MakeMap(outt)) + } + l := len(n.children) + for i := 0; i < l; i += 2 { + if isMerge(n.children[i]) { + d.merge(n.children[i+1], out) + continue + } + k := reflect.New(kt).Elem() + if d.unmarshal(n.children[i], k) { + kkind := k.Kind() + if kkind == reflect.Interface { + kkind = k.Elem().Kind() + } + if kkind == reflect.Map || kkind == reflect.Slice { + failf("invalid map key: %#v", k.Interface()) + } + e := reflect.New(et).Elem() + if d.unmarshal(n.children[i+1], e) { + d.setMapIndex(n.children[i+1], out, k, e) + } + } + } + d.mapType = mapType + return true +} + +func (d *decoder) setMapIndex(n *node, out, k, v reflect.Value) { + if d.strict && out.MapIndex(k) != zeroValue { + d.terrors = append(d.terrors, fmt.Sprintf("line %d: key %#v already set in map", n.line+1, k.Interface())) + return + } + out.SetMapIndex(k, v) +} + +func (d *decoder) mappingSlice(n *node, out reflect.Value) (good bool) { + outt := out.Type() + if outt.Elem() != mapItemType { + d.terror(n, yaml_MAP_TAG, out) + return false + } + + mapType := d.mapType + d.mapType = outt + + var slice []MapItem + var l = len(n.children) + for i := 0; i < l; i += 2 { + if isMerge(n.children[i]) { + d.merge(n.children[i+1], out) + continue + } + item := MapItem{} + k := reflect.ValueOf(&item.Key).Elem() + if d.unmarshal(n.children[i], k) { + v := reflect.ValueOf(&item.Value).Elem() + if d.unmarshal(n.children[i+1], v) { + slice = append(slice, item) + } + } + } + out.Set(reflect.ValueOf(slice)) + d.mapType = mapType + return true +} + +func (d *decoder) mappingStruct(n *node, out reflect.Value) (good bool) { + sinfo, err := getStructInfo(out.Type()) + if err != nil { + panic(err) + } + name := settableValueOf("") + l := len(n.children) + + var inlineMap reflect.Value + var elemType reflect.Type + if sinfo.InlineMap != -1 { + inlineMap = out.Field(sinfo.InlineMap) + inlineMap.Set(reflect.New(inlineMap.Type()).Elem()) + elemType = inlineMap.Type().Elem() + } + + var doneFields []bool + if d.strict { + doneFields = make([]bool, len(sinfo.FieldsList)) + } + for i := 0; i < l; i += 2 { + ni := n.children[i] + if isMerge(ni) { + d.merge(n.children[i+1], out) + continue + } + if !d.unmarshal(ni, name) { + continue + } + if info, ok := sinfo.FieldsMap[name.String()]; ok { + if d.strict { + if doneFields[info.Id] { + d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s already set in type %s", ni.line+1, name.String(), out.Type())) + continue + } + doneFields[info.Id] = true + } + var field reflect.Value + if info.Inline == nil { + field = out.Field(info.Num) + } else { + field = out.FieldByIndex(info.Inline) + } + d.unmarshal(n.children[i+1], field) + } else if sinfo.InlineMap != -1 { + if inlineMap.IsNil() { + inlineMap.Set(reflect.MakeMap(inlineMap.Type())) + } + value := reflect.New(elemType).Elem() + d.unmarshal(n.children[i+1], value) + d.setMapIndex(n.children[i+1], inlineMap, name, value) + } else if d.strict { + d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in type %s", ni.line+1, name.String(), out.Type())) + } + } + return true +} + +func failWantMap() { + failf("map merge requires map or sequence of maps as the value") +} + +func (d *decoder) merge(n *node, out reflect.Value) { + switch n.kind { + case mappingNode: + d.unmarshal(n, out) + case aliasNode: + an, ok := d.doc.anchors[n.value] + if ok && an.kind != mappingNode { + failWantMap() + } + d.unmarshal(n, out) + case sequenceNode: + // Step backwards as earlier nodes take precedence. + for i := len(n.children) - 1; i >= 0; i-- { + ni := n.children[i] + if ni.kind == aliasNode { + an, ok := d.doc.anchors[ni.value] + if ok && an.kind != mappingNode { + failWantMap() + } + } else if ni.kind != mappingNode { + failWantMap() + } + d.unmarshal(ni, out) + } + default: + failWantMap() + } +} + +func isMerge(n *node) bool { + return n.kind == scalarNode && n.value == "<<" && (n.implicit == true || n.tag == yaml_MERGE_TAG) +} diff --git a/vendor/github.com/go-yaml/yaml/emitterc.go b/vendor/github.com/go-yaml/yaml/emitterc.go new file mode 100644 index 0000000000000..cf0db118ac9ac --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/emitterc.go @@ -0,0 +1,1685 @@ +package yaml + +import ( + "bytes" + "fmt" +) + +// Flush the buffer if needed. +func flush(emitter *yaml_emitter_t) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) { + return yaml_emitter_flush(emitter) + } + return true +} + +// Put a character to the output buffer. +func put(emitter *yaml_emitter_t, value byte) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { + return false + } + emitter.buffer[emitter.buffer_pos] = value + emitter.buffer_pos++ + emitter.column++ + return true +} + +// Put a line break to the output buffer. +func put_break(emitter *yaml_emitter_t) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { + return false + } + switch emitter.line_break { + case yaml_CR_BREAK: + emitter.buffer[emitter.buffer_pos] = '\r' + emitter.buffer_pos += 1 + case yaml_LN_BREAK: + emitter.buffer[emitter.buffer_pos] = '\n' + emitter.buffer_pos += 1 + case yaml_CRLN_BREAK: + emitter.buffer[emitter.buffer_pos+0] = '\r' + emitter.buffer[emitter.buffer_pos+1] = '\n' + emitter.buffer_pos += 2 + default: + panic("unknown line break setting") + } + emitter.column = 0 + emitter.line++ + return true +} + +// Copy a character from a string into buffer. +func write(emitter *yaml_emitter_t, s []byte, i *int) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { + return false + } + p := emitter.buffer_pos + w := width(s[*i]) + switch w { + case 4: + emitter.buffer[p+3] = s[*i+3] + fallthrough + case 3: + emitter.buffer[p+2] = s[*i+2] + fallthrough + case 2: + emitter.buffer[p+1] = s[*i+1] + fallthrough + case 1: + emitter.buffer[p+0] = s[*i+0] + default: + panic("unknown character width") + } + emitter.column++ + emitter.buffer_pos += w + *i += w + return true +} + +// Write a whole string into buffer. +func write_all(emitter *yaml_emitter_t, s []byte) bool { + for i := 0; i < len(s); { + if !write(emitter, s, &i) { + return false + } + } + return true +} + +// Copy a line break character from a string into buffer. +func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool { + if s[*i] == '\n' { + if !put_break(emitter) { + return false + } + *i++ + } else { + if !write(emitter, s, i) { + return false + } + emitter.column = 0 + emitter.line++ + } + return true +} + +// Set an emitter error and return false. +func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool { + emitter.error = yaml_EMITTER_ERROR + emitter.problem = problem + return false +} + +// Emit an event. +func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool { + emitter.events = append(emitter.events, *event) + for !yaml_emitter_need_more_events(emitter) { + event := &emitter.events[emitter.events_head] + if !yaml_emitter_analyze_event(emitter, event) { + return false + } + if !yaml_emitter_state_machine(emitter, event) { + return false + } + yaml_event_delete(event) + emitter.events_head++ + } + return true +} + +// Check if we need to accumulate more events before emitting. +// +// We accumulate extra +// - 1 event for DOCUMENT-START +// - 2 events for SEQUENCE-START +// - 3 events for MAPPING-START +// +func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool { + if emitter.events_head == len(emitter.events) { + return true + } + var accumulate int + switch emitter.events[emitter.events_head].typ { + case yaml_DOCUMENT_START_EVENT: + accumulate = 1 + break + case yaml_SEQUENCE_START_EVENT: + accumulate = 2 + break + case yaml_MAPPING_START_EVENT: + accumulate = 3 + break + default: + return false + } + if len(emitter.events)-emitter.events_head > accumulate { + return false + } + var level int + for i := emitter.events_head; i < len(emitter.events); i++ { + switch emitter.events[i].typ { + case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT: + level++ + case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT: + level-- + } + if level == 0 { + return false + } + } + return true +} + +// Append a directive to the directives stack. +func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool { + for i := 0; i < len(emitter.tag_directives); i++ { + if bytes.Equal(value.handle, emitter.tag_directives[i].handle) { + if allow_duplicates { + return true + } + return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive") + } + } + + // [Go] Do we actually need to copy this given garbage collection + // and the lack of deallocating destructors? + tag_copy := yaml_tag_directive_t{ + handle: make([]byte, len(value.handle)), + prefix: make([]byte, len(value.prefix)), + } + copy(tag_copy.handle, value.handle) + copy(tag_copy.prefix, value.prefix) + emitter.tag_directives = append(emitter.tag_directives, tag_copy) + return true +} + +// Increase the indentation level. +func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool { + emitter.indents = append(emitter.indents, emitter.indent) + if emitter.indent < 0 { + if flow { + emitter.indent = emitter.best_indent + } else { + emitter.indent = 0 + } + } else if !indentless { + emitter.indent += emitter.best_indent + } + return true +} + +// State dispatcher. +func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool { + switch emitter.state { + default: + case yaml_EMIT_STREAM_START_STATE: + return yaml_emitter_emit_stream_start(emitter, event) + + case yaml_EMIT_FIRST_DOCUMENT_START_STATE: + return yaml_emitter_emit_document_start(emitter, event, true) + + case yaml_EMIT_DOCUMENT_START_STATE: + return yaml_emitter_emit_document_start(emitter, event, false) + + case yaml_EMIT_DOCUMENT_CONTENT_STATE: + return yaml_emitter_emit_document_content(emitter, event) + + case yaml_EMIT_DOCUMENT_END_STATE: + return yaml_emitter_emit_document_end(emitter, event) + + case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE: + return yaml_emitter_emit_flow_sequence_item(emitter, event, true) + + case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE: + return yaml_emitter_emit_flow_sequence_item(emitter, event, false) + + case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE: + return yaml_emitter_emit_flow_mapping_key(emitter, event, true) + + case yaml_EMIT_FLOW_MAPPING_KEY_STATE: + return yaml_emitter_emit_flow_mapping_key(emitter, event, false) + + case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE: + return yaml_emitter_emit_flow_mapping_value(emitter, event, true) + + case yaml_EMIT_FLOW_MAPPING_VALUE_STATE: + return yaml_emitter_emit_flow_mapping_value(emitter, event, false) + + case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE: + return yaml_emitter_emit_block_sequence_item(emitter, event, true) + + case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE: + return yaml_emitter_emit_block_sequence_item(emitter, event, false) + + case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE: + return yaml_emitter_emit_block_mapping_key(emitter, event, true) + + case yaml_EMIT_BLOCK_MAPPING_KEY_STATE: + return yaml_emitter_emit_block_mapping_key(emitter, event, false) + + case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE: + return yaml_emitter_emit_block_mapping_value(emitter, event, true) + + case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE: + return yaml_emitter_emit_block_mapping_value(emitter, event, false) + + case yaml_EMIT_END_STATE: + return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END") + } + panic("invalid emitter state") +} + +// Expect STREAM-START. +func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if event.typ != yaml_STREAM_START_EVENT { + return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START") + } + if emitter.encoding == yaml_ANY_ENCODING { + emitter.encoding = event.encoding + if emitter.encoding == yaml_ANY_ENCODING { + emitter.encoding = yaml_UTF8_ENCODING + } + } + if emitter.best_indent < 2 || emitter.best_indent > 9 { + emitter.best_indent = 2 + } + if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 { + emitter.best_width = 80 + } + if emitter.best_width < 0 { + emitter.best_width = 1<<31 - 1 + } + if emitter.line_break == yaml_ANY_BREAK { + emitter.line_break = yaml_LN_BREAK + } + + emitter.indent = -1 + emitter.line = 0 + emitter.column = 0 + emitter.whitespace = true + emitter.indention = true + + if emitter.encoding != yaml_UTF8_ENCODING { + if !yaml_emitter_write_bom(emitter) { + return false + } + } + emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE + return true +} + +// Expect DOCUMENT-START or STREAM-END. +func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + + if event.typ == yaml_DOCUMENT_START_EVENT { + + if event.version_directive != nil { + if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) { + return false + } + } + + for i := 0; i < len(event.tag_directives); i++ { + tag_directive := &event.tag_directives[i] + if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) { + return false + } + if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) { + return false + } + } + + for i := 0; i < len(default_tag_directives); i++ { + tag_directive := &default_tag_directives[i] + if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) { + return false + } + } + + implicit := event.implicit + if !first || emitter.canonical { + implicit = false + } + + if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) { + if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + + if event.version_directive != nil { + implicit = false + if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + + if len(event.tag_directives) > 0 { + implicit = false + for i := 0; i < len(event.tag_directives); i++ { + tag_directive := &event.tag_directives[i] + if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) { + return false + } + if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) { + return false + } + if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + } + + if yaml_emitter_check_empty_document(emitter) { + implicit = false + } + if !implicit { + if !yaml_emitter_write_indent(emitter) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) { + return false + } + if emitter.canonical { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + } + + emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE + return true + } + + if event.typ == yaml_STREAM_END_EVENT { + if emitter.open_ended { + if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_flush(emitter) { + return false + } + emitter.state = yaml_EMIT_END_STATE + return true + } + + return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END") +} + +// Expect the root node. +func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool { + emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE) + return yaml_emitter_emit_node(emitter, event, true, false, false, false) +} + +// Expect DOCUMENT-END. +func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if event.typ != yaml_DOCUMENT_END_EVENT { + return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END") + } + if !yaml_emitter_write_indent(emitter) { + return false + } + if !event.implicit { + // [Go] Allocate the slice elsewhere. + if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_flush(emitter) { + return false + } + emitter.state = yaml_EMIT_DOCUMENT_START_STATE + emitter.tag_directives = emitter.tag_directives[:0] + return true +} + +// Expect a flow item node. +func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) { + return false + } + if !yaml_emitter_increase_indent(emitter, true, false) { + return false + } + emitter.flow_level++ + } + + if event.typ == yaml_SEQUENCE_END_EVENT { + emitter.flow_level-- + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + if emitter.canonical && !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) { + return false + } + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + + return true + } + + if !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + } + + if emitter.canonical || emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE) + return yaml_emitter_emit_node(emitter, event, false, true, false, false) +} + +// Expect a flow key node. +func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { + return false + } + if !yaml_emitter_increase_indent(emitter, true, false) { + return false + } + emitter.flow_level++ + } + + if event.typ == yaml_MAPPING_END_EVENT { + emitter.flow_level-- + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + if emitter.canonical && !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { + return false + } + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true + } + + if !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + } + if emitter.canonical || emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + + if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { + emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, true) + } + if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { + return false + } + emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a flow value node. +func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { + if simple { + if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { + return false + } + } else { + if emitter.canonical || emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { + return false + } + } + emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a block item node. +func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) { + return false + } + } + if event.typ == yaml_SEQUENCE_END_EVENT { + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true + } + if !yaml_emitter_write_indent(emitter) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { + return false + } + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) + return yaml_emitter_emit_node(emitter, event, false, true, false, false) +} + +// Expect a block key node. +func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_increase_indent(emitter, false, false) { + return false + } + } + if event.typ == yaml_MAPPING_END_EVENT { + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true + } + if !yaml_emitter_write_indent(emitter) { + return false + } + if yaml_emitter_check_simple_key(emitter) { + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, true) + } + if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { + return false + } + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a block value node. +func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { + if simple { + if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { + return false + } + } else { + if !yaml_emitter_write_indent(emitter) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { + return false + } + } + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a node. +func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, + root bool, sequence bool, mapping bool, simple_key bool) bool { + + emitter.root_context = root + emitter.sequence_context = sequence + emitter.mapping_context = mapping + emitter.simple_key_context = simple_key + + switch event.typ { + case yaml_ALIAS_EVENT: + return yaml_emitter_emit_alias(emitter, event) + case yaml_SCALAR_EVENT: + return yaml_emitter_emit_scalar(emitter, event) + case yaml_SEQUENCE_START_EVENT: + return yaml_emitter_emit_sequence_start(emitter, event) + case yaml_MAPPING_START_EVENT: + return yaml_emitter_emit_mapping_start(emitter, event) + default: + return yaml_emitter_set_emitter_error(emitter, + fmt.Sprintf("expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, but got %v", event.typ)) + } +} + +// Expect ALIAS. +func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_process_anchor(emitter) { + return false + } + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true +} + +// Expect SCALAR. +func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_select_scalar_style(emitter, event) { + return false + } + if !yaml_emitter_process_anchor(emitter) { + return false + } + if !yaml_emitter_process_tag(emitter) { + return false + } + if !yaml_emitter_increase_indent(emitter, true, false) { + return false + } + if !yaml_emitter_process_scalar(emitter) { + return false + } + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true +} + +// Expect SEQUENCE-START. +func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_process_anchor(emitter) { + return false + } + if !yaml_emitter_process_tag(emitter) { + return false + } + if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || + yaml_emitter_check_empty_sequence(emitter) { + emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE + } else { + emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE + } + return true +} + +// Expect MAPPING-START. +func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_process_anchor(emitter) { + return false + } + if !yaml_emitter_process_tag(emitter) { + return false + } + if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || + yaml_emitter_check_empty_mapping(emitter) { + emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE + } else { + emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE + } + return true +} + +// Check if the document content is an empty scalar. +func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool { + return false // [Go] Huh? +} + +// Check if the next events represent an empty sequence. +func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { + if len(emitter.events)-emitter.events_head < 2 { + return false + } + return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && + emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT +} + +// Check if the next events represent an empty mapping. +func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { + if len(emitter.events)-emitter.events_head < 2 { + return false + } + return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && + emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT +} + +// Check if the next node can be expressed as a simple key. +func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { + length := 0 + switch emitter.events[emitter.events_head].typ { + case yaml_ALIAS_EVENT: + length += len(emitter.anchor_data.anchor) + case yaml_SCALAR_EVENT: + if emitter.scalar_data.multiline { + return false + } + length += len(emitter.anchor_data.anchor) + + len(emitter.tag_data.handle) + + len(emitter.tag_data.suffix) + + len(emitter.scalar_data.value) + case yaml_SEQUENCE_START_EVENT: + if !yaml_emitter_check_empty_sequence(emitter) { + return false + } + length += len(emitter.anchor_data.anchor) + + len(emitter.tag_data.handle) + + len(emitter.tag_data.suffix) + case yaml_MAPPING_START_EVENT: + if !yaml_emitter_check_empty_mapping(emitter) { + return false + } + length += len(emitter.anchor_data.anchor) + + len(emitter.tag_data.handle) + + len(emitter.tag_data.suffix) + default: + return false + } + return length <= 128 +} + +// Determine an acceptable scalar style. +func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { + + no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 + if no_tag && !event.implicit && !event.quoted_implicit { + return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") + } + + style := event.scalar_style() + if style == yaml_ANY_SCALAR_STYLE { + style = yaml_PLAIN_SCALAR_STYLE + } + if emitter.canonical { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + if emitter.simple_key_context && emitter.scalar_data.multiline { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + + if style == yaml_PLAIN_SCALAR_STYLE { + if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || + emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { + style = yaml_SINGLE_QUOTED_SCALAR_STYLE + } + if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { + style = yaml_SINGLE_QUOTED_SCALAR_STYLE + } + if no_tag && !event.implicit { + style = yaml_SINGLE_QUOTED_SCALAR_STYLE + } + } + if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { + if !emitter.scalar_data.single_quoted_allowed { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + } + if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { + if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + } + + if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { + emitter.tag_data.handle = []byte{'!'} + } + emitter.scalar_data.style = style + return true +} + +// Write an achor. +func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { + if emitter.anchor_data.anchor == nil { + return true + } + c := []byte{'&'} + if emitter.anchor_data.alias { + c[0] = '*' + } + if !yaml_emitter_write_indicator(emitter, c, true, false, false) { + return false + } + return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) +} + +// Write a tag. +func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { + if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { + return true + } + if len(emitter.tag_data.handle) > 0 { + if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { + return false + } + if len(emitter.tag_data.suffix) > 0 { + if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { + return false + } + } + } else { + // [Go] Allocate these slices elsewhere. + if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { + return false + } + if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) { + return false + } + } + return true +} + +// Write a scalar. +func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool { + switch emitter.scalar_data.style { + case yaml_PLAIN_SCALAR_STYLE: + return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) + + case yaml_SINGLE_QUOTED_SCALAR_STYLE: + return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) + + case yaml_DOUBLE_QUOTED_SCALAR_STYLE: + return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) + + case yaml_LITERAL_SCALAR_STYLE: + return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value) + + case yaml_FOLDED_SCALAR_STYLE: + return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value) + } + panic("unknown scalar style") +} + +// Check if a %YAML directive is valid. +func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool { + if version_directive.major != 1 || version_directive.minor != 1 { + return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive") + } + return true +} + +// Check if a %TAG directive is valid. +func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool { + handle := tag_directive.handle + prefix := tag_directive.prefix + if len(handle) == 0 { + return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty") + } + if handle[0] != '!' { + return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'") + } + if handle[len(handle)-1] != '!' { + return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'") + } + for i := 1; i < len(handle)-1; i += width(handle[i]) { + if !is_alpha(handle, i) { + return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only") + } + } + if len(prefix) == 0 { + return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty") + } + return true +} + +// Check if an anchor is valid. +func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool { + if len(anchor) == 0 { + problem := "anchor value must not be empty" + if alias { + problem = "alias value must not be empty" + } + return yaml_emitter_set_emitter_error(emitter, problem) + } + for i := 0; i < len(anchor); i += width(anchor[i]) { + if !is_alpha(anchor, i) { + problem := "anchor value must contain alphanumerical characters only" + if alias { + problem = "alias value must contain alphanumerical characters only" + } + return yaml_emitter_set_emitter_error(emitter, problem) + } + } + emitter.anchor_data.anchor = anchor + emitter.anchor_data.alias = alias + return true +} + +// Check if a tag is valid. +func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool { + if len(tag) == 0 { + return yaml_emitter_set_emitter_error(emitter, "tag value must not be empty") + } + for i := 0; i < len(emitter.tag_directives); i++ { + tag_directive := &emitter.tag_directives[i] + if bytes.HasPrefix(tag, tag_directive.prefix) { + emitter.tag_data.handle = tag_directive.handle + emitter.tag_data.suffix = tag[len(tag_directive.prefix):] + return true + } + } + emitter.tag_data.suffix = tag + return true +} + +// Check if a scalar is valid. +func yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool { + var ( + block_indicators = false + flow_indicators = false + line_breaks = false + special_characters = false + + leading_space = false + leading_break = false + trailing_space = false + trailing_break = false + break_space = false + space_break = false + + preceded_by_whitespace = false + followed_by_whitespace = false + previous_space = false + previous_break = false + ) + + emitter.scalar_data.value = value + + if len(value) == 0 { + emitter.scalar_data.multiline = false + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = true + emitter.scalar_data.single_quoted_allowed = true + emitter.scalar_data.block_allowed = false + return true + } + + if len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) { + block_indicators = true + flow_indicators = true + } + + preceded_by_whitespace = true + for i, w := 0, 0; i < len(value); i += w { + w = width(value[i]) + followed_by_whitespace = i+w >= len(value) || is_blank(value, i+w) + + if i == 0 { + switch value[i] { + case '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`': + flow_indicators = true + block_indicators = true + case '?', ':': + flow_indicators = true + if followed_by_whitespace { + block_indicators = true + } + case '-': + if followed_by_whitespace { + flow_indicators = true + block_indicators = true + } + } + } else { + switch value[i] { + case ',', '?', '[', ']', '{', '}': + flow_indicators = true + case ':': + flow_indicators = true + if followed_by_whitespace { + block_indicators = true + } + case '#': + if preceded_by_whitespace { + flow_indicators = true + block_indicators = true + } + } + } + + if !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode { + special_characters = true + } + if is_space(value, i) { + if i == 0 { + leading_space = true + } + if i+width(value[i]) == len(value) { + trailing_space = true + } + if previous_break { + break_space = true + } + previous_space = true + previous_break = false + } else if is_break(value, i) { + line_breaks = true + if i == 0 { + leading_break = true + } + if i+width(value[i]) == len(value) { + trailing_break = true + } + if previous_space { + space_break = true + } + previous_space = false + previous_break = true + } else { + previous_space = false + previous_break = false + } + + // [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition. + preceded_by_whitespace = is_blankz(value, i) + } + + emitter.scalar_data.multiline = line_breaks + emitter.scalar_data.flow_plain_allowed = true + emitter.scalar_data.block_plain_allowed = true + emitter.scalar_data.single_quoted_allowed = true + emitter.scalar_data.block_allowed = true + + if leading_space || leading_break || trailing_space || trailing_break { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + } + if trailing_space { + emitter.scalar_data.block_allowed = false + } + if break_space { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + emitter.scalar_data.single_quoted_allowed = false + } + if space_break || special_characters { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + emitter.scalar_data.single_quoted_allowed = false + emitter.scalar_data.block_allowed = false + } + if line_breaks { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + } + if flow_indicators { + emitter.scalar_data.flow_plain_allowed = false + } + if block_indicators { + emitter.scalar_data.block_plain_allowed = false + } + return true +} + +// Check if the event data is valid. +func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { + + emitter.anchor_data.anchor = nil + emitter.tag_data.handle = nil + emitter.tag_data.suffix = nil + emitter.scalar_data.value = nil + + switch event.typ { + case yaml_ALIAS_EVENT: + if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) { + return false + } + + case yaml_SCALAR_EVENT: + if len(event.anchor) > 0 { + if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { + return false + } + } + if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) { + if !yaml_emitter_analyze_tag(emitter, event.tag) { + return false + } + } + if !yaml_emitter_analyze_scalar(emitter, event.value) { + return false + } + + case yaml_SEQUENCE_START_EVENT: + if len(event.anchor) > 0 { + if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { + return false + } + } + if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { + if !yaml_emitter_analyze_tag(emitter, event.tag) { + return false + } + } + + case yaml_MAPPING_START_EVENT: + if len(event.anchor) > 0 { + if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { + return false + } + } + if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { + if !yaml_emitter_analyze_tag(emitter, event.tag) { + return false + } + } + } + return true +} + +// Write the BOM character. +func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool { + if !flush(emitter) { + return false + } + pos := emitter.buffer_pos + emitter.buffer[pos+0] = '\xEF' + emitter.buffer[pos+1] = '\xBB' + emitter.buffer[pos+2] = '\xBF' + emitter.buffer_pos += 3 + return true +} + +func yaml_emitter_write_indent(emitter *yaml_emitter_t) bool { + indent := emitter.indent + if indent < 0 { + indent = 0 + } + if !emitter.indention || emitter.column > indent || (emitter.column == indent && !emitter.whitespace) { + if !put_break(emitter) { + return false + } + } + for emitter.column < indent { + if !put(emitter, ' ') { + return false + } + } + emitter.whitespace = true + emitter.indention = true + return true +} + +func yaml_emitter_write_indicator(emitter *yaml_emitter_t, indicator []byte, need_whitespace, is_whitespace, is_indention bool) bool { + if need_whitespace && !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + if !write_all(emitter, indicator) { + return false + } + emitter.whitespace = is_whitespace + emitter.indention = (emitter.indention && is_indention) + emitter.open_ended = false + return true +} + +func yaml_emitter_write_anchor(emitter *yaml_emitter_t, value []byte) bool { + if !write_all(emitter, value) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_tag_handle(emitter *yaml_emitter_t, value []byte) bool { + if !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + if !write_all(emitter, value) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, need_whitespace bool) bool { + if need_whitespace && !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + for i := 0; i < len(value); { + var must_write bool + switch value[i] { + case ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '_', '.', '~', '*', '\'', '(', ')', '[', ']': + must_write = true + default: + must_write = is_alpha(value, i) + } + if must_write { + if !write(emitter, value, &i) { + return false + } + } else { + w := width(value[i]) + for k := 0; k < w; k++ { + octet := value[i] + i++ + if !put(emitter, '%') { + return false + } + + c := octet >> 4 + if c < 10 { + c += '0' + } else { + c += 'A' - 10 + } + if !put(emitter, c) { + return false + } + + c = octet & 0x0f + if c < 10 { + c += '0' + } else { + c += 'A' - 10 + } + if !put(emitter, c) { + return false + } + } + } + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_plain_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { + if !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + + spaces := false + breaks := false + for i := 0; i < len(value); { + if is_space(value, i) { + if allow_breaks && !spaces && emitter.column > emitter.best_width && !is_space(value, i+1) { + if !yaml_emitter_write_indent(emitter) { + return false + } + i += width(value[i]) + } else { + if !write(emitter, value, &i) { + return false + } + } + spaces = true + } else if is_break(value, i) { + if !breaks && value[i] == '\n' { + if !put_break(emitter) { + return false + } + } + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !write(emitter, value, &i) { + return false + } + emitter.indention = false + spaces = false + breaks = false + } + } + + emitter.whitespace = false + emitter.indention = false + if emitter.root_context { + emitter.open_ended = true + } + + return true +} + +func yaml_emitter_write_single_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { + + if !yaml_emitter_write_indicator(emitter, []byte{'\''}, true, false, false) { + return false + } + + spaces := false + breaks := false + for i := 0; i < len(value); { + if is_space(value, i) { + if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 && !is_space(value, i+1) { + if !yaml_emitter_write_indent(emitter) { + return false + } + i += width(value[i]) + } else { + if !write(emitter, value, &i) { + return false + } + } + spaces = true + } else if is_break(value, i) { + if !breaks && value[i] == '\n' { + if !put_break(emitter) { + return false + } + } + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if value[i] == '\'' { + if !put(emitter, '\'') { + return false + } + } + if !write(emitter, value, &i) { + return false + } + emitter.indention = false + spaces = false + breaks = false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{'\''}, false, false, false) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_double_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { + spaces := false + if !yaml_emitter_write_indicator(emitter, []byte{'"'}, true, false, false) { + return false + } + + for i := 0; i < len(value); { + if !is_printable(value, i) || (!emitter.unicode && !is_ascii(value, i)) || + is_bom(value, i) || is_break(value, i) || + value[i] == '"' || value[i] == '\\' { + + octet := value[i] + + var w int + var v rune + switch { + case octet&0x80 == 0x00: + w, v = 1, rune(octet&0x7F) + case octet&0xE0 == 0xC0: + w, v = 2, rune(octet&0x1F) + case octet&0xF0 == 0xE0: + w, v = 3, rune(octet&0x0F) + case octet&0xF8 == 0xF0: + w, v = 4, rune(octet&0x07) + } + for k := 1; k < w; k++ { + octet = value[i+k] + v = (v << 6) + (rune(octet) & 0x3F) + } + i += w + + if !put(emitter, '\\') { + return false + } + + var ok bool + switch v { + case 0x00: + ok = put(emitter, '0') + case 0x07: + ok = put(emitter, 'a') + case 0x08: + ok = put(emitter, 'b') + case 0x09: + ok = put(emitter, 't') + case 0x0A: + ok = put(emitter, 'n') + case 0x0b: + ok = put(emitter, 'v') + case 0x0c: + ok = put(emitter, 'f') + case 0x0d: + ok = put(emitter, 'r') + case 0x1b: + ok = put(emitter, 'e') + case 0x22: + ok = put(emitter, '"') + case 0x5c: + ok = put(emitter, '\\') + case 0x85: + ok = put(emitter, 'N') + case 0xA0: + ok = put(emitter, '_') + case 0x2028: + ok = put(emitter, 'L') + case 0x2029: + ok = put(emitter, 'P') + default: + if v <= 0xFF { + ok = put(emitter, 'x') + w = 2 + } else if v <= 0xFFFF { + ok = put(emitter, 'u') + w = 4 + } else { + ok = put(emitter, 'U') + w = 8 + } + for k := (w - 1) * 4; ok && k >= 0; k -= 4 { + digit := byte((v >> uint(k)) & 0x0F) + if digit < 10 { + ok = put(emitter, digit+'0') + } else { + ok = put(emitter, digit+'A'-10) + } + } + } + if !ok { + return false + } + spaces = false + } else if is_space(value, i) { + if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 { + if !yaml_emitter_write_indent(emitter) { + return false + } + if is_space(value, i+1) { + if !put(emitter, '\\') { + return false + } + } + i += width(value[i]) + } else if !write(emitter, value, &i) { + return false + } + spaces = true + } else { + if !write(emitter, value, &i) { + return false + } + spaces = false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{'"'}, false, false, false) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_block_scalar_hints(emitter *yaml_emitter_t, value []byte) bool { + if is_space(value, 0) || is_break(value, 0) { + indent_hint := []byte{'0' + byte(emitter.best_indent)} + if !yaml_emitter_write_indicator(emitter, indent_hint, false, false, false) { + return false + } + } + + emitter.open_ended = false + + var chomp_hint [1]byte + if len(value) == 0 { + chomp_hint[0] = '-' + } else { + i := len(value) - 1 + for value[i]&0xC0 == 0x80 { + i-- + } + if !is_break(value, i) { + chomp_hint[0] = '-' + } else if i == 0 { + chomp_hint[0] = '+' + emitter.open_ended = true + } else { + i-- + for value[i]&0xC0 == 0x80 { + i-- + } + if is_break(value, i) { + chomp_hint[0] = '+' + emitter.open_ended = true + } + } + } + if chomp_hint[0] != 0 { + if !yaml_emitter_write_indicator(emitter, chomp_hint[:], false, false, false) { + return false + } + } + return true +} + +func yaml_emitter_write_literal_scalar(emitter *yaml_emitter_t, value []byte) bool { + if !yaml_emitter_write_indicator(emitter, []byte{'|'}, true, false, false) { + return false + } + if !yaml_emitter_write_block_scalar_hints(emitter, value) { + return false + } + if !put_break(emitter) { + return false + } + emitter.indention = true + emitter.whitespace = true + breaks := true + for i := 0; i < len(value); { + if is_break(value, i) { + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !write(emitter, value, &i) { + return false + } + emitter.indention = false + breaks = false + } + } + + return true +} + +func yaml_emitter_write_folded_scalar(emitter *yaml_emitter_t, value []byte) bool { + if !yaml_emitter_write_indicator(emitter, []byte{'>'}, true, false, false) { + return false + } + if !yaml_emitter_write_block_scalar_hints(emitter, value) { + return false + } + + if !put_break(emitter) { + return false + } + emitter.indention = true + emitter.whitespace = true + + breaks := true + leading_spaces := true + for i := 0; i < len(value); { + if is_break(value, i) { + if !breaks && !leading_spaces && value[i] == '\n' { + k := 0 + for is_break(value, k) { + k += width(value[k]) + } + if !is_blankz(value, k) { + if !put_break(emitter) { + return false + } + } + } + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + leading_spaces = is_blank(value, i) + } + if !breaks && is_space(value, i) && !is_space(value, i+1) && emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + i += width(value[i]) + } else { + if !write(emitter, value, &i) { + return false + } + } + emitter.indention = false + breaks = false + } + } + return true +} diff --git a/vendor/github.com/go-yaml/yaml/encode.go b/vendor/github.com/go-yaml/yaml/encode.go new file mode 100644 index 0000000000000..1e730eff6a822 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/encode.go @@ -0,0 +1,358 @@ +package yaml + +import ( + "encoding" + "fmt" + "io" + "reflect" + "regexp" + "sort" + "strconv" + "strings" + "time" + "unicode/utf8" +) + +type encoder struct { + emitter yaml_emitter_t + event yaml_event_t + out []byte + flow bool + // doneInit holds whether the initial stream_start_event has been + // emitted. + doneInit bool +} + +func newEncoder() *encoder { + e := &encoder{} + yaml_emitter_initialize(&e.emitter) + yaml_emitter_set_output_string(&e.emitter, &e.out) + yaml_emitter_set_unicode(&e.emitter, true) + return e +} + +func newEncoderWithWriter(w io.Writer) *encoder { + e := &encoder{} + yaml_emitter_initialize(&e.emitter) + yaml_emitter_set_output_writer(&e.emitter, w) + yaml_emitter_set_unicode(&e.emitter, true) + return e +} + +func (e *encoder) init() { + if e.doneInit { + return + } + yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING) + e.emit() + e.doneInit = true +} + +func (e *encoder) finish() { + e.emitter.open_ended = false + yaml_stream_end_event_initialize(&e.event) + e.emit() +} + +func (e *encoder) destroy() { + yaml_emitter_delete(&e.emitter) +} + +func (e *encoder) emit() { + // This will internally delete the e.event value. + e.must(yaml_emitter_emit(&e.emitter, &e.event)) +} + +func (e *encoder) must(ok bool) { + if !ok { + msg := e.emitter.problem + if msg == "" { + msg = "unknown problem generating YAML content" + } + failf("%s", msg) + } +} + +func (e *encoder) marshalDoc(tag string, in reflect.Value) { + e.init() + yaml_document_start_event_initialize(&e.event, nil, nil, true) + e.emit() + e.marshal(tag, in) + yaml_document_end_event_initialize(&e.event, true) + e.emit() +} + +func (e *encoder) marshal(tag string, in reflect.Value) { + if !in.IsValid() || in.Kind() == reflect.Ptr && in.IsNil() { + e.nilv() + return + } + iface := in.Interface() + switch m := iface.(type) { + case time.Time, *time.Time: + // Although time.Time implements TextMarshaler, + // we don't want to treat it as a string for YAML + // purposes because YAML has special support for + // timestamps. + case Marshaler: + v, err := m.MarshalYAML() + if err != nil { + fail(err) + } + if v == nil { + e.nilv() + return + } + in = reflect.ValueOf(v) + case encoding.TextMarshaler: + text, err := m.MarshalText() + if err != nil { + fail(err) + } + in = reflect.ValueOf(string(text)) + case nil: + e.nilv() + return + } + switch in.Kind() { + case reflect.Interface: + e.marshal(tag, in.Elem()) + case reflect.Map: + e.mapv(tag, in) + case reflect.Ptr: + if in.Type() == ptrTimeType { + e.timev(tag, in.Elem()) + } else { + e.marshal(tag, in.Elem()) + } + case reflect.Struct: + if in.Type() == timeType { + e.timev(tag, in) + } else { + e.structv(tag, in) + } + case reflect.Slice: + if in.Type().Elem() == mapItemType { + e.itemsv(tag, in) + } else { + e.slicev(tag, in) + } + case reflect.String: + e.stringv(tag, in) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if in.Type() == durationType { + e.stringv(tag, reflect.ValueOf(iface.(time.Duration).String())) + } else { + e.intv(tag, in) + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + e.uintv(tag, in) + case reflect.Float32, reflect.Float64: + e.floatv(tag, in) + case reflect.Bool: + e.boolv(tag, in) + default: + panic("cannot marshal type: " + in.Type().String()) + } +} + +func (e *encoder) mapv(tag string, in reflect.Value) { + e.mappingv(tag, func() { + keys := keyList(in.MapKeys()) + sort.Sort(keys) + for _, k := range keys { + e.marshal("", k) + e.marshal("", in.MapIndex(k)) + } + }) +} + +func (e *encoder) itemsv(tag string, in reflect.Value) { + e.mappingv(tag, func() { + slice := in.Convert(reflect.TypeOf([]MapItem{})).Interface().([]MapItem) + for _, item := range slice { + e.marshal("", reflect.ValueOf(item.Key)) + e.marshal("", reflect.ValueOf(item.Value)) + } + }) +} + +func (e *encoder) structv(tag string, in reflect.Value) { + sinfo, err := getStructInfo(in.Type()) + if err != nil { + panic(err) + } + e.mappingv(tag, func() { + for _, info := range sinfo.FieldsList { + var value reflect.Value + if info.Inline == nil { + value = in.Field(info.Num) + } else { + value = in.FieldByIndex(info.Inline) + } + if info.OmitEmpty && isZero(value) { + continue + } + e.marshal("", reflect.ValueOf(info.Key)) + e.flow = info.Flow + e.marshal("", value) + } + if sinfo.InlineMap >= 0 { + m := in.Field(sinfo.InlineMap) + if m.Len() > 0 { + e.flow = false + keys := keyList(m.MapKeys()) + sort.Sort(keys) + for _, k := range keys { + if _, found := sinfo.FieldsMap[k.String()]; found { + panic(fmt.Sprintf("Can't have key %q in inlined map; conflicts with struct field", k.String())) + } + e.marshal("", k) + e.flow = false + e.marshal("", m.MapIndex(k)) + } + } + } + }) +} + +func (e *encoder) mappingv(tag string, f func()) { + implicit := tag == "" + style := yaml_BLOCK_MAPPING_STYLE + if e.flow { + e.flow = false + style = yaml_FLOW_MAPPING_STYLE + } + yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style) + e.emit() + f() + yaml_mapping_end_event_initialize(&e.event) + e.emit() +} + +func (e *encoder) slicev(tag string, in reflect.Value) { + implicit := tag == "" + style := yaml_BLOCK_SEQUENCE_STYLE + if e.flow { + e.flow = false + style = yaml_FLOW_SEQUENCE_STYLE + } + e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) + e.emit() + n := in.Len() + for i := 0; i < n; i++ { + e.marshal("", in.Index(i)) + } + e.must(yaml_sequence_end_event_initialize(&e.event)) + e.emit() +} + +// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1. +// +// The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported +// in YAML 1.2 and by this package, but these should be marshalled quoted for +// the time being for compatibility with other parsers. +func isBase60Float(s string) (result bool) { + // Fast path. + if s == "" { + return false + } + c := s[0] + if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { + return false + } + // Do the full match. + return base60float.MatchString(s) +} + +// From http://yaml.org/type/float.html, except the regular expression there +// is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix. +var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`) + +func (e *encoder) stringv(tag string, in reflect.Value) { + var style yaml_scalar_style_t + s := in.String() + canUsePlain := true + switch { + case !utf8.ValidString(s): + if tag == yaml_BINARY_TAG { + failf("explicitly tagged !!binary data must be base64-encoded") + } + if tag != "" { + failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag)) + } + // It can't be encoded directly as YAML so use a binary tag + // and encode it as base64. + tag = yaml_BINARY_TAG + s = encodeBase64(s) + case tag == "": + // Check to see if it would resolve to a specific + // tag when encoded unquoted. If it doesn't, + // there's no need to quote it. + rtag, _ := resolve("", s) + canUsePlain = rtag == yaml_STR_TAG && !isBase60Float(s) + } + // Note: it's possible for user code to emit invalid YAML + // if they explicitly specify a tag and a string containing + // text that's incompatible with that tag. + switch { + case strings.Contains(s, "\n"): + style = yaml_LITERAL_SCALAR_STYLE + case canUsePlain: + style = yaml_PLAIN_SCALAR_STYLE + default: + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + e.emitScalar(s, "", tag, style) +} + +func (e *encoder) boolv(tag string, in reflect.Value) { + var s string + if in.Bool() { + s = "true" + } else { + s = "false" + } + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) intv(tag string, in reflect.Value) { + s := strconv.FormatInt(in.Int(), 10) + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) uintv(tag string, in reflect.Value) { + s := strconv.FormatUint(in.Uint(), 10) + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) timev(tag string, in reflect.Value) { + t := in.Interface().(time.Time) + if tag == "" { + tag = yaml_TIMESTAMP_TAG + } + e.emitScalar(t.Format(time.RFC3339Nano), "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) floatv(tag string, in reflect.Value) { + s := strconv.FormatFloat(in.Float(), 'g', -1, 64) + switch s { + case "+Inf": + s = ".inf" + case "-Inf": + s = "-.inf" + case "NaN": + s = ".nan" + } + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) nilv() { + e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t) { + implicit := tag == "" + e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style)) + e.emit() +} diff --git a/vendor/github.com/go-yaml/yaml/parserc.go b/vendor/github.com/go-yaml/yaml/parserc.go new file mode 100644 index 0000000000000..81d05dfe573f9 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/parserc.go @@ -0,0 +1,1095 @@ +package yaml + +import ( + "bytes" +) + +// The parser implements the following grammar: +// +// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END +// implicit_document ::= block_node DOCUMENT-END* +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// block_node_or_indentless_sequence ::= +// ALIAS +// | properties (block_content | indentless_block_sequence)? +// | block_content +// | indentless_block_sequence +// block_node ::= ALIAS +// | properties block_content? +// | block_content +// flow_node ::= ALIAS +// | properties flow_content? +// | flow_content +// properties ::= TAG ANCHOR? | ANCHOR TAG? +// block_content ::= block_collection | flow_collection | SCALAR +// flow_content ::= flow_collection | SCALAR +// block_collection ::= block_sequence | block_mapping +// flow_collection ::= flow_sequence | flow_mapping +// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END +// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ +// block_mapping ::= BLOCK-MAPPING_START +// ((KEY block_node_or_indentless_sequence?)? +// (VALUE block_node_or_indentless_sequence?)?)* +// BLOCK-END +// flow_sequence ::= FLOW-SEQUENCE-START +// (flow_sequence_entry FLOW-ENTRY)* +// flow_sequence_entry? +// FLOW-SEQUENCE-END +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// flow_mapping ::= FLOW-MAPPING-START +// (flow_mapping_entry FLOW-ENTRY)* +// flow_mapping_entry? +// FLOW-MAPPING-END +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + +// Peek the next token in the token queue. +func peek_token(parser *yaml_parser_t) *yaml_token_t { + if parser.token_available || yaml_parser_fetch_more_tokens(parser) { + return &parser.tokens[parser.tokens_head] + } + return nil +} + +// Remove the next token from the queue (must be called after peek_token). +func skip_token(parser *yaml_parser_t) { + parser.token_available = false + parser.tokens_parsed++ + parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN + parser.tokens_head++ +} + +// Get the next event. +func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool { + // Erase the event object. + *event = yaml_event_t{} + + // No events after the end of the stream or error. + if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE { + return true + } + + // Generate the next event. + return yaml_parser_state_machine(parser, event) +} + +// Set parser error. +func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool { + parser.error = yaml_PARSER_ERROR + parser.problem = problem + parser.problem_mark = problem_mark + return false +} + +func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool { + parser.error = yaml_PARSER_ERROR + parser.context = context + parser.context_mark = context_mark + parser.problem = problem + parser.problem_mark = problem_mark + return false +} + +// State dispatcher. +func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool { + //trace("yaml_parser_state_machine", "state:", parser.state.String()) + + switch parser.state { + case yaml_PARSE_STREAM_START_STATE: + return yaml_parser_parse_stream_start(parser, event) + + case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: + return yaml_parser_parse_document_start(parser, event, true) + + case yaml_PARSE_DOCUMENT_START_STATE: + return yaml_parser_parse_document_start(parser, event, false) + + case yaml_PARSE_DOCUMENT_CONTENT_STATE: + return yaml_parser_parse_document_content(parser, event) + + case yaml_PARSE_DOCUMENT_END_STATE: + return yaml_parser_parse_document_end(parser, event) + + case yaml_PARSE_BLOCK_NODE_STATE: + return yaml_parser_parse_node(parser, event, true, false) + + case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: + return yaml_parser_parse_node(parser, event, true, true) + + case yaml_PARSE_FLOW_NODE_STATE: + return yaml_parser_parse_node(parser, event, false, false) + + case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: + return yaml_parser_parse_block_sequence_entry(parser, event, true) + + case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: + return yaml_parser_parse_block_sequence_entry(parser, event, false) + + case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: + return yaml_parser_parse_indentless_sequence_entry(parser, event) + + case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: + return yaml_parser_parse_block_mapping_key(parser, event, true) + + case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: + return yaml_parser_parse_block_mapping_key(parser, event, false) + + case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: + return yaml_parser_parse_block_mapping_value(parser, event) + + case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: + return yaml_parser_parse_flow_sequence_entry(parser, event, true) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: + return yaml_parser_parse_flow_sequence_entry(parser, event, false) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: + return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: + return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: + return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event) + + case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: + return yaml_parser_parse_flow_mapping_key(parser, event, true) + + case yaml_PARSE_FLOW_MAPPING_KEY_STATE: + return yaml_parser_parse_flow_mapping_key(parser, event, false) + + case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: + return yaml_parser_parse_flow_mapping_value(parser, event, false) + + case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: + return yaml_parser_parse_flow_mapping_value(parser, event, true) + + default: + panic("invalid parser state") + } +} + +// Parse the production: +// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END +// ************ +func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_STREAM_START_TOKEN { + return yaml_parser_set_parser_error(parser, "did not find expected ", token.start_mark) + } + parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE + *event = yaml_event_t{ + typ: yaml_STREAM_START_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + encoding: token.encoding, + } + skip_token(parser) + return true +} + +// Parse the productions: +// implicit_document ::= block_node DOCUMENT-END* +// * +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// ************************* +func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool { + + token := peek_token(parser) + if token == nil { + return false + } + + // Parse extra document end indicators. + if !implicit { + for token.typ == yaml_DOCUMENT_END_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + } + + if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN && + token.typ != yaml_TAG_DIRECTIVE_TOKEN && + token.typ != yaml_DOCUMENT_START_TOKEN && + token.typ != yaml_STREAM_END_TOKEN { + // Parse an implicit document. + if !yaml_parser_process_directives(parser, nil, nil) { + return false + } + parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) + parser.state = yaml_PARSE_BLOCK_NODE_STATE + + *event = yaml_event_t{ + typ: yaml_DOCUMENT_START_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + + } else if token.typ != yaml_STREAM_END_TOKEN { + // Parse an explicit document. + var version_directive *yaml_version_directive_t + var tag_directives []yaml_tag_directive_t + start_mark := token.start_mark + if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) { + return false + } + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_DOCUMENT_START_TOKEN { + yaml_parser_set_parser_error(parser, + "did not find expected ", token.start_mark) + return false + } + parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) + parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE + end_mark := token.end_mark + + *event = yaml_event_t{ + typ: yaml_DOCUMENT_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + version_directive: version_directive, + tag_directives: tag_directives, + implicit: false, + } + skip_token(parser) + + } else { + // Parse the stream end. + parser.state = yaml_PARSE_END_STATE + *event = yaml_event_t{ + typ: yaml_STREAM_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + skip_token(parser) + } + + return true +} + +// Parse the productions: +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// *********** +// +func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_VERSION_DIRECTIVE_TOKEN || + token.typ == yaml_TAG_DIRECTIVE_TOKEN || + token.typ == yaml_DOCUMENT_START_TOKEN || + token.typ == yaml_DOCUMENT_END_TOKEN || + token.typ == yaml_STREAM_END_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + return yaml_parser_process_empty_scalar(parser, event, + token.start_mark) + } + return yaml_parser_parse_node(parser, event, true, false) +} + +// Parse the productions: +// implicit_document ::= block_node DOCUMENT-END* +// ************* +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// +func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + + start_mark := token.start_mark + end_mark := token.start_mark + + implicit := true + if token.typ == yaml_DOCUMENT_END_TOKEN { + end_mark = token.end_mark + skip_token(parser) + implicit = false + } + + parser.tag_directives = parser.tag_directives[:0] + + parser.state = yaml_PARSE_DOCUMENT_START_STATE + *event = yaml_event_t{ + typ: yaml_DOCUMENT_END_EVENT, + start_mark: start_mark, + end_mark: end_mark, + implicit: implicit, + } + return true +} + +// Parse the productions: +// block_node_or_indentless_sequence ::= +// ALIAS +// ***** +// | properties (block_content | indentless_block_sequence)? +// ********** * +// | block_content | indentless_block_sequence +// * +// block_node ::= ALIAS +// ***** +// | properties block_content? +// ********** * +// | block_content +// * +// flow_node ::= ALIAS +// ***** +// | properties flow_content? +// ********** * +// | flow_content +// * +// properties ::= TAG ANCHOR? | ANCHOR TAG? +// ************************* +// block_content ::= block_collection | flow_collection | SCALAR +// ****** +// flow_content ::= flow_collection | SCALAR +// ****** +func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool { + //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)() + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_ALIAS_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + *event = yaml_event_t{ + typ: yaml_ALIAS_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + anchor: token.value, + } + skip_token(parser) + return true + } + + start_mark := token.start_mark + end_mark := token.start_mark + + var tag_token bool + var tag_handle, tag_suffix, anchor []byte + var tag_mark yaml_mark_t + if token.typ == yaml_ANCHOR_TOKEN { + anchor = token.value + start_mark = token.start_mark + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_TAG_TOKEN { + tag_token = true + tag_handle = token.value + tag_suffix = token.suffix + tag_mark = token.start_mark + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + } else if token.typ == yaml_TAG_TOKEN { + tag_token = true + tag_handle = token.value + tag_suffix = token.suffix + start_mark = token.start_mark + tag_mark = token.start_mark + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_ANCHOR_TOKEN { + anchor = token.value + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + } + + var tag []byte + if tag_token { + if len(tag_handle) == 0 { + tag = tag_suffix + tag_suffix = nil + } else { + for i := range parser.tag_directives { + if bytes.Equal(parser.tag_directives[i].handle, tag_handle) { + tag = append([]byte(nil), parser.tag_directives[i].prefix...) + tag = append(tag, tag_suffix...) + break + } + } + if len(tag) == 0 { + yaml_parser_set_parser_error_context(parser, + "while parsing a node", start_mark, + "found undefined tag handle", tag_mark) + return false + } + } + } + + implicit := len(tag) == 0 + if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), + } + return true + } + if token.typ == yaml_SCALAR_TOKEN { + var plain_implicit, quoted_implicit bool + end_mark = token.end_mark + if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') { + plain_implicit = true + } else if len(tag) == 0 { + quoted_implicit = true + } + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + value: token.value, + implicit: plain_implicit, + quoted_implicit: quoted_implicit, + style: yaml_style_t(token.style), + } + skip_token(parser) + return true + } + if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN { + // [Go] Some of the events below can be merged as they differ only on style. + end_mark = token.end_mark + parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE), + } + return true + } + if token.typ == yaml_FLOW_MAPPING_START_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), + } + return true + } + if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), + } + return true + } + if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE), + } + return true + } + if len(anchor) > 0 || len(tag) > 0 { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + quoted_implicit: false, + style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), + } + return true + } + + context := "while parsing a flow node" + if block { + context = "while parsing a block node" + } + yaml_parser_set_parser_error_context(parser, context, start_mark, + "did not find expected node content", token.start_mark) + return false +} + +// Parse the productions: +// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END +// ******************** *********** * ********* +// +func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_BLOCK_ENTRY_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE) + return yaml_parser_parse_node(parser, event, true, false) + } else { + parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + } + if token.typ == yaml_BLOCK_END_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + + skip_token(parser) + return true + } + + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a block collection", context_mark, + "did not find expected '-' indicator", token.start_mark) +} + +// Parse the productions: +// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ +// *********** * +func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_BLOCK_ENTRY_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_BLOCK_ENTRY_TOKEN && + token.typ != yaml_KEY_TOKEN && + token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE) + return yaml_parser_parse_node(parser, event, true, false) + } + parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + start_mark: token.start_mark, + end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark? + } + return true +} + +// Parse the productions: +// block_mapping ::= BLOCK-MAPPING_START +// ******************* +// ((KEY block_node_or_indentless_sequence?)? +// *** * +// (VALUE block_node_or_indentless_sequence?)?)* +// +// BLOCK-END +// ********* +// +func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_KEY_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_KEY_TOKEN && + token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE) + return yaml_parser_parse_node(parser, event, true, true) + } else { + parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + } else if token.typ == yaml_BLOCK_END_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + skip_token(parser) + return true + } + + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a block mapping", context_mark, + "did not find expected key", token.start_mark) +} + +// Parse the productions: +// block_mapping ::= BLOCK-MAPPING_START +// +// ((KEY block_node_or_indentless_sequence?)? +// +// (VALUE block_node_or_indentless_sequence?)?)* +// ***** * +// BLOCK-END +// +// +func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_VALUE_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_KEY_TOKEN && + token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE) + return yaml_parser_parse_node(parser, event, true, true) + } + parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) +} + +// Parse the productions: +// flow_sequence ::= FLOW-SEQUENCE-START +// ******************* +// (flow_sequence_entry FLOW-ENTRY)* +// * ********** +// flow_sequence_entry? +// * +// FLOW-SEQUENCE-END +// ***************** +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * +// +func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + if !first { + if token.typ == yaml_FLOW_ENTRY_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } else { + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a flow sequence", context_mark, + "did not find expected ',' or ']'", token.start_mark) + } + } + + if token.typ == yaml_KEY_TOKEN { + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + implicit: true, + style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), + } + skip_token(parser) + return true + } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + + skip_token(parser) + return true +} + +// +// Parse the productions: +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// *** * +// +func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_FLOW_ENTRY_TOKEN && + token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + mark := token.end_mark + skip_token(parser) + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) +} + +// Parse the productions: +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// ***** * +// +func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_VALUE_TOKEN { + skip_token(parser) + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) +} + +// Parse the productions: +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * +// +func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + start_mark: token.start_mark, + end_mark: token.start_mark, // [Go] Shouldn't this be end_mark? + } + return true +} + +// Parse the productions: +// flow_mapping ::= FLOW-MAPPING-START +// ****************** +// (flow_mapping_entry FLOW-ENTRY)* +// * ********** +// flow_mapping_entry? +// ****************** +// FLOW-MAPPING-END +// **************** +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * *** * +// +func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ != yaml_FLOW_MAPPING_END_TOKEN { + if !first { + if token.typ == yaml_FLOW_ENTRY_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } else { + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a flow mapping", context_mark, + "did not find expected ',' or '}'", token.start_mark) + } + } + + if token.typ == yaml_KEY_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_FLOW_ENTRY_TOKEN && + token.typ != yaml_FLOW_MAPPING_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } else { + parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) + } + } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + skip_token(parser) + return true +} + +// Parse the productions: +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * ***** * +// +func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool { + token := peek_token(parser) + if token == nil { + return false + } + if empty { + parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) + } + if token.typ == yaml_VALUE_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) +} + +// Generate an empty scalar event. +func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool { + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + start_mark: mark, + end_mark: mark, + value: nil, // Empty + implicit: true, + style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), + } + return true +} + +var default_tag_directives = []yaml_tag_directive_t{ + {[]byte("!"), []byte("!")}, + {[]byte("!!"), []byte("tag:yaml.org,2002:")}, +} + +// Parse directives. +func yaml_parser_process_directives(parser *yaml_parser_t, + version_directive_ref **yaml_version_directive_t, + tag_directives_ref *[]yaml_tag_directive_t) bool { + + var version_directive *yaml_version_directive_t + var tag_directives []yaml_tag_directive_t + + token := peek_token(parser) + if token == nil { + return false + } + + for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN { + if token.typ == yaml_VERSION_DIRECTIVE_TOKEN { + if version_directive != nil { + yaml_parser_set_parser_error(parser, + "found duplicate %YAML directive", token.start_mark) + return false + } + if token.major != 1 || token.minor != 1 { + yaml_parser_set_parser_error(parser, + "found incompatible YAML document", token.start_mark) + return false + } + version_directive = &yaml_version_directive_t{ + major: token.major, + minor: token.minor, + } + } else if token.typ == yaml_TAG_DIRECTIVE_TOKEN { + value := yaml_tag_directive_t{ + handle: token.value, + prefix: token.prefix, + } + if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) { + return false + } + tag_directives = append(tag_directives, value) + } + + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + + for i := range default_tag_directives { + if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) { + return false + } + } + + if version_directive_ref != nil { + *version_directive_ref = version_directive + } + if tag_directives_ref != nil { + *tag_directives_ref = tag_directives + } + return true +} + +// Append a tag directive to the directives stack. +func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool { + for i := range parser.tag_directives { + if bytes.Equal(value.handle, parser.tag_directives[i].handle) { + if allow_duplicates { + return true + } + return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark) + } + } + + // [Go] I suspect the copy is unnecessary. This was likely done + // because there was no way to track ownership of the data. + value_copy := yaml_tag_directive_t{ + handle: make([]byte, len(value.handle)), + prefix: make([]byte, len(value.prefix)), + } + copy(value_copy.handle, value.handle) + copy(value_copy.prefix, value.prefix) + parser.tag_directives = append(parser.tag_directives, value_copy) + return true +} diff --git a/vendor/github.com/go-yaml/yaml/readerc.go b/vendor/github.com/go-yaml/yaml/readerc.go new file mode 100644 index 0000000000000..f450791717bf2 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/readerc.go @@ -0,0 +1,394 @@ +package yaml + +import ( + "io" +) + +// Set the reader error and return 0. +func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { + parser.error = yaml_READER_ERROR + parser.problem = problem + parser.problem_offset = offset + parser.problem_value = value + return false +} + +// Byte order marks. +const ( + bom_UTF8 = "\xef\xbb\xbf" + bom_UTF16LE = "\xff\xfe" + bom_UTF16BE = "\xfe\xff" +) + +// Determine the input stream encoding by checking the BOM symbol. If no BOM is +// found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure. +func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { + // Ensure that we had enough bytes in the raw buffer. + for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { + if !yaml_parser_update_raw_buffer(parser) { + return false + } + } + + // Determine the encoding. + buf := parser.raw_buffer + pos := parser.raw_buffer_pos + avail := len(buf) - pos + if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { + parser.encoding = yaml_UTF16LE_ENCODING + parser.raw_buffer_pos += 2 + parser.offset += 2 + } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { + parser.encoding = yaml_UTF16BE_ENCODING + parser.raw_buffer_pos += 2 + parser.offset += 2 + } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { + parser.encoding = yaml_UTF8_ENCODING + parser.raw_buffer_pos += 3 + parser.offset += 3 + } else { + parser.encoding = yaml_UTF8_ENCODING + } + return true +} + +// Update the raw buffer. +func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { + size_read := 0 + + // Return if the raw buffer is full. + if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { + return true + } + + // Return on EOF. + if parser.eof { + return true + } + + // Move the remaining bytes in the raw buffer to the beginning. + if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { + copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) + } + parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] + parser.raw_buffer_pos = 0 + + // Call the read handler to fill the buffer. + size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) + parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] + if err == io.EOF { + parser.eof = true + } else if err != nil { + return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) + } + return true +} + +// Ensure that the buffer contains at least `length` characters. +// Return true on success, false on failure. +// +// The length is supposed to be significantly less that the buffer size. +func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { + if parser.read_handler == nil { + panic("read handler must be set") + } + + // If the EOF flag is set and the raw buffer is empty, do nothing. + if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) { + return true + } + + // Return if the buffer contains enough characters. + if parser.unread >= length { + return true + } + + // Determine the input encoding if it is not known yet. + if parser.encoding == yaml_ANY_ENCODING { + if !yaml_parser_determine_encoding(parser) { + return false + } + } + + // Move the unread characters to the beginning of the buffer. + buffer_len := len(parser.buffer) + if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len { + copy(parser.buffer, parser.buffer[parser.buffer_pos:]) + buffer_len -= parser.buffer_pos + parser.buffer_pos = 0 + } else if parser.buffer_pos == buffer_len { + buffer_len = 0 + parser.buffer_pos = 0 + } + + // Open the whole buffer for writing, and cut it before returning. + parser.buffer = parser.buffer[:cap(parser.buffer)] + + // Fill the buffer until it has enough characters. + first := true + for parser.unread < length { + + // Fill the raw buffer if necessary. + if !first || parser.raw_buffer_pos == len(parser.raw_buffer) { + if !yaml_parser_update_raw_buffer(parser) { + parser.buffer = parser.buffer[:buffer_len] + return false + } + } + first = false + + // Decode the raw buffer. + inner: + for parser.raw_buffer_pos != len(parser.raw_buffer) { + var value rune + var width int + + raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos + + // Decode the next character. + switch parser.encoding { + case yaml_UTF8_ENCODING: + // Decode a UTF-8 character. Check RFC 3629 + // (http://www.ietf.org/rfc/rfc3629.txt) for more details. + // + // The following table (taken from the RFC) is used for + // decoding. + // + // Char. number range | UTF-8 octet sequence + // (hexadecimal) | (binary) + // --------------------+------------------------------------ + // 0000 0000-0000 007F | 0xxxxxxx + // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx + // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx + // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + // + // Additionally, the characters in the range 0xD800-0xDFFF + // are prohibited as they are reserved for use with UTF-16 + // surrogate pairs. + + // Determine the length of the UTF-8 sequence. + octet := parser.raw_buffer[parser.raw_buffer_pos] + switch { + case octet&0x80 == 0x00: + width = 1 + case octet&0xE0 == 0xC0: + width = 2 + case octet&0xF0 == 0xE0: + width = 3 + case octet&0xF8 == 0xF0: + width = 4 + default: + // The leading octet is invalid. + return yaml_parser_set_reader_error(parser, + "invalid leading UTF-8 octet", + parser.offset, int(octet)) + } + + // Check if the raw buffer contains an incomplete character. + if width > raw_unread { + if parser.eof { + return yaml_parser_set_reader_error(parser, + "incomplete UTF-8 octet sequence", + parser.offset, -1) + } + break inner + } + + // Decode the leading octet. + switch { + case octet&0x80 == 0x00: + value = rune(octet & 0x7F) + case octet&0xE0 == 0xC0: + value = rune(octet & 0x1F) + case octet&0xF0 == 0xE0: + value = rune(octet & 0x0F) + case octet&0xF8 == 0xF0: + value = rune(octet & 0x07) + default: + value = 0 + } + + // Check and decode the trailing octets. + for k := 1; k < width; k++ { + octet = parser.raw_buffer[parser.raw_buffer_pos+k] + + // Check if the octet is valid. + if (octet & 0xC0) != 0x80 { + return yaml_parser_set_reader_error(parser, + "invalid trailing UTF-8 octet", + parser.offset+k, int(octet)) + } + + // Decode the octet. + value = (value << 6) + rune(octet&0x3F) + } + + // Check the length of the sequence against the value. + switch { + case width == 1: + case width == 2 && value >= 0x80: + case width == 3 && value >= 0x800: + case width == 4 && value >= 0x10000: + default: + return yaml_parser_set_reader_error(parser, + "invalid length of a UTF-8 sequence", + parser.offset, -1) + } + + // Check the range of the value. + if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF { + return yaml_parser_set_reader_error(parser, + "invalid Unicode character", + parser.offset, int(value)) + } + + case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING: + var low, high int + if parser.encoding == yaml_UTF16LE_ENCODING { + low, high = 0, 1 + } else { + low, high = 1, 0 + } + + // The UTF-16 encoding is not as simple as one might + // naively think. Check RFC 2781 + // (http://www.ietf.org/rfc/rfc2781.txt). + // + // Normally, two subsequent bytes describe a Unicode + // character. However a special technique (called a + // surrogate pair) is used for specifying character + // values larger than 0xFFFF. + // + // A surrogate pair consists of two pseudo-characters: + // high surrogate area (0xD800-0xDBFF) + // low surrogate area (0xDC00-0xDFFF) + // + // The following formulas are used for decoding + // and encoding characters using surrogate pairs: + // + // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF) + // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF) + // W1 = 110110yyyyyyyyyy + // W2 = 110111xxxxxxxxxx + // + // where U is the character value, W1 is the high surrogate + // area, W2 is the low surrogate area. + + // Check for incomplete UTF-16 character. + if raw_unread < 2 { + if parser.eof { + return yaml_parser_set_reader_error(parser, + "incomplete UTF-16 character", + parser.offset, -1) + } + break inner + } + + // Get the character. + value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) + + (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8) + + // Check for unexpected low surrogate area. + if value&0xFC00 == 0xDC00 { + return yaml_parser_set_reader_error(parser, + "unexpected low surrogate area", + parser.offset, int(value)) + } + + // Check for a high surrogate area. + if value&0xFC00 == 0xD800 { + width = 4 + + // Check for incomplete surrogate pair. + if raw_unread < 4 { + if parser.eof { + return yaml_parser_set_reader_error(parser, + "incomplete UTF-16 surrogate pair", + parser.offset, -1) + } + break inner + } + + // Get the next character. + value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) + + (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8) + + // Check for a low surrogate area. + if value2&0xFC00 != 0xDC00 { + return yaml_parser_set_reader_error(parser, + "expected low surrogate area", + parser.offset+2, int(value2)) + } + + // Generate the value of the surrogate pair. + value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF) + } else { + width = 2 + } + + default: + panic("impossible") + } + + // Check if the character is in the allowed range: + // #x9 | #xA | #xD | [#x20-#x7E] (8 bit) + // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit) + // | [#x10000-#x10FFFF] (32 bit) + switch { + case value == 0x09: + case value == 0x0A: + case value == 0x0D: + case value >= 0x20 && value <= 0x7E: + case value == 0x85: + case value >= 0xA0 && value <= 0xD7FF: + case value >= 0xE000 && value <= 0xFFFD: + case value >= 0x10000 && value <= 0x10FFFF: + default: + return yaml_parser_set_reader_error(parser, + "control characters are not allowed", + parser.offset, int(value)) + } + + // Move the raw pointers. + parser.raw_buffer_pos += width + parser.offset += width + + // Finally put the character into the buffer. + if value <= 0x7F { + // 0000 0000-0000 007F . 0xxxxxxx + parser.buffer[buffer_len+0] = byte(value) + buffer_len += 1 + } else if value <= 0x7FF { + // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx + parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6)) + parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F)) + buffer_len += 2 + } else if value <= 0xFFFF { + // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx + parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12)) + parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F)) + parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F)) + buffer_len += 3 + } else { + // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18)) + parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F)) + parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F)) + parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F)) + buffer_len += 4 + } + + parser.unread++ + } + + // On EOF, put NUL into the buffer and return. + if parser.eof { + parser.buffer[buffer_len] = 0 + buffer_len++ + parser.unread++ + break + } + } + parser.buffer = parser.buffer[:buffer_len] + return true +} diff --git a/vendor/github.com/go-yaml/yaml/resolve.go b/vendor/github.com/go-yaml/yaml/resolve.go new file mode 100644 index 0000000000000..ea90bd5e0dea0 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/resolve.go @@ -0,0 +1,245 @@ +package yaml + +import ( + "encoding/base64" + "math" + "regexp" + "strconv" + "strings" + "time" +) + +type resolveMapItem struct { + value interface{} + tag string +} + +var resolveTable = make([]byte, 256) +var resolveMap = make(map[string]resolveMapItem) + +func init() { + t := resolveTable + t[int('+')] = 'S' // Sign + t[int('-')] = 'S' + for _, c := range "0123456789" { + t[int(c)] = 'D' // Digit + } + for _, c := range "yYnNtTfFoO~" { + t[int(c)] = 'M' // In map + } + t[int('.')] = '.' // Float (potentially in map) + + var resolveMapList = []struct { + v interface{} + tag string + l []string + }{ + {true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}}, + {true, yaml_BOOL_TAG, []string{"true", "True", "TRUE"}}, + {true, yaml_BOOL_TAG, []string{"on", "On", "ON"}}, + {false, yaml_BOOL_TAG, []string{"n", "N", "no", "No", "NO"}}, + {false, yaml_BOOL_TAG, []string{"false", "False", "FALSE"}}, + {false, yaml_BOOL_TAG, []string{"off", "Off", "OFF"}}, + {nil, yaml_NULL_TAG, []string{"", "~", "null", "Null", "NULL"}}, + {math.NaN(), yaml_FLOAT_TAG, []string{".nan", ".NaN", ".NAN"}}, + {math.Inf(+1), yaml_FLOAT_TAG, []string{".inf", ".Inf", ".INF"}}, + {math.Inf(+1), yaml_FLOAT_TAG, []string{"+.inf", "+.Inf", "+.INF"}}, + {math.Inf(-1), yaml_FLOAT_TAG, []string{"-.inf", "-.Inf", "-.INF"}}, + {"<<", yaml_MERGE_TAG, []string{"<<"}}, + } + + m := resolveMap + for _, item := range resolveMapList { + for _, s := range item.l { + m[s] = resolveMapItem{item.v, item.tag} + } + } +} + +const longTagPrefix = "tag:yaml.org,2002:" + +func shortTag(tag string) string { + // TODO This can easily be made faster and produce less garbage. + if strings.HasPrefix(tag, longTagPrefix) { + return "!!" + tag[len(longTagPrefix):] + } + return tag +} + +func longTag(tag string) string { + if strings.HasPrefix(tag, "!!") { + return longTagPrefix + tag[2:] + } + return tag +} + +func resolvableTag(tag string) bool { + switch tag { + case "", yaml_STR_TAG, yaml_BOOL_TAG, yaml_INT_TAG, yaml_FLOAT_TAG, yaml_NULL_TAG, yaml_TIMESTAMP_TAG: + return true + } + return false +} + +var yamlStyleFloat = regexp.MustCompile(`^[-+]?[0-9]*\.?[0-9]+([eE][-+][0-9]+)?$`) + +func resolve(tag string, in string) (rtag string, out interface{}) { + if !resolvableTag(tag) { + return tag, in + } + + defer func() { + switch tag { + case "", rtag, yaml_STR_TAG, yaml_BINARY_TAG: + return + } + failf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag)) + }() + + // Any data is accepted as a !!str or !!binary. + // Otherwise, the prefix is enough of a hint about what it might be. + hint := byte('N') + if in != "" { + hint = resolveTable[in[0]] + } + if hint != 0 && tag != yaml_STR_TAG && tag != yaml_BINARY_TAG { + // Handle things we can lookup in a map. + if item, ok := resolveMap[in]; ok { + return item.tag, item.value + } + + // Base 60 floats are a bad idea, were dropped in YAML 1.2, and + // are purposefully unsupported here. They're still quoted on + // the way out for compatibility with other parser, though. + + switch hint { + case 'M': + // We've already checked the map above. + + case '.': + // Not in the map, so maybe a normal float. + floatv, err := strconv.ParseFloat(in, 64) + if err == nil { + return yaml_FLOAT_TAG, floatv + } + + case 'D', 'S': + // Int, float, or timestamp. + // Only try values as a timestamp if the value is unquoted or there's an explicit + // !!timestamp tag. + if tag == "" || tag == yaml_TIMESTAMP_TAG { + t, ok := parseTimestamp(in) + if ok { + return yaml_TIMESTAMP_TAG, t + } + } + + plain := strings.Replace(in, "_", "", -1) + intv, err := strconv.ParseInt(plain, 0, 64) + if err == nil { + if intv == int64(int(intv)) { + return yaml_INT_TAG, int(intv) + } else { + return yaml_INT_TAG, intv + } + } + uintv, err := strconv.ParseUint(plain, 0, 64) + if err == nil { + return yaml_INT_TAG, uintv + } + if yamlStyleFloat.MatchString(plain) { + floatv, err := strconv.ParseFloat(plain, 64) + if err == nil { + return yaml_FLOAT_TAG, floatv + } + } + if strings.HasPrefix(plain, "0b") { + intv, err := strconv.ParseInt(plain[2:], 2, 64) + if err == nil { + if intv == int64(int(intv)) { + return yaml_INT_TAG, int(intv) + } else { + return yaml_INT_TAG, intv + } + } + uintv, err := strconv.ParseUint(plain[2:], 2, 64) + if err == nil { + return yaml_INT_TAG, uintv + } + } else if strings.HasPrefix(plain, "-0b") { + intv, err := strconv.ParseInt(plain[3:], 2, 64) + if err == nil { + if intv == int64(int(intv)) { + return yaml_INT_TAG, -int(intv) + } else { + return yaml_INT_TAG, -intv + } + } + } + default: + panic("resolveTable item not yet handled: " + string(rune(hint)) + " (with " + in + ")") + } + } + return yaml_STR_TAG, in +} + +// encodeBase64 encodes s as base64 that is broken up into multiple lines +// as appropriate for the resulting length. +func encodeBase64(s string) string { + const lineLen = 70 + encLen := base64.StdEncoding.EncodedLen(len(s)) + lines := encLen/lineLen + 1 + buf := make([]byte, encLen*2+lines) + in := buf[0:encLen] + out := buf[encLen:] + base64.StdEncoding.Encode(in, []byte(s)) + k := 0 + for i := 0; i < len(in); i += lineLen { + j := i + lineLen + if j > len(in) { + j = len(in) + } + k += copy(out[k:], in[i:j]) + if lines > 1 { + out[k] = '\n' + k++ + } + } + return string(out[:k]) +} + +// This is a subset of the formats allowed by the regular expression +// defined at http://yaml.org/type/timestamp.html. +var allowedTimestampFormats = []string{ + "2006-1-2T15:4:5Z07:00", + "2006-1-2t15:4:5Z07:00", // RFC3339 with lower-case "t". + "2006-1-2 15:4:5", // space separated with no time zone + "2006-1-2", // date only + // Notable exception: time.Parse cannot handle: "2001-12-14 21:59:43.10 -5" + // from the set of examples. +} + +// parseTimestamp parses s as a timestamp string and +// returns the timestamp and reports whether it succeeded. +// Timestamp formats are defined at http://yaml.org/type/timestamp.html +func parseTimestamp(s string) (time.Time, bool) { + // TODO write code to check all the formats supported by + // http://yaml.org/type/timestamp.html instead of using time.Parse. + + // Quick check: all date formats start with YYYY-. + i := 0 + for ; i < len(s); i++ { + if c := s[i]; c < '0' || c > '9' { + break + } + } + if i != 4 || i == len(s) || s[i] != '-' { + return time.Time{}, false + } + for _, format := range allowedTimestampFormats { + if t, err := time.Parse(format, s); err == nil { + return t, true + } + } + return time.Time{}, false +} diff --git a/vendor/github.com/go-yaml/yaml/scannerc.go b/vendor/github.com/go-yaml/yaml/scannerc.go new file mode 100644 index 0000000000000..492a9845dacc7 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/scannerc.go @@ -0,0 +1,2702 @@ +package yaml + +import ( + "bytes" + "fmt" +) + +// Introduction +// ************ +// +// The following notes assume that you are familiar with the YAML specification +// (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in +// some cases we are less restrictive that it requires. +// +// The process of transforming a YAML stream into a sequence of events is +// divided on two steps: Scanning and Parsing. +// +// The Scanner transforms the input stream into a sequence of tokens, while the +// parser transform the sequence of tokens produced by the Scanner into a +// sequence of parsing events. +// +// The Scanner is rather clever and complicated. The Parser, on the contrary, +// is a straightforward implementation of a recursive-descendant parser (or, +// LL(1) parser, as it is usually called). +// +// Actually there are two issues of Scanning that might be called "clever", the +// rest is quite straightforward. The issues are "block collection start" and +// "simple keys". Both issues are explained below in details. +// +// Here the Scanning step is explained and implemented. We start with the list +// of all the tokens produced by the Scanner together with short descriptions. +// +// Now, tokens: +// +// STREAM-START(encoding) # The stream start. +// STREAM-END # The stream end. +// VERSION-DIRECTIVE(major,minor) # The '%YAML' directive. +// TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive. +// DOCUMENT-START # '---' +// DOCUMENT-END # '...' +// BLOCK-SEQUENCE-START # Indentation increase denoting a block +// BLOCK-MAPPING-START # sequence or a block mapping. +// BLOCK-END # Indentation decrease. +// FLOW-SEQUENCE-START # '[' +// FLOW-SEQUENCE-END # ']' +// BLOCK-SEQUENCE-START # '{' +// BLOCK-SEQUENCE-END # '}' +// BLOCK-ENTRY # '-' +// FLOW-ENTRY # ',' +// KEY # '?' or nothing (simple keys). +// VALUE # ':' +// ALIAS(anchor) # '*anchor' +// ANCHOR(anchor) # '&anchor' +// TAG(handle,suffix) # '!handle!suffix' +// SCALAR(value,style) # A scalar. +// +// The following two tokens are "virtual" tokens denoting the beginning and the +// end of the stream: +// +// STREAM-START(encoding) +// STREAM-END +// +// We pass the information about the input stream encoding with the +// STREAM-START token. +// +// The next two tokens are responsible for tags: +// +// VERSION-DIRECTIVE(major,minor) +// TAG-DIRECTIVE(handle,prefix) +// +// Example: +// +// %YAML 1.1 +// %TAG ! !foo +// %TAG !yaml! tag:yaml.org,2002: +// --- +// +// The correspoding sequence of tokens: +// +// STREAM-START(utf-8) +// VERSION-DIRECTIVE(1,1) +// TAG-DIRECTIVE("!","!foo") +// TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:") +// DOCUMENT-START +// STREAM-END +// +// Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole +// line. +// +// The document start and end indicators are represented by: +// +// DOCUMENT-START +// DOCUMENT-END +// +// Note that if a YAML stream contains an implicit document (without '---' +// and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be +// produced. +// +// In the following examples, we present whole documents together with the +// produced tokens. +// +// 1. An implicit document: +// +// 'a scalar' +// +// Tokens: +// +// STREAM-START(utf-8) +// SCALAR("a scalar",single-quoted) +// STREAM-END +// +// 2. An explicit document: +// +// --- +// 'a scalar' +// ... +// +// Tokens: +// +// STREAM-START(utf-8) +// DOCUMENT-START +// SCALAR("a scalar",single-quoted) +// DOCUMENT-END +// STREAM-END +// +// 3. Several documents in a stream: +// +// 'a scalar' +// --- +// 'another scalar' +// --- +// 'yet another scalar' +// +// Tokens: +// +// STREAM-START(utf-8) +// SCALAR("a scalar",single-quoted) +// DOCUMENT-START +// SCALAR("another scalar",single-quoted) +// DOCUMENT-START +// SCALAR("yet another scalar",single-quoted) +// STREAM-END +// +// We have already introduced the SCALAR token above. The following tokens are +// used to describe aliases, anchors, tag, and scalars: +// +// ALIAS(anchor) +// ANCHOR(anchor) +// TAG(handle,suffix) +// SCALAR(value,style) +// +// The following series of examples illustrate the usage of these tokens: +// +// 1. A recursive sequence: +// +// &A [ *A ] +// +// Tokens: +// +// STREAM-START(utf-8) +// ANCHOR("A") +// FLOW-SEQUENCE-START +// ALIAS("A") +// FLOW-SEQUENCE-END +// STREAM-END +// +// 2. A tagged scalar: +// +// !!float "3.14" # A good approximation. +// +// Tokens: +// +// STREAM-START(utf-8) +// TAG("!!","float") +// SCALAR("3.14",double-quoted) +// STREAM-END +// +// 3. Various scalar styles: +// +// --- # Implicit empty plain scalars do not produce tokens. +// --- a plain scalar +// --- 'a single-quoted scalar' +// --- "a double-quoted scalar" +// --- |- +// a literal scalar +// --- >- +// a folded +// scalar +// +// Tokens: +// +// STREAM-START(utf-8) +// DOCUMENT-START +// DOCUMENT-START +// SCALAR("a plain scalar",plain) +// DOCUMENT-START +// SCALAR("a single-quoted scalar",single-quoted) +// DOCUMENT-START +// SCALAR("a double-quoted scalar",double-quoted) +// DOCUMENT-START +// SCALAR("a literal scalar",literal) +// DOCUMENT-START +// SCALAR("a folded scalar",folded) +// STREAM-END +// +// Now it's time to review collection-related tokens. We will start with +// flow collections: +// +// FLOW-SEQUENCE-START +// FLOW-SEQUENCE-END +// FLOW-MAPPING-START +// FLOW-MAPPING-END +// FLOW-ENTRY +// KEY +// VALUE +// +// The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and +// FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}' +// correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the +// indicators '?' and ':', which are used for denoting mapping keys and values, +// are represented by the KEY and VALUE tokens. +// +// The following examples show flow collections: +// +// 1. A flow sequence: +// +// [item 1, item 2, item 3] +// +// Tokens: +// +// STREAM-START(utf-8) +// FLOW-SEQUENCE-START +// SCALAR("item 1",plain) +// FLOW-ENTRY +// SCALAR("item 2",plain) +// FLOW-ENTRY +// SCALAR("item 3",plain) +// FLOW-SEQUENCE-END +// STREAM-END +// +// 2. A flow mapping: +// +// { +// a simple key: a value, # Note that the KEY token is produced. +// ? a complex key: another value, +// } +// +// Tokens: +// +// STREAM-START(utf-8) +// FLOW-MAPPING-START +// KEY +// SCALAR("a simple key",plain) +// VALUE +// SCALAR("a value",plain) +// FLOW-ENTRY +// KEY +// SCALAR("a complex key",plain) +// VALUE +// SCALAR("another value",plain) +// FLOW-ENTRY +// FLOW-MAPPING-END +// STREAM-END +// +// A simple key is a key which is not denoted by the '?' indicator. Note that +// the Scanner still produce the KEY token whenever it encounters a simple key. +// +// For scanning block collections, the following tokens are used (note that we +// repeat KEY and VALUE here): +// +// BLOCK-SEQUENCE-START +// BLOCK-MAPPING-START +// BLOCK-END +// BLOCK-ENTRY +// KEY +// VALUE +// +// The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation +// increase that precedes a block collection (cf. the INDENT token in Python). +// The token BLOCK-END denote indentation decrease that ends a block collection +// (cf. the DEDENT token in Python). However YAML has some syntax pecularities +// that makes detections of these tokens more complex. +// +// The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators +// '-', '?', and ':' correspondingly. +// +// The following examples show how the tokens BLOCK-SEQUENCE-START, +// BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner: +// +// 1. Block sequences: +// +// - item 1 +// - item 2 +// - +// - item 3.1 +// - item 3.2 +// - +// key 1: value 1 +// key 2: value 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-ENTRY +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 3.1",plain) +// BLOCK-ENTRY +// SCALAR("item 3.2",plain) +// BLOCK-END +// BLOCK-ENTRY +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// 2. Block mappings: +// +// a simple key: a value # The KEY token is produced here. +// ? a complex key +// : another value +// a mapping: +// key 1: value 1 +// key 2: value 2 +// a sequence: +// - item 1 +// - item 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-MAPPING-START +// KEY +// SCALAR("a simple key",plain) +// VALUE +// SCALAR("a value",plain) +// KEY +// SCALAR("a complex key",plain) +// VALUE +// SCALAR("another value",plain) +// KEY +// SCALAR("a mapping",plain) +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// KEY +// SCALAR("a sequence",plain) +// VALUE +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// YAML does not always require to start a new block collection from a new +// line. If the current line contains only '-', '?', and ':' indicators, a new +// block collection may start at the current line. The following examples +// illustrate this case: +// +// 1. Collections in a sequence: +// +// - - item 1 +// - item 2 +// - key 1: value 1 +// key 2: value 2 +// - ? complex key +// : complex value +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// BLOCK-ENTRY +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// BLOCK-ENTRY +// BLOCK-MAPPING-START +// KEY +// SCALAR("complex key") +// VALUE +// SCALAR("complex value") +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// 2. Collections in a mapping: +// +// ? a sequence +// : - item 1 +// - item 2 +// ? a mapping +// : key 1: value 1 +// key 2: value 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-MAPPING-START +// KEY +// SCALAR("a sequence",plain) +// VALUE +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// KEY +// SCALAR("a mapping",plain) +// VALUE +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// YAML also permits non-indented sequences if they are included into a block +// mapping. In this case, the token BLOCK-SEQUENCE-START is not produced: +// +// key: +// - item 1 # BLOCK-SEQUENCE-START is NOT produced here. +// - item 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-MAPPING-START +// KEY +// SCALAR("key",plain) +// VALUE +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// + +// Ensure that the buffer contains the required number of characters. +// Return true on success, false on failure (reader error or memory error). +func cache(parser *yaml_parser_t, length int) bool { + // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B) + return parser.unread >= length || yaml_parser_update_buffer(parser, length) +} + +// Advance the buffer pointer. +func skip(parser *yaml_parser_t) { + parser.mark.index++ + parser.mark.column++ + parser.unread-- + parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) +} + +func skip_line(parser *yaml_parser_t) { + if is_crlf(parser.buffer, parser.buffer_pos) { + parser.mark.index += 2 + parser.mark.column = 0 + parser.mark.line++ + parser.unread -= 2 + parser.buffer_pos += 2 + } else if is_break(parser.buffer, parser.buffer_pos) { + parser.mark.index++ + parser.mark.column = 0 + parser.mark.line++ + parser.unread-- + parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) + } +} + +// Copy a character to a string buffer and advance pointers. +func read(parser *yaml_parser_t, s []byte) []byte { + w := width(parser.buffer[parser.buffer_pos]) + if w == 0 { + panic("invalid character sequence") + } + if len(s) == 0 { + s = make([]byte, 0, 32) + } + if w == 1 && len(s)+w <= cap(s) { + s = s[:len(s)+1] + s[len(s)-1] = parser.buffer[parser.buffer_pos] + parser.buffer_pos++ + } else { + s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) + parser.buffer_pos += w + } + parser.mark.index++ + parser.mark.column++ + parser.unread-- + return s +} + +// Copy a line break character to a string buffer and advance pointers. +func read_line(parser *yaml_parser_t, s []byte) []byte { + buf := parser.buffer + pos := parser.buffer_pos + switch { + case buf[pos] == '\r' && buf[pos+1] == '\n': + // CR LF . LF + s = append(s, '\n') + parser.buffer_pos += 2 + parser.mark.index++ + parser.unread-- + case buf[pos] == '\r' || buf[pos] == '\n': + // CR|LF . LF + s = append(s, '\n') + parser.buffer_pos += 1 + case buf[pos] == '\xC2' && buf[pos+1] == '\x85': + // NEL . LF + s = append(s, '\n') + parser.buffer_pos += 2 + case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): + // LS|PS . LS|PS + s = append(s, buf[parser.buffer_pos:pos+3]...) + parser.buffer_pos += 3 + default: + return s + } + parser.mark.index++ + parser.mark.column = 0 + parser.mark.line++ + parser.unread-- + return s +} + +// Get the next token. +func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { + // Erase the token object. + *token = yaml_token_t{} // [Go] Is this necessary? + + // No tokens after STREAM-END or error. + if parser.stream_end_produced || parser.error != yaml_NO_ERROR { + return true + } + + // Ensure that the tokens queue contains enough tokens. + if !parser.token_available { + if !yaml_parser_fetch_more_tokens(parser) { + return false + } + } + + // Fetch the next token from the queue. + *token = parser.tokens[parser.tokens_head] + parser.tokens_head++ + parser.tokens_parsed++ + parser.token_available = false + + if token.typ == yaml_STREAM_END_TOKEN { + parser.stream_end_produced = true + } + return true +} + +// Set the scanner error and return false. +func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { + parser.error = yaml_SCANNER_ERROR + parser.context = context + parser.context_mark = context_mark + parser.problem = problem + parser.problem_mark = parser.mark + return false +} + +func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool { + context := "while parsing a tag" + if directive { + context = "while parsing a %TAG directive" + } + return yaml_parser_set_scanner_error(parser, context, context_mark, problem) +} + +func trace(args ...interface{}) func() { + pargs := append([]interface{}{"+++"}, args...) + fmt.Println(pargs...) + pargs = append([]interface{}{"---"}, args...) + return func() { fmt.Println(pargs...) } +} + +// Ensure that the tokens queue contains at least one token which can be +// returned to the Parser. +func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { + // While we need more tokens to fetch, do it. + for { + // Check if we really need to fetch more tokens. + need_more_tokens := false + + if parser.tokens_head == len(parser.tokens) { + // Queue is empty. + need_more_tokens = true + } else { + // Check if any potential simple key may occupy the head position. + if !yaml_parser_stale_simple_keys(parser) { + return false + } + + for i := range parser.simple_keys { + simple_key := &parser.simple_keys[i] + if simple_key.possible && simple_key.token_number == parser.tokens_parsed { + need_more_tokens = true + break + } + } + } + + // We are finished. + if !need_more_tokens { + break + } + // Fetch the next token. + if !yaml_parser_fetch_next_token(parser) { + return false + } + } + + parser.token_available = true + return true +} + +// The dispatcher for token fetchers. +func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { + // Ensure that the buffer is initialized. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + // Check if we just started scanning. Fetch STREAM-START then. + if !parser.stream_start_produced { + return yaml_parser_fetch_stream_start(parser) + } + + // Eat whitespaces and comments until we reach the next token. + if !yaml_parser_scan_to_next_token(parser) { + return false + } + + // Remove obsolete potential simple keys. + if !yaml_parser_stale_simple_keys(parser) { + return false + } + + // Check the indentation level against the current column. + if !yaml_parser_unroll_indent(parser, parser.mark.column) { + return false + } + + // Ensure that the buffer contains at least 4 characters. 4 is the length + // of the longest indicators ('--- ' and '... '). + if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { + return false + } + + // Is it the end of the stream? + if is_z(parser.buffer, parser.buffer_pos) { + return yaml_parser_fetch_stream_end(parser) + } + + // Is it a directive? + if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { + return yaml_parser_fetch_directive(parser) + } + + buf := parser.buffer + pos := parser.buffer_pos + + // Is it the document start indicator? + if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { + return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) + } + + // Is it the document end indicator? + if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { + return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) + } + + // Is it the flow sequence start indicator? + if buf[pos] == '[' { + return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN) + } + + // Is it the flow mapping start indicator? + if parser.buffer[parser.buffer_pos] == '{' { + return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN) + } + + // Is it the flow sequence end indicator? + if parser.buffer[parser.buffer_pos] == ']' { + return yaml_parser_fetch_flow_collection_end(parser, + yaml_FLOW_SEQUENCE_END_TOKEN) + } + + // Is it the flow mapping end indicator? + if parser.buffer[parser.buffer_pos] == '}' { + return yaml_parser_fetch_flow_collection_end(parser, + yaml_FLOW_MAPPING_END_TOKEN) + } + + // Is it the flow entry indicator? + if parser.buffer[parser.buffer_pos] == ',' { + return yaml_parser_fetch_flow_entry(parser) + } + + // Is it the block entry indicator? + if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) { + return yaml_parser_fetch_block_entry(parser) + } + + // Is it the key indicator? + if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { + return yaml_parser_fetch_key(parser) + } + + // Is it the value indicator? + if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { + return yaml_parser_fetch_value(parser) + } + + // Is it an alias? + if parser.buffer[parser.buffer_pos] == '*' { + return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN) + } + + // Is it an anchor? + if parser.buffer[parser.buffer_pos] == '&' { + return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN) + } + + // Is it a tag? + if parser.buffer[parser.buffer_pos] == '!' { + return yaml_parser_fetch_tag(parser) + } + + // Is it a literal scalar? + if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 { + return yaml_parser_fetch_block_scalar(parser, true) + } + + // Is it a folded scalar? + if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 { + return yaml_parser_fetch_block_scalar(parser, false) + } + + // Is it a single-quoted scalar? + if parser.buffer[parser.buffer_pos] == '\'' { + return yaml_parser_fetch_flow_scalar(parser, true) + } + + // Is it a double-quoted scalar? + if parser.buffer[parser.buffer_pos] == '"' { + return yaml_parser_fetch_flow_scalar(parser, false) + } + + // Is it a plain scalar? + // + // A plain scalar may start with any non-blank characters except + // + // '-', '?', ':', ',', '[', ']', '{', '}', + // '#', '&', '*', '!', '|', '>', '\'', '\"', + // '%', '@', '`'. + // + // In the block context (and, for the '-' indicator, in the flow context + // too), it may also start with the characters + // + // '-', '?', ':' + // + // if it is followed by a non-space character. + // + // The last rule is more restrictive than the specification requires. + // [Go] Make this logic more reasonable. + //switch parser.buffer[parser.buffer_pos] { + //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`': + //} + if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' || + parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || + parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' || + parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || + parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' || + parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' || + parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' || + parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' || + parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' || + parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') || + (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) || + (parser.flow_level == 0 && + (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') && + !is_blankz(parser.buffer, parser.buffer_pos+1)) { + return yaml_parser_fetch_plain_scalar(parser) + } + + // If we don't determine the token type so far, it is an error. + return yaml_parser_set_scanner_error(parser, + "while scanning for the next token", parser.mark, + "found character that cannot start any token") +} + +// Check the list of potential simple keys and remove the positions that +// cannot contain simple keys anymore. +func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { + // Check for a potential simple key for each flow level. + for i := range parser.simple_keys { + simple_key := &parser.simple_keys[i] + + // The specification requires that a simple key + // + // - is limited to a single line, + // - is shorter than 1024 characters. + if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { + + // Check if the potential simple key to be removed is required. + if simple_key.required { + return yaml_parser_set_scanner_error(parser, + "while scanning a simple key", simple_key.mark, + "could not find expected ':'") + } + simple_key.possible = false + } + } + return true +} + +// Check if a simple key may start at the current position and add it if +// needed. +func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { + // A simple key is required at the current position if the scanner is in + // the block context and the current column coincides with the indentation + // level. + + required := parser.flow_level == 0 && parser.indent == parser.mark.column + + // A simple key is required only when it is the first token in the current + // line. Therefore it is always allowed. But we add a check anyway. + if required && !parser.simple_key_allowed { + panic("should not happen") + } + + // + // If the current position may start a simple key, save it. + // + if parser.simple_key_allowed { + simple_key := yaml_simple_key_t{ + possible: true, + required: required, + token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + } + simple_key.mark = parser.mark + + if !yaml_parser_remove_simple_key(parser) { + return false + } + parser.simple_keys[len(parser.simple_keys)-1] = simple_key + } + return true +} + +// Remove a potential simple key at the current flow level. +func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { + i := len(parser.simple_keys) - 1 + if parser.simple_keys[i].possible { + // If the key is required, it is an error. + if parser.simple_keys[i].required { + return yaml_parser_set_scanner_error(parser, + "while scanning a simple key", parser.simple_keys[i].mark, + "could not find expected ':'") + } + } + // Remove the key from the stack. + parser.simple_keys[i].possible = false + return true +} + +// Increase the flow level and resize the simple key list if needed. +func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { + // Reset the simple key on the next level. + parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + + // Increase the flow level. + parser.flow_level++ + return true +} + +// Decrease the flow level. +func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { + if parser.flow_level > 0 { + parser.flow_level-- + parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] + } + return true +} + +// Push the current indentation level to the stack and set the new level +// the current column is greater than the indentation level. In this case, +// append or insert the specified token into the token queue. +func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { + // In the flow context, do nothing. + if parser.flow_level > 0 { + return true + } + + if parser.indent < column { + // Push the current indentation level to the stack and set the new + // indentation level. + parser.indents = append(parser.indents, parser.indent) + parser.indent = column + + // Create a token and insert it into the queue. + token := yaml_token_t{ + typ: typ, + start_mark: mark, + end_mark: mark, + } + if number > -1 { + number -= parser.tokens_parsed + } + yaml_insert_token(parser, number, &token) + } + return true +} + +// Pop indentation levels from the indents stack until the current level +// becomes less or equal to the column. For each indentation level, append +// the BLOCK-END token. +func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { + // In the flow context, do nothing. + if parser.flow_level > 0 { + return true + } + + // Loop through the indentation levels in the stack. + for parser.indent > column { + // Create a token and append it to the queue. + token := yaml_token_t{ + typ: yaml_BLOCK_END_TOKEN, + start_mark: parser.mark, + end_mark: parser.mark, + } + yaml_insert_token(parser, -1, &token) + + // Pop the indentation level. + parser.indent = parser.indents[len(parser.indents)-1] + parser.indents = parser.indents[:len(parser.indents)-1] + } + return true +} + +// Initialize the scanner and produce the STREAM-START token. +func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { + + // Set the initial indentation. + parser.indent = -1 + + // Initialize the simple key stack. + parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + + // A simple key is allowed at the beginning of the stream. + parser.simple_key_allowed = true + + // We have started. + parser.stream_start_produced = true + + // Create the STREAM-START token and append it to the queue. + token := yaml_token_t{ + typ: yaml_STREAM_START_TOKEN, + start_mark: parser.mark, + end_mark: parser.mark, + encoding: parser.encoding, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the STREAM-END token and shut down the scanner. +func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { + + // Force new line. + if parser.mark.column != 0 { + parser.mark.column = 0 + parser.mark.line++ + } + + // Reset the indentation level. + if !yaml_parser_unroll_indent(parser, -1) { + return false + } + + // Reset simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + parser.simple_key_allowed = false + + // Create the STREAM-END token and append it to the queue. + token := yaml_token_t{ + typ: yaml_STREAM_END_TOKEN, + start_mark: parser.mark, + end_mark: parser.mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token. +func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { + // Reset the indentation level. + if !yaml_parser_unroll_indent(parser, -1) { + return false + } + + // Reset simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + parser.simple_key_allowed = false + + // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. + token := yaml_token_t{} + if !yaml_parser_scan_directive(parser, &token) { + return false + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the DOCUMENT-START or DOCUMENT-END token. +func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // Reset the indentation level. + if !yaml_parser_unroll_indent(parser, -1) { + return false + } + + // Reset simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + parser.simple_key_allowed = false + + // Consume the token. + start_mark := parser.mark + + skip(parser) + skip(parser) + skip(parser) + + end_mark := parser.mark + + // Create the DOCUMENT-START or DOCUMENT-END token. + token := yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token. +func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // The indicators '[' and '{' may start a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // Increase the flow level. + if !yaml_parser_increase_flow_level(parser) { + return false + } + + // A simple key may follow the indicators '[' and '{'. + parser.simple_key_allowed = true + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. + token := yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token. +func yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // Reset any potential simple key on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Decrease the flow level. + if !yaml_parser_decrease_flow_level(parser) { + return false + } + + // No simple keys after the indicators ']' and '}'. + parser.simple_key_allowed = false + + // Consume the token. + + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. + token := yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the FLOW-ENTRY token. +func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool { + // Reset any potential simple keys on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Simple keys are allowed after ','. + parser.simple_key_allowed = true + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the FLOW-ENTRY token and append it to the queue. + token := yaml_token_t{ + typ: yaml_FLOW_ENTRY_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the BLOCK-ENTRY token. +func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool { + // Check if the scanner is in the block context. + if parser.flow_level == 0 { + // Check if we are allowed to start a new entry. + if !parser.simple_key_allowed { + return yaml_parser_set_scanner_error(parser, "", parser.mark, + "block sequence entries are not allowed in this context") + } + // Add the BLOCK-SEQUENCE-START token if needed. + if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) { + return false + } + } else { + // It is an error for the '-' indicator to occur in the flow context, + // but we let the Parser detect and report about it because the Parser + // is able to point to the context. + } + + // Reset any potential simple keys on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Simple keys are allowed after '-'. + parser.simple_key_allowed = true + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the BLOCK-ENTRY token and append it to the queue. + token := yaml_token_t{ + typ: yaml_BLOCK_ENTRY_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the KEY token. +func yaml_parser_fetch_key(parser *yaml_parser_t) bool { + + // In the block context, additional checks are required. + if parser.flow_level == 0 { + // Check if we are allowed to start a new key (not nessesary simple). + if !parser.simple_key_allowed { + return yaml_parser_set_scanner_error(parser, "", parser.mark, + "mapping keys are not allowed in this context") + } + // Add the BLOCK-MAPPING-START token if needed. + if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { + return false + } + } + + // Reset any potential simple keys on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Simple keys are allowed after '?' in the block context. + parser.simple_key_allowed = parser.flow_level == 0 + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the KEY token and append it to the queue. + token := yaml_token_t{ + typ: yaml_KEY_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the VALUE token. +func yaml_parser_fetch_value(parser *yaml_parser_t) bool { + + simple_key := &parser.simple_keys[len(parser.simple_keys)-1] + + // Have we found a simple key? + if simple_key.possible { + // Create the KEY token and insert it into the queue. + token := yaml_token_t{ + typ: yaml_KEY_TOKEN, + start_mark: simple_key.mark, + end_mark: simple_key.mark, + } + yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token) + + // In the block context, we may need to add the BLOCK-MAPPING-START token. + if !yaml_parser_roll_indent(parser, simple_key.mark.column, + simple_key.token_number, + yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { + return false + } + + // Remove the simple key. + simple_key.possible = false + + // A simple key cannot follow another simple key. + parser.simple_key_allowed = false + + } else { + // The ':' indicator follows a complex key. + + // In the block context, extra checks are required. + if parser.flow_level == 0 { + + // Check if we are allowed to start a complex value. + if !parser.simple_key_allowed { + return yaml_parser_set_scanner_error(parser, "", parser.mark, + "mapping values are not allowed in this context") + } + + // Add the BLOCK-MAPPING-START token if needed. + if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { + return false + } + } + + // Simple keys after ':' are allowed in the block context. + parser.simple_key_allowed = parser.flow_level == 0 + } + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the VALUE token and append it to the queue. + token := yaml_token_t{ + typ: yaml_VALUE_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the ALIAS or ANCHOR token. +func yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // An anchor or an alias could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow an anchor or an alias. + parser.simple_key_allowed = false + + // Create the ALIAS or ANCHOR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_anchor(parser, &token, typ) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the TAG token. +func yaml_parser_fetch_tag(parser *yaml_parser_t) bool { + // A tag could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow a tag. + parser.simple_key_allowed = false + + // Create the TAG token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_tag(parser, &token) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens. +func yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool { + // Remove any potential simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // A simple key may follow a block scalar. + parser.simple_key_allowed = true + + // Create the SCALAR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_block_scalar(parser, &token, literal) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens. +func yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool { + // A plain scalar could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow a flow scalar. + parser.simple_key_allowed = false + + // Create the SCALAR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_flow_scalar(parser, &token, single) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the SCALAR(...,plain) token. +func yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool { + // A plain scalar could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow a flow scalar. + parser.simple_key_allowed = false + + // Create the SCALAR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_plain_scalar(parser, &token) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Eat whitespaces and comments until the next token is found. +func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool { + + // Until the next token is not found. + for { + // Allow the BOM mark to start a line. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) { + skip(parser) + } + + // Eat whitespaces. + // Tabs are allowed: + // - in the flow context + // - in the block context, but not at the beginning of the line or + // after '-', '?', or ':' (complex value). + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\t') { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Eat a comment until a line break. + if parser.buffer[parser.buffer_pos] == '#' { + for !is_breakz(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + } + + // If it is a line break, eat it. + if is_break(parser.buffer, parser.buffer_pos) { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + skip_line(parser) + + // In the block context, a new line may start a simple key. + if parser.flow_level == 0 { + parser.simple_key_allowed = true + } + } else { + break // We have found a token. + } + } + + return true +} + +// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// +func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool { + // Eat '%'. + start_mark := parser.mark + skip(parser) + + // Scan the directive name. + var name []byte + if !yaml_parser_scan_directive_name(parser, start_mark, &name) { + return false + } + + // Is it a YAML directive? + if bytes.Equal(name, []byte("YAML")) { + // Scan the VERSION directive value. + var major, minor int8 + if !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) { + return false + } + end_mark := parser.mark + + // Create a VERSION-DIRECTIVE token. + *token = yaml_token_t{ + typ: yaml_VERSION_DIRECTIVE_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + major: major, + minor: minor, + } + + // Is it a TAG directive? + } else if bytes.Equal(name, []byte("TAG")) { + // Scan the TAG directive value. + var handle, prefix []byte + if !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) { + return false + } + end_mark := parser.mark + + // Create a TAG-DIRECTIVE token. + *token = yaml_token_t{ + typ: yaml_TAG_DIRECTIVE_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: handle, + prefix: prefix, + } + + // Unknown directive. + } else { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "found unknown directive name") + return false + } + + // Eat the rest of the line including any comments. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + if parser.buffer[parser.buffer_pos] == '#' { + for !is_breakz(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + } + + // Check if we are at the end of the line. + if !is_breakz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "did not find expected comment or line break") + return false + } + + // Eat a line break. + if is_break(parser.buffer, parser.buffer_pos) { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + skip_line(parser) + } + + return true +} + +// Scan the directive name. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^^^^ +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^ +// +func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool { + // Consume the directive name. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + var s []byte + for is_alpha(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check if the name is empty. + if len(s) == 0 { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "could not find expected directive name") + return false + } + + // Check for an blank character after the name. + if !is_blankz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "found unexpected non-alphabetical character") + return false + } + *name = s + return true +} + +// Scan the value of VERSION-DIRECTIVE. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^^^^^^ +func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool { + // Eat whitespaces. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Consume the major version number. + if !yaml_parser_scan_version_directive_number(parser, start_mark, major) { + return false + } + + // Eat '.'. + if parser.buffer[parser.buffer_pos] != '.' { + return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", + start_mark, "did not find expected digit or '.' character") + } + + skip(parser) + + // Consume the minor version number. + if !yaml_parser_scan_version_directive_number(parser, start_mark, minor) { + return false + } + return true +} + +const max_number_length = 2 + +// Scan the version number of VERSION-DIRECTIVE. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^ +// %YAML 1.1 # a comment \n +// ^ +func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool { + + // Repeat while the next character is digit. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + var value, length int8 + for is_digit(parser.buffer, parser.buffer_pos) { + // Check if the number is too long. + length++ + if length > max_number_length { + return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", + start_mark, "found extremely long version number") + } + value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos)) + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check if the number was present. + if length == 0 { + return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", + start_mark, "did not find expected version number") + } + *number = value + return true +} + +// Scan the value of a TAG-DIRECTIVE token. +// +// Scope: +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// +func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool { + var handle_value, prefix_value []byte + + // Eat whitespaces. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Scan a handle. + if !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) { + return false + } + + // Expect a whitespace. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if !is_blank(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", + start_mark, "did not find expected whitespace") + return false + } + + // Eat whitespaces. + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Scan a prefix. + if !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) { + return false + } + + // Expect a whitespace or line break. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if !is_blankz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", + start_mark, "did not find expected whitespace or line break") + return false + } + + *handle = handle_value + *prefix = prefix_value + return true +} + +func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool { + var s []byte + + // Eat the indicator character. + start_mark := parser.mark + skip(parser) + + // Consume the value. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_alpha(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + end_mark := parser.mark + + /* + * Check if length of the anchor is greater than 0 and it is followed by + * a whitespace character or one of the indicators: + * + * '?', ':', ',', ']', '}', '%', '@', '`'. + */ + + if len(s) == 0 || + !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' || + parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || + parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' || + parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || + parser.buffer[parser.buffer_pos] == '`') { + context := "while scanning an alias" + if typ == yaml_ANCHOR_TOKEN { + context = "while scanning an anchor" + } + yaml_parser_set_scanner_error(parser, context, start_mark, + "did not find expected alphabetic or numeric character") + return false + } + + // Create a token. + *token = yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + value: s, + } + + return true +} + +/* + * Scan a TAG token. + */ + +func yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool { + var handle, suffix []byte + + start_mark := parser.mark + + // Check if the tag is in the canonical form. + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + if parser.buffer[parser.buffer_pos+1] == '<' { + // Keep the handle as '' + + // Eat '!<' + skip(parser) + skip(parser) + + // Consume the tag value. + if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { + return false + } + + // Check for '>' and eat it. + if parser.buffer[parser.buffer_pos] != '>' { + yaml_parser_set_scanner_error(parser, "while scanning a tag", + start_mark, "did not find the expected '>'") + return false + } + + skip(parser) + } else { + // The tag has either the '!suffix' or the '!handle!suffix' form. + + // First, try to scan a handle. + if !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) { + return false + } + + // Check if it is, indeed, handle. + if handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' { + // Scan the suffix now. + if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { + return false + } + } else { + // It wasn't a handle after all. Scan the rest of the tag. + if !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) { + return false + } + + // Set the handle to '!'. + handle = []byte{'!'} + + // A special case: the '!' tag. Set the handle to '' and the + // suffix to '!'. + if len(suffix) == 0 { + handle, suffix = suffix, handle + } + } + } + + // Check the character which ends the tag. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if !is_blankz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a tag", + start_mark, "did not find expected whitespace or line break") + return false + } + + end_mark := parser.mark + + // Create a token. + *token = yaml_token_t{ + typ: yaml_TAG_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: handle, + suffix: suffix, + } + return true +} + +// Scan a tag handle. +func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool { + // Check the initial '!' character. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if parser.buffer[parser.buffer_pos] != '!' { + yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find expected '!'") + return false + } + + var s []byte + + // Copy the '!' character. + s = read(parser, s) + + // Copy all subsequent alphabetical and numerical characters. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for is_alpha(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check if the trailing character is '!' and copy it. + if parser.buffer[parser.buffer_pos] == '!' { + s = read(parser, s) + } else { + // It's either the '!' tag or not really a tag handle. If it's a %TAG + // directive, it's an error. If it's a tag token, it must be a part of URI. + if directive && string(s) != "!" { + yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find expected '!'") + return false + } + } + + *handle = s + return true +} + +// Scan a tag. +func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool { + //size_t length = head ? strlen((char *)head) : 0 + var s []byte + hasTag := len(head) > 0 + + // Copy the head if needed. + // + // Note that we don't copy the leading '!' character. + if len(head) > 1 { + s = append(s, head[1:]...) + } + + // Scan the tag. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + // The set of characters that may appear in URI is as follows: + // + // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', + // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']', + // '%'. + // [Go] Convert this into more reasonable logic. + for is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' || + parser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' || + parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' || + parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' || + parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' || + parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' || + parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' || + parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\'' || + parser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' || + parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || + parser.buffer[parser.buffer_pos] == '%' { + // Check if it is a URI-escape sequence. + if parser.buffer[parser.buffer_pos] == '%' { + if !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) { + return false + } + } else { + s = read(parser, s) + } + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + hasTag = true + } + + if !hasTag { + yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find expected tag URI") + return false + } + *uri = s + return true +} + +// Decode an URI-escape sequence corresponding to a single UTF-8 character. +func yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool { + + // Decode the required number of characters. + w := 1024 + for w > 0 { + // Check for a URI-escaped octet. + if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { + return false + } + + if !(parser.buffer[parser.buffer_pos] == '%' && + is_hex(parser.buffer, parser.buffer_pos+1) && + is_hex(parser.buffer, parser.buffer_pos+2)) { + return yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find URI escaped octet") + } + + // Get the octet. + octet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2)) + + // If it is the leading octet, determine the length of the UTF-8 sequence. + if w == 1024 { + w = width(octet) + if w == 0 { + return yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "found an incorrect leading UTF-8 octet") + } + } else { + // Check if the trailing octet is correct. + if octet&0xC0 != 0x80 { + return yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "found an incorrect trailing UTF-8 octet") + } + } + + // Copy the octet and move the pointers. + *s = append(*s, octet) + skip(parser) + skip(parser) + skip(parser) + w-- + } + return true +} + +// Scan a block scalar. +func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool { + // Eat the indicator '|' or '>'. + start_mark := parser.mark + skip(parser) + + // Scan the additional block scalar indicators. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + // Check for a chomping indicator. + var chomping, increment int + if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { + // Set the chomping method and eat the indicator. + if parser.buffer[parser.buffer_pos] == '+' { + chomping = +1 + } else { + chomping = -1 + } + skip(parser) + + // Check for an indentation indicator. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if is_digit(parser.buffer, parser.buffer_pos) { + // Check that the indentation is greater than 0. + if parser.buffer[parser.buffer_pos] == '0' { + yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "found an indentation indicator equal to 0") + return false + } + + // Get the indentation level and eat the indicator. + increment = as_digit(parser.buffer, parser.buffer_pos) + skip(parser) + } + + } else if is_digit(parser.buffer, parser.buffer_pos) { + // Do the same as above, but in the opposite order. + + if parser.buffer[parser.buffer_pos] == '0' { + yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "found an indentation indicator equal to 0") + return false + } + increment = as_digit(parser.buffer, parser.buffer_pos) + skip(parser) + + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { + if parser.buffer[parser.buffer_pos] == '+' { + chomping = +1 + } else { + chomping = -1 + } + skip(parser) + } + } + + // Eat whitespaces and comments to the end of the line. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + if parser.buffer[parser.buffer_pos] == '#' { + for !is_breakz(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + } + + // Check if we are at the end of the line. + if !is_breakz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "did not find expected comment or line break") + return false + } + + // Eat a line break. + if is_break(parser.buffer, parser.buffer_pos) { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + skip_line(parser) + } + + end_mark := parser.mark + + // Set the indentation level if it was specified. + var indent int + if increment > 0 { + if parser.indent >= 0 { + indent = parser.indent + increment + } else { + indent = increment + } + } + + // Scan the leading line breaks and determine the indentation level if needed. + var s, leading_break, trailing_breaks []byte + if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { + return false + } + + // Scan the block scalar content. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + var leading_blank, trailing_blank bool + for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) { + // We are at the beginning of a non-empty line. + + // Is it a trailing whitespace? + trailing_blank = is_blank(parser.buffer, parser.buffer_pos) + + // Check if we need to fold the leading line break. + if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' { + // Do we need to join the lines by space? + if len(trailing_breaks) == 0 { + s = append(s, ' ') + } + } else { + s = append(s, leading_break...) + } + leading_break = leading_break[:0] + + // Append the remaining line breaks. + s = append(s, trailing_breaks...) + trailing_breaks = trailing_breaks[:0] + + // Is it a leading whitespace? + leading_blank = is_blank(parser.buffer, parser.buffer_pos) + + // Consume the current line. + for !is_breakz(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Consume the line break. + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + leading_break = read_line(parser, leading_break) + + // Eat the following indentation spaces and line breaks. + if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { + return false + } + } + + // Chomp the tail. + if chomping != -1 { + s = append(s, leading_break...) + } + if chomping == 1 { + s = append(s, trailing_breaks...) + } + + // Create a token. + *token = yaml_token_t{ + typ: yaml_SCALAR_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: s, + style: yaml_LITERAL_SCALAR_STYLE, + } + if !literal { + token.style = yaml_FOLDED_SCALAR_STYLE + } + return true +} + +// Scan indentation spaces and line breaks for a block scalar. Determine the +// indentation level if needed. +func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool { + *end_mark = parser.mark + + // Eat the indentation spaces and line breaks. + max_indent := 0 + for { + // Eat the indentation spaces. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + if parser.mark.column > max_indent { + max_indent = parser.mark.column + } + + // Check for a tab character messing the indentation. + if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) { + return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "found a tab character where an indentation space is expected") + } + + // Have we found a non-empty line? + if !is_break(parser.buffer, parser.buffer_pos) { + break + } + + // Consume the line break. + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + // [Go] Should really be returning breaks instead. + *breaks = read_line(parser, *breaks) + *end_mark = parser.mark + } + + // Determine the indentation level if needed. + if *indent == 0 { + *indent = max_indent + if *indent < parser.indent+1 { + *indent = parser.indent + 1 + } + if *indent < 1 { + *indent = 1 + } + } + return true +} + +// Scan a quoted scalar. +func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool { + // Eat the left quote. + start_mark := parser.mark + skip(parser) + + // Consume the content of the quoted scalar. + var s, leading_break, trailing_breaks, whitespaces []byte + for { + // Check that there are no document indicators at the beginning of the line. + if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { + return false + } + + if parser.mark.column == 0 && + ((parser.buffer[parser.buffer_pos+0] == '-' && + parser.buffer[parser.buffer_pos+1] == '-' && + parser.buffer[parser.buffer_pos+2] == '-') || + (parser.buffer[parser.buffer_pos+0] == '.' && + parser.buffer[parser.buffer_pos+1] == '.' && + parser.buffer[parser.buffer_pos+2] == '.')) && + is_blankz(parser.buffer, parser.buffer_pos+3) { + yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", + start_mark, "found unexpected document indicator") + return false + } + + // Check for EOF. + if is_z(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", + start_mark, "found unexpected end of stream") + return false + } + + // Consume non-blank characters. + leading_blanks := false + for !is_blankz(parser.buffer, parser.buffer_pos) { + if single && parser.buffer[parser.buffer_pos] == '\'' && parser.buffer[parser.buffer_pos+1] == '\'' { + // Is is an escaped single quote. + s = append(s, '\'') + skip(parser) + skip(parser) + + } else if single && parser.buffer[parser.buffer_pos] == '\'' { + // It is a right single quote. + break + } else if !single && parser.buffer[parser.buffer_pos] == '"' { + // It is a right double quote. + break + + } else if !single && parser.buffer[parser.buffer_pos] == '\\' && is_break(parser.buffer, parser.buffer_pos+1) { + // It is an escaped line break. + if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { + return false + } + skip(parser) + skip_line(parser) + leading_blanks = true + break + + } else if !single && parser.buffer[parser.buffer_pos] == '\\' { + // It is an escape sequence. + code_length := 0 + + // Check the escape character. + switch parser.buffer[parser.buffer_pos+1] { + case '0': + s = append(s, 0) + case 'a': + s = append(s, '\x07') + case 'b': + s = append(s, '\x08') + case 't', '\t': + s = append(s, '\x09') + case 'n': + s = append(s, '\x0A') + case 'v': + s = append(s, '\x0B') + case 'f': + s = append(s, '\x0C') + case 'r': + s = append(s, '\x0D') + case 'e': + s = append(s, '\x1B') + case ' ': + s = append(s, '\x20') + case '"': + s = append(s, '"') + case '\'': + s = append(s, '\'') + case '\\': + s = append(s, '\\') + case 'N': // NEL (#x85) + s = append(s, '\xC2') + s = append(s, '\x85') + case '_': // #xA0 + s = append(s, '\xC2') + s = append(s, '\xA0') + case 'L': // LS (#x2028) + s = append(s, '\xE2') + s = append(s, '\x80') + s = append(s, '\xA8') + case 'P': // PS (#x2029) + s = append(s, '\xE2') + s = append(s, '\x80') + s = append(s, '\xA9') + case 'x': + code_length = 2 + case 'u': + code_length = 4 + case 'U': + code_length = 8 + default: + yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", + start_mark, "found unknown escape character") + return false + } + + skip(parser) + skip(parser) + + // Consume an arbitrary escape code. + if code_length > 0 { + var value int + + // Scan the character value. + if parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) { + return false + } + for k := 0; k < code_length; k++ { + if !is_hex(parser.buffer, parser.buffer_pos+k) { + yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", + start_mark, "did not find expected hexdecimal number") + return false + } + value = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k) + } + + // Check the value and write the character. + if (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF { + yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", + start_mark, "found invalid Unicode character escape code") + return false + } + if value <= 0x7F { + s = append(s, byte(value)) + } else if value <= 0x7FF { + s = append(s, byte(0xC0+(value>>6))) + s = append(s, byte(0x80+(value&0x3F))) + } else if value <= 0xFFFF { + s = append(s, byte(0xE0+(value>>12))) + s = append(s, byte(0x80+((value>>6)&0x3F))) + s = append(s, byte(0x80+(value&0x3F))) + } else { + s = append(s, byte(0xF0+(value>>18))) + s = append(s, byte(0x80+((value>>12)&0x3F))) + s = append(s, byte(0x80+((value>>6)&0x3F))) + s = append(s, byte(0x80+(value&0x3F))) + } + + // Advance the pointer. + for k := 0; k < code_length; k++ { + skip(parser) + } + } + } else { + // It is a non-escaped non-blank character. + s = read(parser, s) + } + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + } + + // Check if we are at the end of the scalar. + if single { + if parser.buffer[parser.buffer_pos] == '\'' { + break + } + } else { + if parser.buffer[parser.buffer_pos] == '"' { + break + } + } + + // Consume blank characters. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { + if is_blank(parser.buffer, parser.buffer_pos) { + // Consume a space or a tab character. + if !leading_blanks { + whitespaces = read(parser, whitespaces) + } else { + skip(parser) + } + } else { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + // Check if it is a first line break. + if !leading_blanks { + whitespaces = whitespaces[:0] + leading_break = read_line(parser, leading_break) + leading_blanks = true + } else { + trailing_breaks = read_line(parser, trailing_breaks) + } + } + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Join the whitespaces or fold line breaks. + if leading_blanks { + // Do we need to fold line breaks? + if len(leading_break) > 0 && leading_break[0] == '\n' { + if len(trailing_breaks) == 0 { + s = append(s, ' ') + } else { + s = append(s, trailing_breaks...) + } + } else { + s = append(s, leading_break...) + s = append(s, trailing_breaks...) + } + trailing_breaks = trailing_breaks[:0] + leading_break = leading_break[:0] + } else { + s = append(s, whitespaces...) + whitespaces = whitespaces[:0] + } + } + + // Eat the right quote. + skip(parser) + end_mark := parser.mark + + // Create a token. + *token = yaml_token_t{ + typ: yaml_SCALAR_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: s, + style: yaml_SINGLE_QUOTED_SCALAR_STYLE, + } + if !single { + token.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + return true +} + +// Scan a plain scalar. +func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool { + + var s, leading_break, trailing_breaks, whitespaces []byte + var leading_blanks bool + var indent = parser.indent + 1 + + start_mark := parser.mark + end_mark := parser.mark + + // Consume the content of the plain scalar. + for { + // Check for a document indicator. + if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { + return false + } + if parser.mark.column == 0 && + ((parser.buffer[parser.buffer_pos+0] == '-' && + parser.buffer[parser.buffer_pos+1] == '-' && + parser.buffer[parser.buffer_pos+2] == '-') || + (parser.buffer[parser.buffer_pos+0] == '.' && + parser.buffer[parser.buffer_pos+1] == '.' && + parser.buffer[parser.buffer_pos+2] == '.')) && + is_blankz(parser.buffer, parser.buffer_pos+3) { + break + } + + // Check for a comment. + if parser.buffer[parser.buffer_pos] == '#' { + break + } + + // Consume non-blank characters. + for !is_blankz(parser.buffer, parser.buffer_pos) { + + // Check for indicators that may end a plain scalar. + if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) || + (parser.flow_level > 0 && + (parser.buffer[parser.buffer_pos] == ',' || + parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' || + parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || + parser.buffer[parser.buffer_pos] == '}')) { + break + } + + // Check if we need to join whitespaces and breaks. + if leading_blanks || len(whitespaces) > 0 { + if leading_blanks { + // Do we need to fold line breaks? + if leading_break[0] == '\n' { + if len(trailing_breaks) == 0 { + s = append(s, ' ') + } else { + s = append(s, trailing_breaks...) + } + } else { + s = append(s, leading_break...) + s = append(s, trailing_breaks...) + } + trailing_breaks = trailing_breaks[:0] + leading_break = leading_break[:0] + leading_blanks = false + } else { + s = append(s, whitespaces...) + whitespaces = whitespaces[:0] + } + } + + // Copy the character. + s = read(parser, s) + + end_mark = parser.mark + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + } + + // Is it the end? + if !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) { + break + } + + // Consume blank characters. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { + if is_blank(parser.buffer, parser.buffer_pos) { + + // Check for tab character that abuse indentation. + if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", + start_mark, "found a tab character that violate indentation") + return false + } + + // Consume a space or a tab character. + if !leading_blanks { + whitespaces = read(parser, whitespaces) + } else { + skip(parser) + } + } else { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + // Check if it is a first line break. + if !leading_blanks { + whitespaces = whitespaces[:0] + leading_break = read_line(parser, leading_break) + leading_blanks = true + } else { + trailing_breaks = read_line(parser, trailing_breaks) + } + } + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check indentation level. + if parser.flow_level == 0 && parser.mark.column < indent { + break + } + } + + // Create a token. + *token = yaml_token_t{ + typ: yaml_SCALAR_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: s, + style: yaml_PLAIN_SCALAR_STYLE, + } + + // Note that we change the 'simple_key_allowed' flag. + if leading_blanks { + parser.simple_key_allowed = true + } + return true +} diff --git a/vendor/github.com/go-yaml/yaml/sorter.go b/vendor/github.com/go-yaml/yaml/sorter.go new file mode 100644 index 0000000000000..5958822f9c6bb --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/sorter.go @@ -0,0 +1,104 @@ +package yaml + +import ( + "reflect" + "unicode" +) + +type keyList []reflect.Value + +func (l keyList) Len() int { return len(l) } +func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } +func (l keyList) Less(i, j int) bool { + a := l[i] + b := l[j] + ak := a.Kind() + bk := b.Kind() + for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { + a = a.Elem() + ak = a.Kind() + } + for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { + b = b.Elem() + bk = b.Kind() + } + af, aok := keyFloat(a) + bf, bok := keyFloat(b) + if aok && bok { + if af != bf { + return af < bf + } + if ak != bk { + return ak < bk + } + return numLess(a, b) + } + if ak != reflect.String || bk != reflect.String { + return ak < bk + } + ar, br := []rune(a.String()), []rune(b.String()) + for i := 0; i < len(ar) && i < len(br); i++ { + if ar[i] == br[i] { + continue + } + al := unicode.IsLetter(ar[i]) + bl := unicode.IsLetter(br[i]) + if al && bl { + return ar[i] < br[i] + } + if al || bl { + return bl + } + var ai, bi int + var an, bn int64 + for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { + an = an*10 + int64(ar[ai]-'0') + } + for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { + bn = bn*10 + int64(br[bi]-'0') + } + if an != bn { + return an < bn + } + if ai != bi { + return ai < bi + } + return ar[i] < br[i] + } + return len(ar) < len(br) +} + +// keyFloat returns a float value for v if it is a number/bool +// and whether it is a number/bool or not. +func keyFloat(v reflect.Value) (f float64, ok bool) { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return float64(v.Int()), true + case reflect.Float32, reflect.Float64: + return v.Float(), true + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return float64(v.Uint()), true + case reflect.Bool: + if v.Bool() { + return 1, true + } + return 0, true + } + return 0, false +} + +// numLess returns whether a < b. +// a and b must necessarily have the same kind. +func numLess(a, b reflect.Value) bool { + switch a.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return a.Int() < b.Int() + case reflect.Float32, reflect.Float64: + return a.Float() < b.Float() + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return a.Uint() < b.Uint() + case reflect.Bool: + return !a.Bool() && b.Bool() + } + panic("not a number") +} diff --git a/vendor/github.com/go-yaml/yaml/writerc.go b/vendor/github.com/go-yaml/yaml/writerc.go new file mode 100644 index 0000000000000..a2dde608cb7a3 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/writerc.go @@ -0,0 +1,26 @@ +package yaml + +// Set the writer error and return false. +func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { + emitter.error = yaml_WRITER_ERROR + emitter.problem = problem + return false +} + +// Flush the output buffer. +func yaml_emitter_flush(emitter *yaml_emitter_t) bool { + if emitter.write_handler == nil { + panic("write handler not set") + } + + // Check if the buffer is empty. + if emitter.buffer_pos == 0 { + return true + } + + if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { + return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) + } + emitter.buffer_pos = 0 + return true +} diff --git a/vendor/github.com/go-yaml/yaml/yaml.go b/vendor/github.com/go-yaml/yaml/yaml.go new file mode 100644 index 0000000000000..483aae58781c0 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/yaml.go @@ -0,0 +1,466 @@ +// Package yaml implements YAML support for the Go language. +// +// Source code and other details for the project are available at GitHub: +// +// https://github.com/go-yaml/yaml +// +package yaml + +import ( + "errors" + "fmt" + "io" + "reflect" + "strings" + "sync" +) + +// MapSlice encodes and decodes as a YAML map. +// The order of keys is preserved when encoding and decoding. +type MapSlice []MapItem + +// MapItem is an item in a MapSlice. +type MapItem struct { + Key, Value interface{} +} + +// The Unmarshaler interface may be implemented by types to customize their +// behavior when being unmarshaled from a YAML document. The UnmarshalYAML +// method receives a function that may be called to unmarshal the original +// YAML value into a field or variable. It is safe to call the unmarshal +// function parameter more than once if necessary. +type Unmarshaler interface { + UnmarshalYAML(unmarshal func(interface{}) error) error +} + +// The Marshaler interface may be implemented by types to customize their +// behavior when being marshaled into a YAML document. The returned value +// is marshaled in place of the original value implementing Marshaler. +// +// If an error is returned by MarshalYAML, the marshaling procedure stops +// and returns with the provided error. +type Marshaler interface { + MarshalYAML() (interface{}, error) +} + +// Unmarshal decodes the first document found within the in byte slice +// and assigns decoded values into the out value. +// +// Maps and pointers (to a struct, string, int, etc) are accepted as out +// values. If an internal pointer within a struct is not initialized, +// the yaml package will initialize it if necessary for unmarshalling +// the provided data. The out parameter must not be nil. +// +// The type of the decoded values should be compatible with the respective +// values in out. If one or more values cannot be decoded due to a type +// mismatches, decoding continues partially until the end of the YAML +// content, and a *yaml.TypeError is returned with details for all +// missed values. +// +// Struct fields are only unmarshalled if they are exported (have an +// upper case first letter), and are unmarshalled using the field name +// lowercased as the default key. Custom keys may be defined via the +// "yaml" name in the field tag: the content preceding the first comma +// is used as the key, and the following comma-separated options are +// used to tweak the marshalling process (see Marshal). +// Conflicting names result in a runtime error. +// +// For example: +// +// type T struct { +// F int `yaml:"a,omitempty"` +// B int +// } +// var t T +// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) +// +// See the documentation of Marshal for the format of tags and a list of +// supported tag options. +// +func Unmarshal(in []byte, out interface{}) (err error) { + return unmarshal(in, out, false) +} + +// UnmarshalStrict is like Unmarshal except that any fields that are found +// in the data that do not have corresponding struct members, or mapping +// keys that are duplicates, will result in +// an error. +func UnmarshalStrict(in []byte, out interface{}) (err error) { + return unmarshal(in, out, true) +} + +// A Decorder reads and decodes YAML values from an input stream. +type Decoder struct { + strict bool + parser *parser +} + +// NewDecoder returns a new decoder that reads from r. +// +// The decoder introduces its own buffering and may read +// data from r beyond the YAML values requested. +func NewDecoder(r io.Reader) *Decoder { + return &Decoder{ + parser: newParserFromReader(r), + } +} + +// SetStrict sets whether strict decoding behaviour is enabled when +// decoding items in the data (see UnmarshalStrict). By default, decoding is not strict. +func (dec *Decoder) SetStrict(strict bool) { + dec.strict = strict +} + +// Decode reads the next YAML-encoded value from its input +// and stores it in the value pointed to by v. +// +// See the documentation for Unmarshal for details about the +// conversion of YAML into a Go value. +func (dec *Decoder) Decode(v interface{}) (err error) { + d := newDecoder(dec.strict) + defer handleErr(&err) + node := dec.parser.parse() + if node == nil { + return io.EOF + } + out := reflect.ValueOf(v) + if out.Kind() == reflect.Ptr && !out.IsNil() { + out = out.Elem() + } + d.unmarshal(node, out) + if len(d.terrors) > 0 { + return &TypeError{d.terrors} + } + return nil +} + +func unmarshal(in []byte, out interface{}, strict bool) (err error) { + defer handleErr(&err) + d := newDecoder(strict) + p := newParser(in) + defer p.destroy() + node := p.parse() + if node != nil { + v := reflect.ValueOf(out) + if v.Kind() == reflect.Ptr && !v.IsNil() { + v = v.Elem() + } + d.unmarshal(node, v) + } + if len(d.terrors) > 0 { + return &TypeError{d.terrors} + } + return nil +} + +// Marshal serializes the value provided into a YAML document. The structure +// of the generated document will reflect the structure of the value itself. +// Maps and pointers (to struct, string, int, etc) are accepted as the in value. +// +// Struct fields are only unmarshalled if they are exported (have an upper case +// first letter), and are unmarshalled using the field name lowercased as the +// default key. Custom keys may be defined via the "yaml" name in the field +// tag: the content preceding the first comma is used as the key, and the +// following comma-separated options are used to tweak the marshalling process. +// Conflicting names result in a runtime error. +// +// The field tag format accepted is: +// +// `(...) yaml:"[][,[,]]" (...)` +// +// The following flags are currently supported: +// +// omitempty Only include the field if it's not set to the zero +// value for the type or to empty slices or maps. +// Zero valued structs will be omitted if all their public +// fields are zero, unless they implement an IsZero +// method (see the IsZeroer interface type), in which +// case the field will be included if that method returns true. +// +// flow Marshal using a flow style (useful for structs, +// sequences and maps). +// +// inline Inline the field, which must be a struct or a map, +// causing all of its fields or keys to be processed as if +// they were part of the outer struct. For maps, keys must +// not conflict with the yaml keys of other struct fields. +// +// In addition, if the key is "-", the field is ignored. +// +// For example: +// +// type T struct { +// F int `yaml:"a,omitempty"` +// B int +// } +// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" +// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" +// +func Marshal(in interface{}) (out []byte, err error) { + defer handleErr(&err) + e := newEncoder() + defer e.destroy() + e.marshalDoc("", reflect.ValueOf(in)) + e.finish() + out = e.out + return +} + +// An Encoder writes YAML values to an output stream. +type Encoder struct { + encoder *encoder +} + +// NewEncoder returns a new encoder that writes to w. +// The Encoder should be closed after use to flush all data +// to w. +func NewEncoder(w io.Writer) *Encoder { + return &Encoder{ + encoder: newEncoderWithWriter(w), + } +} + +// Encode writes the YAML encoding of v to the stream. +// If multiple items are encoded to the stream, the +// second and subsequent document will be preceded +// with a "---" document separator, but the first will not. +// +// See the documentation for Marshal for details about the conversion of Go +// values to YAML. +func (e *Encoder) Encode(v interface{}) (err error) { + defer handleErr(&err) + e.encoder.marshalDoc("", reflect.ValueOf(v)) + return nil +} + +// Close closes the encoder by writing any remaining data. +// It does not write a stream terminating string "...". +func (e *Encoder) Close() (err error) { + defer handleErr(&err) + e.encoder.finish() + return nil +} + +func handleErr(err *error) { + if v := recover(); v != nil { + if e, ok := v.(yamlError); ok { + *err = e.err + } else { + panic(v) + } + } +} + +type yamlError struct { + err error +} + +func fail(err error) { + panic(yamlError{err}) +} + +func failf(format string, args ...interface{}) { + panic(yamlError{fmt.Errorf("yaml: "+format, args...)}) +} + +// A TypeError is returned by Unmarshal when one or more fields in +// the YAML document cannot be properly decoded into the requested +// types. When this error is returned, the value is still +// unmarshaled partially. +type TypeError struct { + Errors []string +} + +func (e *TypeError) Error() string { + return fmt.Sprintf("yaml: unmarshal errors:\n %s", strings.Join(e.Errors, "\n ")) +} + +// -------------------------------------------------------------------------- +// Maintain a mapping of keys to structure field indexes + +// The code in this section was copied from mgo/bson. + +// structInfo holds details for the serialization of fields of +// a given struct. +type structInfo struct { + FieldsMap map[string]fieldInfo + FieldsList []fieldInfo + + // InlineMap is the number of the field in the struct that + // contains an ,inline map, or -1 if there's none. + InlineMap int +} + +type fieldInfo struct { + Key string + Num int + OmitEmpty bool + Flow bool + // Id holds the unique field identifier, so we can cheaply + // check for field duplicates without maintaining an extra map. + Id int + + // Inline holds the field index if the field is part of an inlined struct. + Inline []int +} + +var structMap = make(map[reflect.Type]*structInfo) +var fieldMapMutex sync.RWMutex + +func getStructInfo(st reflect.Type) (*structInfo, error) { + fieldMapMutex.RLock() + sinfo, found := structMap[st] + fieldMapMutex.RUnlock() + if found { + return sinfo, nil + } + + n := st.NumField() + fieldsMap := make(map[string]fieldInfo) + fieldsList := make([]fieldInfo, 0, n) + inlineMap := -1 + for i := 0; i != n; i++ { + field := st.Field(i) + if field.PkgPath != "" && !field.Anonymous { + continue // Private field + } + + info := fieldInfo{Num: i} + + tag := field.Tag.Get("yaml") + if tag == "" && strings.Index(string(field.Tag), ":") < 0 { + tag = string(field.Tag) + } + if tag == "-" { + continue + } + + inline := false + fields := strings.Split(tag, ",") + if len(fields) > 1 { + for _, flag := range fields[1:] { + switch flag { + case "omitempty": + info.OmitEmpty = true + case "flow": + info.Flow = true + case "inline": + inline = true + default: + return nil, errors.New(fmt.Sprintf("Unsupported flag %q in tag %q of type %s", flag, tag, st)) + } + } + tag = fields[0] + } + + if inline { + switch field.Type.Kind() { + case reflect.Map: + if inlineMap >= 0 { + return nil, errors.New("Multiple ,inline maps in struct " + st.String()) + } + if field.Type.Key() != reflect.TypeOf("") { + return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String()) + } + inlineMap = info.Num + case reflect.Struct: + sinfo, err := getStructInfo(field.Type) + if err != nil { + return nil, err + } + for _, finfo := range sinfo.FieldsList { + if _, found := fieldsMap[finfo.Key]; found { + msg := "Duplicated key '" + finfo.Key + "' in struct " + st.String() + return nil, errors.New(msg) + } + if finfo.Inline == nil { + finfo.Inline = []int{i, finfo.Num} + } else { + finfo.Inline = append([]int{i}, finfo.Inline...) + } + finfo.Id = len(fieldsList) + fieldsMap[finfo.Key] = finfo + fieldsList = append(fieldsList, finfo) + } + default: + //return nil, errors.New("Option ,inline needs a struct value or map field") + return nil, errors.New("Option ,inline needs a struct value field") + } + continue + } + + if tag != "" { + info.Key = tag + } else { + info.Key = strings.ToLower(field.Name) + } + + if _, found = fieldsMap[info.Key]; found { + msg := "Duplicated key '" + info.Key + "' in struct " + st.String() + return nil, errors.New(msg) + } + + info.Id = len(fieldsList) + fieldsList = append(fieldsList, info) + fieldsMap[info.Key] = info + } + + sinfo = &structInfo{ + FieldsMap: fieldsMap, + FieldsList: fieldsList, + InlineMap: inlineMap, + } + + fieldMapMutex.Lock() + structMap[st] = sinfo + fieldMapMutex.Unlock() + return sinfo, nil +} + +// IsZeroer is used to check whether an object is zero to +// determine whether it should be omitted when marshaling +// with the omitempty flag. One notable implementation +// is time.Time. +type IsZeroer interface { + IsZero() bool +} + +func isZero(v reflect.Value) bool { + kind := v.Kind() + if z, ok := v.Interface().(IsZeroer); ok { + if (kind == reflect.Ptr || kind == reflect.Interface) && v.IsNil() { + return true + } + return z.IsZero() + } + switch kind { + case reflect.String: + return len(v.String()) == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + case reflect.Slice: + return v.Len() == 0 + case reflect.Map: + return v.Len() == 0 + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Struct: + vt := v.Type() + for i := v.NumField() - 1; i >= 0; i-- { + if vt.Field(i).PkgPath != "" { + continue // Private field + } + if !isZero(v.Field(i)) { + return false + } + } + return true + } + return false +} diff --git a/vendor/github.com/go-yaml/yaml/yamlh.go b/vendor/github.com/go-yaml/yaml/yamlh.go new file mode 100644 index 0000000000000..e25cee563be82 --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/yamlh.go @@ -0,0 +1,738 @@ +package yaml + +import ( + "fmt" + "io" +) + +// The version directive data. +type yaml_version_directive_t struct { + major int8 // The major version number. + minor int8 // The minor version number. +} + +// The tag directive data. +type yaml_tag_directive_t struct { + handle []byte // The tag handle. + prefix []byte // The tag prefix. +} + +type yaml_encoding_t int + +// The stream encoding. +const ( + // Let the parser choose the encoding. + yaml_ANY_ENCODING yaml_encoding_t = iota + + yaml_UTF8_ENCODING // The default UTF-8 encoding. + yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM. + yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM. +) + +type yaml_break_t int + +// Line break types. +const ( + // Let the parser choose the break type. + yaml_ANY_BREAK yaml_break_t = iota + + yaml_CR_BREAK // Use CR for line breaks (Mac style). + yaml_LN_BREAK // Use LN for line breaks (Unix style). + yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style). +) + +type yaml_error_type_t int + +// Many bad things could happen with the parser and emitter. +const ( + // No error is produced. + yaml_NO_ERROR yaml_error_type_t = iota + + yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory. + yaml_READER_ERROR // Cannot read or decode the input stream. + yaml_SCANNER_ERROR // Cannot scan the input stream. + yaml_PARSER_ERROR // Cannot parse the input stream. + yaml_COMPOSER_ERROR // Cannot compose a YAML document. + yaml_WRITER_ERROR // Cannot write to the output stream. + yaml_EMITTER_ERROR // Cannot emit a YAML stream. +) + +// The pointer position. +type yaml_mark_t struct { + index int // The position index. + line int // The position line. + column int // The position column. +} + +// Node Styles + +type yaml_style_t int8 + +type yaml_scalar_style_t yaml_style_t + +// Scalar styles. +const ( + // Let the emitter choose the style. + yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota + + yaml_PLAIN_SCALAR_STYLE // The plain scalar style. + yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style. + yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style. + yaml_LITERAL_SCALAR_STYLE // The literal scalar style. + yaml_FOLDED_SCALAR_STYLE // The folded scalar style. +) + +type yaml_sequence_style_t yaml_style_t + +// Sequence styles. +const ( + // Let the emitter choose the style. + yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota + + yaml_BLOCK_SEQUENCE_STYLE // The block sequence style. + yaml_FLOW_SEQUENCE_STYLE // The flow sequence style. +) + +type yaml_mapping_style_t yaml_style_t + +// Mapping styles. +const ( + // Let the emitter choose the style. + yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota + + yaml_BLOCK_MAPPING_STYLE // The block mapping style. + yaml_FLOW_MAPPING_STYLE // The flow mapping style. +) + +// Tokens + +type yaml_token_type_t int + +// Token types. +const ( + // An empty token. + yaml_NO_TOKEN yaml_token_type_t = iota + + yaml_STREAM_START_TOKEN // A STREAM-START token. + yaml_STREAM_END_TOKEN // A STREAM-END token. + + yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token. + yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token. + yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token. + yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token. + + yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token. + yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token. + yaml_BLOCK_END_TOKEN // A BLOCK-END token. + + yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token. + yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token. + yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token. + yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token. + + yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token. + yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token. + yaml_KEY_TOKEN // A KEY token. + yaml_VALUE_TOKEN // A VALUE token. + + yaml_ALIAS_TOKEN // An ALIAS token. + yaml_ANCHOR_TOKEN // An ANCHOR token. + yaml_TAG_TOKEN // A TAG token. + yaml_SCALAR_TOKEN // A SCALAR token. +) + +func (tt yaml_token_type_t) String() string { + switch tt { + case yaml_NO_TOKEN: + return "yaml_NO_TOKEN" + case yaml_STREAM_START_TOKEN: + return "yaml_STREAM_START_TOKEN" + case yaml_STREAM_END_TOKEN: + return "yaml_STREAM_END_TOKEN" + case yaml_VERSION_DIRECTIVE_TOKEN: + return "yaml_VERSION_DIRECTIVE_TOKEN" + case yaml_TAG_DIRECTIVE_TOKEN: + return "yaml_TAG_DIRECTIVE_TOKEN" + case yaml_DOCUMENT_START_TOKEN: + return "yaml_DOCUMENT_START_TOKEN" + case yaml_DOCUMENT_END_TOKEN: + return "yaml_DOCUMENT_END_TOKEN" + case yaml_BLOCK_SEQUENCE_START_TOKEN: + return "yaml_BLOCK_SEQUENCE_START_TOKEN" + case yaml_BLOCK_MAPPING_START_TOKEN: + return "yaml_BLOCK_MAPPING_START_TOKEN" + case yaml_BLOCK_END_TOKEN: + return "yaml_BLOCK_END_TOKEN" + case yaml_FLOW_SEQUENCE_START_TOKEN: + return "yaml_FLOW_SEQUENCE_START_TOKEN" + case yaml_FLOW_SEQUENCE_END_TOKEN: + return "yaml_FLOW_SEQUENCE_END_TOKEN" + case yaml_FLOW_MAPPING_START_TOKEN: + return "yaml_FLOW_MAPPING_START_TOKEN" + case yaml_FLOW_MAPPING_END_TOKEN: + return "yaml_FLOW_MAPPING_END_TOKEN" + case yaml_BLOCK_ENTRY_TOKEN: + return "yaml_BLOCK_ENTRY_TOKEN" + case yaml_FLOW_ENTRY_TOKEN: + return "yaml_FLOW_ENTRY_TOKEN" + case yaml_KEY_TOKEN: + return "yaml_KEY_TOKEN" + case yaml_VALUE_TOKEN: + return "yaml_VALUE_TOKEN" + case yaml_ALIAS_TOKEN: + return "yaml_ALIAS_TOKEN" + case yaml_ANCHOR_TOKEN: + return "yaml_ANCHOR_TOKEN" + case yaml_TAG_TOKEN: + return "yaml_TAG_TOKEN" + case yaml_SCALAR_TOKEN: + return "yaml_SCALAR_TOKEN" + } + return "" +} + +// The token structure. +type yaml_token_t struct { + // The token type. + typ yaml_token_type_t + + // The start/end of the token. + start_mark, end_mark yaml_mark_t + + // The stream encoding (for yaml_STREAM_START_TOKEN). + encoding yaml_encoding_t + + // The alias/anchor/scalar value or tag/tag directive handle + // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN). + value []byte + + // The tag suffix (for yaml_TAG_TOKEN). + suffix []byte + + // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN). + prefix []byte + + // The scalar style (for yaml_SCALAR_TOKEN). + style yaml_scalar_style_t + + // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN). + major, minor int8 +} + +// Events + +type yaml_event_type_t int8 + +// Event types. +const ( + // An empty event. + yaml_NO_EVENT yaml_event_type_t = iota + + yaml_STREAM_START_EVENT // A STREAM-START event. + yaml_STREAM_END_EVENT // A STREAM-END event. + yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event. + yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event. + yaml_ALIAS_EVENT // An ALIAS event. + yaml_SCALAR_EVENT // A SCALAR event. + yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event. + yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event. + yaml_MAPPING_START_EVENT // A MAPPING-START event. + yaml_MAPPING_END_EVENT // A MAPPING-END event. +) + +var eventStrings = []string{ + yaml_NO_EVENT: "none", + yaml_STREAM_START_EVENT: "stream start", + yaml_STREAM_END_EVENT: "stream end", + yaml_DOCUMENT_START_EVENT: "document start", + yaml_DOCUMENT_END_EVENT: "document end", + yaml_ALIAS_EVENT: "alias", + yaml_SCALAR_EVENT: "scalar", + yaml_SEQUENCE_START_EVENT: "sequence start", + yaml_SEQUENCE_END_EVENT: "sequence end", + yaml_MAPPING_START_EVENT: "mapping start", + yaml_MAPPING_END_EVENT: "mapping end", +} + +func (e yaml_event_type_t) String() string { + if e < 0 || int(e) >= len(eventStrings) { + return fmt.Sprintf("unknown event %d", e) + } + return eventStrings[e] +} + +// The event structure. +type yaml_event_t struct { + + // The event type. + typ yaml_event_type_t + + // The start and end of the event. + start_mark, end_mark yaml_mark_t + + // The document encoding (for yaml_STREAM_START_EVENT). + encoding yaml_encoding_t + + // The version directive (for yaml_DOCUMENT_START_EVENT). + version_directive *yaml_version_directive_t + + // The list of tag directives (for yaml_DOCUMENT_START_EVENT). + tag_directives []yaml_tag_directive_t + + // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT). + anchor []byte + + // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). + tag []byte + + // The scalar value (for yaml_SCALAR_EVENT). + value []byte + + // Is the document start/end indicator implicit, or the tag optional? + // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT). + implicit bool + + // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT). + quoted_implicit bool + + // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). + style yaml_style_t +} + +func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) } +func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) } +func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) } + +// Nodes + +const ( + yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null. + yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false. + yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values. + yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values. + yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values. + yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values. + + yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences. + yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping. + + // Not in original libyaml. + yaml_BINARY_TAG = "tag:yaml.org,2002:binary" + yaml_MERGE_TAG = "tag:yaml.org,2002:merge" + + yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str. + yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq. + yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map. +) + +type yaml_node_type_t int + +// Node types. +const ( + // An empty node. + yaml_NO_NODE yaml_node_type_t = iota + + yaml_SCALAR_NODE // A scalar node. + yaml_SEQUENCE_NODE // A sequence node. + yaml_MAPPING_NODE // A mapping node. +) + +// An element of a sequence node. +type yaml_node_item_t int + +// An element of a mapping node. +type yaml_node_pair_t struct { + key int // The key of the element. + value int // The value of the element. +} + +// The node structure. +type yaml_node_t struct { + typ yaml_node_type_t // The node type. + tag []byte // The node tag. + + // The node data. + + // The scalar parameters (for yaml_SCALAR_NODE). + scalar struct { + value []byte // The scalar value. + length int // The length of the scalar value. + style yaml_scalar_style_t // The scalar style. + } + + // The sequence parameters (for YAML_SEQUENCE_NODE). + sequence struct { + items_data []yaml_node_item_t // The stack of sequence items. + style yaml_sequence_style_t // The sequence style. + } + + // The mapping parameters (for yaml_MAPPING_NODE). + mapping struct { + pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value). + pairs_start *yaml_node_pair_t // The beginning of the stack. + pairs_end *yaml_node_pair_t // The end of the stack. + pairs_top *yaml_node_pair_t // The top of the stack. + style yaml_mapping_style_t // The mapping style. + } + + start_mark yaml_mark_t // The beginning of the node. + end_mark yaml_mark_t // The end of the node. + +} + +// The document structure. +type yaml_document_t struct { + + // The document nodes. + nodes []yaml_node_t + + // The version directive. + version_directive *yaml_version_directive_t + + // The list of tag directives. + tag_directives_data []yaml_tag_directive_t + tag_directives_start int // The beginning of the tag directives list. + tag_directives_end int // The end of the tag directives list. + + start_implicit int // Is the document start indicator implicit? + end_implicit int // Is the document end indicator implicit? + + // The start/end of the document. + start_mark, end_mark yaml_mark_t +} + +// The prototype of a read handler. +// +// The read handler is called when the parser needs to read more bytes from the +// source. The handler should write not more than size bytes to the buffer. +// The number of written bytes should be set to the size_read variable. +// +// [in,out] data A pointer to an application data specified by +// yaml_parser_set_input(). +// [out] buffer The buffer to write the data from the source. +// [in] size The size of the buffer. +// [out] size_read The actual number of bytes read from the source. +// +// On success, the handler should return 1. If the handler failed, +// the returned value should be 0. On EOF, the handler should set the +// size_read to 0 and return 1. +type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) + +// This structure holds information about a potential simple key. +type yaml_simple_key_t struct { + possible bool // Is a simple key possible? + required bool // Is a simple key required? + token_number int // The number of the token. + mark yaml_mark_t // The position mark. +} + +// The states of the parser. +type yaml_parser_state_t int + +const ( + yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota + + yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document. + yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START. + yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document. + yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END. + yaml_PARSE_BLOCK_NODE_STATE // Expect a block node. + yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence. + yaml_PARSE_FLOW_NODE_STATE // Expect a flow node. + yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence. + yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence. + yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence. + yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. + yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key. + yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value. + yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry. + yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. + yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. + yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. + yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping. + yaml_PARSE_END_STATE // Expect nothing. +) + +func (ps yaml_parser_state_t) String() string { + switch ps { + case yaml_PARSE_STREAM_START_STATE: + return "yaml_PARSE_STREAM_START_STATE" + case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: + return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE" + case yaml_PARSE_DOCUMENT_START_STATE: + return "yaml_PARSE_DOCUMENT_START_STATE" + case yaml_PARSE_DOCUMENT_CONTENT_STATE: + return "yaml_PARSE_DOCUMENT_CONTENT_STATE" + case yaml_PARSE_DOCUMENT_END_STATE: + return "yaml_PARSE_DOCUMENT_END_STATE" + case yaml_PARSE_BLOCK_NODE_STATE: + return "yaml_PARSE_BLOCK_NODE_STATE" + case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: + return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE" + case yaml_PARSE_FLOW_NODE_STATE: + return "yaml_PARSE_FLOW_NODE_STATE" + case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: + return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE" + case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: + return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE" + case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: + return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE" + case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: + return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE" + case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: + return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE" + case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: + return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE" + case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE" + case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: + return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE" + case yaml_PARSE_FLOW_MAPPING_KEY_STATE: + return "yaml_PARSE_FLOW_MAPPING_KEY_STATE" + case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: + return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE" + case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: + return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE" + case yaml_PARSE_END_STATE: + return "yaml_PARSE_END_STATE" + } + return "" +} + +// This structure holds aliases data. +type yaml_alias_data_t struct { + anchor []byte // The anchor. + index int // The node id. + mark yaml_mark_t // The anchor mark. +} + +// The parser structure. +// +// All members are internal. Manage the structure using the +// yaml_parser_ family of functions. +type yaml_parser_t struct { + + // Error handling + + error yaml_error_type_t // Error type. + + problem string // Error description. + + // The byte about which the problem occurred. + problem_offset int + problem_value int + problem_mark yaml_mark_t + + // The error context. + context string + context_mark yaml_mark_t + + // Reader stuff + + read_handler yaml_read_handler_t // Read handler. + + input_reader io.Reader // File input data. + input []byte // String input data. + input_pos int + + eof bool // EOF flag + + buffer []byte // The working buffer. + buffer_pos int // The current position of the buffer. + + unread int // The number of unread characters in the buffer. + + raw_buffer []byte // The raw buffer. + raw_buffer_pos int // The current position of the buffer. + + encoding yaml_encoding_t // The input encoding. + + offset int // The offset of the current position (in bytes). + mark yaml_mark_t // The mark of the current position. + + // Scanner stuff + + stream_start_produced bool // Have we started to scan the input stream? + stream_end_produced bool // Have we reached the end of the input stream? + + flow_level int // The number of unclosed '[' and '{' indicators. + + tokens []yaml_token_t // The tokens queue. + tokens_head int // The head of the tokens queue. + tokens_parsed int // The number of tokens fetched from the queue. + token_available bool // Does the tokens queue contain a token ready for dequeueing. + + indent int // The current indentation level. + indents []int // The indentation levels stack. + + simple_key_allowed bool // May a simple key occur at the current position? + simple_keys []yaml_simple_key_t // The stack of simple keys. + + // Parser stuff + + state yaml_parser_state_t // The current parser state. + states []yaml_parser_state_t // The parser states stack. + marks []yaml_mark_t // The stack of marks. + tag_directives []yaml_tag_directive_t // The list of TAG directives. + + // Dumper stuff + + aliases []yaml_alias_data_t // The alias data. + + document *yaml_document_t // The currently parsed document. +} + +// Emitter Definitions + +// The prototype of a write handler. +// +// The write handler is called when the emitter needs to flush the accumulated +// characters to the output. The handler should write @a size bytes of the +// @a buffer to the output. +// +// @param[in,out] data A pointer to an application data specified by +// yaml_emitter_set_output(). +// @param[in] buffer The buffer with bytes to be written. +// @param[in] size The size of the buffer. +// +// @returns On success, the handler should return @c 1. If the handler failed, +// the returned value should be @c 0. +// +type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error + +type yaml_emitter_state_t int + +// The emitter states. +const ( + // Expect STREAM-START. + yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota + + yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END. + yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END. + yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document. + yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END. + yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence. + yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence. + yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. + yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. + yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping. + yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. + yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence. + yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence. + yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. + yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping. + yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping. + yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping. + yaml_EMIT_END_STATE // Expect nothing. +) + +// The emitter structure. +// +// All members are internal. Manage the structure using the @c yaml_emitter_ +// family of functions. +type yaml_emitter_t struct { + + // Error handling + + error yaml_error_type_t // Error type. + problem string // Error description. + + // Writer stuff + + write_handler yaml_write_handler_t // Write handler. + + output_buffer *[]byte // String output data. + output_writer io.Writer // File output data. + + buffer []byte // The working buffer. + buffer_pos int // The current position of the buffer. + + raw_buffer []byte // The raw buffer. + raw_buffer_pos int // The current position of the buffer. + + encoding yaml_encoding_t // The stream encoding. + + // Emitter stuff + + canonical bool // If the output is in the canonical style? + best_indent int // The number of indentation spaces. + best_width int // The preferred width of the output lines. + unicode bool // Allow unescaped non-ASCII characters? + line_break yaml_break_t // The preferred line break. + + state yaml_emitter_state_t // The current emitter state. + states []yaml_emitter_state_t // The stack of states. + + events []yaml_event_t // The event queue. + events_head int // The head of the event queue. + + indents []int // The stack of indentation levels. + + tag_directives []yaml_tag_directive_t // The list of tag directives. + + indent int // The current indentation level. + + flow_level int // The current flow level. + + root_context bool // Is it the document root context? + sequence_context bool // Is it a sequence context? + mapping_context bool // Is it a mapping context? + simple_key_context bool // Is it a simple mapping key context? + + line int // The current line. + column int // The current column. + whitespace bool // If the last character was a whitespace? + indention bool // If the last character was an indentation character (' ', '-', '?', ':')? + open_ended bool // If an explicit document end is required? + + // Anchor analysis. + anchor_data struct { + anchor []byte // The anchor value. + alias bool // Is it an alias? + } + + // Tag analysis. + tag_data struct { + handle []byte // The tag handle. + suffix []byte // The tag suffix. + } + + // Scalar analysis. + scalar_data struct { + value []byte // The scalar value. + multiline bool // Does the scalar contain line breaks? + flow_plain_allowed bool // Can the scalar be expessed in the flow plain style? + block_plain_allowed bool // Can the scalar be expressed in the block plain style? + single_quoted_allowed bool // Can the scalar be expressed in the single quoted style? + block_allowed bool // Can the scalar be expressed in the literal or folded styles? + style yaml_scalar_style_t // The output style. + } + + // Dumper stuff + + opened bool // If the stream was already opened? + closed bool // If the stream was already closed? + + // The information associated with the document nodes. + anchors *struct { + references int // The number of references. + anchor int // The anchor id. + serialized bool // If the node has been emitted? + } + + last_anchor_id int // The last assigned anchor id. + + document *yaml_document_t // The currently emitted document. +} diff --git a/vendor/github.com/go-yaml/yaml/yamlprivateh.go b/vendor/github.com/go-yaml/yaml/yamlprivateh.go new file mode 100644 index 0000000000000..8110ce3c37a6b --- /dev/null +++ b/vendor/github.com/go-yaml/yaml/yamlprivateh.go @@ -0,0 +1,173 @@ +package yaml + +const ( + // The size of the input raw buffer. + input_raw_buffer_size = 512 + + // The size of the input buffer. + // It should be possible to decode the whole raw buffer. + input_buffer_size = input_raw_buffer_size * 3 + + // The size of the output buffer. + output_buffer_size = 128 + + // The size of the output raw buffer. + // It should be possible to encode the whole output buffer. + output_raw_buffer_size = (output_buffer_size*2 + 2) + + // The size of other stacks and queues. + initial_stack_size = 16 + initial_queue_size = 16 + initial_string_size = 16 +) + +// Check if the character at the specified position is an alphabetical +// character, a digit, '_', or '-'. +func is_alpha(b []byte, i int) bool { + return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' +} + +// Check if the character at the specified position is a digit. +func is_digit(b []byte, i int) bool { + return b[i] >= '0' && b[i] <= '9' +} + +// Get the value of a digit. +func as_digit(b []byte, i int) int { + return int(b[i]) - '0' +} + +// Check if the character at the specified position is a hex-digit. +func is_hex(b []byte, i int) bool { + return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' +} + +// Get the value of a hex-digit. +func as_hex(b []byte, i int) int { + bi := b[i] + if bi >= 'A' && bi <= 'F' { + return int(bi) - 'A' + 10 + } + if bi >= 'a' && bi <= 'f' { + return int(bi) - 'a' + 10 + } + return int(bi) - '0' +} + +// Check if the character is ASCII. +func is_ascii(b []byte, i int) bool { + return b[i] <= 0x7F +} + +// Check if the character at the start of the buffer can be printed unescaped. +func is_printable(b []byte, i int) bool { + return ((b[i] == 0x0A) || // . == #x0A + (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E + (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF + (b[i] > 0xC2 && b[i] < 0xED) || + (b[i] == 0xED && b[i+1] < 0xA0) || + (b[i] == 0xEE) || + (b[i] == 0xEF && // #xE000 <= . <= #xFFFD + !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF + !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) +} + +// Check if the character at the specified position is NUL. +func is_z(b []byte, i int) bool { + return b[i] == 0x00 +} + +// Check if the beginning of the buffer is a BOM. +func is_bom(b []byte, i int) bool { + return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF +} + +// Check if the character at the specified position is space. +func is_space(b []byte, i int) bool { + return b[i] == ' ' +} + +// Check if the character at the specified position is tab. +func is_tab(b []byte, i int) bool { + return b[i] == '\t' +} + +// Check if the character at the specified position is blank (space or tab). +func is_blank(b []byte, i int) bool { + //return is_space(b, i) || is_tab(b, i) + return b[i] == ' ' || b[i] == '\t' +} + +// Check if the character at the specified position is a line break. +func is_break(b []byte, i int) bool { + return (b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) +} + +func is_crlf(b []byte, i int) bool { + return b[i] == '\r' && b[i+1] == '\n' +} + +// Check if the character is a line break or NUL. +func is_breakz(b []byte, i int) bool { + //return is_break(b, i) || is_z(b, i) + return ( // is_break: + b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) + // is_z: + b[i] == 0) +} + +// Check if the character is a line break, space, or NUL. +func is_spacez(b []byte, i int) bool { + //return is_space(b, i) || is_breakz(b, i) + return ( // is_space: + b[i] == ' ' || + // is_breakz: + b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) + b[i] == 0) +} + +// Check if the character is a line break, space, tab, or NUL. +func is_blankz(b []byte, i int) bool { + //return is_blank(b, i) || is_breakz(b, i) + return ( // is_blank: + b[i] == ' ' || b[i] == '\t' || + // is_breakz: + b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) + b[i] == 0) +} + +// Determine the width of the character. +func width(b byte) int { + // Don't replace these by a switch without first + // confirming that it is being inlined. + if b&0x80 == 0x00 { + return 1 + } + if b&0xE0 == 0xC0 { + return 2 + } + if b&0xF0 == 0xE0 { + return 3 + } + if b&0xF8 == 0xF0 { + return 4 + } + return 0 + +} diff --git a/vendor/github.com/google/go-github/github/gen-accessors.go b/vendor/github.com/google/go-github/github/gen-accessors.go new file mode 100644 index 0000000000000..fe92206fcf869 --- /dev/null +++ b/vendor/github.com/google/go-github/github/gen-accessors.go @@ -0,0 +1,332 @@ +// Copyright 2017 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// gen-accessors generates accessor methods for structs with pointer fields. +// +// It is meant to be used by the go-github authors in conjunction with the +// go generate tool before sending a commit to GitHub. +package main + +import ( + "bytes" + "flag" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "io/ioutil" + "log" + "os" + "sort" + "strings" + "text/template" +) + +const ( + fileSuffix = "-accessors.go" +) + +var ( + verbose = flag.Bool("v", false, "Print verbose log messages") + + sourceTmpl = template.Must(template.New("source").Parse(source)) + + // blacklistStructMethod lists "struct.method" combos to skip. + blacklistStructMethod = map[string]bool{ + "RepositoryContent.GetContent": true, + "Client.GetBaseURL": true, + "Client.GetUploadURL": true, + "ErrorResponse.GetResponse": true, + "RateLimitError.GetResponse": true, + "AbuseRateLimitError.GetResponse": true, + } + // blacklistStruct lists structs to skip. + blacklistStruct = map[string]bool{ + "Client": true, + } +) + +func logf(fmt string, args ...interface{}) { + if *verbose { + log.Printf(fmt, args...) + } +} + +func main() { + flag.Parse() + fset := token.NewFileSet() + + pkgs, err := parser.ParseDir(fset, ".", sourceFilter, 0) + if err != nil { + log.Fatal(err) + return + } + + for pkgName, pkg := range pkgs { + t := &templateData{ + filename: pkgName + fileSuffix, + Year: 2017, + Package: pkgName, + Imports: map[string]string{}, + } + for filename, f := range pkg.Files { + logf("Processing %v...", filename) + if err := t.processAST(f); err != nil { + log.Fatal(err) + } + } + if err := t.dump(); err != nil { + log.Fatal(err) + } + } + logf("Done.") +} + +func (t *templateData) processAST(f *ast.File) error { + for _, decl := range f.Decls { + gd, ok := decl.(*ast.GenDecl) + if !ok { + continue + } + for _, spec := range gd.Specs { + ts, ok := spec.(*ast.TypeSpec) + if !ok { + continue + } + // Skip unexported identifiers. + if !ts.Name.IsExported() { + logf("Struct %v is unexported; skipping.", ts.Name) + continue + } + // Check if the struct is blacklisted. + if blacklistStruct[ts.Name.Name] { + logf("Struct %v is blacklisted; skipping.", ts.Name) + continue + } + st, ok := ts.Type.(*ast.StructType) + if !ok { + continue + } + for _, field := range st.Fields.List { + se, ok := field.Type.(*ast.StarExpr) + if len(field.Names) == 0 || !ok { + continue + } + + fieldName := field.Names[0] + // Skip unexported identifiers. + if !fieldName.IsExported() { + logf("Field %v is unexported; skipping.", fieldName) + continue + } + // Check if "struct.method" is blacklisted. + if key := fmt.Sprintf("%v.Get%v", ts.Name, fieldName); blacklistStructMethod[key] { + logf("Method %v is blacklisted; skipping.", key) + continue + } + + switch x := se.X.(type) { + case *ast.ArrayType: + t.addArrayType(x, ts.Name.String(), fieldName.String()) + case *ast.Ident: + t.addIdent(x, ts.Name.String(), fieldName.String()) + case *ast.MapType: + t.addMapType(x, ts.Name.String(), fieldName.String()) + case *ast.SelectorExpr: + t.addSelectorExpr(x, ts.Name.String(), fieldName.String()) + default: + logf("processAST: type %q, field %q, unknown %T: %+v", ts.Name, fieldName, x, x) + } + } + } + } + return nil +} + +func sourceFilter(fi os.FileInfo) bool { + return !strings.HasSuffix(fi.Name(), "_test.go") && !strings.HasSuffix(fi.Name(), fileSuffix) +} + +func (t *templateData) dump() error { + if len(t.Getters) == 0 { + logf("No getters for %v; skipping.", t.filename) + return nil + } + + // Sort getters by ReceiverType.FieldName. + sort.Sort(byName(t.Getters)) + + var buf bytes.Buffer + if err := sourceTmpl.Execute(&buf, t); err != nil { + return err + } + clean, err := format.Source(buf.Bytes()) + if err != nil { + return err + } + + logf("Writing %v...", t.filename) + return ioutil.WriteFile(t.filename, clean, 0644) +} + +func newGetter(receiverType, fieldName, fieldType, zeroValue string, namedStruct bool) *getter { + return &getter{ + sortVal: strings.ToLower(receiverType) + "." + strings.ToLower(fieldName), + ReceiverVar: strings.ToLower(receiverType[:1]), + ReceiverType: receiverType, + FieldName: fieldName, + FieldType: fieldType, + ZeroValue: zeroValue, + NamedStruct: namedStruct, + } +} + +func (t *templateData) addArrayType(x *ast.ArrayType, receiverType, fieldName string) { + var eltType string + switch elt := x.Elt.(type) { + case *ast.Ident: + eltType = elt.String() + default: + logf("addArrayType: type %q, field %q: unknown elt type: %T %+v; skipping.", receiverType, fieldName, elt, elt) + return + } + + t.Getters = append(t.Getters, newGetter(receiverType, fieldName, "[]"+eltType, "nil", false)) +} + +func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) { + var zeroValue string + var namedStruct = false + switch x.String() { + case "int", "int64": + zeroValue = "0" + case "string": + zeroValue = `""` + case "bool": + zeroValue = "false" + case "Timestamp": + zeroValue = "Timestamp{}" + default: + zeroValue = "nil" + namedStruct = true + } + + t.Getters = append(t.Getters, newGetter(receiverType, fieldName, x.String(), zeroValue, namedStruct)) +} + +func (t *templateData) addMapType(x *ast.MapType, receiverType, fieldName string) { + var keyType string + switch key := x.Key.(type) { + case *ast.Ident: + keyType = key.String() + default: + logf("addMapType: type %q, field %q: unknown key type: %T %+v; skipping.", receiverType, fieldName, key, key) + return + } + + var valueType string + switch value := x.Value.(type) { + case *ast.Ident: + valueType = value.String() + default: + logf("addMapType: type %q, field %q: unknown value type: %T %+v; skipping.", receiverType, fieldName, value, value) + return + } + + fieldType := fmt.Sprintf("map[%v]%v", keyType, valueType) + zeroValue := fmt.Sprintf("map[%v]%v{}", keyType, valueType) + t.Getters = append(t.Getters, newGetter(receiverType, fieldName, fieldType, zeroValue, false)) +} + +func (t *templateData) addSelectorExpr(x *ast.SelectorExpr, receiverType, fieldName string) { + if strings.ToLower(fieldName[:1]) == fieldName[:1] { // Non-exported field. + return + } + + var xX string + if xx, ok := x.X.(*ast.Ident); ok { + xX = xx.String() + } + + switch xX { + case "time", "json": + if xX == "json" { + t.Imports["encoding/json"] = "encoding/json" + } else { + t.Imports[xX] = xX + } + fieldType := fmt.Sprintf("%v.%v", xX, x.Sel.Name) + zeroValue := fmt.Sprintf("%v.%v{}", xX, x.Sel.Name) + if xX == "time" && x.Sel.Name == "Duration" { + zeroValue = "0" + } + t.Getters = append(t.Getters, newGetter(receiverType, fieldName, fieldType, zeroValue, false)) + default: + logf("addSelectorExpr: xX %q, type %q, field %q: unknown x=%+v; skipping.", xX, receiverType, fieldName, x) + } +} + +type templateData struct { + filename string + Year int + Package string + Imports map[string]string + Getters []*getter +} + +type getter struct { + sortVal string // Lower-case version of "ReceiverType.FieldName". + ReceiverVar string // The one-letter variable name to match the ReceiverType. + ReceiverType string + FieldName string + FieldType string + ZeroValue string + NamedStruct bool // Getter for named struct. +} + +type byName []*getter + +func (b byName) Len() int { return len(b) } +func (b byName) Less(i, j int) bool { return b[i].sortVal < b[j].sortVal } +func (b byName) Swap(i, j int) { b[i], b[j] = b[j], b[i] } + +const source = `// Copyright {{.Year}} The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen-accessors; DO NOT EDIT. + +package {{.Package}} +{{with .Imports}} +import ( + {{- range . -}} + "{{.}}" + {{end -}} +) +{{end}} +{{range .Getters}} +{{if .NamedStruct}} +// Get{{.FieldName}} returns the {{.FieldName}} field. +func ({{.ReceiverVar}} *{{.ReceiverType}}) Get{{.FieldName}}() *{{.FieldType}} { + if {{.ReceiverVar}} == nil { + return {{.ZeroValue}} + } + return {{.ReceiverVar}}.{{.FieldName}} +} +{{else}} +// Get{{.FieldName}} returns the {{.FieldName}} field if it's non-nil, zero value otherwise. +func ({{.ReceiverVar}} *{{.ReceiverType}}) Get{{.FieldName}}() {{.FieldType}} { + if {{.ReceiverVar}} == nil || {{.ReceiverVar}}.{{.FieldName}} == nil { + return {{.ZeroValue}} + } + return *{{.ReceiverVar}}.{{.FieldName}} +} +{{end}} +{{end}} +` diff --git a/vendor/github.com/hashicorp/vault/api/client.go b/vendor/github.com/hashicorp/vault/api/client.go index 434663b12a43e..2f4f90ee353e6 100644 --- a/vendor/github.com/hashicorp/vault/api/client.go +++ b/vendor/github.com/hashicorp/vault/api/client.go @@ -688,8 +688,8 @@ func (c *Client) SetPolicyOverride(override bool) { // portMap defines the standard port map var portMap = map[string]string{ - "http": "80", - "https": "443", + "http": "80", + "https": "443", } // NewRequest creates a new raw request object to query the Vault server @@ -711,7 +711,7 @@ func (c *Client) NewRequest(method, requestPath string) *Request { // Avoid lookup of SRV record if scheme is known port, ok := portMap[addr.Scheme] if ok { - host = net.JoinHostPort(host, port) + host = net.JoinHostPort(host, port) } else { // Internet Draft specifies that the SRV record is ignored if a port is given _, addrs, err := net.LookupSRV("http", "tcp", addr.Hostname()) diff --git a/vendor/github.com/hashicorp/vault/api/go.sum b/vendor/github.com/hashicorp/vault/api/go.sum index 24a91133430ab..b85da99ce0ffd 100644 --- a/vendor/github.com/hashicorp/vault/api/go.sum +++ b/vendor/github.com/hashicorp/vault/api/go.sum @@ -48,6 +48,7 @@ github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0S github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= diff --git a/vendor/github.com/kelseyhightower/envconfig/.travis.yml b/vendor/github.com/kelseyhightower/envconfig/.travis.yml new file mode 100644 index 0000000000000..e15301a594332 --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/.travis.yml @@ -0,0 +1,7 @@ +language: go + +go: + - 1.4 + - 1.5 + - 1.6 + - tip diff --git a/vendor/github.com/chrismalek/oktasdk-go/LICENSE.txt b/vendor/github.com/kelseyhightower/envconfig/LICENSE similarity index 60% rename from vendor/github.com/chrismalek/oktasdk-go/LICENSE.txt rename to vendor/github.com/kelseyhightower/envconfig/LICENSE index 63b4b681cb65b..4bfa7a84d818d 100644 --- a/vendor/github.com/chrismalek/oktasdk-go/LICENSE.txt +++ b/vendor/github.com/kelseyhightower/envconfig/LICENSE @@ -1,13 +1,11 @@ -MIT License +Copyright (c) 2013 Kelsey Hightower -Copyright (c) [year] [fullname] - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -18,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/vendor/github.com/kelseyhightower/envconfig/MAINTAINERS b/vendor/github.com/kelseyhightower/envconfig/MAINTAINERS new file mode 100644 index 0000000000000..6527a9f2cc274 --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/MAINTAINERS @@ -0,0 +1,2 @@ +Kelsey Hightower kelsey.hightower@gmail.com github.com/kelseyhightower +Travis Parker travis.parker@gmail.com github.com/teepark diff --git a/vendor/github.com/kelseyhightower/envconfig/README.md b/vendor/github.com/kelseyhightower/envconfig/README.md new file mode 100644 index 0000000000000..b6c65a8a3fa27 --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/README.md @@ -0,0 +1,188 @@ +# envconfig + +[![Build Status](https://travis-ci.org/kelseyhightower/envconfig.png)](https://travis-ci.org/kelseyhightower/envconfig) + +```Go +import "github.com/kelseyhightower/envconfig" +``` + +## Documentation + +See [godoc](http://godoc.org/github.com/kelseyhightower/envconfig) + +## Usage + +Set some environment variables: + +```Bash +export MYAPP_DEBUG=false +export MYAPP_PORT=8080 +export MYAPP_USER=Kelsey +export MYAPP_RATE="0.5" +export MYAPP_TIMEOUT="3m" +export MYAPP_USERS="rob,ken,robert" +export MYAPP_COLORCODES="red:1,green:2,blue:3" +``` + +Write some code: + +```Go +package main + +import ( + "fmt" + "log" + "time" + + "github.com/kelseyhightower/envconfig" +) + +type Specification struct { + Debug bool + Port int + User string + Users []string + Rate float32 + Timeout time.Duration + ColorCodes map[string]int +} + +func main() { + var s Specification + err := envconfig.Process("myapp", &s) + if err != nil { + log.Fatal(err.Error()) + } + format := "Debug: %v\nPort: %d\nUser: %s\nRate: %f\nTimeout: %s\n" + _, err = fmt.Printf(format, s.Debug, s.Port, s.User, s.Rate) + if err != nil { + log.Fatal(err.Error()) + } + + fmt.Println("Users:") + for _, u := range s.Users { + fmt.Printf(" %s\n", u) + } + + fmt.Println("Color codes:") + for k, v := range s.ColorCodes { + fmt.Printf(" %s: %d\n", k, v) + } +} +``` + +Results: + +```Bash +Debug: false +Port: 8080 +User: Kelsey +Rate: 0.500000 +Timeout: 3m0s +Users: + rob + ken + robert +Color codes: + red: 1 + green: 2 + blue: 3 +``` + +## Struct Tag Support + +Envconfig supports the use of struct tags to specify alternate, default, and required +environment variables. + +For example, consider the following struct: + +```Go +type Specification struct { + ManualOverride1 string `envconfig:"manual_override_1"` + DefaultVar string `default:"foobar"` + RequiredVar string `required:"true"` + IgnoredVar string `ignored:"true"` + AutoSplitVar string `split_words:"true"` +} +``` + +Envconfig has automatic support for CamelCased struct elements when the +`split_words:"true"` tag is supplied. Without this tag, `AutoSplitVar` above +would look for an environment variable called `MYAPP_AUTOSPLITVAR`. With the +setting applied it will look for `MYAPP_AUTO_SPLIT_VAR`. Note that numbers +will get globbed into the previous word. If the setting does not do the +right thing, you may use a manual override. + +Envconfig will process value for `ManualOverride1` by populating it with the +value for `MYAPP_MANUAL_OVERRIDE_1`. Without this struct tag, it would have +instead looked up `MYAPP_MANUALOVERRIDE1`. With the `split_words:"true"` tag +it would have looked up `MYAPP_MANUAL_OVERRIDE1`. + +```Bash +export MYAPP_MANUAL_OVERRIDE_1="this will be the value" + +# export MYAPP_MANUALOVERRIDE1="and this will not" +``` + +If envconfig can't find an environment variable value for `MYAPP_DEFAULTVAR`, +it will populate it with "foobar" as a default value. + +If envconfig can't find an environment variable value for `MYAPP_REQUIREDVAR`, +it will return an error when asked to process the struct. + +If envconfig can't find an environment variable in the form `PREFIX_MYVAR`, and there +is a struct tag defined, it will try to populate your variable with an environment +variable that directly matches the envconfig tag in your struct definition: + +```shell +export SERVICE_HOST=127.0.0.1 +export MYAPP_DEBUG=true +``` +```Go +type Specification struct { + ServiceHost string `envconfig:"SERVICE_HOST"` + Debug bool +} +``` + +Envconfig won't process a field with the "ignored" tag set to "true", even if a corresponding +environment variable is set. + +## Supported Struct Field Types + +envconfig supports supports these struct field types: + + * string + * int8, int16, int32, int64 + * bool + * float32, float64 + * slices of any supported type + * maps (keys and values of any supported type) + * [encoding.TextUnmarshaler](https://golang.org/pkg/encoding/#TextUnmarshaler) + +Embedded structs using these fields are also supported. + +## Custom Decoders + +Any field whose type (or pointer-to-type) implements `envconfig.Decoder` can +control its own deserialization: + +```Bash +export DNS_SERVER=8.8.8.8 +``` + +```Go +type IPDecoder net.IP + +func (ipd *IPDecoder) Decode(value string) error { + *ipd = IPDecoder(net.ParseIP(value)) + return nil +} + +type DNSConfig struct { + Address IPDecoder `envconfig:"DNS_SERVER"` +} +``` + +Also, envconfig will use a `Set(string) error` method like from the +[flag.Value](https://godoc.org/flag#Value) interface if implemented. diff --git a/vendor/github.com/kelseyhightower/envconfig/doc.go b/vendor/github.com/kelseyhightower/envconfig/doc.go new file mode 100644 index 0000000000000..f28561cd1cbc4 --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/doc.go @@ -0,0 +1,8 @@ +// Copyright (c) 2013 Kelsey Hightower. All rights reserved. +// Use of this source code is governed by the MIT License that can be found in +// the LICENSE file. + +// Package envconfig implements decoding of environment variables based on a user +// defined specification. A typical use is using environment variables for +// configuration settings. +package envconfig diff --git a/vendor/github.com/kelseyhightower/envconfig/env_os.go b/vendor/github.com/kelseyhightower/envconfig/env_os.go new file mode 100644 index 0000000000000..a6a014a2b476b --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/env_os.go @@ -0,0 +1,7 @@ +// +build appengine + +package envconfig + +import "os" + +var lookupEnv = os.LookupEnv diff --git a/vendor/github.com/kelseyhightower/envconfig/env_syscall.go b/vendor/github.com/kelseyhightower/envconfig/env_syscall.go new file mode 100644 index 0000000000000..9d98085b99fe7 --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/env_syscall.go @@ -0,0 +1,7 @@ +// +build !appengine + +package envconfig + +import "syscall" + +var lookupEnv = syscall.Getenv diff --git a/vendor/github.com/kelseyhightower/envconfig/envconfig.go b/vendor/github.com/kelseyhightower/envconfig/envconfig.go new file mode 100644 index 0000000000000..892d74699f696 --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/envconfig.go @@ -0,0 +1,319 @@ +// Copyright (c) 2013 Kelsey Hightower. All rights reserved. +// Use of this source code is governed by the MIT License that can be found in +// the LICENSE file. + +package envconfig + +import ( + "encoding" + "errors" + "fmt" + "reflect" + "regexp" + "strconv" + "strings" + "time" +) + +// ErrInvalidSpecification indicates that a specification is of the wrong type. +var ErrInvalidSpecification = errors.New("specification must be a struct pointer") + +// A ParseError occurs when an environment variable cannot be converted to +// the type required by a struct field during assignment. +type ParseError struct { + KeyName string + FieldName string + TypeName string + Value string + Err error +} + +// Decoder has the same semantics as Setter, but takes higher precedence. +// It is provided for historical compatibility. +type Decoder interface { + Decode(value string) error +} + +// Setter is implemented by types can self-deserialize values. +// Any type that implements flag.Value also implements Setter. +type Setter interface { + Set(value string) error +} + +func (e *ParseError) Error() string { + return fmt.Sprintf("envconfig.Process: assigning %[1]s to %[2]s: converting '%[3]s' to type %[4]s. details: %[5]s", e.KeyName, e.FieldName, e.Value, e.TypeName, e.Err) +} + +// varInfo maintains information about the configuration variable +type varInfo struct { + Name string + Alt string + Key string + Field reflect.Value + Tags reflect.StructTag +} + +// GatherInfo gathers information about the specified struct +func gatherInfo(prefix string, spec interface{}) ([]varInfo, error) { + expr := regexp.MustCompile("([^A-Z]+|[A-Z][^A-Z]+|[A-Z]+)") + s := reflect.ValueOf(spec) + + if s.Kind() != reflect.Ptr { + return nil, ErrInvalidSpecification + } + s = s.Elem() + if s.Kind() != reflect.Struct { + return nil, ErrInvalidSpecification + } + typeOfSpec := s.Type() + + // over allocate an info array, we will extend if needed later + infos := make([]varInfo, 0, s.NumField()) + for i := 0; i < s.NumField(); i++ { + f := s.Field(i) + ftype := typeOfSpec.Field(i) + if !f.CanSet() || ftype.Tag.Get("ignored") == "true" { + continue + } + + for f.Kind() == reflect.Ptr { + if f.IsNil() { + if f.Type().Elem().Kind() != reflect.Struct { + // nil pointer to a non-struct: leave it alone + break + } + // nil pointer to struct: create a zero instance + f.Set(reflect.New(f.Type().Elem())) + } + f = f.Elem() + } + + // Capture information about the config variable + info := varInfo{ + Name: ftype.Name, + Field: f, + Tags: ftype.Tag, + Alt: strings.ToUpper(ftype.Tag.Get("envconfig")), + } + + // Default to the field name as the env var name (will be upcased) + info.Key = info.Name + + // Best effort to un-pick camel casing as separate words + if ftype.Tag.Get("split_words") == "true" { + words := expr.FindAllStringSubmatch(ftype.Name, -1) + if len(words) > 0 { + var name []string + for _, words := range words { + name = append(name, words[0]) + } + + info.Key = strings.Join(name, "_") + } + } + if info.Alt != "" { + info.Key = info.Alt + } + if prefix != "" { + info.Key = fmt.Sprintf("%s_%s", prefix, info.Key) + } + info.Key = strings.ToUpper(info.Key) + infos = append(infos, info) + + if f.Kind() == reflect.Struct { + // honor Decode if present + if decoderFrom(f) == nil && setterFrom(f) == nil && textUnmarshaler(f) == nil { + innerPrefix := prefix + if !ftype.Anonymous { + innerPrefix = info.Key + } + + embeddedPtr := f.Addr().Interface() + embeddedInfos, err := gatherInfo(innerPrefix, embeddedPtr) + if err != nil { + return nil, err + } + infos = append(infos[:len(infos)-1], embeddedInfos...) + + continue + } + } + } + return infos, nil +} + +// Process populates the specified struct based on environment variables +func Process(prefix string, spec interface{}) error { + infos, err := gatherInfo(prefix, spec) + + for _, info := range infos { + + // `os.Getenv` cannot differentiate between an explicitly set empty value + // and an unset value. `os.LookupEnv` is preferred to `syscall.Getenv`, + // but it is only available in go1.5 or newer. We're using Go build tags + // here to use os.LookupEnv for >=go1.5 + value, ok := lookupEnv(info.Key) + if !ok && info.Alt != "" { + value, ok = lookupEnv(info.Alt) + } + + def := info.Tags.Get("default") + if def != "" && !ok { + value = def + } + + req := info.Tags.Get("required") + if !ok && def == "" { + if req == "true" { + return fmt.Errorf("required key %s missing value", info.Key) + } + continue + } + + err := processField(value, info.Field) + if err != nil { + return &ParseError{ + KeyName: info.Key, + FieldName: info.Name, + TypeName: info.Field.Type().String(), + Value: value, + Err: err, + } + } + } + + return err +} + +// MustProcess is the same as Process but panics if an error occurs +func MustProcess(prefix string, spec interface{}) { + if err := Process(prefix, spec); err != nil { + panic(err) + } +} + +func processField(value string, field reflect.Value) error { + typ := field.Type() + + decoder := decoderFrom(field) + if decoder != nil { + return decoder.Decode(value) + } + // look for Set method if Decode not defined + setter := setterFrom(field) + if setter != nil { + return setter.Set(value) + } + + if t := textUnmarshaler(field); t != nil { + return t.UnmarshalText([]byte(value)) + } + + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + if field.IsNil() { + field.Set(reflect.New(typ)) + } + field = field.Elem() + } + + switch typ.Kind() { + case reflect.String: + field.SetString(value) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + var ( + val int64 + err error + ) + if field.Kind() == reflect.Int64 && typ.PkgPath() == "time" && typ.Name() == "Duration" { + var d time.Duration + d, err = time.ParseDuration(value) + val = int64(d) + } else { + val, err = strconv.ParseInt(value, 0, typ.Bits()) + } + if err != nil { + return err + } + + field.SetInt(val) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + val, err := strconv.ParseUint(value, 0, typ.Bits()) + if err != nil { + return err + } + field.SetUint(val) + case reflect.Bool: + val, err := strconv.ParseBool(value) + if err != nil { + return err + } + field.SetBool(val) + case reflect.Float32, reflect.Float64: + val, err := strconv.ParseFloat(value, typ.Bits()) + if err != nil { + return err + } + field.SetFloat(val) + case reflect.Slice: + vals := strings.Split(value, ",") + sl := reflect.MakeSlice(typ, len(vals), len(vals)) + for i, val := range vals { + err := processField(val, sl.Index(i)) + if err != nil { + return err + } + } + field.Set(sl) + case reflect.Map: + pairs := strings.Split(value, ",") + mp := reflect.MakeMap(typ) + for _, pair := range pairs { + kvpair := strings.Split(pair, ":") + if len(kvpair) != 2 { + return fmt.Errorf("invalid map item: %q", pair) + } + k := reflect.New(typ.Key()).Elem() + err := processField(kvpair[0], k) + if err != nil { + return err + } + v := reflect.New(typ.Elem()).Elem() + err = processField(kvpair[1], v) + if err != nil { + return err + } + mp.SetMapIndex(k, v) + } + field.Set(mp) + } + + return nil +} + +func interfaceFrom(field reflect.Value, fn func(interface{}, *bool)) { + // it may be impossible for a struct field to fail this check + if !field.CanInterface() { + return + } + var ok bool + fn(field.Interface(), &ok) + if !ok && field.CanAddr() { + fn(field.Addr().Interface(), &ok) + } +} + +func decoderFrom(field reflect.Value) (d Decoder) { + interfaceFrom(field, func(v interface{}, ok *bool) { d, *ok = v.(Decoder) }) + return d +} + +func setterFrom(field reflect.Value) (s Setter) { + interfaceFrom(field, func(v interface{}, ok *bool) { s, *ok = v.(Setter) }) + return s +} + +func textUnmarshaler(field reflect.Value) (t encoding.TextUnmarshaler) { + interfaceFrom(field, func(v interface{}, ok *bool) { t, *ok = v.(encoding.TextUnmarshaler) }) + return t +} diff --git a/vendor/github.com/kelseyhightower/envconfig/usage.go b/vendor/github.com/kelseyhightower/envconfig/usage.go new file mode 100644 index 0000000000000..184635380f2b2 --- /dev/null +++ b/vendor/github.com/kelseyhightower/envconfig/usage.go @@ -0,0 +1,158 @@ +// Copyright (c) 2016 Kelsey Hightower and others. All rights reserved. +// Use of this source code is governed by the MIT License that can be found in +// the LICENSE file. + +package envconfig + +import ( + "encoding" + "fmt" + "io" + "os" + "reflect" + "strconv" + "strings" + "text/tabwriter" + "text/template" +) + +const ( + // DefaultListFormat constant to use to display usage in a list format + DefaultListFormat = `This application is configured via the environment. The following environment +variables can be used: +{{range .}} +{{usage_key .}} + [description] {{usage_description .}} + [type] {{usage_type .}} + [default] {{usage_default .}} + [required] {{usage_required .}}{{end}} +` + // DefaultTableFormat constant to use to display usage in a tabluar format + DefaultTableFormat = `This application is configured via the environment. The following environment +variables can be used: + +KEY TYPE DEFAULT REQUIRED DESCRIPTION +{{range .}}{{usage_key .}} {{usage_type .}} {{usage_default .}} {{usage_required .}} {{usage_description .}} +{{end}}` +) + +var ( + decoderType = reflect.TypeOf((*Decoder)(nil)).Elem() + setterType = reflect.TypeOf((*Setter)(nil)).Elem() + unmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() +) + +func implementsInterface(t reflect.Type) bool { + return t.Implements(decoderType) || + reflect.PtrTo(t).Implements(decoderType) || + t.Implements(setterType) || + reflect.PtrTo(t).Implements(setterType) || + t.Implements(unmarshalerType) || + reflect.PtrTo(t).Implements(unmarshalerType) +} + +// toTypeDescription converts Go types into a human readable description +func toTypeDescription(t reflect.Type) string { + switch t.Kind() { + case reflect.Array, reflect.Slice: + return fmt.Sprintf("Comma-separated list of %s", toTypeDescription(t.Elem())) + case reflect.Map: + return fmt.Sprintf( + "Comma-separated list of %s:%s pairs", + toTypeDescription(t.Key()), + toTypeDescription(t.Elem()), + ) + case reflect.Ptr: + return toTypeDescription(t.Elem()) + case reflect.Struct: + if implementsInterface(t) && t.Name() != "" { + return t.Name() + } + return "" + case reflect.String: + name := t.Name() + if name != "" && name != "string" { + return name + } + return "String" + case reflect.Bool: + name := t.Name() + if name != "" && name != "bool" { + return name + } + return "True or False" + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + name := t.Name() + if name != "" && !strings.HasPrefix(name, "int") { + return name + } + return "Integer" + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + name := t.Name() + if name != "" && !strings.HasPrefix(name, "uint") { + return name + } + return "Unsigned Integer" + case reflect.Float32, reflect.Float64: + name := t.Name() + if name != "" && !strings.HasPrefix(name, "float") { + return name + } + return "Float" + } + return fmt.Sprintf("%+v", t) +} + +// Usage writes usage information to stderr using the default header and table format +func Usage(prefix string, spec interface{}) error { + // The default is to output the usage information as a table + // Create tabwriter instance to support table output + tabs := tabwriter.NewWriter(os.Stdout, 1, 0, 4, ' ', 0) + + err := Usagef(prefix, spec, tabs, DefaultTableFormat) + tabs.Flush() + return err +} + +// Usagef writes usage information to the specified io.Writer using the specifed template specification +func Usagef(prefix string, spec interface{}, out io.Writer, format string) error { + + // Specify the default usage template functions + functions := template.FuncMap{ + "usage_key": func(v varInfo) string { return v.Key }, + "usage_description": func(v varInfo) string { return v.Tags.Get("desc") }, + "usage_type": func(v varInfo) string { return toTypeDescription(v.Field.Type()) }, + "usage_default": func(v varInfo) string { return v.Tags.Get("default") }, + "usage_required": func(v varInfo) (string, error) { + req := v.Tags.Get("required") + if req != "" { + reqB, err := strconv.ParseBool(req) + if err != nil { + return "", err + } + if reqB { + req = "true" + } + } + return req, nil + }, + } + + tmpl, err := template.New("envconfig").Funcs(functions).Parse(format) + if err != nil { + return err + } + + return Usaget(prefix, spec, out, tmpl) +} + +// Usaget writes usage information to the specified io.Writer using the specified template +func Usaget(prefix string, spec interface{}, out io.Writer, tmpl *template.Template) error { + // gather first + infos, err := gatherInfo(prefix, spec) + if err != nil { + return err + } + + return tmpl.Execute(out, infos) +} diff --git a/vendor/github.com/lib/pq/oid/gen.go b/vendor/github.com/lib/pq/oid/gen.go new file mode 100644 index 0000000000000..7c634cdc5cd63 --- /dev/null +++ b/vendor/github.com/lib/pq/oid/gen.go @@ -0,0 +1,93 @@ +// +build ignore + +// Generate the table of OID values +// Run with 'go run gen.go'. +package main + +import ( + "database/sql" + "fmt" + "log" + "os" + "os/exec" + "strings" + + _ "github.com/lib/pq" +) + +// OID represent a postgres Object Identifier Type. +type OID struct { + ID int + Type string +} + +// Name returns an upper case version of the oid type. +func (o OID) Name() string { + return strings.ToUpper(o.Type) +} + +func main() { + datname := os.Getenv("PGDATABASE") + sslmode := os.Getenv("PGSSLMODE") + + if datname == "" { + os.Setenv("PGDATABASE", "pqgotest") + } + + if sslmode == "" { + os.Setenv("PGSSLMODE", "disable") + } + + db, err := sql.Open("postgres", "") + if err != nil { + log.Fatal(err) + } + rows, err := db.Query(` + SELECT typname, oid + FROM pg_type WHERE oid < 10000 + ORDER BY oid; + `) + if err != nil { + log.Fatal(err) + } + oids := make([]*OID, 0) + for rows.Next() { + var oid OID + if err = rows.Scan(&oid.Type, &oid.ID); err != nil { + log.Fatal(err) + } + oids = append(oids, &oid) + } + if err = rows.Err(); err != nil { + log.Fatal(err) + } + cmd := exec.Command("gofmt") + cmd.Stderr = os.Stderr + w, err := cmd.StdinPipe() + if err != nil { + log.Fatal(err) + } + f, err := os.Create("types.go") + if err != nil { + log.Fatal(err) + } + cmd.Stdout = f + err = cmd.Start() + if err != nil { + log.Fatal(err) + } + fmt.Fprintln(w, "// Code generated by gen.go. DO NOT EDIT.") + fmt.Fprintln(w, "\npackage oid") + fmt.Fprintln(w, "const (") + for _, oid := range oids { + fmt.Fprintf(w, "T_%s Oid = %d\n", oid.Type, oid.ID) + } + fmt.Fprintln(w, ")") + fmt.Fprintln(w, "var TypeName = map[Oid]string{") + for _, oid := range oids { + fmt.Fprintf(w, "T_%s: \"%s\",\n", oid.Type, oid.Name()) + } + fmt.Fprintln(w, "}") + w.Close() + cmd.Wait() +} diff --git a/vendor/github.com/okta/okta-sdk-golang/LICENSE.md b/vendor/github.com/okta/okta-sdk-golang/LICENSE.md new file mode 100644 index 0000000000000..edeebdb0384fa --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/LICENSE.md @@ -0,0 +1,194 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy]-Present Okta + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/okta/okta-sdk-golang/NOTICE.md b/vendor/github.com/okta/okta-sdk-golang/NOTICE.md new file mode 100644 index 0000000000000..75f362507c01a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/NOTICE.md @@ -0,0 +1,5 @@ +The Okta software accompanied by this notice is provided pursuant to the following terms: + +Copyright © 2018-Present, Okta, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/appLink.go b/vendor/github.com/okta/okta-sdk-golang/okta/appLink.go new file mode 100644 index 0000000000000..82faed5118800 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/appLink.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type AppLink struct { + AppAssignmentId string `json:"appAssignmentId,omitempty"` + AppInstanceId string `json:"appInstanceId,omitempty"` + AppName string `json:"appName,omitempty"` + CredentialsSetup *bool `json:"credentialsSetup,omitempty"` + Hidden *bool `json:"hidden,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LinkUrl string `json:"linkUrl,omitempty"` + LogoUrl string `json:"logoUrl,omitempty"` + SortOrder int64 `json:"sortOrder,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/appUser.go b/vendor/github.com/okta/okta-sdk-golang/okta/appUser.go new file mode 100644 index 0000000000000..f1e9de1a1434b --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/appUser.go @@ -0,0 +1,83 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" + "time" +) + +type AppUserResource resource + +type AppUser struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *AppUserCredentials `json:"credentials,omitempty"` + ExternalId string `json:"externalId,omitempty"` + Id string `json:"id,omitempty"` + LastSync *time.Time `json:"lastSync,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + PasswordChanged *time.Time `json:"passwordChanged,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Scope string `json:"scope,omitempty"` + Status string `json:"status,omitempty"` + StatusChanged *time.Time `json:"statusChanged,omitempty"` + SyncState string `json:"syncState,omitempty"` +} + +func NewAppUser() *AppUser { + return &AppUser{} +} + +func (a *AppUser) IsApplicationInstance() bool { + return true +} + +func (m *AppUserResource) UpdateApplicationUser(appId string, userId string, body AppUser) (*AppUser, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/users/%v", appId, userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var appUser *AppUser + resp, err := m.client.requestExecutor.Do(req, &appUser) + if err != nil { + return nil, resp, err + } + return appUser, resp, nil +} +func (m *AppUserResource) DeleteApplicationUser(appId string, userId string, qp *query.Params) (*Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/users/%v", appId, userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/appUserCredentials.go b/vendor/github.com/okta/okta-sdk-golang/okta/appUserCredentials.go new file mode 100644 index 0000000000000..7cb8660fb0f8f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/appUserCredentials.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type AppUserCredentials struct { + Password *AppUserPasswordCredential `json:"password,omitempty"` + UserName string `json:"userName,omitempty"` +} + +func NewAppUserCredentials() *AppUserCredentials { + return &AppUserCredentials{} +} + +func (a *AppUserCredentials) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/appUserPasswordCredential.go b/vendor/github.com/okta/okta-sdk-golang/okta/appUserPasswordCredential.go new file mode 100644 index 0000000000000..7fd802a2449f9 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/appUserPasswordCredential.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type AppUserPasswordCredential struct { + Value string `json:"value,omitempty"` +} + +func NewAppUserPasswordCredential() *AppUserPasswordCredential { + return &AppUserPasswordCredential{} +} + +func (a *AppUserPasswordCredential) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/application.go b/vendor/github.com/okta/okta-sdk-golang/okta/application.go new file mode 100644 index 0000000000000..a15a35ebea102 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/application.go @@ -0,0 +1,347 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" + "time" +) + +type App interface { + IsApplicationInstance() bool +} + +type ApplicationResource resource + +type Application struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *ApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *ApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewApplication() *Application { + return &Application{} +} + +func (a *Application) IsApplicationInstance() bool { + return true +} + +func (m *ApplicationResource) GetApplication(appId string, appInstance App, qp *query.Params) (interface{}, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v", appId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + application := appInstance + resp, err := m.client.requestExecutor.Do(req, &application) + if err != nil { + return nil, resp, err + } + return application, resp, nil +} +func (m *ApplicationResource) UpdateApplication(appId string, body App) (interface{}, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v", appId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + application := body + resp, err := m.client.requestExecutor.Do(req, &application) + if err != nil { + return nil, resp, err + } + return application, resp, nil +} +func (m *ApplicationResource) DeleteApplication(appId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v", appId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *ApplicationResource) ListApplications(qp *query.Params) ([]App, *Response, error) { + url := fmt.Sprintf("/api/v1/apps") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var application []App + resp, err := m.client.requestExecutor.Do(req, &application) + if err != nil { + return nil, resp, err + } + return application, resp, nil +} +func (m *ApplicationResource) CreateApplication(body App, qp *query.Params) (interface{}, *Response, error) { + url := fmt.Sprintf("/api/v1/apps") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + application := body + resp, err := m.client.requestExecutor.Do(req, &application) + if err != nil { + return nil, resp, err + } + return application, resp, nil +} +func (m *ApplicationResource) ListApplicationKeys(appId string) ([]*JsonWebKey, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/credentials/keys", appId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var jsonWebKey []*JsonWebKey + resp, err := m.client.requestExecutor.Do(req, &jsonWebKey) + if err != nil { + return nil, resp, err + } + return jsonWebKey, resp, nil +} +func (m *ApplicationResource) GetApplicationKey(appId string, keyId string) (*JsonWebKey, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/credentials/keys/%v", appId, keyId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var jsonWebKey *JsonWebKey + resp, err := m.client.requestExecutor.Do(req, &jsonWebKey) + if err != nil { + return nil, resp, err + } + return jsonWebKey, resp, nil +} +func (m *ApplicationResource) CloneApplicationKey(appId string, keyId string, qp *query.Params) (*JsonWebKey, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/credentials/keys/%v/clone", appId, keyId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, nil, err + } + + var jsonWebKey *JsonWebKey + resp, err := m.client.requestExecutor.Do(req, &jsonWebKey) + if err != nil { + return nil, resp, err + } + return jsonWebKey, resp, nil +} +func (m *ApplicationResource) ListApplicationGroupAssignments(appId string, qp *query.Params) ([]*ApplicationGroupAssignment, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/groups", appId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var applicationGroupAssignment []*ApplicationGroupAssignment + resp, err := m.client.requestExecutor.Do(req, &applicationGroupAssignment) + if err != nil { + return nil, resp, err + } + return applicationGroupAssignment, resp, nil +} +func (m *ApplicationResource) DeleteApplicationGroupAssignment(appId string, groupId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/groups/%v", appId, groupId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *ApplicationResource) GetApplicationGroupAssignment(appId string, groupId string, qp *query.Params) (*ApplicationGroupAssignment, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/groups/%v", appId, groupId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var applicationGroupAssignment *ApplicationGroupAssignment + resp, err := m.client.requestExecutor.Do(req, &applicationGroupAssignment) + if err != nil { + return nil, resp, err + } + return applicationGroupAssignment, resp, nil +} +func (m *ApplicationResource) CreateApplicationGroupAssignment(appId string, groupId string, body ApplicationGroupAssignment) (*ApplicationGroupAssignment, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/groups/%v", appId, groupId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var applicationGroupAssignment *ApplicationGroupAssignment + resp, err := m.client.requestExecutor.Do(req, &applicationGroupAssignment) + if err != nil { + return nil, resp, err + } + return applicationGroupAssignment, resp, nil +} +func (m *ApplicationResource) ActivateApplication(appId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/lifecycle/activate", appId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *ApplicationResource) DeactivateApplication(appId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/lifecycle/deactivate", appId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *ApplicationResource) ListApplicationUsers(appId string, qp *query.Params) ([]*AppUser, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/users", appId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var appUser []*AppUser + resp, err := m.client.requestExecutor.Do(req, &appUser) + if err != nil { + return nil, resp, err + } + return appUser, resp, nil +} +func (m *ApplicationResource) AssignUserToApplication(appId string, body AppUser) (*AppUser, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/users", appId) + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var appUser *AppUser + resp, err := m.client.requestExecutor.Do(req, &appUser) + if err != nil { + return nil, resp, err + } + return appUser, resp, nil +} +func (m *ApplicationResource) DeleteApplicationUser(appId string, userId string, qp *query.Params) (*Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/users/%v", appId, userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *ApplicationResource) GetApplicationUser(appId string, userId string, qp *query.Params) (*AppUser, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/users/%v", appId, userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var appUser *AppUser + resp, err := m.client.requestExecutor.Do(req, &appUser) + if err != nil { + return nil, resp, err + } + return appUser, resp, nil +} +func (m *ApplicationResource) UpdateApplicationUser(appId string, userId string, body AppUser) (*AppUser, *Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/users/%v", appId, userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var appUser *AppUser + resp, err := m.client.requestExecutor.Do(req, &appUser) + if err != nil { + return nil, resp, err + } + return appUser, resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationAccessibility.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationAccessibility.go new file mode 100644 index 0000000000000..88e4e4f1ae85a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationAccessibility.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationAccessibility struct { + ErrorRedirectUrl string `json:"errorRedirectUrl,omitempty"` + LoginRedirectUrl string `json:"loginRedirectUrl,omitempty"` + SelfService *bool `json:"selfService,omitempty"` +} + +func NewApplicationAccessibility() *ApplicationAccessibility { + return &ApplicationAccessibility{} +} + +func (a *ApplicationAccessibility) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentials.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentials.go new file mode 100644 index 0000000000000..4e9dd948ea495 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentials.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationCredentials struct { + Signing *ApplicationCredentialsSigning `json:"signing,omitempty"` + UserNameTemplate *ApplicationCredentialsUsernameTemplate `json:"userNameTemplate,omitempty"` +} + +func NewApplicationCredentials() *ApplicationCredentials { + return &ApplicationCredentials{} +} + +func (a *ApplicationCredentials) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsOAuthClient.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsOAuthClient.go new file mode 100644 index 0000000000000..ccb37ffde1b8b --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsOAuthClient.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationCredentialsOAuthClient struct { + AutoKeyRotation *bool `json:"autoKeyRotation,omitempty"` + ClientId string `json:"client_id,omitempty"` + ClientSecret string `json:"client_secret,omitempty"` + TokenEndpointAuthMethod string `json:"token_endpoint_auth_method,omitempty"` +} + +func NewApplicationCredentialsOAuthClient() *ApplicationCredentialsOAuthClient { + return &ApplicationCredentialsOAuthClient{} +} + +func (a *ApplicationCredentialsOAuthClient) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsScheme.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsScheme.go new file mode 100644 index 0000000000000..ea4b911929a22 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsScheme.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationCredentialsScheme struct { +} + +func NewApplicationCredentialsScheme() *ApplicationCredentialsScheme { + return &ApplicationCredentialsScheme{} +} + +func (a *ApplicationCredentialsScheme) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsSigning.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsSigning.go new file mode 100644 index 0000000000000..42defb9ecbff6 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsSigning.go @@ -0,0 +1,38 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type ApplicationCredentialsSigning struct { + Kid string `json:"kid,omitempty"` + LastRotated *time.Time `json:"lastRotated,omitempty"` + NextRotation *time.Time `json:"nextRotation,omitempty"` + RotationMode string `json:"rotationMode,omitempty"` +} + +func NewApplicationCredentialsSigning() *ApplicationCredentialsSigning { + return &ApplicationCredentialsSigning{} +} + +func (a *ApplicationCredentialsSigning) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsUsernameTemplate.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsUsernameTemplate.go new file mode 100644 index 0000000000000..816fd56d745aa --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationCredentialsUsernameTemplate.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationCredentialsUsernameTemplate struct { + Suffix string `json:"suffix,omitempty"` + Template string `json:"template,omitempty"` + Type string `json:"type,omitempty"` +} + +func NewApplicationCredentialsUsernameTemplate() *ApplicationCredentialsUsernameTemplate { + return &ApplicationCredentialsUsernameTemplate{} +} + +func (a *ApplicationCredentialsUsernameTemplate) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationGroupAssignment.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationGroupAssignment.go new file mode 100644 index 0000000000000..0d79bbf826425 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationGroupAssignment.go @@ -0,0 +1,57 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "time" +) + +type ApplicationGroupAssignmentResource resource + +type ApplicationGroupAssignment struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Priority int64 `json:"priority,omitempty"` + Profile interface{} `json:"profile,omitempty"` +} + +func NewApplicationGroupAssignment() *ApplicationGroupAssignment { + return &ApplicationGroupAssignment{} +} + +func (a *ApplicationGroupAssignment) IsApplicationInstance() bool { + return true +} + +func (m *ApplicationGroupAssignmentResource) DeleteApplicationGroupAssignment(appId string, groupId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/apps/%v/groups/%v", appId, groupId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationLicensing.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationLicensing.go new file mode 100644 index 0000000000000..02e41852ebe55 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationLicensing.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationLicensing struct { + SeatCount int64 `json:"seatCount,omitempty"` +} + +func NewApplicationLicensing() *ApplicationLicensing { + return &ApplicationLicensing{} +} + +func (a *ApplicationLicensing) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettings.go new file mode 100644 index 0000000000000..9b2eb25bf9040 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettings.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationSettings struct { + App *ApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` +} + +func NewApplicationSettings() *ApplicationSettings { + return &ApplicationSettings{} +} + +func (a *ApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsApplication.go new file mode 100644 index 0000000000000..784e3eb42aea2 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsApplication.go @@ -0,0 +1,31 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationSettingsApplication map[string]interface{} + +func NewApplicationSettingsApplication() *ApplicationSettingsApplication { + return &ApplicationSettingsApplication{} +} + +func (a *ApplicationSettingsApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotifications.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotifications.go new file mode 100644 index 0000000000000..8e6862950fe0b --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotifications.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationSettingsNotifications struct { + Vpn *ApplicationSettingsNotificationsVpn `json:"vpn,omitempty"` +} + +func NewApplicationSettingsNotifications() *ApplicationSettingsNotifications { + return &ApplicationSettingsNotifications{} +} + +func (a *ApplicationSettingsNotifications) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpn.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpn.go new file mode 100644 index 0000000000000..12ab669c51b09 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpn.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationSettingsNotificationsVpn struct { + HelpUrl string `json:"helpUrl,omitempty"` + Message string `json:"message,omitempty"` + Network *ApplicationSettingsNotificationsVpnNetwork `json:"network,omitempty"` +} + +func NewApplicationSettingsNotificationsVpn() *ApplicationSettingsNotificationsVpn { + return &ApplicationSettingsNotificationsVpn{} +} + +func (a *ApplicationSettingsNotificationsVpn) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpnNetwork.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpnNetwork.go new file mode 100644 index 0000000000000..d9cc9dee47418 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSettingsNotificationsVpnNetwork.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationSettingsNotificationsVpnNetwork struct { + Connection string `json:"connection,omitempty"` + Exclude []string `json:"exclude,omitempty"` + Include []string `json:"include,omitempty"` +} + +func NewApplicationSettingsNotificationsVpnNetwork() *ApplicationSettingsNotificationsVpnNetwork { + return &ApplicationSettingsNotificationsVpnNetwork{} +} + +func (a *ApplicationSettingsNotificationsVpnNetwork) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationSignOnMode.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSignOnMode.go new file mode 100644 index 0000000000000..78cdee8cb12b0 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationSignOnMode.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationSignOnMode struct { +} + +func NewApplicationSignOnMode() *ApplicationSignOnMode { + return &ApplicationSignOnMode{} +} + +func (a *ApplicationSignOnMode) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibility.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibility.go new file mode 100644 index 0000000000000..c48584d1d9abb --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibility.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationVisibility struct { + AppLinks interface{} `json:"appLinks,omitempty"` + AutoSubmitToolbar *bool `json:"autoSubmitToolbar,omitempty"` + Hide *ApplicationVisibilityHide `json:"hide,omitempty"` +} + +func NewApplicationVisibility() *ApplicationVisibility { + return &ApplicationVisibility{} +} + +func (a *ApplicationVisibility) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibilityHide.go b/vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibilityHide.go new file mode 100644 index 0000000000000..049491122b2f8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/applicationVisibilityHide.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ApplicationVisibilityHide struct { + IOS *bool `json:"iOS,omitempty"` + Web *bool `json:"web,omitempty"` +} + +func NewApplicationVisibilityHide() *ApplicationVisibilityHide { + return &ApplicationVisibilityHide{} +} + +func (a *ApplicationVisibilityHide) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/authenticationProvider.go b/vendor/github.com/okta/okta-sdk-golang/okta/authenticationProvider.go new file mode 100644 index 0000000000000..39be8db34efaf --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/authenticationProvider.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type AuthenticationProvider struct { + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/authenticationProviderType.go b/vendor/github.com/okta/okta-sdk-golang/okta/authenticationProviderType.go new file mode 100644 index 0000000000000..18463268a8e92 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/authenticationProviderType.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type AuthenticationProviderType struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplication.go new file mode 100644 index 0000000000000..6728de545f24d --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplication.go @@ -0,0 +1,52 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type AutoLoginApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *SchemeApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *AutoLoginApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewAutoLoginApplication() *AutoLoginApplication { + return &AutoLoginApplication{ + SignOnMode: "AUTO_LOGIN", + } +} + +func (a *AutoLoginApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettings.go new file mode 100644 index 0000000000000..6fb15461ad664 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettings.go @@ -0,0 +1,37 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type AutoLoginApplicationSettings struct { + App *ApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` + SignOn *AutoLoginApplicationSettingsSignOn `json:"signOn,omitempty"` +} + +func NewAutoLoginApplicationSettings() *AutoLoginApplicationSettings { + return &AutoLoginApplicationSettings{} +} + +func (a *AutoLoginApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettingsSignOn.go b/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettingsSignOn.go new file mode 100644 index 0000000000000..b613fed46c99d --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/autoLoginApplicationSettingsSignOn.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type AutoLoginApplicationSettingsSignOn struct { + LoginUrl string `json:"loginUrl,omitempty"` + RedirectUrl string `json:"redirectUrl,omitempty"` +} + +func NewAutoLoginApplicationSettingsSignOn() *AutoLoginApplicationSettingsSignOn { + return &AutoLoginApplicationSettingsSignOn{} +} + +func (a *AutoLoginApplicationSettingsSignOn) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettings.go new file mode 100644 index 0000000000000..cfe0da8c8e453 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettings.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type BasicApplicationSettings struct { + App *BasicApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` +} + +func NewBasicApplicationSettings() *BasicApplicationSettings { + return &BasicApplicationSettings{} +} + +func (a *BasicApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettingsApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettingsApplication.go new file mode 100644 index 0000000000000..7db78ec1e122f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/basicApplicationSettingsApplication.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type BasicApplicationSettingsApplication struct { + AuthURL string `json:"authURL,omitempty"` + Url string `json:"url,omitempty"` +} + +func NewBasicApplicationSettingsApplication() *BasicApplicationSettingsApplication { + return &BasicApplicationSettingsApplication{} +} + +func (a *BasicApplicationSettingsApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/basicAuthApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/basicAuthApplication.go new file mode 100644 index 0000000000000..23dc02edb0d9f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/basicAuthApplication.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type BasicAuthApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *SchemeApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *BasicApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewBasicAuthApplication() *BasicAuthApplication { + return &BasicAuthApplication{ + Name: "template_basic_auth", + SignOnMode: "BASIC_AUTH", + } +} + +func (a *BasicAuthApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplication.go new file mode 100644 index 0000000000000..85c41e8841d9f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplication.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type BookmarkApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *ApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *BookmarkApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewBookmarkApplication() *BookmarkApplication { + return &BookmarkApplication{ + Name: "bookmark", + SignOnMode: "BOOKMARK", + } +} + +func (a *BookmarkApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettings.go new file mode 100644 index 0000000000000..b7dd15256eb01 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettings.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type BookmarkApplicationSettings struct { + App *BookmarkApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` +} + +func NewBookmarkApplicationSettings() *BookmarkApplicationSettings { + return &BookmarkApplicationSettings{} +} + +func (a *BookmarkApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettingsApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettingsApplication.go new file mode 100644 index 0000000000000..e6abcc85b9724 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/bookmarkApplicationSettingsApplication.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type BookmarkApplicationSettingsApplication struct { + RequestIntegration *bool `json:"requestIntegration,omitempty"` + Url string `json:"url,omitempty"` +} + +func NewBookmarkApplicationSettingsApplication() *BookmarkApplicationSettingsApplication { + return &BookmarkApplicationSettingsApplication{} +} + +func (a *BookmarkApplicationSettingsApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/browserPluginApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/browserPluginApplication.go new file mode 100644 index 0000000000000..d0f7b8b4ac3a2 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/browserPluginApplication.go @@ -0,0 +1,52 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type BrowserPluginApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *SchemeApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *ApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewBrowserPluginApplication() *BrowserPluginApplication { + return &BrowserPluginApplication{ + SignOnMode: "BROWSER_PLUGIN", + } +} + +func (a *BrowserPluginApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/cache/cache.go b/vendor/github.com/okta/okta-sdk-golang/okta/cache/cache.go new file mode 100644 index 0000000000000..89a4dfafe4051 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/cache/cache.go @@ -0,0 +1,48 @@ +/* + * Copyright 2018 - Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cache + +import ( + "bytes" + "io/ioutil" + "net/http" +) + +type Cache interface { + Get(key string) *http.Response + Set(key string, value *http.Response) + Delete(key string) + Clear() + Has(key string) bool +} + +func CreateCacheKey(req *http.Request) string { + s := req.URL.Scheme + "://" + req.URL.Host + req.URL.RequestURI() + return s +} + +func CopyResponse(resp *http.Response) *http.Response { + c := *resp + respBody, err := ioutil.ReadAll(resp.Body) + if err != nil { + return resp + } + + c.Body = ioutil.NopCloser(bytes.NewBuffer(respBody)) + + return &c +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/cache/goCache.go b/vendor/github.com/okta/okta-sdk-golang/okta/cache/goCache.go new file mode 100644 index 0000000000000..73723f287a864 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/cache/goCache.go @@ -0,0 +1,69 @@ +/* + * Copyright 2018 - Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cache + +import ( + "net/http" + "time" + + patrickmnGoCache "github.com/patrickmn/go-cache" +) + +type GoCache struct { + ttl time.Duration + tti time.Duration + rootLibrary *patrickmnGoCache.Cache +} + +func NewGoCache(ttl int32, tti int32) GoCache { + c := patrickmnGoCache.New(time.Duration(ttl)*time.Second, time.Duration(tti)*time.Second) + + gc := GoCache{ + ttl: time.Duration(ttl) * time.Second, + tti: time.Duration(tti) * time.Second, + rootLibrary: c, + } + + return gc +} + +func (c GoCache) Get(key string) *http.Response { + item, found := c.rootLibrary.Get(key) + if found { + itemCopy := CopyResponse(item.(*http.Response)) + return itemCopy + } + + return nil +} + +func (c GoCache) Set(key string, value *http.Response) { + c.rootLibrary.Set(key, value, c.ttl) +} + +func (c GoCache) Delete(key string) { + c.rootLibrary.Delete(key) +} + +func (c GoCache) Clear() { + c.rootLibrary.Flush() +} + +func (c GoCache) Has(key string) bool { + _, found := c.rootLibrary.Get(key) + return found +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/cache/noopCache.go b/vendor/github.com/okta/okta-sdk-golang/okta/cache/noopCache.go new file mode 100644 index 0000000000000..333e4677e3c5f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/cache/noopCache.go @@ -0,0 +1,46 @@ +/* + * Copyright 2018 - Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cache + +import "net/http" + +type NoOpCache struct { +} + +func NewNoOpCache() Cache { + return NoOpCache{} +} + +func (c NoOpCache) Get(key string) *http.Response { + return nil +} + +func (c NoOpCache) Set(key string, value *http.Response) { + +} + +func (c NoOpCache) Delete(key string) { + +} + +func (c NoOpCache) Clear() { + +} + +func (c NoOpCache) Has(key string) bool { + return false +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/callFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/callFactor.go new file mode 100644 index 0000000000000..0372ad237c2b1 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/callFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type CallFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *CallFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewCallFactor() *CallFactor { + return &CallFactor{ + FactorType: "call", + } +} + +func (a *CallFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/callFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/callFactorProfile.go new file mode 100644 index 0000000000000..e649419ff7914 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/callFactorProfile.go @@ -0,0 +1,34 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type CallFactorProfile struct { + PhoneExtension string `json:"phoneExtension,omitempty"` + PhoneNumber string `json:"phoneNumber,omitempty"` +} + +func NewCallFactorProfile() *CallFactorProfile { + return &CallFactorProfile{} +} + +func (a *CallFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/changePasswordRequest.go b/vendor/github.com/okta/okta-sdk-golang/okta/changePasswordRequest.go new file mode 100644 index 0000000000000..2cfc30e792502 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/changePasswordRequest.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ChangePasswordRequest struct { + NewPassword *PasswordCredential `json:"newPassword,omitempty"` + OldPassword *PasswordCredential `json:"oldPassword,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/config.go b/vendor/github.com/okta/okta-sdk-golang/okta/config.go new file mode 100644 index 0000000000000..e0d8c0e06f226 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/config.go @@ -0,0 +1,177 @@ +/* + * Copyright 2018 - Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package okta + +import ( + "net/http" + + "github.com/okta/okta-sdk-golang/okta/cache" +) + +type config struct { + Okta struct { + Client struct { + Cache struct { + Enabled bool `yaml:"enabled" envconfig:"OKTA_CLIENT_CACHE_ENABLED"` + DefaultTtl int32 `yaml:"defaultTtl" envconfig:"OKTA_CLIENT_CACHE_DEFAULT_TTL"` + DefaultTti int32 `yaml:"defaultTti" envconfig:"OKTA_CLIENT_CACHE_DEFAULT_TTI"` + } `yaml:"cache"` + Proxy struct { + Port int32 `yaml:"port" envconfig:"OKTA_CLIENT_PROXY_PORT"` + Host string `yaml:"host" envconfig:"OKTA_CLIENT_PROXY_HOST"` + Username string `yaml:"username" envconfig:"OKTA_CLIENT_PROXY_USERNAME"` + Password string `yaml:"password" envconfig:"OKTA_CLIENT_PROXY_PASSWORD"` + } `yaml:"proxy"` + ConnectionTimeout int32 `yaml:"connectionTimeout" envconfig:"OKTA_CLIENT_CONNECTION_TIMEOUT"` + RequestTimeout int32 `yaml:"requestTimeout" envconfig:"OKTA_CLIENT_REQUEST_TIMEOUT"` + RateLimit struct { + MaxRetries int32 `yaml:"maxRetries" envconfig:"OKTA_CLIENT_RATE_LIMIT_MAX_RETRIES"` + } `yaml:"rateLimit"` + OrgUrl string `yaml:"orgUrl" envconfig:"OKTA_CLIENT_ORGURL"` + Token string `yaml:"token" envconfig:"OKTA_CLIENT_TOKEN"` + } `yaml:"client"` + Testing struct { + DisableHttpsCheck bool `yaml:"disableHttpsCheck" envconfig:"OKTA_TESTING_DISABLE_HTTPS_CHECK"` + } `yaml:"testing"` + } `yaml:"okta"` + UserAgentExtra string + HttpClient http.Client + CacheManager cache.Cache +} + +func NewConfig(conf ...ConfigSetter) (*config, error) { + config := &config{} + + setConfigDefaults(config) + config = readConfigFromSystem(*config) + config = readConfigFromApplication(*config) + config = readConfigFromEnvironment(*config) + + for _, confSetter := range conf { + confSetter(config) + } + return config, nil +} + +func NewCache(config *config) (cache.Cache, error) { + if !config.Okta.Client.Cache.Enabled { + return cache.NewNoOpCache(), nil + } + if config.CacheManager != nil { + return config.CacheManager, nil + } + return cache.NewGoCache(config.Okta.Client.Cache.DefaultTtl, + config.Okta.Client.Cache.DefaultTti), nil +} + +type ConfigSetter func(*config) + +func WithCache(cache bool) ConfigSetter { + return func(c *config) { + c.Okta.Client.Cache.Enabled = cache + } +} + +func WithCacheManager(cacheManager cache.Cache) ConfigSetter { + return func(c *config) { + c.CacheManager = cacheManager + } +} + +func WithCacheTtl(i int32) ConfigSetter { + return func(c *config) { + c.Okta.Client.Cache.DefaultTtl = i + } +} + +func WithCacheTti(i int32) ConfigSetter { + return func(c *config) { + c.Okta.Client.Cache.DefaultTti = i + } +} + +func WithConnectionTimeout(i int32) ConfigSetter { + return func(c *config) { + c.Okta.Client.ConnectionTimeout = i + } +} + +func WithProxyPort(i int32) ConfigSetter { + return func(c *config) { + c.Okta.Client.Proxy.Port = i + } +} + +func WithProxyHost(host string) ConfigSetter { + return func(c *config) { + c.Okta.Client.Proxy.Host = host + } +} + +func WithProxyUsername(username string) ConfigSetter { + return func(c *config) { + c.Okta.Client.Proxy.Username = username + } +} + +func WithProxyPassword(pass string) ConfigSetter { + return func(c *config) { + c.Okta.Client.Proxy.Password = pass + } +} + +func WithOrgUrl(url string) ConfigSetter { + return func(c *config) { + c.Okta.Client.OrgUrl = url + } +} + +func WithToken(token string) ConfigSetter { + return func(c *config) { + c.Okta.Client.Token = token + } +} + +func WithUserAgentExtra(userAgent string) ConfigSetter { + return func(c *config) { + c.UserAgentExtra = userAgent + } +} + +func WithHttpClient(httpClient http.Client) ConfigSetter { + return func(c *config) { + c.HttpClient = httpClient + } +} + +func WithTestingDisableHttpsCheck(httpsCheck bool) ConfigSetter { + return func(c *config) { + c.Okta.Testing.DisableHttpsCheck = httpsCheck + } +} + +func WithRequestTimeout(requestTimeout int32) ConfigSetter { + return func(c *config) { + c.Okta.Client.RequestTimeout = requestTimeout + } +} + +func WithRateLimitMaxRetries(maxRetries int32) ConfigSetter { + return func(c *config) { + c.Okta.Client.RateLimit.MaxRetries = maxRetries + } +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/createSessionRequest.go b/vendor/github.com/okta/okta-sdk-golang/okta/createSessionRequest.go new file mode 100644 index 0000000000000..d37c52c9e8b12 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/createSessionRequest.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type CreateSessionRequest struct { + SessionToken string `json:"sessionToken,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/emailAddress.go b/vendor/github.com/okta/okta-sdk-golang/okta/emailAddress.go new file mode 100644 index 0000000000000..89520485e0ddf --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/emailAddress.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type EmailAddress struct { + Status string `json:"status,omitempty"` + Type string `json:"type,omitempty"` + Value string `json:"value,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/emailFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/emailFactor.go new file mode 100644 index 0000000000000..0b7b98be3672f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/emailFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type EmailFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *EmailFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewEmailFactor() *EmailFactor { + return &EmailFactor{ + FactorType: "email", + } +} + +func (a *EmailFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/emailFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/emailFactorProfile.go new file mode 100644 index 0000000000000..7f901a6c89bbb --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/emailFactorProfile.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type EmailFactorProfile struct { + Email string `json:"email,omitempty"` +} + +func NewEmailFactorProfile() *EmailFactorProfile { + return &EmailFactorProfile{} +} + +func (a *EmailFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/emailStatus.go b/vendor/github.com/okta/okta-sdk-golang/okta/emailStatus.go new file mode 100644 index 0000000000000..84bd2400688d4 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/emailStatus.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type EmailStatus struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/emailType.go b/vendor/github.com/okta/okta-sdk-golang/okta/emailType.go new file mode 100644 index 0000000000000..ee7e564d4577e --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/emailType.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type EmailType struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/error.go b/vendor/github.com/okta/okta-sdk-golang/okta/error.go new file mode 100644 index 0000000000000..8b1a85b4f7794 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/error.go @@ -0,0 +1,47 @@ +/* + * Copyright 2018 - Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package okta + +import ( + "fmt" + "strings" +) + +type Error struct { + ErrorCode string `json:"errorCode,omitempty"` + ErrorSummary string `json:"errorSummary,omitempty"` + ErrorLink string `json:"errorLink,omitempty"` + ErrorId string `json:"errorId,omitempty"` + ErrorCauses []map[string]interface{} `json:"errorCauses,omitempty"` +} + +func (e *Error) Error() string { + formattedErr := fmt.Sprintf("The API returned an error: %s", e.ErrorSummary) + + if len(e.ErrorCauses) > 0 { + causes := []string{} + + for _, cause := range e.ErrorCauses { + for key, val := range cause { + causes = append(causes, fmt.Sprintf("%s: %v", key, val)) + } + } + formattedErr = fmt.Sprintf("%s. Causes: %s", formattedErr, strings.Join(causes, ", ")) + } + + return formattedErr +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/factor.go b/vendor/github.com/okta/okta-sdk-golang/okta/factor.go new file mode 100644 index 0000000000000..896c9d6cd549c --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/factor.go @@ -0,0 +1,174 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" +) + +type UserFactor interface { + IsUserFactorInstance() bool +} + +type FactorResource resource + +type Factor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *FactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewFactor() *Factor { + return &Factor{} +} + +func (a *Factor) IsUserFactorInstance() bool { + return true +} + +func (m *FactorResource) DeleteFactor(userId string, factorId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors/%v", userId, factorId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *FactorResource) ListFactors(userId string) ([]UserFactor, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors", userId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var factor []UserFactor + resp, err := m.client.requestExecutor.Do(req, &factor) + if err != nil { + return nil, resp, err + } + return factor, resp, nil +} +func (m *FactorResource) AddFactor(userId string, body UserFactor, qp *query.Params) (interface{}, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + factor := body + resp, err := m.client.requestExecutor.Do(req, &factor) + if err != nil { + return nil, resp, err + } + return factor, resp, nil +} +func (m *FactorResource) ListSupportedFactors(userId string) ([]interface{}, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors/catalog", userId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var factor []interface{} + resp, err := m.client.requestExecutor.Do(req, &factor) + if err != nil { + return nil, resp, err + } + return factor, resp, nil +} +func (m *FactorResource) ListSupportedSecurityQuestions(userId string) ([]*SecurityQuestion, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors/questions", userId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var securityQuestion []*SecurityQuestion + resp, err := m.client.requestExecutor.Do(req, &securityQuestion) + if err != nil { + return nil, resp, err + } + return securityQuestion, resp, nil +} +func (m *FactorResource) GetFactor(userId string, factorId string, factorInstance UserFactor) (interface{}, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors/%v", userId, factorId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + factor := factorInstance + resp, err := m.client.requestExecutor.Do(req, &factor) + if err != nil { + return nil, resp, err + } + return factor, resp, nil +} +func (m *FactorResource) ActivateFactor(userId string, factorId string, body VerifyFactorRequest) (interface{}, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors/%v/lifecycle/activate", userId, factorId) + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + factor := body + resp, err := m.client.requestExecutor.Do(req, &factor) + if err != nil { + return nil, resp, err + } + return factor, resp, nil +} +func (m *FactorResource) VerifyFactor(userId string, factorId string, body VerifyFactorRequest, qp *query.Params) (*VerifyFactorResponse, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/factors/%v/verify", userId, factorId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var verifyFactorResponse *VerifyFactorResponse + resp, err := m.client.requestExecutor.Do(req, &verifyFactorResponse) + if err != nil { + return nil, resp, err + } + return verifyFactorResponse, resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/factorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/factorProfile.go new file mode 100644 index 0000000000000..6d8ad6b65ce4c --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/factorProfile.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type FactorProfile struct { +} + +func NewFactorProfile() *FactorProfile { + return &FactorProfile{} +} + +func (a *FactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/factorProvider.go b/vendor/github.com/okta/okta-sdk-golang/okta/factorProvider.go new file mode 100644 index 0000000000000..99da795f9d6a4 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/factorProvider.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type FactorProvider struct { +} + +func NewFactorProvider() *FactorProvider { + return &FactorProvider{} +} + +func (a *FactorProvider) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/factorResultType.go b/vendor/github.com/okta/okta-sdk-golang/okta/factorResultType.go new file mode 100644 index 0000000000000..ff34061052918 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/factorResultType.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type FactorResultType struct { +} + +func NewFactorResultType() *FactorResultType { + return &FactorResultType{} +} + +func (a *FactorResultType) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/factorStatus.go b/vendor/github.com/okta/okta-sdk-golang/okta/factorStatus.go new file mode 100644 index 0000000000000..fcebcfac9fb85 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/factorStatus.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type FactorStatus struct { +} + +func NewFactorStatus() *FactorStatus { + return &FactorStatus{} +} + +func (a *FactorStatus) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/factorType.go b/vendor/github.com/okta/okta-sdk-golang/okta/factorType.go new file mode 100644 index 0000000000000..6c1919c48604c --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/factorType.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type FactorType struct { +} + +func NewFactorType() *FactorType { + return &FactorType{} +} + +func (a *FactorType) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/forgotPasswordResponse.go b/vendor/github.com/okta/okta-sdk-golang/okta/forgotPasswordResponse.go new file mode 100644 index 0000000000000..950cb03d911e5 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/forgotPasswordResponse.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ForgotPasswordResponse struct { + ResetPasswordUrl string `json:"resetPasswordUrl,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/group.go b/vendor/github.com/okta/okta-sdk-golang/okta/group.go new file mode 100644 index 0000000000000..88bf35871d56c --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/group.go @@ -0,0 +1,262 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" + "time" +) + +type GroupResource resource + +type Group struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Created *time.Time `json:"created,omitempty"` + Id string `json:"id,omitempty"` + LastMembershipUpdated *time.Time `json:"lastMembershipUpdated,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + ObjectClass []string `json:"objectClass,omitempty"` + Profile *GroupProfile `json:"profile,omitempty"` + Type string `json:"type,omitempty"` +} + +func (m *GroupResource) UpdateGroup(groupId string, body Group) (*Group, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/%v", groupId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var group *Group + resp, err := m.client.requestExecutor.Do(req, &group) + if err != nil { + return nil, resp, err + } + return group, resp, nil +} +func (m *GroupResource) DeleteGroup(groupId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/groups/%v", groupId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *GroupResource) ListGroups(qp *query.Params) ([]*Group, *Response, error) { + url := fmt.Sprintf("/api/v1/groups") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var group []*Group + resp, err := m.client.requestExecutor.Do(req, &group) + if err != nil { + return nil, resp, err + } + return group, resp, nil +} +func (m *GroupResource) CreateGroup(body Group) (*Group, *Response, error) { + url := fmt.Sprintf("/api/v1/groups") + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var group *Group + resp, err := m.client.requestExecutor.Do(req, &group) + if err != nil { + return nil, resp, err + } + return group, resp, nil +} +func (m *GroupResource) ListRules(qp *query.Params) ([]*GroupRule, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var groupRule []*GroupRule + resp, err := m.client.requestExecutor.Do(req, &groupRule) + if err != nil { + return nil, resp, err + } + return groupRule, resp, nil +} +func (m *GroupResource) CreateRule(body GroupRule) (*GroupRule, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules") + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var groupRule *GroupRule + resp, err := m.client.requestExecutor.Do(req, &groupRule) + if err != nil { + return nil, resp, err + } + return groupRule, resp, nil +} +func (m *GroupResource) DeleteRule(ruleId string, qp *query.Params) (*Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules/%v", ruleId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *GroupResource) GetRule(ruleId string, qp *query.Params) (*GroupRule, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules/%v", ruleId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var groupRule *GroupRule + resp, err := m.client.requestExecutor.Do(req, &groupRule) + if err != nil { + return nil, resp, err + } + return groupRule, resp, nil +} +func (m *GroupResource) UpdateRule(ruleId string, body GroupRule) (*GroupRule, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules/%v", ruleId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var groupRule *GroupRule + resp, err := m.client.requestExecutor.Do(req, &groupRule) + if err != nil { + return nil, resp, err + } + return groupRule, resp, nil +} +func (m *GroupResource) ActivateRule(ruleId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules/%v/lifecycle/activate", ruleId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *GroupResource) DeactivateRule(ruleId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules/%v/lifecycle/deactivate", ruleId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *GroupResource) GetGroup(groupId string, qp *query.Params) (*Group, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/%v", groupId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var group *Group + resp, err := m.client.requestExecutor.Do(req, &group) + if err != nil { + return nil, resp, err + } + return group, resp, nil +} +func (m *GroupResource) ListGroupUsers(groupId string, qp *query.Params) ([]*User, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/%v/users", groupId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var user []*User + resp, err := m.client.requestExecutor.Do(req, &user) + if err != nil { + return nil, resp, err + } + return user, resp, nil +} +func (m *GroupResource) RemoveGroupUser(groupId string, userId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/groups/%v/users/%v", groupId, userId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *GroupResource) AddUserToGroup(groupId string, userId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/groups/%v/users/%v", groupId, userId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupCondition.go new file mode 100644 index 0000000000000..5e1af0c1a4ace --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupCondition.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupCondition struct { + Exclude []string `json:"exclude,omitempty"` + Include []string `json:"include,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupProfile.go new file mode 100644 index 0000000000000..41c0afafdfaae --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupProfile.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupProfile struct { + Description string `json:"description,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRule.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRule.go new file mode 100644 index 0000000000000..25430c99ac8b5 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRule.go @@ -0,0 +1,71 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" + "time" +) + +type GroupRuleResource resource + +type GroupRule struct { + Embedded interface{} `json:"_embedded,omitempty"` + Actions *GroupRuleAction `json:"actions,omitempty"` + AllGroupsValid *bool `json:"allGroupsValid,omitempty"` + Conditions *GroupRuleConditions `json:"conditions,omitempty"` + Created *time.Time `json:"created,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Name string `json:"name,omitempty"` + Status string `json:"status,omitempty"` + Type string `json:"type,omitempty"` +} + +func (m *GroupRuleResource) UpdateRule(ruleId string, body GroupRule) (*GroupRule, *Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules/%v", ruleId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var groupRule *GroupRule + resp, err := m.client.requestExecutor.Do(req, &groupRule) + if err != nil { + return nil, resp, err + } + return groupRule, resp, nil +} +func (m *GroupRuleResource) DeleteRule(ruleId string, qp *query.Params) (*Response, error) { + url := fmt.Sprintf("/api/v1/groups/rules/%v", ruleId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleAction.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleAction.go new file mode 100644 index 0000000000000..b4063b638d585 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleAction.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRuleAction struct { + AssignUserToGroups *GroupRuleGroupAssignment `json:"assignUserToGroups,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleConditions.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleConditions.go new file mode 100644 index 0000000000000..135862ba62cd8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleConditions.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRuleConditions struct { + Expression *GroupRuleExpression `json:"expression,omitempty"` + People *GroupRulePeopleCondition `json:"people,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleExpression.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleExpression.go new file mode 100644 index 0000000000000..396927ab4ae63 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleExpression.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRuleExpression struct { + Type string `json:"type,omitempty"` + Value string `json:"value,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupAssignment.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupAssignment.go new file mode 100644 index 0000000000000..5193a4ef6fba1 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupAssignment.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRuleGroupAssignment struct { + GroupIds []string `json:"groupIds,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupCondition.go new file mode 100644 index 0000000000000..232a6432f8ce2 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleGroupCondition.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRuleGroupCondition struct { + Exclude []string `json:"exclude,omitempty"` + Include []string `json:"include,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRulePeopleCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRulePeopleCondition.go new file mode 100644 index 0000000000000..4019e66e0af58 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRulePeopleCondition.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRulePeopleCondition struct { + Groups *GroupRuleGroupCondition `json:"groups,omitempty"` + Users *GroupRuleUserCondition `json:"users,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleStatus.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleStatus.go new file mode 100644 index 0000000000000..d746681491c5f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleStatus.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRuleStatus struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleUserCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleUserCondition.go new file mode 100644 index 0000000000000..349b1382dc2d8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/groupRuleUserCondition.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type GroupRuleUserCondition struct { + Exclude []string `json:"exclude,omitempty"` + Include []string `json:"include,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactor.go new file mode 100644 index 0000000000000..9faff5f6102e7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type HardwareFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *HardwareFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewHardwareFactor() *HardwareFactor { + return &HardwareFactor{ + FactorType: "token:hardware", + } +} + +func (a *HardwareFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactorProfile.go new file mode 100644 index 0000000000000..a1dbdc5c9f742 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/hardwareFactorProfile.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type HardwareFactorProfile struct { + CredentialId string `json:"credentialId,omitempty"` +} + +func NewHardwareFactorProfile() *HardwareFactorProfile { + return &HardwareFactorProfile{} +} + +func (a *HardwareFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/jsonWebKey.go b/vendor/github.com/okta/okta-sdk-golang/okta/jsonWebKey.go new file mode 100644 index 0000000000000..9e4bf12da591d --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/jsonWebKey.go @@ -0,0 +1,50 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type JsonWebKey struct { + Links interface{} `json:"_links,omitempty"` + Alg string `json:"alg,omitempty"` + Created *time.Time `json:"created,omitempty"` + E string `json:"e,omitempty"` + ExpiresAt *time.Time `json:"expiresAt,omitempty"` + KeyOps []string `json:"key_ops,omitempty"` + Kid string `json:"kid,omitempty"` + Kty string `json:"kty,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + N string `json:"n,omitempty"` + Status string `json:"status,omitempty"` + Use string `json:"use,omitempty"` + X5c []string `json:"x5c,omitempty"` + X5t string `json:"x5t,omitempty"` + X5tS256 string `json:"x5t#S256,omitempty"` + X5u string `json:"x5u,omitempty"` +} + +func NewJsonWebKey() *JsonWebKey { + return &JsonWebKey{} +} + +func (a *JsonWebKey) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logActor.go b/vendor/github.com/okta/okta-sdk-golang/okta/logActor.go new file mode 100644 index 0000000000000..868c25408add7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logActor.go @@ -0,0 +1,29 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogActor struct { + AlternateId string `json:"alternateId,omitempty"` + Detail interface{} `json:"detail,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Id string `json:"id,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationContext.go b/vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationContext.go new file mode 100644 index 0000000000000..3646542742d18 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationContext.go @@ -0,0 +1,31 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogAuthenticationContext struct { + AuthenticationProvider string `json:"authenticationProvider,omitempty"` + AuthenticationStep int64 `json:"authenticationStep,omitempty"` + CredentialProvider []*LogCredentialProvider `json:"credentialProvider,omitempty"` + CredentialType []*LogCredentialType `json:"credentialType,omitempty"` + ExternalSessionId string `json:"externalSessionId,omitempty"` + Interface string `json:"interface,omitempty"` + Issuer *LogIssuer `json:"issuer,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationProvider.go b/vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationProvider.go new file mode 100644 index 0000000000000..b9a6376614f32 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logAuthenticationProvider.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogAuthenticationProvider struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logClient.go b/vendor/github.com/okta/okta-sdk-golang/okta/logClient.go new file mode 100644 index 0000000000000..242b593de61ec --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logClient.go @@ -0,0 +1,30 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogClient struct { + Device string `json:"device,omitempty"` + GeographicalContext *LogGeographicalContext `json:"geographicalContext,omitempty"` + Id string `json:"id,omitempty"` + IpAddress string `json:"ipAddress,omitempty"` + UserAgent *LogUserAgent `json:"userAgent,omitempty"` + Zone string `json:"zone,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logCredentialProvider.go b/vendor/github.com/okta/okta-sdk-golang/okta/logCredentialProvider.go new file mode 100644 index 0000000000000..ad3e0fd96d3e1 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logCredentialProvider.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogCredentialProvider struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logCredentialType.go b/vendor/github.com/okta/okta-sdk-golang/okta/logCredentialType.go new file mode 100644 index 0000000000000..73595c256bcf7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logCredentialType.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogCredentialType struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logDebugContext.go b/vendor/github.com/okta/okta-sdk-golang/okta/logDebugContext.go new file mode 100644 index 0000000000000..5b30c51bedb58 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logDebugContext.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogDebugContext struct { + DebugData interface{} `json:"debugData,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logEvent.go b/vendor/github.com/okta/okta-sdk-golang/okta/logEvent.go new file mode 100644 index 0000000000000..9094bb0e961f4 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logEvent.go @@ -0,0 +1,64 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" + "time" +) + +type LogEventResource resource + +type LogEvent struct { + Actor *LogActor `json:"actor,omitempty"` + AuthenticationContext *LogAuthenticationContext `json:"authenticationContext,omitempty"` + Client *LogClient `json:"client,omitempty"` + DebugContext *LogDebugContext `json:"debugContext,omitempty"` + DisplayMessage string `json:"displayMessage,omitempty"` + EventType string `json:"eventType,omitempty"` + LegacyEventType string `json:"legacyEventType,omitempty"` + Outcome *LogOutcome `json:"outcome,omitempty"` + Published *time.Time `json:"published,omitempty"` + Request *LogRequest `json:"request,omitempty"` + SecurityContext *LogSecurityContext `json:"securityContext,omitempty"` + Severity string `json:"severity,omitempty"` + Target []*LogTarget `json:"target,omitempty"` + Transaction *LogTransaction `json:"transaction,omitempty"` + Uuid string `json:"uuid,omitempty"` + Version string `json:"version,omitempty"` +} + +func (m *LogEventResource) GetLogs(qp *query.Params) ([]*LogEvent, *Response, error) { + url := fmt.Sprintf("/api/v1/logs") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var logEvent []*LogEvent + resp, err := m.client.requestExecutor.Do(req, &logEvent) + if err != nil { + return nil, resp, err + } + return logEvent, resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logGeographicalContext.go b/vendor/github.com/okta/okta-sdk-golang/okta/logGeographicalContext.go new file mode 100644 index 0000000000000..b1eee824a3952 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logGeographicalContext.go @@ -0,0 +1,29 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogGeographicalContext struct { + City string `json:"city,omitempty"` + Country string `json:"country,omitempty"` + Geolocation *LogGeolocation `json:"geolocation,omitempty"` + PostalCode string `json:"postalCode,omitempty"` + State string `json:"state,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logGeolocation.go b/vendor/github.com/okta/okta-sdk-golang/okta/logGeolocation.go new file mode 100644 index 0000000000000..5d0c329045515 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logGeolocation.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogGeolocation struct { + Lat float64 `json:"lat,omitempty"` + Lon float64 `json:"lon,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logIpAddress.go b/vendor/github.com/okta/okta-sdk-golang/okta/logIpAddress.go new file mode 100644 index 0000000000000..fa1db792834e2 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logIpAddress.go @@ -0,0 +1,28 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogIpAddress struct { + GeographicalContext *LogGeographicalContext `json:"geographicalContext,omitempty"` + Ip string `json:"ip,omitempty"` + Source string `json:"source,omitempty"` + Version string `json:"version,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logIssuer.go b/vendor/github.com/okta/okta-sdk-golang/okta/logIssuer.go new file mode 100644 index 0000000000000..081a3ccc891b7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logIssuer.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogIssuer struct { + Id string `json:"id,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logOutcome.go b/vendor/github.com/okta/okta-sdk-golang/okta/logOutcome.go new file mode 100644 index 0000000000000..bc6dae15f9c4b --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logOutcome.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogOutcome struct { + Reason string `json:"reason,omitempty"` + Result string `json:"result,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logRequest.go b/vendor/github.com/okta/okta-sdk-golang/okta/logRequest.go new file mode 100644 index 0000000000000..226c2d73cbb49 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logRequest.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogRequest struct { + IpChain []*LogIpAddress `json:"ipChain,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logSecurityContext.go b/vendor/github.com/okta/okta-sdk-golang/okta/logSecurityContext.go new file mode 100644 index 0000000000000..0942f261e986a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logSecurityContext.go @@ -0,0 +1,29 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogSecurityContext struct { + AsNumber int64 `json:"asNumber,omitempty"` + AsOrg string `json:"asOrg,omitempty"` + Domain string `json:"domain,omitempty"` + IsProxy *bool `json:"isProxy,omitempty"` + Isp string `json:"isp,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logSeverity.go b/vendor/github.com/okta/okta-sdk-golang/okta/logSeverity.go new file mode 100644 index 0000000000000..4d9e6ad7f4701 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logSeverity.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogSeverity struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logTarget.go b/vendor/github.com/okta/okta-sdk-golang/okta/logTarget.go new file mode 100644 index 0000000000000..e42c01e45bbaf --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logTarget.go @@ -0,0 +1,29 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogTarget struct { + AlternateId string `json:"alternateId,omitempty"` + DetailEntry interface{} `json:"detailEntry,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Id string `json:"id,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logTransaction.go b/vendor/github.com/okta/okta-sdk-golang/okta/logTransaction.go new file mode 100644 index 0000000000000..0fb764c896259 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logTransaction.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogTransaction struct { + Detail interface{} `json:"detail,omitempty"` + Id string `json:"id,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/logUserAgent.go b/vendor/github.com/okta/okta-sdk-golang/okta/logUserAgent.go new file mode 100644 index 0000000000000..f3e5502a2cac8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/logUserAgent.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type LogUserAgent struct { + Browser string `json:"browser,omitempty"` + Os string `json:"os,omitempty"` + RawUserAgent string `json:"rawUserAgent,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oAuthApplicationCredentials.go b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthApplicationCredentials.go new file mode 100644 index 0000000000000..a7ae1f4b44cd4 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthApplicationCredentials.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OAuthApplicationCredentials struct { + Signing *ApplicationCredentialsSigning `json:"signing,omitempty"` + UserNameTemplate *ApplicationCredentialsUsernameTemplate `json:"userNameTemplate,omitempty"` + OauthClient *ApplicationCredentialsOAuthClient `json:"oauthClient,omitempty"` +} + +func NewOAuthApplicationCredentials() *OAuthApplicationCredentials { + return &OAuthApplicationCredentials{} +} + +func (a *OAuthApplicationCredentials) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oAuthEndpointAuthenticationMethod.go b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthEndpointAuthenticationMethod.go new file mode 100644 index 0000000000000..314fa99499dfe --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthEndpointAuthenticationMethod.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OAuthEndpointAuthenticationMethod struct { +} + +func NewOAuthEndpointAuthenticationMethod() *OAuthEndpointAuthenticationMethod { + return &OAuthEndpointAuthenticationMethod{} +} + +func (a *OAuthEndpointAuthenticationMethod) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oAuthGrantType.go b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthGrantType.go new file mode 100644 index 0000000000000..3af7fd6f15e5f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthGrantType.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OAuthGrantType struct { +} + +func NewOAuthGrantType() *OAuthGrantType { + return &OAuthGrantType{} +} + +func (a *OAuthGrantType) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oAuthResponseType.go b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthResponseType.go new file mode 100644 index 0000000000000..7d5329c1b2b2f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oAuthResponseType.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OAuthResponseType struct { +} + +func NewOAuthResponseType() *OAuthResponseType { + return &OAuthResponseType{} +} + +func (a *OAuthResponseType) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/okta.go b/vendor/github.com/okta/okta-sdk-golang/okta/okta.go new file mode 100644 index 0000000000000..bf8d06220e318 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/okta.go @@ -0,0 +1,164 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "context" + "fmt" + "io/ioutil" + "os/user" + + "github.com/go-yaml/yaml" + "github.com/kelseyhightower/envconfig" +) + +const Version = "0.1.0" + +type Client struct { + config *config + + requestExecutor *RequestExecutor + + resource resource + + Application *ApplicationResource + Group *GroupResource + LogEvent *LogEventResource + Policy *PolicyResource + Session *SessionResource + User *UserResource + Factor *FactorResource +} + +type resource struct { + client *Client +} + +func NewClient(ctx context.Context, conf ...ConfigSetter) (*Client, error) { + config, err := NewConfig(conf...) + if err != nil { + return nil, err + } + + cache, err := NewCache(config) + if err != nil { + return nil, err + } + + config.CacheManager = cache + + config, err = ValidateConfig(config) + if err != nil { + panic(err) + } + + c := &Client{} + c.config = config + c.requestExecutor = NewRequestExecutor(&config.HttpClient, cache, config) + + c.resource.client = c + + c.Application = (*ApplicationResource)(&c.resource) + c.Group = (*GroupResource)(&c.resource) + c.LogEvent = (*LogEventResource)(&c.resource) + c.Policy = (*PolicyResource)(&c.resource) + c.Session = (*SessionResource)(&c.resource) + c.User = (*UserResource)(&c.resource) + c.Factor = (*FactorResource)(&c.resource) + return c, nil +} + +func (c *Client) GetConfig() *config { + return c.config +} + +func (c *Client) GetRequestExecutor() *RequestExecutor { + return c.requestExecutor +} + +func setConfigDefaults(c *config) { + var conf []ConfigSetter + + conf = append(conf, + WithConnectionTimeout(30), + WithCache(true), + WithCacheTtl(300), + WithCacheTti(300), + WithUserAgentExtra(""), + WithTestingDisableHttpsCheck(false), + WithRequestTimeout(0), + WithRateLimitMaxRetries(2)) + + for _, confSetter := range conf { + confSetter(c) + } +} + +func readConfigFromFile(location string) (*config, error) { + yamlConfig, err := ioutil.ReadFile(location) + + if err != nil { + return nil, err + } + + conf := config{} + err = yaml.Unmarshal(yamlConfig, &conf) + if err != nil { + return nil, err + } + + return &conf, err +} + +func readConfigFromSystem(c config) *config { + currUser, err := user.Current() + if err != nil { + return &c + } + if currUser.HomeDir == "" { + return &c + } + + conf, err := readConfigFromFile(currUser.HomeDir + "/.okta/okta.yaml") + + if err != nil { + return &c + } + + return conf +} + +func readConfigFromApplication(c config) *config { + conf, err := readConfigFromFile(".okta.yaml") + + if err != nil { + return &c + } + + return conf +} + +func readConfigFromEnvironment(c config) *config { + err := envconfig.Process("okta", &c) + if err != nil { + fmt.Println("error parsing") + return &c + } + return &c +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicy.go b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicy.go new file mode 100644 index 0000000000000..7567874b157a6 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicy.go @@ -0,0 +1,38 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type OktaSignOnPolicy struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Created *time.Time `json:"created,omitempty"` + Description string `json:"description,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Name string `json:"name,omitempty"` + Priority int64 `json:"priority,omitempty"` + Status string `json:"status,omitempty"` + System *bool `json:"system,omitempty"` + Type string `json:"type,omitempty"` + Conditions *OktaSignOnPolicyConditions `json:"conditions,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyConditions.go b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyConditions.go new file mode 100644 index 0000000000000..f1b9d91c5f157 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyConditions.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OktaSignOnPolicyConditions struct { + People *PolicyPeopleCondition `json:"people,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRule.go b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRule.go new file mode 100644 index 0000000000000..5e48ee3706eff --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRule.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type OktaSignOnPolicyRule struct { + Created *time.Time `json:"created,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Priority int64 `json:"priority,omitempty"` + Status string `json:"status,omitempty"` + System *bool `json:"system,omitempty"` + Type string `json:"type,omitempty"` + Actions *OktaSignOnPolicyRuleActions `json:"actions,omitempty"` + Conditions *OktaSignOnPolicyRuleConditions `json:"conditions,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleActions.go b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleActions.go new file mode 100644 index 0000000000000..6c4f922ace059 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleActions.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OktaSignOnPolicyRuleActions struct { + Signon *OktaSignOnPolicyRuleSignonActions `json:"signon,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleConditions.go b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleConditions.go new file mode 100644 index 0000000000000..82ee0b417595d --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleConditions.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OktaSignOnPolicyRuleConditions struct { + AuthContext *PolicyRuleAuthContextCondition `json:"authContext,omitempty"` + Network *PolicyNetworkCondition `json:"network,omitempty"` + People *PolicyPeopleCondition `json:"people,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonActions.go b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonActions.go new file mode 100644 index 0000000000000..5da0b53531c1a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonActions.go @@ -0,0 +1,30 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OktaSignOnPolicyRuleSignonActions struct { + Access string `json:"access,omitempty"` + FactorLifetime int64 `json:"factorLifetime,omitempty"` + FactorPromptMode string `json:"factorPromptMode,omitempty"` + RememberDeviceByDefault *bool `json:"rememberDeviceByDefault,omitempty"` + RequireFactor *bool `json:"requireFactor,omitempty"` + Session *OktaSignOnPolicyRuleSignonSessionActions `json:"session,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonSessionActions.go b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonSessionActions.go new file mode 100644 index 0000000000000..574cf3b5bcfa2 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/oktaSignOnPolicyRuleSignonSessionActions.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OktaSignOnPolicyRuleSignonSessionActions struct { + MaxSessionIdleMinutes int64 `json:"maxSessionIdleMinutes,omitempty"` + MaxSessionLifetimeMinutes int64 `json:"maxSessionLifetimeMinutes,omitempty"` + UsePersistentCookie *bool `json:"usePersistentCookie,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplication.go new file mode 100644 index 0000000000000..b8e56099252cf --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplication.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type OpenIdConnectApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *OAuthApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *OpenIdConnectApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewOpenIdConnectApplication() *OpenIdConnectApplication { + return &OpenIdConnectApplication{ + Name: "oidc_client", + SignOnMode: "OPENID_CONNECT", + } +} + +func (a *OpenIdConnectApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationConsentMethod.go b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationConsentMethod.go new file mode 100644 index 0000000000000..1cd267cb8a398 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationConsentMethod.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OpenIdConnectApplicationConsentMethod struct { +} + +func NewOpenIdConnectApplicationConsentMethod() *OpenIdConnectApplicationConsentMethod { + return &OpenIdConnectApplicationConsentMethod{} +} + +func (a *OpenIdConnectApplicationConsentMethod) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettings.go new file mode 100644 index 0000000000000..2e71c13b7b596 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettings.go @@ -0,0 +1,37 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OpenIdConnectApplicationSettings struct { + App *ApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` + OauthClient *OpenIdConnectApplicationSettingsClient `json:"oauthClient,omitempty"` +} + +func NewOpenIdConnectApplicationSettings() *OpenIdConnectApplicationSettings { + return &OpenIdConnectApplicationSettings{} +} + +func (a *OpenIdConnectApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettingsClient.go b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettingsClient.go new file mode 100644 index 0000000000000..e508e3ec2667a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationSettingsClient.go @@ -0,0 +1,42 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OpenIdConnectApplicationSettingsClient struct { + ApplicationType string `json:"application_type,omitempty"` + ClientUri string `json:"client_uri,omitempty"` + ConsentMethod string `json:"consent_method,omitempty"` + GrantTypes []*OAuthGrantType `json:"grant_types,omitempty"` + LogoUri string `json:"logo_uri,omitempty"` + PolicyUri string `json:"policy_uri,omitempty"` + PostLogoutRedirectUris []string `json:"post_logout_redirect_uris,omitempty"` + RedirectUris []string `json:"redirect_uris,omitempty"` + ResponseTypes []*OAuthResponseType `json:"response_types,omitempty"` + TosUri string `json:"tos_uri,omitempty"` +} + +func NewOpenIdConnectApplicationSettingsClient() *OpenIdConnectApplicationSettingsClient { + return &OpenIdConnectApplicationSettingsClient{} +} + +func (a *OpenIdConnectApplicationSettingsClient) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationType.go b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationType.go new file mode 100644 index 0000000000000..70f44eef25f21 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/openIdConnectApplicationType.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type OpenIdConnectApplicationType struct { +} + +func NewOpenIdConnectApplicationType() *OpenIdConnectApplicationType { + return &OpenIdConnectApplicationType{} +} + +func (a *OpenIdConnectApplicationType) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordCredential.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordCredential.go new file mode 100644 index 0000000000000..f9222746fccec --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordCredential.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordCredential struct { + Value string `json:"value,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionary.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionary.go new file mode 100644 index 0000000000000..9351bd6fef260 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionary.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordDictionary struct { + Common *PasswordDictionaryCommon `json:"common,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionaryCommon.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionaryCommon.go new file mode 100644 index 0000000000000..63139579749b1 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordDictionaryCommon.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordDictionaryCommon struct { + Exclude *bool `json:"exclude,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicy.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicy.go new file mode 100644 index 0000000000000..89394bf549ed0 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicy.go @@ -0,0 +1,39 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type PasswordPolicy struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Created *time.Time `json:"created,omitempty"` + Description string `json:"description,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Name string `json:"name,omitempty"` + Priority int64 `json:"priority,omitempty"` + Status string `json:"status,omitempty"` + System *bool `json:"system,omitempty"` + Type string `json:"type,omitempty"` + Conditions *PasswordPolicyConditions `json:"conditions,omitempty"` + Settings *PasswordPolicySettings `json:"settings,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyAuthenticationProviderCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyAuthenticationProviderCondition.go new file mode 100644 index 0000000000000..5f45ad765e6a9 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyAuthenticationProviderCondition.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyAuthenticationProviderCondition struct { + Include []string `json:"include,omitempty"` + Provider string `json:"provider,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyConditions.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyConditions.go new file mode 100644 index 0000000000000..5339db48d149e --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyConditions.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyConditions struct { + AuthProvider *PasswordPolicyAuthenticationProviderCondition `json:"authProvider,omitempty"` + People *PolicyPeopleCondition `json:"people,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettings.go new file mode 100644 index 0000000000000..bcf64c6bdc66c --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettings.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyDelegationSettings struct { + Options *PasswordPolicyDelegationSettingsOptions `json:"options,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettingsOptions.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettingsOptions.go new file mode 100644 index 0000000000000..0223b5768a186 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyDelegationSettingsOptions.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyDelegationSettingsOptions struct { + SkipUnlock *bool `json:"skipUnlock,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettings.go new file mode 100644 index 0000000000000..b6661f17483bd --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettings.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyPasswordSettings struct { + Age *PasswordPolicyPasswordSettingsAge `json:"age,omitempty"` + Complexity *PasswordPolicyPasswordSettingsComplexity `json:"complexity,omitempty"` + Lockout *PasswordPolicyPasswordSettingsLockout `json:"lockout,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsAge.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsAge.go new file mode 100644 index 0000000000000..831499ae648d8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsAge.go @@ -0,0 +1,28 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyPasswordSettingsAge struct { + ExpireWarnDays int64 `json:"expireWarnDays,omitempty"` + HistoryCount int64 `json:"historyCount,omitempty"` + MaxAgeDays int64 `json:"maxAgeDays,omitempty"` + MinAgeMinutes int64 `json:"minAgeMinutes,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsComplexity.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsComplexity.go new file mode 100644 index 0000000000000..8550830043398 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsComplexity.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyPasswordSettingsComplexity struct { + Dictionary *PasswordDictionary `json:"dictionary,omitempty"` + ExcludeAttributes []string `json:"excludeAttributes,omitempty"` + ExcludeUsername *bool `json:"excludeUsername,omitempty"` + MinLength int64 `json:"minLength,omitempty"` + MinLowerCase int64 `json:"minLowerCase,omitempty"` + MinNumber int64 `json:"minNumber,omitempty"` + MinSymbol int64 `json:"minSymbol,omitempty"` + MinUpperCase int64 `json:"minUpperCase,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsLockout.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsLockout.go new file mode 100644 index 0000000000000..c4f1567b1c734 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyPasswordSettingsLockout.go @@ -0,0 +1,28 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyPasswordSettingsLockout struct { + AutoUnlockMinutes int64 `json:"autoUnlockMinutes,omitempty"` + MaxAttempts int64 `json:"maxAttempts,omitempty"` + ShowLockoutFailures *bool `json:"showLockoutFailures,omitempty"` + UserLockoutNotificationChannels []string `json:"userLockoutNotificationChannels,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmail.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmail.go new file mode 100644 index 0000000000000..137c24ecb37f7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmail.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryEmail struct { + Properties *PasswordPolicyRecoveryEmailProperties `json:"properties,omitempty"` + Status string `json:"status,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailProperties.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailProperties.go new file mode 100644 index 0000000000000..439cca48cf657 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailProperties.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryEmailProperties struct { + RecoveryToken *PasswordPolicyRecoveryEmailRecoveryToken `json:"recoveryToken,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailRecoveryToken.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailRecoveryToken.go new file mode 100644 index 0000000000000..e51e6a87d4879 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryEmailRecoveryToken.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryEmailRecoveryToken struct { + TokenLifetimeMinutes int64 `json:"tokenLifetimeMinutes,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactorSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactorSettings.go new file mode 100644 index 0000000000000..cbb94aa1e5647 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactorSettings.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryFactorSettings struct { + Status string `json:"status,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactors.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactors.go new file mode 100644 index 0000000000000..f75f2db649ae6 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryFactors.go @@ -0,0 +1,28 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryFactors struct { + OktaCall *PasswordPolicyRecoveryFactorSettings `json:"okta_call,omitempty"` + OktaEmail *PasswordPolicyRecoveryEmail `json:"okta_email,omitempty"` + OktaSms *PasswordPolicyRecoveryFactorSettings `json:"okta_sms,omitempty"` + RecoveryQuestion *PasswordPolicyRecoveryQuestion `json:"recovery_question,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestion.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestion.go new file mode 100644 index 0000000000000..c1226e1b5e43f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestion.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryQuestion struct { + Properties *PasswordPolicyRecoveryQuestionProperties `json:"properties,omitempty"` + Status string `json:"status,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionComplexity.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionComplexity.go new file mode 100644 index 0000000000000..d6c94140ef4ab --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionComplexity.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryQuestionComplexity struct { + MinLength int64 `json:"minLength,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionProperties.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionProperties.go new file mode 100644 index 0000000000000..569d2080b0b27 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoveryQuestionProperties.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoveryQuestionProperties struct { + Complexity *PasswordPolicyRecoveryQuestionComplexity `json:"complexity,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoverySettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoverySettings.go new file mode 100644 index 0000000000000..edab8bab037c2 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRecoverySettings.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRecoverySettings struct { + Factors *PasswordPolicyRecoveryFactors `json:"factors,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRule.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRule.go new file mode 100644 index 0000000000000..808d64f19a0f8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRule.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type PasswordPolicyRule struct { + Created *time.Time `json:"created,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Priority int64 `json:"priority,omitempty"` + Status string `json:"status,omitempty"` + System *bool `json:"system,omitempty"` + Type string `json:"type,omitempty"` + Actions *PasswordPolicyRuleActions `json:"actions,omitempty"` + Conditions *PasswordPolicyRuleConditions `json:"conditions,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleAction.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleAction.go new file mode 100644 index 0000000000000..a7770b188495d --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleAction.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRuleAction struct { + Access string `json:"access,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleActions.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleActions.go new file mode 100644 index 0000000000000..de033820e2e91 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleActions.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRuleActions struct { + PasswordChange *PasswordPolicyRuleAction `json:"passwordChange,omitempty"` + SelfServicePasswordReset *PasswordPolicyRuleAction `json:"selfServicePasswordReset,omitempty"` + SelfServiceUnlock *PasswordPolicyRuleAction `json:"selfServiceUnlock,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleConditions.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleConditions.go new file mode 100644 index 0000000000000..3e50e73e1f1dd --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicyRuleConditions.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicyRuleConditions struct { + Network *PolicyNetworkCondition `json:"network,omitempty"` + People *PolicyPeopleCondition `json:"people,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicySettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicySettings.go new file mode 100644 index 0000000000000..c078ac7575305 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/passwordPolicySettings.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PasswordPolicySettings struct { + Delegation *PasswordPolicyDelegationSettings `json:"delegation,omitempty"` + Password *PasswordPolicyPasswordSettings `json:"password,omitempty"` + Recovery *PasswordPolicyRecoverySettings `json:"recovery,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/policy.go b/vendor/github.com/okta/okta-sdk-golang/okta/policy.go new file mode 100644 index 0000000000000..e56d13c1eb397 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/policy.go @@ -0,0 +1,244 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" + "time" +) + +type PolicyResource resource + +type Policy struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Created *time.Time `json:"created,omitempty"` + Description string `json:"description,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Name string `json:"name,omitempty"` + Priority int64 `json:"priority,omitempty"` + Status string `json:"status,omitempty"` + System *bool `json:"system,omitempty"` + Type string `json:"type,omitempty"` +} + +func (m *PolicyResource) GetPolicy(policyId string, qp *query.Params) (*Policy, *Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v", policyId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var policy *Policy + resp, err := m.client.requestExecutor.Do(req, &policy) + if err != nil { + return nil, resp, err + } + return policy, resp, nil +} +func (m *PolicyResource) UpdatePolicy(policyId string, body Policy) (*Policy, *Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v", policyId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var policy *Policy + resp, err := m.client.requestExecutor.Do(req, &policy) + if err != nil { + return nil, resp, err + } + return policy, resp, nil +} +func (m *PolicyResource) DeletePolicy(policyId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v", policyId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *PolicyResource) ListPolicies(qp *query.Params) ([]*Policy, *Response, error) { + url := fmt.Sprintf("/api/v1/policies") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var policy []*Policy + resp, err := m.client.requestExecutor.Do(req, &policy) + if err != nil { + return nil, resp, err + } + return policy, resp, nil +} +func (m *PolicyResource) CreatePolicy(body Policy, qp *query.Params) (*Policy, *Response, error) { + url := fmt.Sprintf("/api/v1/policies") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var policy *Policy + resp, err := m.client.requestExecutor.Do(req, &policy) + if err != nil { + return nil, resp, err + } + return policy, resp, nil +} +func (m *PolicyResource) ActivatePolicy(policyId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/lifecycle/activate", policyId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *PolicyResource) DeactivatePolicy(policyId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/lifecycle/deactivate", policyId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *PolicyResource) ListPolicyRules(policyId string) ([]*PolicyRule, *Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules", policyId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var policyRule []*PolicyRule + resp, err := m.client.requestExecutor.Do(req, &policyRule) + if err != nil { + return nil, resp, err + } + return policyRule, resp, nil +} +func (m *PolicyResource) AddPolicyRule(policyId string, body PolicyRule, qp *query.Params) (*PolicyRule, *Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules", policyId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var policyRule *PolicyRule + resp, err := m.client.requestExecutor.Do(req, &policyRule) + if err != nil { + return nil, resp, err + } + return policyRule, resp, nil +} +func (m *PolicyResource) DeletePolicyRule(policyId string, ruleId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules/%v", policyId, ruleId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *PolicyResource) GetPolicyRule(policyId string, ruleId string) (*PolicyRule, *Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules/%v", policyId, ruleId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var policyRule *PolicyRule + resp, err := m.client.requestExecutor.Do(req, &policyRule) + if err != nil { + return nil, resp, err + } + return policyRule, resp, nil +} +func (m *PolicyResource) UpdatePolicyRule(policyId string, ruleId string, body PolicyRule) (*PolicyRule, *Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules/%v", policyId, ruleId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var policyRule *PolicyRule + resp, err := m.client.requestExecutor.Do(req, &policyRule) + if err != nil { + return nil, resp, err + } + return policyRule, resp, nil +} +func (m *PolicyResource) ActivatePolicyRule(policyId string, ruleId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules/%v/lifecycle/activate", policyId, ruleId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *PolicyResource) DeactivatePolicyRule(policyId string, ruleId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules/%v/lifecycle/deactivate", policyId, ruleId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/policyNetworkCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/policyNetworkCondition.go new file mode 100644 index 0000000000000..aad3eedd33c1b --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/policyNetworkCondition.go @@ -0,0 +1,27 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PolicyNetworkCondition struct { + Connection string `json:"connection,omitempty"` + Exclude []string `json:"exclude,omitempty"` + Include []string `json:"include,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/policyPeopleCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/policyPeopleCondition.go new file mode 100644 index 0000000000000..1fbe6d870bb2d --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/policyPeopleCondition.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PolicyPeopleCondition struct { + Groups *GroupCondition `json:"groups,omitempty"` + Users *UserCondition `json:"users,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/policyRule.go b/vendor/github.com/okta/okta-sdk-golang/okta/policyRule.go new file mode 100644 index 0000000000000..cae750f434518 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/policyRule.go @@ -0,0 +1,64 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "time" +) + +type PolicyRuleResource resource + +type PolicyRule struct { + Created *time.Time `json:"created,omitempty"` + Id string `json:"id,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Priority int64 `json:"priority,omitempty"` + Status string `json:"status,omitempty"` + System *bool `json:"system,omitempty"` + Type string `json:"type,omitempty"` +} + +func (m *PolicyRuleResource) UpdatePolicyRule(policyId string, ruleId string, body PolicyRule) (*PolicyRule, *Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules/%v", policyId, ruleId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var policyRule *PolicyRule + resp, err := m.client.requestExecutor.Do(req, &policyRule) + if err != nil { + return nil, resp, err + } + return policyRule, resp, nil +} +func (m *PolicyRuleResource) DeletePolicyRule(policyId string, ruleId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/policies/%v/rules/%v", policyId, ruleId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/policyRuleAuthContextCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/policyRuleAuthContextCondition.go new file mode 100644 index 0000000000000..5b37e811ad548 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/policyRuleAuthContextCondition.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PolicyRuleAuthContextCondition struct { + AuthType string `json:"authType,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/policyType.go b/vendor/github.com/okta/okta-sdk-golang/okta/policyType.go new file mode 100644 index 0000000000000..cccb810bc57a8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/policyType.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PolicyType struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/pushFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/pushFactor.go new file mode 100644 index 0000000000000..6494be5df47a4 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/pushFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PushFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *PushFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewPushFactor() *PushFactor { + return &PushFactor{ + FactorType: "push", + } +} + +func (a *PushFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/pushFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/pushFactorProfile.go new file mode 100644 index 0000000000000..058f206224482 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/pushFactorProfile.go @@ -0,0 +1,37 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type PushFactorProfile struct { + CredentialId string `json:"credentialId,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + Name string `json:"name,omitempty"` + Platform string `json:"platform,omitempty"` + Version string `json:"version,omitempty"` +} + +func NewPushFactorProfile() *PushFactorProfile { + return &PushFactorProfile{} +} + +func (a *PushFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/query/query.go b/vendor/github.com/okta/okta-sdk-golang/okta/query/query.go new file mode 100644 index 0000000000000..ffe8dedc2c775 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/query/query.go @@ -0,0 +1,320 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package query + +import ( + "net/url" + "strconv" +) + +type Params struct { + Q string `json:"q,omitempty"` + After string `json:"after,omitempty"` + Limit int64 `json:"limit,omitempty"` + Filter string `json:"filter,omitempty"` + Expand string `json:"expand,omitempty"` + IncludeNonDeleted *bool `json:"includeNonDeleted,omitempty"` + Activate *bool `json:"activate,omitempty"` + TargetAid string `json:"targetAid,omitempty"` + QueryScope string `json:"query_scope,omitempty"` + SendEmail *bool `json:"sendEmail,omitempty"` + RemoveUsers *bool `json:"removeUsers,omitempty"` + ManagedBy string `json:"managedBy,omitempty"` + Until string `json:"until,omitempty"` + Since string `json:"since,omitempty"` + SortOrder string `json:"sortOrder,omitempty"` + Type string `json:"type,omitempty"` + Status string `json:"status,omitempty"` + Format string `json:"format,omitempty"` + Search string `json:"search,omitempty"` + Provider string `json:"provider,omitempty"` + NextLogin string `json:"nextLogin,omitempty"` + Strict *bool `json:"strict,omitempty"` + ShowAll *bool `json:"showAll,omitempty"` + UpdatePhone *bool `json:"updatePhone,omitempty"` + TemplateId string `json:"templateId,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + TempPassword *bool `json:"tempPassword,omitempty"` + OauthTokens *bool `json:"oauthTokens,omitempty"` +} + +func NewQueryParams(paramOpt ...ParamOptions) *Params { + p := &Params{} + + for _, par := range paramOpt { + par(p) + } + + return p +} + +type ParamOptions func(*Params) + +func WithQ(queryQ string) ParamOptions { + return func(p *Params) { + p.Q = queryQ + } +} +func WithAfter(queryAfter string) ParamOptions { + return func(p *Params) { + p.After = queryAfter + } +} +func WithLimit(queryLimit int64) ParamOptions { + return func(p *Params) { + p.Limit = queryLimit + } +} +func WithFilter(queryFilter string) ParamOptions { + return func(p *Params) { + p.Filter = queryFilter + } +} +func WithExpand(queryExpand string) ParamOptions { + return func(p *Params) { + p.Expand = queryExpand + } +} +func WithIncludeNonDeleted(queryIncludeNonDeleted bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryIncludeNonDeleted + p.IncludeNonDeleted = b + } +} +func WithActivate(queryActivate bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryActivate + p.Activate = b + } +} +func WithTargetAid(queryTargetAid string) ParamOptions { + return func(p *Params) { + p.TargetAid = queryTargetAid + } +} +func WithQueryScope(queryQueryScope string) ParamOptions { + return func(p *Params) { + p.QueryScope = queryQueryScope + } +} +func WithSendEmail(querySendEmail bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = querySendEmail + p.SendEmail = b + } +} +func WithRemoveUsers(queryRemoveUsers bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryRemoveUsers + p.RemoveUsers = b + } +} +func WithManagedBy(queryManagedBy string) ParamOptions { + return func(p *Params) { + p.ManagedBy = queryManagedBy + } +} +func WithUntil(queryUntil string) ParamOptions { + return func(p *Params) { + p.Until = queryUntil + } +} +func WithSince(querySince string) ParamOptions { + return func(p *Params) { + p.Since = querySince + } +} +func WithSortOrder(querySortOrder string) ParamOptions { + return func(p *Params) { + p.SortOrder = querySortOrder + } +} +func WithType(queryType string) ParamOptions { + return func(p *Params) { + p.Type = queryType + } +} +func WithStatus(queryStatus string) ParamOptions { + return func(p *Params) { + p.Status = queryStatus + } +} +func WithFormat(queryFormat string) ParamOptions { + return func(p *Params) { + p.Format = queryFormat + } +} +func WithSearch(querySearch string) ParamOptions { + return func(p *Params) { + p.Search = querySearch + } +} +func WithProvider(queryProvider string) ParamOptions { + return func(p *Params) { + p.Provider = queryProvider + } +} +func WithNextLogin(queryNextLogin string) ParamOptions { + return func(p *Params) { + p.NextLogin = queryNextLogin + } +} +func WithStrict(queryStrict bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryStrict + p.Strict = b + } +} +func WithShowAll(queryShowAll bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryShowAll + p.ShowAll = b + } +} +func WithUpdatePhone(queryUpdatePhone bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryUpdatePhone + p.UpdatePhone = b + } +} +func WithTemplateId(queryTemplateId string) ParamOptions { + return func(p *Params) { + p.TemplateId = queryTemplateId + } +} +func WithTokenLifetimeSeconds(queryTokenLifetimeSeconds int64) ParamOptions { + return func(p *Params) { + p.TokenLifetimeSeconds = queryTokenLifetimeSeconds + } +} +func WithTempPassword(queryTempPassword bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryTempPassword + p.TempPassword = b + } +} +func WithOauthTokens(queryOauthTokens bool) ParamOptions { + return func(p *Params) { + b := new(bool) + *b = queryOauthTokens + p.OauthTokens = b + } +} + +func (p *Params) String() string { + qs := url.Values{} + + if p.Q != "" { + qs.Add(`q`, p.Q) + } + if p.After != "" { + qs.Add(`after`, p.After) + } + if p.Limit != 0 { + qs.Add(`limit`, strconv.FormatInt(p.Limit, 10)) + } + if p.Filter != "" { + qs.Add(`filter`, p.Filter) + } + if p.Expand != "" { + qs.Add(`expand`, p.Expand) + } + if p.IncludeNonDeleted != nil { + qs.Add(`includeNonDeleted`, strconv.FormatBool(*p.IncludeNonDeleted)) + } + if p.Activate != nil { + qs.Add(`activate`, strconv.FormatBool(*p.Activate)) + } + if p.TargetAid != "" { + qs.Add(`targetAid`, p.TargetAid) + } + if p.QueryScope != "" { + qs.Add(`query_scope`, p.QueryScope) + } + if p.SendEmail != nil { + qs.Add(`sendEmail`, strconv.FormatBool(*p.SendEmail)) + } + if p.RemoveUsers != nil { + qs.Add(`removeUsers`, strconv.FormatBool(*p.RemoveUsers)) + } + if p.ManagedBy != "" { + qs.Add(`managedBy`, p.ManagedBy) + } + if p.Until != "" { + qs.Add(`until`, p.Until) + } + if p.Since != "" { + qs.Add(`since`, p.Since) + } + if p.SortOrder != "" { + qs.Add(`sortOrder`, p.SortOrder) + } + if p.Type != "" { + qs.Add(`type`, p.Type) + } + if p.Status != "" { + qs.Add(`status`, p.Status) + } + if p.Format != "" { + qs.Add(`format`, p.Format) + } + if p.Search != "" { + qs.Add(`search`, p.Search) + } + if p.Provider != "" { + qs.Add(`provider`, p.Provider) + } + if p.NextLogin != "" { + qs.Add(`nextLogin`, p.NextLogin) + } + if p.Strict != nil { + qs.Add(`strict`, strconv.FormatBool(*p.Strict)) + } + if p.ShowAll != nil { + qs.Add(`showAll`, strconv.FormatBool(*p.ShowAll)) + } + if p.UpdatePhone != nil { + qs.Add(`updatePhone`, strconv.FormatBool(*p.UpdatePhone)) + } + if p.TemplateId != "" { + qs.Add(`templateId`, p.TemplateId) + } + if p.TokenLifetimeSeconds != 0 { + qs.Add(`tokenLifetimeSeconds`, strconv.FormatInt(p.TokenLifetimeSeconds, 10)) + } + if p.TempPassword != nil { + qs.Add(`tempPassword`, strconv.FormatBool(*p.TempPassword)) + } + if p.OauthTokens != nil { + qs.Add(`oauthTokens`, strconv.FormatBool(*p.OauthTokens)) + } + + if len(qs) != 0 { + return "?" + qs.Encode() + } + return "" +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/recoveryQuestionCredential.go b/vendor/github.com/okta/okta-sdk-golang/okta/recoveryQuestionCredential.go new file mode 100644 index 0000000000000..030b47e0d2b65 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/recoveryQuestionCredential.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type RecoveryQuestionCredential struct { + Answer string `json:"answer,omitempty"` + Question string `json:"question,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go b/vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go new file mode 100644 index 0000000000000..0907366069b8d --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go @@ -0,0 +1,253 @@ +/* + * Copyright 2018 - Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package okta + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "reflect" + "sort" + "strconv" + "time" + + "github.com/okta/okta-sdk-golang/okta/cache" +) + +type RequestExecutor struct { + httpClient *http.Client + config *config + BaseUrl *url.URL + cache cache.Cache +} + +func NewRequestExecutor(httpClient *http.Client, cache cache.Cache, config *config) *RequestExecutor { + re := RequestExecutor{} + re.httpClient = httpClient + re.config = config + re.cache = cache + + if httpClient == nil { + tr := &http.Transport{ + IdleConnTimeout: 30 * time.Second, + } + re.httpClient = &http.Client{Transport: tr} + } + + return &re +} + +func (re *RequestExecutor) NewRequest(method string, url string, body interface{}) (*http.Request, error) { + var buff io.ReadWriter + if body != nil { + buff = new(bytes.Buffer) + encoder := json.NewEncoder(buff) + encoder.SetEscapeHTML(false) + err := encoder.Encode(body) + if err != nil { + return nil, err + } + } + url = re.config.Okta.Client.OrgUrl + url + + req, err := http.NewRequest(method, url, buff) + + if err != nil { + return nil, err + } + req.Header.Add("Authorization", "SSWS "+re.config.Okta.Client.Token) + req.Header.Add("User-Agent", NewUserAgent(re.config).String()) + req.Header.Add("Accept", "application/json") + + if body != nil { + req.Header.Set("Content-Type", "application/json") + } + + return req, nil +} + +func (re *RequestExecutor) Do(req *http.Request, v interface{}) (*Response, error) { + requestStarted := time.Now().Unix() + cacheKey := cache.CreateCacheKey(req) + if req.Method != http.MethodGet { + re.cache.Delete(cacheKey) + } + inCache := re.cache.Has(cacheKey) + + if !inCache { + + resp, err := re.doWithRetries(req, 0, requestStarted, nil) + + if err != nil { + return nil, err + } + defer resp.Body.Close() + respBody, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + origResp := ioutil.NopCloser(bytes.NewBuffer(respBody)) + resp.Body = origResp + if resp.StatusCode >= 200 && resp.StatusCode <= 299 && req.Method == http.MethodGet && reflect.TypeOf(v).Kind() != reflect.Slice { + re.cache.Set(cacheKey, resp) + } + return buildResponse(resp, &v) + } + + resp := re.cache.Get(cacheKey) + return buildResponse(resp, &v) + +} + +func (re *RequestExecutor) doWithRetries(req *http.Request, retryCount int32, requestStarted int64, lastResponse *http.Response) (*http.Response, error) { + iterationStart := time.Now().Unix() + maxRetries := re.config.Okta.Client.RateLimit.MaxRetries + requestTimeout := int64(re.config.Okta.Client.RequestTimeout) + + if req.Body != nil { + bodyBytes, _ := ioutil.ReadAll(req.Body) + req.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) + } + + if requestTimeout > 0 && (iterationStart-requestStarted) >= requestTimeout { + return lastResponse, errors.New("reached the max request time") + } + + resp, err := re.httpClient.Do(req) + + if (err != nil || tooManyRequests(resp)) && retryCount < maxRetries { + if resp != nil { + err := tryDrainBody(resp.Body) + if err != nil { + return nil, err + } + } + + retryLimitReset := resp.Header.Get("X-Rate-Limit-Reset") + date := resp.Header.Get("Date") + if retryLimitReset == "" || date == "" { + return resp, errors.New("a 429 response must include the x-retry-limit-reset and date headers") + } + + if tooManyRequests(resp) { + err := backoffPause(retryCount, resp) + if err != nil { + return nil, err + } + } + retryCount++ + + req.Header.Add("X-Okta-Retry-For", resp.Header.Get("X-Okta-Request-Id")) + req.Header.Add("X-Okta-Retry-Count", fmt.Sprint(retryCount)) + + resp, err = re.doWithRetries(req, retryCount, requestStarted, resp) + } + + return resp, err +} + +func tooManyRequests(resp *http.Response) bool { + return resp != nil && resp.StatusCode == http.StatusTooManyRequests +} + +func tryDrainBody(body io.ReadCloser) error { + defer body.Close() + _, err := io.Copy(ioutil.Discard, io.LimitReader(body, 4096)) + if err != nil { + return err + } + return nil +} + +func backoffPause(retryCount int32, response *http.Response) error { + if response.StatusCode == http.StatusTooManyRequests { + backoffSeconds := Get429BackoffTime(response) + time.Sleep(time.Duration(backoffSeconds) * time.Second) + + return nil + } + + return nil +} + +func Get429BackoffTime(response *http.Response) int64 { + var limitResetMap []int + + for _, time := range response.Header["X-Rate-Limit-Reset"] { + timestamp, _ := strconv.Atoi(time) + limitResetMap = append(limitResetMap, timestamp) + } + + sort.Ints(limitResetMap) + + requestDate, _ := time.Parse("Mon, 02 Jan 2006 15:04:05 Z", response.Header.Get("Date")) + requestDateUnix := requestDate.Unix() + backoffSeconds := int64(limitResetMap[0]) - requestDateUnix + 1 + return backoffSeconds +} + +type Response struct { + *http.Response +} + +func newResponse(r *http.Response) *Response { + response := &Response{Response: r} + return response +} + +func CheckResponseForError(resp *http.Response) error { + statusCode := resp.StatusCode + if statusCode >= http.StatusOK && statusCode < http.StatusBadRequest { + return nil + } + + bodyBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + + e := new(Error) + json.Unmarshal(bodyBytes, &e) + return e + +} + +func buildResponse(resp *http.Response, v interface{}) (*Response, error) { + response := newResponse(resp) + + err := CheckResponseForError(resp) + if err != nil { + return response, err + } + + if v != nil { + decodeError := json.NewDecoder(resp.Body).Decode(v) + if decodeError == io.EOF { + decodeError = nil + } + if decodeError != nil { + err = decodeError + } + + } + return response, err +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/resetPasswordToken.go b/vendor/github.com/okta/okta-sdk-golang/okta/resetPasswordToken.go new file mode 100644 index 0000000000000..4a5d902f7b278 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/resetPasswordToken.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type ResetPasswordToken struct { + ResetPasswordUrl string `json:"resetPasswordUrl,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/role.go b/vendor/github.com/okta/okta-sdk-golang/okta/role.go new file mode 100644 index 0000000000000..1da63523cb606 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/role.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type Role struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + AssignmentType string `json:"assignmentType,omitempty"` + Created *time.Time `json:"created,omitempty"` + Description string `json:"description,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Status string `json:"status,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/roleStatus.go b/vendor/github.com/okta/okta-sdk-golang/okta/roleStatus.go new file mode 100644 index 0000000000000..dc1f71e201683 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/roleStatus.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type RoleStatus struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/samlApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/samlApplication.go new file mode 100644 index 0000000000000..370043155d4d3 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/samlApplication.go @@ -0,0 +1,52 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type SamlApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *ApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *SamlApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewSamlApplication() *SamlApplication { + return &SamlApplication{ + SignOnMode: "SAML_2_0", + } +} + +func (a *SamlApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettings.go new file mode 100644 index 0000000000000..c436d6bc4661b --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettings.go @@ -0,0 +1,37 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SamlApplicationSettings struct { + App *ApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` + SignOn *SamlApplicationSettingsSignOn `json:"signOn,omitempty"` +} + +func NewSamlApplicationSettings() *SamlApplicationSettings { + return &SamlApplicationSettings{} +} + +func (a *SamlApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettingsSignOn.go b/vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettingsSignOn.go new file mode 100644 index 0000000000000..6bec206844f00 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/samlApplicationSettingsSignOn.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SamlApplicationSettingsSignOn struct { + AssertionSigned *bool `json:"assertionSigned,omitempty"` + AttributeStatements []*SamlAttributeStatement `json:"attributeStatements,omitempty"` + Audience string `json:"audience,omitempty"` + AudienceOverride string `json:"audienceOverride,omitempty"` + AuthnContextClassRef string `json:"authnContextClassRef,omitempty"` + DefaultRelayState string `json:"defaultRelayState,omitempty"` + Destination string `json:"destination,omitempty"` + DestinationOverride string `json:"destinationOverride,omitempty"` + DigestAlgorithm string `json:"digestAlgorithm,omitempty"` + HonorForceAuthn *bool `json:"honorForceAuthn,omitempty"` + IdpIssuer string `json:"idpIssuer,omitempty"` + Recipient string `json:"recipient,omitempty"` + RecipientOverride string `json:"recipientOverride,omitempty"` + RequestCompressed *bool `json:"requestCompressed,omitempty"` + ResponseSigned *bool `json:"responseSigned,omitempty"` + SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"` + SpIssuer string `json:"spIssuer,omitempty"` + SsoAcsUrl string `json:"ssoAcsUrl,omitempty"` + SsoAcsUrlOverride string `json:"ssoAcsUrlOverride,omitempty"` + SubjectNameIdFormat string `json:"subjectNameIdFormat,omitempty"` + SubjectNameIdTemplate string `json:"subjectNameIdTemplate,omitempty"` +} + +func NewSamlApplicationSettingsSignOn() *SamlApplicationSettingsSignOn { + return &SamlApplicationSettingsSignOn{} +} + +func (a *SamlApplicationSettingsSignOn) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/samlAttributeStatement.go b/vendor/github.com/okta/okta-sdk-golang/okta/samlAttributeStatement.go new file mode 100644 index 0000000000000..3fde503f7f8d3 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/samlAttributeStatement.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SamlAttributeStatement struct { + Name string `json:"name,omitempty"` + Namespace string `json:"namespace,omitempty"` + Type string `json:"type,omitempty"` + Values []string `json:"values,omitempty"` +} + +func NewSamlAttributeStatement() *SamlAttributeStatement { + return &SamlAttributeStatement{} +} + +func (a *SamlAttributeStatement) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/schemeApplicationCredentials.go b/vendor/github.com/okta/okta-sdk-golang/okta/schemeApplicationCredentials.go new file mode 100644 index 0000000000000..e5c6bbff741b5 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/schemeApplicationCredentials.go @@ -0,0 +1,38 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SchemeApplicationCredentials struct { + Signing *ApplicationCredentialsSigning `json:"signing,omitempty"` + UserNameTemplate *ApplicationCredentialsUsernameTemplate `json:"userNameTemplate,omitempty"` + Password *PasswordCredential `json:"password,omitempty"` + RevealPassword *bool `json:"revealPassword,omitempty"` + Scheme string `json:"scheme,omitempty"` + UserName string `json:"userName,omitempty"` +} + +func NewSchemeApplicationCredentials() *SchemeApplicationCredentials { + return &SchemeApplicationCredentials{} +} + +func (a *SchemeApplicationCredentials) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplication.go new file mode 100644 index 0000000000000..0e8b1122dd615 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplication.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type SecurePasswordStoreApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *SchemeApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *SecurePasswordStoreApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewSecurePasswordStoreApplication() *SecurePasswordStoreApplication { + return &SecurePasswordStoreApplication{ + Name: "template_sps", + SignOnMode: "SECURE_PASSWORD_STORE", + } +} + +func (a *SecurePasswordStoreApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettings.go new file mode 100644 index 0000000000000..00758899b3bf7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettings.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SecurePasswordStoreApplicationSettings struct { + App *SecurePasswordStoreApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` +} + +func NewSecurePasswordStoreApplicationSettings() *SecurePasswordStoreApplicationSettings { + return &SecurePasswordStoreApplicationSettings{} +} + +func (a *SecurePasswordStoreApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettingsApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettingsApplication.go new file mode 100644 index 0000000000000..c82ea21be8ba4 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/securePasswordStoreApplicationSettingsApplication.go @@ -0,0 +1,41 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SecurePasswordStoreApplicationSettingsApplication struct { + OptionalField1 string `json:"optionalField1,omitempty"` + OptionalField1Value string `json:"optionalField1Value,omitempty"` + OptionalField2 string `json:"optionalField2,omitempty"` + OptionalField2Value string `json:"optionalField2Value,omitempty"` + OptionalField3 string `json:"optionalField3,omitempty"` + OptionalField3Value string `json:"optionalField3Value,omitempty"` + PasswordField string `json:"passwordField,omitempty"` + Url string `json:"url,omitempty"` + UsernameField string `json:"usernameField,omitempty"` +} + +func NewSecurePasswordStoreApplicationSettingsApplication() *SecurePasswordStoreApplicationSettingsApplication { + return &SecurePasswordStoreApplicationSettingsApplication{} +} + +func (a *SecurePasswordStoreApplicationSettingsApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestion.go b/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestion.go new file mode 100644 index 0000000000000..eab2c31c4daad --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestion.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SecurityQuestion struct { + Answer string `json:"answer,omitempty"` + Question string `json:"question,omitempty"` + QuestionText string `json:"questionText,omitempty"` +} + +func NewSecurityQuestion() *SecurityQuestion { + return &SecurityQuestion{} +} + +func (a *SecurityQuestion) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactor.go new file mode 100644 index 0000000000000..7a3247cfa8940 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SecurityQuestionFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *SecurityQuestionFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewSecurityQuestionFactor() *SecurityQuestionFactor { + return &SecurityQuestionFactor{ + FactorType: "question", + } +} + +func (a *SecurityQuestionFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactorProfile.go new file mode 100644 index 0000000000000..f20c19c98d388 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/securityQuestionFactorProfile.go @@ -0,0 +1,35 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SecurityQuestionFactorProfile struct { + Answer string `json:"answer,omitempty"` + Question string `json:"question,omitempty"` + QuestionText string `json:"questionText,omitempty"` +} + +func NewSecurityQuestionFactorProfile() *SecurityQuestionFactorProfile { + return &SecurityQuestionFactorProfile{} +} + +func (a *SecurityQuestionFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/session.go b/vendor/github.com/okta/okta-sdk-golang/okta/session.go new file mode 100644 index 0000000000000..456c0afc94f75 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/session.go @@ -0,0 +1,96 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "time" +) + +type SessionResource resource + +type Session struct { + Links interface{} `json:"_links,omitempty"` + Amr []*SessionAuthenticationMethod `json:"amr,omitempty"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + ExpiresAt *time.Time `json:"expiresAt,omitempty"` + Id string `json:"id,omitempty"` + Idp *SessionIdentityProvider `json:"idp,omitempty"` + LastFactorVerification *time.Time `json:"lastFactorVerification,omitempty"` + LastPasswordVerification *time.Time `json:"lastPasswordVerification,omitempty"` + Login string `json:"login,omitempty"` + Status string `json:"status,omitempty"` + UserId string `json:"userId,omitempty"` +} + +func (m *SessionResource) GetSession(sessionId string) (*Session, *Response, error) { + url := fmt.Sprintf("/api/v1/sessions/%v", sessionId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var session *Session + resp, err := m.client.requestExecutor.Do(req, &session) + if err != nil { + return nil, resp, err + } + return session, resp, nil +} +func (m *SessionResource) EndSession(sessionId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/sessions/%v", sessionId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *SessionResource) CreateSession(body CreateSessionRequest) (*Session, *Response, error) { + url := fmt.Sprintf("/api/v1/sessions") + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var session *Session + resp, err := m.client.requestExecutor.Do(req, &session) + if err != nil { + return nil, resp, err + } + return session, resp, nil +} +func (m *SessionResource) RefreshSession(sessionId string) (*Session, *Response, error) { + url := fmt.Sprintf("/api/v1/sessions/%v/lifecycle/refresh", sessionId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, nil, err + } + + var session *Session + resp, err := m.client.requestExecutor.Do(req, &session) + if err != nil { + return nil, resp, err + } + return session, resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/sessionAuthenticationMethod.go b/vendor/github.com/okta/okta-sdk-golang/okta/sessionAuthenticationMethod.go new file mode 100644 index 0000000000000..f5be5c63975cb --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/sessionAuthenticationMethod.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SessionAuthenticationMethod struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProvider.go b/vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProvider.go new file mode 100644 index 0000000000000..94af14884cc09 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProvider.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SessionIdentityProvider struct { + Id string `json:"id,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProviderType.go b/vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProviderType.go new file mode 100644 index 0000000000000..0c7dcc0d1e2e6 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/sessionIdentityProviderType.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SessionIdentityProviderType struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/sessionStatus.go b/vendor/github.com/okta/okta-sdk-golang/okta/sessionStatus.go new file mode 100644 index 0000000000000..61af14d725eb3 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/sessionStatus.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SessionStatus struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/smsFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/smsFactor.go new file mode 100644 index 0000000000000..dd307d9f03d6c --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/smsFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SmsFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *SmsFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewSmsFactor() *SmsFactor { + return &SmsFactor{ + FactorType: "sms", + } +} + +func (a *SmsFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/smsFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/smsFactorProfile.go new file mode 100644 index 0000000000000..c99064545ccd2 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/smsFactorProfile.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SmsFactorProfile struct { + PhoneNumber string `json:"phoneNumber,omitempty"` +} + +func NewSmsFactorProfile() *SmsFactorProfile { + return &SmsFactorProfile{} +} + +func (a *SmsFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/swaApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/swaApplication.go new file mode 100644 index 0000000000000..ce0670b578bc8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/swaApplication.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type SwaApplication struct { + Credentials *ApplicationCredentials `json:"credentials,omitempty"` + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *SwaApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewSwaApplication() *SwaApplication { + return &SwaApplication{ + Name: "template_swa", + SignOnMode: "BROWSER_PLUGIN", + } +} + +func (a *SwaApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettings.go new file mode 100644 index 0000000000000..43644ae8b0e7f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettings.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SwaApplicationSettings struct { + App *SwaApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` +} + +func NewSwaApplicationSettings() *SwaApplicationSettings { + return &SwaApplicationSettings{} +} + +func (a *SwaApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettingsApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettingsApplication.go new file mode 100644 index 0000000000000..ace7b7e213ddc --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/swaApplicationSettingsApplication.go @@ -0,0 +1,37 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SwaApplicationSettingsApplication struct { + ButtonField string `json:"buttonField,omitempty"` + LoginUrlRegex string `json:"loginUrlRegex,omitempty"` + PasswordField string `json:"passwordField,omitempty"` + Url string `json:"url,omitempty"` + UsernameField string `json:"usernameField,omitempty"` +} + +func NewSwaApplicationSettingsApplication() *SwaApplicationSettingsApplication { + return &SwaApplicationSettingsApplication{} +} + +func (a *SwaApplicationSettingsApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplication.go new file mode 100644 index 0000000000000..a21a052d78192 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplication.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type SwaThreeFieldApplication struct { + Credentials *ApplicationCredentials `json:"credentials,omitempty"` + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *SwaThreeFieldApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewSwaThreeFieldApplication() *SwaThreeFieldApplication { + return &SwaThreeFieldApplication{ + Name: "template_swa3field", + SignOnMode: "BROWSER_PLUGIN", + } +} + +func (a *SwaThreeFieldApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettings.go new file mode 100644 index 0000000000000..6651ef6ccd77a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettings.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SwaThreeFieldApplicationSettings struct { + App *SwaThreeFieldApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` +} + +func NewSwaThreeFieldApplicationSettings() *SwaThreeFieldApplicationSettings { + return &SwaThreeFieldApplicationSettings{} +} + +func (a *SwaThreeFieldApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettingsApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettingsApplication.go new file mode 100644 index 0000000000000..fb50b719c0da7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/swaThreeFieldApplicationSettingsApplication.go @@ -0,0 +1,39 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type SwaThreeFieldApplicationSettingsApplication struct { + ButtonSelector string `json:"buttonSelector,omitempty"` + ExtraFieldSelector string `json:"extraFieldSelector,omitempty"` + ExtraFieldValue string `json:"extraFieldValue,omitempty"` + LoginUrlRegex string `json:"loginUrlRegex,omitempty"` + PasswordSelector string `json:"passwordSelector,omitempty"` + TargetUrl string `json:"targetUrl,omitempty"` + UserNameSelector string `json:"userNameSelector,omitempty"` +} + +func NewSwaThreeFieldApplicationSettingsApplication() *SwaThreeFieldApplicationSettingsApplication { + return &SwaThreeFieldApplicationSettingsApplication{} +} + +func (a *SwaThreeFieldApplicationSettingsApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/tempPassword.go b/vendor/github.com/okta/okta-sdk-golang/okta/tempPassword.go new file mode 100644 index 0000000000000..1083b244befe5 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/tempPassword.go @@ -0,0 +1,25 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type TempPassword struct { + TempPassword string `json:"tempPassword,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/tokenFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/tokenFactor.go new file mode 100644 index 0000000000000..079d2a6a37426 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/tokenFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type TokenFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *TokenFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewTokenFactor() *TokenFactor { + return &TokenFactor{ + FactorType: "token", + } +} + +func (a *TokenFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/tokenFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/tokenFactorProfile.go new file mode 100644 index 0000000000000..44fbacd78b8d8 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/tokenFactorProfile.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type TokenFactorProfile struct { + CredentialId string `json:"credentialId,omitempty"` +} + +func NewTokenFactorProfile() *TokenFactorProfile { + return &TokenFactorProfile{} +} + +func (a *TokenFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/totpFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/totpFactor.go new file mode 100644 index 0000000000000..458b276cf7e01 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/totpFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type TotpFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *TotpFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewTotpFactor() *TotpFactor { + return &TotpFactor{ + FactorType: "token:software:totp", + } +} + +func (a *TotpFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/totpFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/totpFactorProfile.go new file mode 100644 index 0000000000000..5b6c8246941bf --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/totpFactorProfile.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type TotpFactorProfile struct { + CredentialId string `json:"credentialId,omitempty"` +} + +func NewTotpFactorProfile() *TotpFactorProfile { + return &TotpFactorProfile{} +} + +func (a *TotpFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/u2fFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/u2fFactor.go new file mode 100644 index 0000000000000..a53255feeb4a7 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/u2fFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type U2fFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *U2fFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewU2fFactor() *U2fFactor { + return &U2fFactor{ + FactorType: "u2f", + } +} + +func (a *U2fFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/u2fFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/u2fFactorProfile.go new file mode 100644 index 0000000000000..f7c029b1d1ad9 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/u2fFactorProfile.go @@ -0,0 +1,32 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type U2fFactorProfile struct { +} + +func NewU2fFactorProfile() *U2fFactorProfile { + return &U2fFactorProfile{} +} + +func (a *U2fFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/user.go b/vendor/github.com/okta/okta-sdk-golang/okta/user.go new file mode 100644 index 0000000000000..b362bcf0e1f9a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/user.go @@ -0,0 +1,429 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "fmt" + "github.com/okta/okta-sdk-golang/okta/query" + "time" +) + +type UserResource resource + +type User struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Activated *time.Time `json:"activated,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *UserCredentials `json:"credentials,omitempty"` + Id string `json:"id,omitempty"` + LastLogin *time.Time `json:"lastLogin,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + PasswordChanged *time.Time `json:"passwordChanged,omitempty"` + Profile *UserProfile `json:"profile,omitempty"` + Status string `json:"status,omitempty"` + StatusChanged *time.Time `json:"statusChanged,omitempty"` + TransitioningToStatus string `json:"transitioningToStatus,omitempty"` +} + +func (m *UserResource) CreateUser(body User, qp *query.Params) (*User, *Response, error) { + url := fmt.Sprintf("/api/v1/users") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var user *User + resp, err := m.client.requestExecutor.Do(req, &user) + if err != nil { + return nil, resp, err + } + return user, resp, nil +} +func (m *UserResource) GetUser(userId string) (*User, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v", userId) + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var user *User + resp, err := m.client.requestExecutor.Do(req, &user) + if err != nil { + return nil, resp, err + } + return user, resp, nil +} +func (m *UserResource) UpdateUser(userId string, body User, qp *query.Params) (*User, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("PUT", url, body) + if err != nil { + return nil, nil, err + } + + var user *User + resp, err := m.client.requestExecutor.Do(req, &user) + if err != nil { + return nil, resp, err + } + return user, resp, nil +} +func (m *UserResource) DeactivateOrDeleteUser(userId string, qp *query.Params) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) ListUsers(qp *query.Params) ([]*User, *Response, error) { + url := fmt.Sprintf("/api/v1/users") + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var user []*User + resp, err := m.client.requestExecutor.Do(req, &user) + if err != nil { + return nil, resp, err + } + return user, resp, nil +} +func (m *UserResource) ListAppLinks(userId string, qp *query.Params) ([]*AppLink, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/appLinks", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var appLink []*AppLink + resp, err := m.client.requestExecutor.Do(req, &appLink) + if err != nil { + return nil, resp, err + } + return appLink, resp, nil +} +func (m *UserResource) ChangePassword(userId string, body ChangePasswordRequest, qp *query.Params) (*UserCredentials, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/credentials/change_password", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var userCredentials *UserCredentials + resp, err := m.client.requestExecutor.Do(req, &userCredentials) + if err != nil { + return nil, resp, err + } + return userCredentials, resp, nil +} +func (m *UserResource) ChangeRecoveryQuestion(userId string, body UserCredentials) (*UserCredentials, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/credentials/change_recovery_question", userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var userCredentials *UserCredentials + resp, err := m.client.requestExecutor.Do(req, &userCredentials) + if err != nil { + return nil, resp, err + } + return userCredentials, resp, nil +} +func (m *UserResource) ForgotPassword(userId string, body UserCredentials, qp *query.Params) (*ForgotPasswordResponse, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/credentials/forgot_password", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var forgotPasswordResponse *ForgotPasswordResponse + resp, err := m.client.requestExecutor.Do(req, &forgotPasswordResponse) + if err != nil { + return nil, resp, err + } + return forgotPasswordResponse, resp, nil +} +func (m *UserResource) ListUserGroups(userId string, qp *query.Params) ([]*Group, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/groups", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var group []*Group + resp, err := m.client.requestExecutor.Do(req, &group) + if err != nil { + return nil, resp, err + } + return group, resp, nil +} +func (m *UserResource) ActivateUser(userId string, qp *query.Params) (*UserActivationToken, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/activate", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, nil, err + } + + var userActivationToken *UserActivationToken + resp, err := m.client.requestExecutor.Do(req, &userActivationToken) + if err != nil { + return nil, resp, err + } + return userActivationToken, resp, nil +} +func (m *UserResource) DeactivateUser(userId string, qp *query.Params) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/deactivate", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) ExpirePassword(userId string, qp *query.Params) (*TempPassword, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/expire_password", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, nil, err + } + + var tempPassword *TempPassword + resp, err := m.client.requestExecutor.Do(req, &tempPassword) + if err != nil { + return nil, resp, err + } + return tempPassword, resp, nil +} +func (m *UserResource) ResetAllFactors(userId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/reset_factors", userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) ResetPassword(userId string, qp *query.Params) (*ResetPasswordToken, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/reset_password", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, nil, err + } + + var resetPasswordToken *ResetPasswordToken + resp, err := m.client.requestExecutor.Do(req, &resetPasswordToken) + if err != nil { + return nil, resp, err + } + return resetPasswordToken, resp, nil +} +func (m *UserResource) SuspendUser(userId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/suspend", userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) UnlockUser(userId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/unlock", userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) UnsuspendUser(userId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/lifecycle/unsuspend", userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) ListAssignedRoles(userId string, qp *query.Params) ([]*Role, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/roles", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var role []*Role + resp, err := m.client.requestExecutor.Do(req, &role) + if err != nil { + return nil, resp, err + } + return role, resp, nil +} +func (m *UserResource) AddRoleToUser(userId string, body Role) (*Role, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/roles", userId) + req, err := m.client.requestExecutor.NewRequest("POST", url, body) + if err != nil { + return nil, nil, err + } + + var role *Role + resp, err := m.client.requestExecutor.Do(req, &role) + if err != nil { + return nil, resp, err + } + return role, resp, nil +} +func (m *UserResource) RemoveRoleFromUser(userId string, roleId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/roles/%v", userId, roleId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) ListGroupTargetsForRole(userId string, roleId string, qp *query.Params) ([]*Group, *Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/roles/%v/targets/groups", userId, roleId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + var group []*Group + resp, err := m.client.requestExecutor.Do(req, &group) + if err != nil { + return nil, resp, err + } + return group, resp, nil +} +func (m *UserResource) RemoveGroupTargetFromRole(userId string, roleId string, groupId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/roles/%v/targets/groups/%v", userId, roleId, groupId) + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) AddGroupTargetToRole(userId string, roleId string, groupId string) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/roles/%v/targets/groups/%v", userId, roleId, groupId) + req, err := m.client.requestExecutor.NewRequest("PUT", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} +func (m *UserResource) EndAllUserSessions(userId string, qp *query.Params) (*Response, error) { + url := fmt.Sprintf("/api/v1/users/%v/sessions", userId) + if qp != nil { + url = url + qp.String() + } + req, err := m.client.requestExecutor.NewRequest("DELETE", url, nil) + if err != nil { + return nil, err + } + + resp, err := m.client.requestExecutor.Do(req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/userActivationToken.go b/vendor/github.com/okta/okta-sdk-golang/okta/userActivationToken.go new file mode 100644 index 0000000000000..b94110f749e6f --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/userActivationToken.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type UserActivationToken struct { + ActivationToken string `json:"activationToken,omitempty"` + ActivationUrl string `json:"activationUrl,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/userAgent.go b/vendor/github.com/okta/okta-sdk-golang/okta/userAgent.go new file mode 100644 index 0000000000000..a5da9856b7f41 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/userAgent.go @@ -0,0 +1,52 @@ +/* + * Copyright 2018 - Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package okta + +import "runtime" + +type UserAgent struct { + goVersion string + + osName string + + osVersion string + + config *config +} + +func NewUserAgent(config *config) UserAgent { + ua := UserAgent{} + ua.config = config + ua.goVersion = runtime.Version() + ua.osName = runtime.GOOS + ua.osVersion = runtime.GOARCH + + return ua + +} + +func (ua UserAgent) String() string { + userAgentString := "okta-sdk-golang/" + Version + " " + userAgentString += "golang/" + ua.goVersion + " " + userAgentString += ua.osName + "/" + ua.osVersion + " " + + if ua.config.UserAgentExtra != "" { + userAgentString += ua.config.UserAgentExtra + " " + } + + return userAgentString +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/userCondition.go b/vendor/github.com/okta/okta-sdk-golang/okta/userCondition.go new file mode 100644 index 0000000000000..1983b27cc3784 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/userCondition.go @@ -0,0 +1,26 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type UserCondition struct { + Exclude []string `json:"exclude,omitempty"` + Include []string `json:"include,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/userCredentials.go b/vendor/github.com/okta/okta-sdk-golang/okta/userCredentials.go new file mode 100644 index 0000000000000..8713220734f61 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/userCredentials.go @@ -0,0 +1,28 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type UserCredentials struct { + Emails []*EmailAddress `json:"emails,omitempty"` + Password *PasswordCredential `json:"password,omitempty"` + Provider *AuthenticationProvider `json:"provider,omitempty"` + RecoveryQuestion *RecoveryQuestionCredential `json:"recovery_question,omitempty"` +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/userNextLogin.go b/vendor/github.com/okta/okta-sdk-golang/okta/userNextLogin.go new file mode 100644 index 0000000000000..8a8e51ea61461 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/userNextLogin.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type UserNextLogin struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/userProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/userProfile.go new file mode 100644 index 0000000000000..c67fc346dadf3 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/userProfile.go @@ -0,0 +1,21 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +type UserProfile map[string]interface{} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/userStatus.go b/vendor/github.com/okta/okta-sdk-golang/okta/userStatus.go new file mode 100644 index 0000000000000..107c281c754f4 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/userStatus.go @@ -0,0 +1,24 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type UserStatus struct { +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/validator.go b/vendor/github.com/okta/okta-sdk-golang/okta/validator.go new file mode 100644 index 0000000000000..1f3106567a89e --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/validator.go @@ -0,0 +1,60 @@ +package okta + +import ( + "errors" + "strings" +) + +func ValidateConfig(c *config) (*config, error) { + var err error + + err = ValidateOktaDomain(c) + if err != nil { + return nil, err + } + + err = ValidateApiToken(c) + if err != nil { + return nil, err + } + + return c, nil +} + +func ValidateOktaDomain(c *config) error { + if c.Okta.Client.OrgUrl == "" { + return errors.New("your Okta URL is missing. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain") + } + + if strings.Contains(c.Okta.Client.OrgUrl, "{yourOktaDomain}") { + return errors.New("replace {yourOktaDomain} with your Okta domain. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain") + } + + if strings.Contains(c.Okta.Client.OrgUrl, "-admin.okta.com") || + strings.Contains(c.Okta.Client.OrgUrl, "-admin.oktapreview.com") || + strings.Contains(c.Okta.Client.OrgUrl, "-admin.okta-emea.com") { + return errors.New("your Okta domain should not contain -admin. Current value: " + c.Okta.Client.OrgUrl + ". You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain") + } + + if strings.HasSuffix(c.Okta.Client.OrgUrl, ".com.com") { + return errors.New("it looks like there's a typo in your Okta domain. Current value: " + c.Okta.Client.OrgUrl + ". You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain") + } + + if c.Okta.Testing.DisableHttpsCheck == false { + if strings.HasPrefix(c.Okta.Client.OrgUrl, "https://") != true { + return errors.New("your Okta URL must start with https. Current value: " + c.Okta.Client.OrgUrl + ". You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain") + } + } + return nil +} + +func ValidateApiToken(c *config) error { + if c.Okta.Client.Token == "" { + return errors.New("your Okta API token is missing. You can generate one in the Okta Developer Console. Follow these instructions: https://bit.ly/get-okta-api-token") + } + + if strings.Contains(c.Okta.Client.Token, "{apiToken}") { + return errors.New("replace {apiToken} with your Okta API token. You can generate one in the Okta Developer Console. Follow these instructions: https://bit.ly/get-okta-api-token") + } + return nil +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorRequest.go b/vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorRequest.go new file mode 100644 index 0000000000000..902f62a9d2de0 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorRequest.go @@ -0,0 +1,37 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type VerifyFactorRequest struct { + ActivationToken string `json:"activationToken,omitempty"` + Answer string `json:"answer,omitempty"` + NextPassCode string `json:"nextPassCode,omitempty"` + PassCode string `json:"passCode,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` +} + +func NewVerifyFactorRequest() *VerifyFactorRequest { + return &VerifyFactorRequest{} +} + +func (a *VerifyFactorRequest) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorResponse.go b/vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorResponse.go new file mode 100644 index 0000000000000..7210c9f1f8fc9 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/verifyFactorResponse.go @@ -0,0 +1,39 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type VerifyFactorResponse struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + ExpiresAt *time.Time `json:"expiresAt,omitempty"` + FactorResult string `json:"factorResult,omitempty"` + FactorResultMessage string `json:"factorResultMessage,omitempty"` +} + +func NewVerifyFactorResponse() *VerifyFactorResponse { + return &VerifyFactorResponse{} +} + +func (a *VerifyFactorResponse) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/webFactor.go b/vendor/github.com/okta/okta-sdk-golang/okta/webFactor.go new file mode 100644 index 0000000000000..97707938a0007 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/webFactor.go @@ -0,0 +1,49 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type WebFactor struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Device string `json:"device,omitempty"` + DeviceType string `json:"deviceType,omitempty"` + FactorType string `json:"factorType,omitempty"` + Id string `json:"id,omitempty"` + MfaStateTokenId string `json:"mfaStateTokenId,omitempty"` + Profile *WebFactorProfile `json:"profile,omitempty"` + Provider string `json:"provider,omitempty"` + RechallengeExistingFactor *bool `json:"rechallengeExistingFactor,omitempty"` + SessionId string `json:"sessionId,omitempty"` + Status string `json:"status,omitempty"` + TokenLifetimeSeconds int64 `json:"tokenLifetimeSeconds,omitempty"` + UserId string `json:"userId,omitempty"` + Verify *VerifyFactorRequest `json:"verify,omitempty"` +} + +func NewWebFactor() *WebFactor { + return &WebFactor{ + FactorType: "web", + } +} + +func (a *WebFactor) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/webFactorProfile.go b/vendor/github.com/okta/okta-sdk-golang/okta/webFactorProfile.go new file mode 100644 index 0000000000000..4a9c0220b4431 --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/webFactorProfile.go @@ -0,0 +1,33 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type WebFactorProfile struct { + CredentialId string `json:"credentialId,omitempty"` +} + +func NewWebFactorProfile() *WebFactorProfile { + return &WebFactorProfile{} +} + +func (a *WebFactorProfile) IsUserFactorInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplication.go new file mode 100644 index 0000000000000..1907fcc05cabc --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplication.go @@ -0,0 +1,53 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import ( + "time" +) + +type WsFederationApplication struct { + Embedded interface{} `json:"_embedded,omitempty"` + Links interface{} `json:"_links,omitempty"` + Accessibility *ApplicationAccessibility `json:"accessibility,omitempty"` + Created *time.Time `json:"created,omitempty"` + Credentials *ApplicationCredentials `json:"credentials,omitempty"` + Features []string `json:"features,omitempty"` + Id string `json:"id,omitempty"` + Label string `json:"label,omitempty"` + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + Licensing *ApplicationLicensing `json:"licensing,omitempty"` + Name string `json:"name,omitempty"` + Profile interface{} `json:"profile,omitempty"` + Settings *WsFederationApplicationSettings `json:"settings,omitempty"` + SignOnMode string `json:"signOnMode,omitempty"` + Status string `json:"status,omitempty"` + Visibility *ApplicationVisibility `json:"visibility,omitempty"` +} + +func NewWsFederationApplication() *WsFederationApplication { + return &WsFederationApplication{ + Name: "template_wsfed", + SignOnMode: "WS_FEDERATION", + } +} + +func (a *WsFederationApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettings.go b/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettings.go new file mode 100644 index 0000000000000..e7b024619d5da --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettings.go @@ -0,0 +1,36 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type WsFederationApplicationSettings struct { + App *WsFederationApplicationSettingsApplication `json:"app,omitempty"` + ImplicitAssignment *bool `json:"implicitAssignment,omitempty"` + InlineHookId string `json:"inlineHookId,omitempty"` + Notifications *ApplicationSettingsNotifications `json:"notifications,omitempty"` +} + +func NewWsFederationApplicationSettings() *WsFederationApplicationSettings { + return &WsFederationApplicationSettings{} +} + +func (a *WsFederationApplicationSettings) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettingsApplication.go b/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettingsApplication.go new file mode 100644 index 0000000000000..357223c57b45a --- /dev/null +++ b/vendor/github.com/okta/okta-sdk-golang/okta/wsFederationApplicationSettingsApplication.go @@ -0,0 +1,44 @@ +/* +* Copyright 2018 - Present Okta, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ + +// AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY + +package okta + +import () + +type WsFederationApplicationSettingsApplication struct { + AttributeStatements string `json:"attributeStatements,omitempty"` + AudienceRestriction string `json:"audienceRestriction,omitempty"` + AuthnContextClassRef string `json:"authnContextClassRef,omitempty"` + GroupFilter string `json:"groupFilter,omitempty"` + GroupName string `json:"groupName,omitempty"` + GroupValueFormat string `json:"groupValueFormat,omitempty"` + NameIDFormat string `json:"nameIDFormat,omitempty"` + Realm string `json:"realm,omitempty"` + SiteURL string `json:"siteURL,omitempty"` + UsernameAttribute string `json:"usernameAttribute,omitempty"` + WReplyOverride *bool `json:"wReplyOverride,omitempty"` + WReplyURL string `json:"wReplyURL,omitempty"` +} + +func NewWsFederationApplicationSettingsApplication() *WsFederationApplicationSettingsApplication { + return &WsFederationApplicationSettingsApplication{} +} + +func (a *WsFederationApplicationSettingsApplication) IsApplicationInstance() bool { + return true +} diff --git a/vendor/github.com/ory/dockertest/docker/pkg/archive/example_changes.go b/vendor/github.com/ory/dockertest/docker/pkg/archive/example_changes.go new file mode 100644 index 0000000000000..d840f5a7ddc7b --- /dev/null +++ b/vendor/github.com/ory/dockertest/docker/pkg/archive/example_changes.go @@ -0,0 +1,97 @@ +// +build ignore + +// Simple tool to create an archive stream from an old and new directory +// +// By default it will stream the comparison of two temporary directories with junk files +package main + +import ( + "flag" + "fmt" + "io" + "io/ioutil" + "os" + "path" + + "github.com/ory/dockertest/docker/pkg/archive" + "github.com/sirupsen/logrus" +) + +var ( + flDebug = flag.Bool("D", false, "debugging output") + flNewDir = flag.String("newdir", "", "") + flOldDir = flag.String("olddir", "", "") + log = logrus.New() +) + +func main() { + flag.Usage = func() { + fmt.Println("Produce a tar from comparing two directory paths. By default a demo tar is created of around 200 files (including hardlinks)") + fmt.Printf("%s [OPTIONS]\n", os.Args[0]) + flag.PrintDefaults() + } + flag.Parse() + log.Out = os.Stderr + if (len(os.Getenv("DEBUG")) > 0) || *flDebug { + logrus.SetLevel(logrus.DebugLevel) + } + var newDir, oldDir string + + if len(*flNewDir) == 0 { + var err error + newDir, err = ioutil.TempDir("", "docker-test-newDir") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(newDir) + if _, err := prepareUntarSourceDirectory(100, newDir, true); err != nil { + log.Fatal(err) + } + } else { + newDir = *flNewDir + } + + if len(*flOldDir) == 0 { + oldDir, err := ioutil.TempDir("", "docker-test-oldDir") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(oldDir) + } else { + oldDir = *flOldDir + } + + changes, err := archive.ChangesDirs(newDir, oldDir) + if err != nil { + log.Fatal(err) + } + + a, err := archive.ExportChanges(newDir, changes) + if err != nil { + log.Fatal(err) + } + defer a.Close() + + i, err := io.Copy(os.Stdout, a) + if err != nil && err != io.EOF { + log.Fatal(err) + } + fmt.Fprintf(os.Stderr, "wrote archive of %d bytes", i) +} + +func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks bool) (int, error) { + fileData := []byte("fooo") + for n := 0; n < numberOfFiles; n++ { + fileName := fmt.Sprintf("file-%d", n) + if err := ioutil.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil { + return 0, err + } + if makeLinks { + if err := os.Link(path.Join(targetPath, fileName), path.Join(targetPath, fileName+"-link")); err != nil { + return 0, err + } + } + } + totalSize := numberOfFiles * len(fileData) + return totalSize, nil +} diff --git a/vendor/github.com/shirou/gopsutil/disk/types_freebsd.go b/vendor/github.com/shirou/gopsutil/disk/types_freebsd.go new file mode 100644 index 0000000000000..dd6ddc4f72867 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/disk/types_freebsd.go @@ -0,0 +1,88 @@ +// +build ignore +// Hand writing: _Ctype_struct___0 + +/* +Input to cgo -godefs. + +*/ + +package disk + +/* +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +// because statinfo has long double snap_time, redefine with changing long long +struct statinfo2 { + long cp_time[CPUSTATES]; + long tk_nin; + long tk_nout; + struct devinfo *dinfo; + long long snap_time; +}; +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong + sizeofLongDouble = C.sizeof_longlong + + DEVSTAT_NO_DATA = 0x00 + DEVSTAT_READ = 0x01 + DEVSTAT_WRITE = 0x02 + DEVSTAT_FREE = 0x03 + + // from sys/mount.h + MNT_RDONLY = 0x00000001 /* read only filesystem */ + MNT_SYNCHRONOUS = 0x00000002 /* filesystem written synchronously */ + MNT_NOEXEC = 0x00000004 /* can't exec from filesystem */ + MNT_NOSUID = 0x00000008 /* don't honor setuid bits on fs */ + MNT_UNION = 0x00000020 /* union with underlying filesystem */ + MNT_ASYNC = 0x00000040 /* filesystem written asynchronously */ + MNT_SUIDDIR = 0x00100000 /* special handling of SUID on dirs */ + MNT_SOFTDEP = 0x00200000 /* soft updates being done */ + MNT_NOSYMFOLLOW = 0x00400000 /* do not follow symlinks */ + MNT_GJOURNAL = 0x02000000 /* GEOM journal support enabled */ + MNT_MULTILABEL = 0x04000000 /* MAC support for individual objects */ + MNT_ACLS = 0x08000000 /* ACL support enabled */ + MNT_NOATIME = 0x10000000 /* disable update of file access time */ + MNT_NOCLUSTERR = 0x40000000 /* disable cluster read */ + MNT_NOCLUSTERW = 0x80000000 /* disable cluster write */ + MNT_NFS4ACLS = 0x00000010 + + MNT_WAIT = 1 /* synchronously wait for I/O to complete */ + MNT_NOWAIT = 2 /* start all I/O, but do not wait for it */ + MNT_LAZY = 3 /* push data not written by filesystem syncer */ + MNT_SUSPEND = 4 /* Suspend file system after sync */ +) + +const ( + sizeOfDevstat = C.sizeof_struct_devstat +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong + _C_long_double C.longlong +) + +type Statfs C.struct_statfs +type Fsid C.struct_fsid + +type Devstat C.struct_devstat +type Bintime C.struct_bintime diff --git a/vendor/github.com/shirou/gopsutil/disk/types_openbsd.go b/vendor/github.com/shirou/gopsutil/disk/types_openbsd.go new file mode 100644 index 0000000000000..1e3ddef5cfb49 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/disk/types_openbsd.go @@ -0,0 +1,70 @@ +// +build ignore +// Hand writing: _Ctype_struct___0 + +/* +Input to cgo -godefs. +*/ + +package disk + +/* +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong + sizeofLongDouble = C.sizeof_longlong + + DEVSTAT_NO_DATA = 0x00 + DEVSTAT_READ = 0x01 + DEVSTAT_WRITE = 0x02 + DEVSTAT_FREE = 0x03 + + // from sys/mount.h + MNT_RDONLY = 0x00000001 /* read only filesystem */ + MNT_SYNCHRONOUS = 0x00000002 /* filesystem written synchronously */ + MNT_NOEXEC = 0x00000004 /* can't exec from filesystem */ + MNT_NOSUID = 0x00000008 /* don't honor setuid bits on fs */ + MNT_NODEV = 0x00000010 /* don't interpret special files */ + MNT_ASYNC = 0x00000040 /* filesystem written asynchronously */ + + MNT_WAIT = 1 /* synchronously wait for I/O to complete */ + MNT_NOWAIT = 2 /* start all I/O, but do not wait for it */ + MNT_LAZY = 3 /* push data not written by filesystem syncer */ +) + +const ( + sizeOfDiskstats = C.sizeof_struct_diskstats +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong + _C_long_double C.longlong +) + +type Statfs C.struct_statfs +type Diskstats C.struct_diskstats +type Fsid C.fsid_t +type Timeval C.struct_timeval + +type Diskstat C.struct_diskstat +type Bintime C.struct_bintime diff --git a/vendor/github.com/shirou/gopsutil/host/types_darwin.go b/vendor/github.com/shirou/gopsutil/host/types_darwin.go new file mode 100644 index 0000000000000..b8582278859b3 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/host/types_darwin.go @@ -0,0 +1,17 @@ +// +build ignore +// plus hand editing about timeval + +/* +Input to cgo -godefs. +*/ + +package host + +/* +#include +#include +*/ +import "C" + +type Utmpx C.struct_utmpx +type Timeval C.struct_timeval diff --git a/vendor/github.com/shirou/gopsutil/host/types_freebsd.go b/vendor/github.com/shirou/gopsutil/host/types_freebsd.go new file mode 100644 index 0000000000000..bbdce0c6a9f24 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/host/types_freebsd.go @@ -0,0 +1,44 @@ +// +build ignore + +/* +Input to cgo -godefs. +*/ + +package host + +/* +#define KERNEL +#include +#include +#include +#include "freebsd_headers/utxdb.h" + +enum { + sizeofPtr = sizeof(void*), +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong + sizeOfUtmpx = C.sizeof_struct_futx +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +type Utmp C.struct_utmp // for FreeBSD 9.0 compatibility +type Utmpx C.struct_futx diff --git a/vendor/github.com/shirou/gopsutil/host/types_linux.go b/vendor/github.com/shirou/gopsutil/host/types_linux.go new file mode 100644 index 0000000000000..8adecb6cfa9f7 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/host/types_linux.go @@ -0,0 +1,42 @@ +// +build ignore + +/* +Input to cgo -godefs. +*/ + +package host + +/* +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong + sizeOfUtmp = C.sizeof_struct_utmp +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +type utmp C.struct_utmp +type exit_status C.struct_exit_status +type timeval C.struct_timeval diff --git a/vendor/github.com/shirou/gopsutil/host/types_openbsd.go b/vendor/github.com/shirou/gopsutil/host/types_openbsd.go new file mode 100644 index 0000000000000..9ebb97ce52e94 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/host/types_openbsd.go @@ -0,0 +1,43 @@ +// +build ignore + +/* +Input to cgo -godefs. +*/ + +package host + +/* +#define KERNEL +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong + sizeOfUtmp = C.sizeof_struct_utmp +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +type Utmp C.struct_utmp +type Timeval C.struct_timeval diff --git a/vendor/github.com/shirou/gopsutil/mem/types_openbsd.go b/vendor/github.com/shirou/gopsutil/mem/types_openbsd.go new file mode 100644 index 0000000000000..83cb91a1964cc --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/mem/types_openbsd.go @@ -0,0 +1,34 @@ +// +build ignore + +/* +Input to cgo -godefs. +*/ + +package mem + +/* +#include +#include +#include +#include + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + CTLVm = 2 + CTLVfs = 10 + VmUvmexp = 4 // get uvmexp + VfsGeneric = 0 + VfsBcacheStat = 3 +) + +const ( + sizeOfUvmexp = C.sizeof_struct_uvmexp + sizeOfBcachestats = C.sizeof_struct_bcachestats +) + +type Uvmexp C.struct_uvmexp +type Bcachestats C.struct_bcachestats diff --git a/vendor/github.com/shirou/gopsutil/process/types_darwin.go b/vendor/github.com/shirou/gopsutil/process/types_darwin.go new file mode 100644 index 0000000000000..21216cd09a77a --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/process/types_darwin.go @@ -0,0 +1,160 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Hand Writing +// - all pointer in ExternProc to uint64 + +// +build ignore + +/* +Input to cgo -godefs. +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ +// +godefs map struct_ [16]byte /* in6_addr */ + +package process + +/* +#define __DARWIN_UNIX03 0 +#define KERNEL +#define _DARWIN_USE_64_BIT_INODE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +struct ucred_queue { + struct ucred *tqe_next; + struct ucred **tqe_prev; + TRACEBUF +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type UGid_t C.gid_t + +type KinfoProc C.struct_kinfo_proc + +type Eproc C.struct_eproc + +type Proc C.struct_proc + +type Session C.struct_session + +type ucred C.struct_ucred + +type Uucred C.struct__ucred + +type Upcred C.struct__pcred + +type Vmspace C.struct_vmspace + +type Sigacts C.struct_sigacts + +type ExternProc C.struct_extern_proc + +type Itimerval C.struct_itimerval + +type Vnode C.struct_vnode + +type Pgrp C.struct_pgrp + +type UserStruct C.struct_user + +type Au_session C.struct_au_session + +type Posix_cred C.struct_posix_cred + +type Label C.struct_label + +type AuditinfoAddr C.struct_auditinfo_addr +type AuMask C.struct_au_mask +type AuTidAddr C.struct_au_tid_addr + +// TAILQ(ucred) +type UcredQueue C.struct_ucred_queue diff --git a/vendor/github.com/shirou/gopsutil/process/types_freebsd.go b/vendor/github.com/shirou/gopsutil/process/types_freebsd.go new file mode 100644 index 0000000000000..aa7b3462de69c --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/process/types_freebsd.go @@ -0,0 +1,95 @@ +// +build ignore + +// We still need editing by hands. +// go tool cgo -godefs types_freebsd.go | sed 's/\*int64/int64/' | sed 's/\*byte/int64/' > process_freebsd_amd64.go + +/* +Input to cgo -godefs. +*/ + +// +godefs map struct_pargs int64 /* pargs */ +// +godefs map struct_proc int64 /* proc */ +// +godefs map struct_user int64 /* user */ +// +godefs map struct_vnode int64 /* vnode */ +// +godefs map struct_vnode int64 /* vnode */ +// +godefs map struct_filedesc int64 /* filedesc */ +// +godefs map struct_vmspace int64 /* vmspace */ +// +godefs map struct_pcb int64 /* pcb */ +// +godefs map struct_thread int64 /* thread */ +// +godefs map struct___sigset [16]byte /* sigset */ + +package process + +/* +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + CTLKern = 1 // "high kernel": proc, limits + KernProc = 14 // struct: process entries + KernProcPID = 1 // by process id + KernProcProc = 8 // only return procs + KernProcPathname = 12 // path to executable + KernProcArgs = 7 // get/set arguments/proctitle +) + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +const ( + sizeOfKinfoVmentry = C.sizeof_struct_kinfo_vmentry + sizeOfKinfoProc = C.sizeof_struct_kinfo_proc +) + +// from sys/proc.h +const ( + SIDL = 1 /* Process being created by fork. */ + SRUN = 2 /* Currently runnable. */ + SSLEEP = 3 /* Sleeping on an address. */ + SSTOP = 4 /* Process debugging or suspension. */ + SZOMB = 5 /* Awaiting collection by parent. */ + SWAIT = 6 /* Waiting for interrupt. */ + SLOCK = 7 /* Blocked on a lock. */ +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type KinfoProc C.struct_kinfo_proc + +type Priority C.struct_priority + +type KinfoVmentry C.struct_kinfo_vmentry diff --git a/vendor/github.com/shirou/gopsutil/process/types_openbsd.go b/vendor/github.com/shirou/gopsutil/process/types_openbsd.go new file mode 100644 index 0000000000000..09ac590288a45 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/process/types_openbsd.go @@ -0,0 +1,103 @@ +// +build ignore + +// We still need editing by hands. +// go tool cgo -godefs types_openbsd.go | sed 's/\*int64/int64/' | sed 's/\*byte/int64/' > process_openbsd_amd64.go + +/* +Input to cgo -godefs. +*/ + +// +godefs map struct_pargs int64 /* pargs */ +// +godefs map struct_proc int64 /* proc */ +// +godefs map struct_user int64 /* user */ +// +godefs map struct_vnode int64 /* vnode */ +// +godefs map struct_vnode int64 /* vnode */ +// +godefs map struct_filedesc int64 /* filedesc */ +// +godefs map struct_vmspace int64 /* vmspace */ +// +godefs map struct_pcb int64 /* pcb */ +// +godefs map struct_thread int64 /* thread */ +// +godefs map struct___sigset [16]byte /* sigset */ + +package process + +/* +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + CTLKern = 1 // "high kernel": proc, limits + KernProc = 66 // struct: process entries + KernProcAll = 0 + KernProcPID = 1 // by process id + KernProcProc = 8 // only return procs + KernProcPathname = 12 // path to executable + KernProcArgs = 55 // get/set arguments/proctitle + KernProcArgv = 1 + KernProcEnv = 3 +) + +const ( + ArgMax = 256 * 1024 // sys/syslimits.h:#define ARG_MAX +) + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +const ( + sizeOfKinfoVmentry = C.sizeof_struct_kinfo_vmentry + sizeOfKinfoProc = C.sizeof_struct_kinfo_proc +) + +// from sys/proc.h +const ( + SIDL = 1 /* Process being created by fork. */ + SRUN = 2 /* Currently runnable. */ + SSLEEP = 3 /* Sleeping on an address. */ + SSTOP = 4 /* Process debugging or suspension. */ + SZOMB = 5 /* Awaiting collection by parent. */ + SDEAD = 6 /* Thread is almost gone */ + SONPROC = 7 /* Thread is currently on a CPU. */ +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type KinfoProc C.struct_kinfo_proc + +type Priority C.struct_priority + +type KinfoVmentry C.struct_kinfo_vmentry diff --git a/vendor/github.com/ugorji/go/codec/xml.go b/vendor/github.com/ugorji/go/codec/xml.go new file mode 100644 index 0000000000000..19fc36caf3cc8 --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/xml.go @@ -0,0 +1,508 @@ +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// +build ignore + +package codec + +import "reflect" + +/* + +A strict Non-validating namespace-aware XML 1.0 parser and (en|de)coder. + +We are attempting this due to perceived issues with encoding/xml: + - Complicated. It tried to do too much, and is not as simple to use as json. + - Due to over-engineering, reflection is over-used AND performance suffers: + java is 6X faster:http://fabsk.eu/blog/category/informatique/dev/golang/ + even PYTHON performs better: http://outgoing.typepad.com/outgoing/2014/07/exploring-golang.html + +codec framework will offer the following benefits + - VASTLY improved performance (when using reflection-mode or codecgen) + - simplicity and consistency: with the rest of the supported formats + - all other benefits of codec framework (streaming, codegeneration, etc) + +codec is not a drop-in replacement for encoding/xml. +It is a replacement, based on the simplicity and performance of codec. +Look at it like JAXB for Go. + +Challenges: + - Need to output XML preamble, with all namespaces at the right location in the output. + - Each "end" block is dynamic, so we need to maintain a context-aware stack + - How to decide when to use an attribute VS an element + - How to handle chardata, attr, comment EXPLICITLY. + - Should it output fragments? + e.g. encoding a bool should just output true OR false, which is not well-formed XML. + +Extend the struct tag. See representative example: + type X struct { + ID uint8 `codec:"http://ugorji.net/x-namespace xid id,omitempty,toarray,attr,cdata"` + // format: [namespace-uri ][namespace-prefix ]local-name, ... + } + +Based on this, we encode + - fields as elements, BUT + encode as attributes if struct tag contains ",attr" and is a scalar (bool, number or string) + - text as entity-escaped text, BUT encode as CDATA if struct tag contains ",cdata". + +To handle namespaces: + - XMLHandle is denoted as being namespace-aware. + Consequently, we WILL use the ns:name pair to encode and decode if defined, else use the plain name. + - *Encoder and *Decoder know whether the Handle "prefers" namespaces. + - add *Encoder.getEncName(*structFieldInfo). + No one calls *structFieldInfo.indexForEncName directly anymore + - OR better yet: indexForEncName is namespace-aware, and helper.go is all namespace-aware + indexForEncName takes a parameter of the form namespace:local-name OR local-name + - add *Decoder.getStructFieldInfo(encName string) // encName here is either like abc, or h1:nsabc + by being a method on *Decoder, or maybe a method on the Handle itself. + No one accesses .encName anymore + - let encode.go and decode.go use these (for consistency) + - only problem exists for gen.go, where we create a big switch on encName. + Now, we also have to add a switch on strings.endsWith(kName, encNsName) + - gen.go will need to have many more methods, and then double-on the 2 switch loops like: + switch k { + case "abc" : x.abc() + case "def" : x.def() + default { + switch { + case !nsAware: panic(...) + case strings.endsWith(":abc"): x.abc() + case strings.endsWith(":def"): x.def() + default: panic(...) + } + } + } + +The structure below accommodates this: + + type typeInfo struct { + sfi []*structFieldInfo // sorted by encName + sfins // sorted by namespace + sfia // sorted, to have those with attributes at the top. Needed to write XML appropriately. + sfip // unsorted + } + type structFieldInfo struct { + encName + nsEncName + ns string + attr bool + cdata bool + } + +indexForEncName is now an internal helper function that takes a sorted array +(one of ti.sfins or ti.sfi). It is only used by *Encoder.getStructFieldInfo(...) + +There will be a separate parser from the builder. +The parser will have a method: next() xmlToken method. It has lookahead support, +so you can pop multiple tokens, make a determination, and push them back in the order popped. +This will be needed to determine whether we are "nakedly" decoding a container or not. +The stack will be implemented using a slice and push/pop happens at the [0] element. + +xmlToken has fields: + - type uint8: 0 | ElementStart | ElementEnd | AttrKey | AttrVal | Text + - value string + - ns string + +SEE: http://www.xml.com/pub/a/98/10/guide0.html?page=3#ENTDECL + +The following are skipped when parsing: + - External Entities (from external file) + - Notation Declaration e.g. + - Entity Declarations & References + - XML Declaration (assume UTF-8) + - XML Directive i.e. + - Other Declarations: Notation, etc. + - Comment + - Processing Instruction + - schema / DTD for validation: + We are not a VALIDATING parser. Validation is done elsewhere. + However, some parts of the DTD internal subset are used (SEE BELOW). + For Attribute List Declarations e.g. + + We considered using the ATTLIST to get "default" value, but not to validate the contents. (VETOED) + +The following XML features are supported + - Namespace + - Element + - Attribute + - cdata + - Unicode escape + +The following DTD (when as an internal sub-set) features are supported: + - Internal Entities e.g. + AND entities for the set: [<>&"'] + - Parameter entities e.g. + + +At decode time, a structure containing the following is kept + - namespace mapping + - default attribute values + - all internal entities (<>&"' and others written in the document) + +When decode starts, it parses XML namespace declarations and creates a map in the +xmlDecDriver. While parsing, that map continuously gets updated. +The only problem happens when a namespace declaration happens on the node that it defines. +e.g. +To handle this, each Element must be fully parsed at a time, +even if it amounts to multiple tokens which are returned one at a time on request. + +xmlns is a special attribute name. + - It is used to define namespaces, including the default + - It is never returned as an AttrKey or AttrVal. + *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.* + +Number, bool, null, mapKey, etc can all be decoded from any xmlToken. +This accommodates map[int]string for example. + +It should be possible to create a schema from the types, +or vice versa (generate types from schema with appropriate tags). +This is however out-of-scope from this parsing project. + +We should write all namespace information at the first point that it is referenced in the tree, +and use the mapping for all child nodes and attributes. This means that state is maintained +at a point in the tree. This also means that calls to Decode or MustDecode will reset some state. + +When decoding, it is important to keep track of entity references and default attribute values. +It seems these can only be stored in the DTD components. We should honor them when decoding. + +Configuration for XMLHandle will look like this: + + XMLHandle + DefaultNS string + // Encoding: + NS map[string]string // ns URI to key, used for encoding + // Decoding: in case ENTITY declared in external schema or dtd, store info needed here + Entities map[string]string // map of entity rep to character + + +During encode, if a namespace mapping is not defined for a namespace found on a struct, +then we create a mapping for it using nsN (where N is 1..1000000, and doesn't conflict +with any other namespace mapping). + +Note that different fields in a struct can have different namespaces. +However, all fields will default to the namespace on the _struct field (if defined). + +An XML document is a name, a map of attributes and a list of children. +Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example). +We have to "DecodeNaked" into something that resembles XML data. + +To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types: + type Name struct { // Preferred. Less allocations due to conversions. + Local string + Space string + } + type Element struct { + Name Name + Attrs map[Name]string + Children []interface{} // each child is either *Element or string + } +Only two "supporting" types are exposed for XML: Name and Element. + +// ------------------ + +We considered 'type Name string' where Name is like "Space Local" (space-separated). +We decided against it, because each creation of a name would lead to +double allocation (first convert []byte to string, then concatenate them into a string). +The benefit is that it is faster to read Attrs from a map. But given that Element is a value +object, we want to eschew methods and have public exposed variables. + +We also considered the following, where xml types were not value objects, and we used +intelligent accessor methods to extract information and for performance. +*** WE DECIDED AGAINST THIS. *** + type Attr struct { + Name Name + Value string + } + // Element is a ValueObject: There are no accessor methods. + // Make element self-contained. + type Element struct { + Name Name + attrsMap map[string]string // where key is "Space Local" + attrs []Attr + childrenT []string + childrenE []Element + childrenI []int // each child is a index into T or E. + } + func (x *Element) child(i) interface{} // returns string or *Element + +// ------------------ + +Per XML spec and our default handling, white space is always treated as +insignificant between elements, except in a text node. The xml:space='preserve' +attribute is ignored. + +**Note: there is no xml: namespace. The xml: attributes were defined before namespaces.** +**So treat them as just "directives" that should be interpreted to mean something**. + +On encoding, we support indenting aka prettifying markup in the same way we support it for json. + +A document or element can only be encoded/decoded from/to a struct. In this mode: + - struct name maps to element name (or tag-info from _struct field) + - fields are mapped to child elements or attributes + +A map is either encoded as attributes on current element, or as a set of child elements. +Maps are encoded as attributes iff their keys and values are primitives (number, bool, string). + +A list is encoded as a set of child elements. + +Primitives (number, bool, string) are encoded as an element, attribute or text +depending on the context. + +Extensions must encode themselves as a text string. + +Encoding is tough, specifically when encoding mappings, because we need to encode +as either attribute or element. To do this, we need to default to encoding as attributes, +and then let Encoder inform the Handle when to start encoding as nodes. +i.e. Encoder does something like: + + h.EncodeMapStart() + h.Encode(), h.Encode(), ... + h.EncodeMapNotAttrSignal() // this is not a bool, because it's a signal + h.Encode(), h.Encode(), ... + h.EncodeEnd() + +Only XMLHandle understands this, and will set itself to start encoding as elements. + +This support extends to maps. For example, if a struct field is a map, and it has +the struct tag signifying it should be attr, then all its fields are encoded as attributes. +e.g. + + type X struct { + M map[string]int `codec:"m,attr"` // encode keys as attributes named + } + +Question: + - if encoding a map, what if map keys have spaces in them??? + Then they cannot be attributes or child elements. Error. + +Options to consider adding later: + - For attribute values, normalize by trimming beginning and ending white space, + and converting every white space sequence to a single space. + - ATTLIST restrictions are enforced. + e.g. default value of xml:space, skipping xml:XYZ style attributes, etc. + - Consider supporting NON-STRICT mode (e.g. to handle HTML parsing). + Some elements e.g. br, hr, etc need not close and should be auto-closed + ... (see http://www.w3.org/TR/html4/loose.dtd) + An expansive set of entities are pre-defined. + - Have easy way to create a HTML parser: + add a HTML() method to XMLHandle, that will set Strict=false, specify AutoClose, + and add HTML Entities to the list. + - Support validating element/attribute XMLName before writing it. + Keep this behind a flag, which is set to false by default (for performance). + type XMLHandle struct { + CheckName bool + } + +Misc: + +ROADMAP (1 weeks): + - build encoder (1 day) + - build decoder (based off xmlParser) (1 day) + - implement xmlParser (2 days). + Look at encoding/xml for inspiration. + - integrate and TEST (1 days) + - write article and post it (1 day) + +// ---------- MORE NOTES FROM 2017-11-30 ------------ + +when parsing +- parse the attributes first +- then parse the nodes + +basically: +- if encoding a field: we use the field name for the wrapper +- if encoding a non-field, then just use the element type name + + map[string]string ==> abcval... or + val... OR + val1val2... <- PREFERED + []string ==> v1v2... + string v1 ==> v1 + bool true ==> true + float 1.0 ==> 1.0 + ... + + F1 map[string]string ==> abcval... OR + val... OR + val... <- PREFERED + F2 []string ==> v1v2... + F3 bool ==> true + ... + +- a scalar is encoded as: + (value) of type T ==> + (value) of field F ==> +- A kv-pair is encoded as: + (key,value) ==> OR + (key,value) of field F ==> OR +- A map or struct is just a list of kv-pairs +- A list is encoded as sequences of same node e.g. + + + value21 + value22 +- we may have to singularize the field name, when entering into xml, + and pluralize them when encoding. +- bi-directional encode->decode->encode is not a MUST. + even encoding/xml cannot decode correctly what was encoded: + + see https://play.golang.org/p/224V_nyhMS + func main() { + fmt.Println("Hello, playground") + v := []interface{}{"hello", 1, true, nil, time.Now()} + s, err := xml.Marshal(v) + fmt.Printf("err: %v, \ns: %s\n", err, s) + var v2 []interface{} + err = xml.Unmarshal(s, &v2) + fmt.Printf("err: %v, \nv2: %v\n", err, v2) + type T struct { + V []interface{} + } + v3 := T{V: v} + s, err = xml.Marshal(v3) + fmt.Printf("err: %v, \ns: %s\n", err, s) + var v4 T + err = xml.Unmarshal(s, &v4) + fmt.Printf("err: %v, \nv4: %v\n", err, v4) + } + Output: + err: , + s: hello1true + err: , + v2: [] + err: , + s: hello1true2009-11-10T23:00:00Z + err: , + v4: {[ ]} +- +*/ + +// ----------- PARSER ------------------- + +type xmlTokenType uint8 + +const ( + _ xmlTokenType = iota << 1 + xmlTokenElemStart + xmlTokenElemEnd + xmlTokenAttrKey + xmlTokenAttrVal + xmlTokenText +) + +type xmlToken struct { + Type xmlTokenType + Value string + Namespace string // blank for AttrVal and Text +} + +type xmlParser struct { + r decReader + toks []xmlToken // list of tokens. + ptr int // ptr into the toks slice + done bool // nothing else to parse. r now returns EOF. +} + +func (x *xmlParser) next() (t *xmlToken) { + // once x.done, or x.ptr == len(x.toks) == 0, then return nil (to signify finish) + if !x.done && len(x.toks) == 0 { + x.nextTag() + } + // parses one element at a time (into possible many tokens) + if x.ptr < len(x.toks) { + t = &(x.toks[x.ptr]) + x.ptr++ + if x.ptr == len(x.toks) { + x.ptr = 0 + x.toks = x.toks[:0] + } + } + return +} + +// nextTag will parses the next element and fill up toks. +// It set done flag if/once EOF is reached. +func (x *xmlParser) nextTag() { + // TODO: implement. +} + +// ----------- ENCODER ------------------- + +type xmlEncDriver struct { + e *Encoder + w encWriter + h *XMLHandle + b [64]byte // scratch + bs []byte // scratch + // s jsonStack + noBuiltInTypes +} + +// ----------- DECODER ------------------- + +type xmlDecDriver struct { + d *Decoder + h *XMLHandle + r decReader // *bytesDecReader decReader + ct valueType // container type. one of unset, array or map. + bstr [8]byte // scratch used for string \UXXX parsing + b [64]byte // scratch + + // wsSkipped bool // whitespace skipped + + // s jsonStack + + noBuiltInTypes +} + +// DecodeNaked will decode into an XMLNode + +// XMLName is a value object representing a namespace-aware NAME +type XMLName struct { + Local string + Space string +} + +// XMLNode represents a "union" of the different types of XML Nodes. +// Only one of fields (Text or *Element) is set. +type XMLNode struct { + Element *Element + Text string +} + +// XMLElement is a value object representing an fully-parsed XML element. +type XMLElement struct { + Name Name + Attrs map[XMLName]string + // Children is a list of child nodes, each being a *XMLElement or string + Children []XMLNode +} + +// ----------- HANDLE ------------------- + +type XMLHandle struct { + BasicHandle + textEncodingType + + DefaultNS string + NS map[string]string // ns URI to key, for encoding + Entities map[string]string // entity representation to string, for encoding. +} + +func (h *XMLHandle) newEncDriver(e *Encoder) encDriver { + return &xmlEncDriver{e: e, w: e.w, h: h} +} + +func (h *XMLHandle) newDecDriver(d *Decoder) decDriver { + // d := xmlDecDriver{r: r.(*bytesDecReader), h: h} + hd := xmlDecDriver{d: d, r: d.r, h: h} + hd.n.bytes = d.b[:] + return &hd +} + +func (h *XMLHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { + return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) +} + +var _ decDriver = (*xmlDecDriver)(nil) +var _ encDriver = (*xmlEncDriver)(nil) diff --git a/vendor/github.com/ulikunitz/xz/example.go b/vendor/github.com/ulikunitz/xz/example.go new file mode 100644 index 0000000000000..855e60aee55e8 --- /dev/null +++ b/vendor/github.com/ulikunitz/xz/example.go @@ -0,0 +1,40 @@ +// Copyright 2014-2017 Ulrich Kunitz. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package main + +import ( + "bytes" + "io" + "log" + "os" + + "github.com/ulikunitz/xz" +) + +func main() { + const text = "The quick brown fox jumps over the lazy dog.\n" + var buf bytes.Buffer + // compress text + w, err := xz.NewWriter(&buf) + if err != nil { + log.Fatalf("xz.NewWriter error %s", err) + } + if _, err := io.WriteString(w, text); err != nil { + log.Fatalf("WriteString error %s", err) + } + if err := w.Close(); err != nil { + log.Fatalf("w.Close error %s", err) + } + // decompress buffer and write output to stdout + r, err := xz.NewReader(&buf) + if err != nil { + log.Fatalf("NewReader error %s", err) + } + if _, err = io.Copy(os.Stdout, r); err != nil { + log.Fatalf("io.Copy error %s", err) + } +} diff --git a/vendor/golang.org/x/sys/unix/mkasm_darwin.go b/vendor/golang.org/x/sys/unix/mkasm_darwin.go new file mode 100644 index 0000000000000..6f7bb6edfb9db --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mkasm_darwin.go @@ -0,0 +1,78 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go. +//This program must be run after mksyscall.go. +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "strings" +) + +func writeASMFile(in string, fileName string, buildTags string) { + trampolines := map[string]bool{} + + var out bytes.Buffer + + fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " ")) + fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n") + fmt.Fprintf(&out, "\n") + fmt.Fprintf(&out, "// +build %s\n", buildTags) + fmt.Fprintf(&out, "\n") + fmt.Fprintf(&out, "#include \"textflag.h\"\n") + for _, line := range strings.Split(in, "\n") { + if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") { + continue + } + fn := line[5 : len(line)-13] + if !trampolines[fn] { + trampolines[fn] = true + fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn) + fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn) + } + } + err := ioutil.WriteFile(fileName, out.Bytes(), 0644) + if err != nil { + log.Fatalf("can't write %s: %s", fileName, err) + } +} + +func main() { + in1, err := ioutil.ReadFile("syscall_darwin.go") + if err != nil { + log.Fatalf("can't open syscall_darwin.go: %s", err) + } + arch := os.Args[1] + in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch)) + if err != nil { + log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err) + } + in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch)) + if err != nil { + log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err) + } + in := string(in1) + string(in2) + string(in3) + + writeASMFile(in, fmt.Sprintf("zsyscall_darwin_%s.s", arch), "go1.12") + + in1, err = ioutil.ReadFile("syscall_darwin.1_13.go") + if err != nil { + log.Fatalf("can't open syscall_darwin.1_13.go: %s", err) + } + in2, err = ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.1_13.go", arch)) + if err != nil { + log.Fatalf("can't open zsyscall_darwin_%s.1_13.go: %s", arch, err) + } + + in = string(in1) + string(in2) + + writeASMFile(in, fmt.Sprintf("zsyscall_darwin_%s.1_13.s", arch), "go1.13") +} diff --git a/vendor/golang.org/x/sys/unix/mkpost.go b/vendor/golang.org/x/sys/unix/mkpost.go new file mode 100644 index 0000000000000..eb4332059aefd --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mkpost.go @@ -0,0 +1,122 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// mkpost processes the output of cgo -godefs to +// modify the generated types. It is used to clean up +// the sys API in an architecture specific manner. +// +// mkpost is run after cgo -godefs; see README.md. +package main + +import ( + "bytes" + "fmt" + "go/format" + "io/ioutil" + "log" + "os" + "regexp" +) + +func main() { + // Get the OS and architecture (using GOARCH_TARGET if it exists) + goos := os.Getenv("GOOS") + goarch := os.Getenv("GOARCH_TARGET") + if goarch == "" { + goarch = os.Getenv("GOARCH") + } + // Check that we are using the Docker-based build system if we should be. + if goos == "linux" { + if os.Getenv("GOLANG_SYS_BUILD") != "docker" { + os.Stderr.WriteString("In the Docker-based build system, mkpost should not be called directly.\n") + os.Stderr.WriteString("See README.md\n") + os.Exit(1) + } + } + + b, err := ioutil.ReadAll(os.Stdin) + if err != nil { + log.Fatal(err) + } + + if goos == "aix" { + // Replace type of Atim, Mtim and Ctim by Timespec in Stat_t + // to avoid having both StTimespec and Timespec. + sttimespec := regexp.MustCompile(`_Ctype_struct_st_timespec`) + b = sttimespec.ReplaceAll(b, []byte("Timespec")) + } + + // Intentionally export __val fields in Fsid and Sigset_t + valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__(bits|val)(\s+\S+\s+)}`) + b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$4}")) + + // Intentionally export __fds_bits field in FdSet + fdSetRegex := regexp.MustCompile(`type (FdSet) struct {(\s+)X__fds_bits(\s+\S+\s+)}`) + b = fdSetRegex.ReplaceAll(b, []byte("type $1 struct {${2}Bits$3}")) + + // If we have empty Ptrace structs, we should delete them. Only s390x emits + // nonempty Ptrace structs. + ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`) + b = ptraceRexexp.ReplaceAll(b, nil) + + // Replace the control_regs union with a blank identifier for now. + controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`) + b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) + + // Remove fields that are added by glibc + // Note that this is unstable as the identifers are private. + removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) + b = removeFieldsRegex.ReplaceAll(b, []byte("_")) + + // Convert [65]int8 to [65]byte in Utsname members to simplify + // conversion to string; see golang.org/issue/20753 + convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`) + b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte")) + + // Convert [1024]int8 to [1024]byte in Ptmget members + convertPtmget := regexp.MustCompile(`([SC]n)(\s+)\[(\d+)\]u?int8`) + b = convertPtmget.ReplaceAll(b, []byte("$1[$3]byte")) + + // Remove spare fields (e.g. in Statx_t) + spareFieldsRegex := regexp.MustCompile(`X__spare\S*`) + b = spareFieldsRegex.ReplaceAll(b, []byte("_")) + + // Remove cgo padding fields + removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) + b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_")) + + // Remove padding, hidden, or unused fields + removeFieldsRegex = regexp.MustCompile(`\b(X_\S+|Padding)`) + b = removeFieldsRegex.ReplaceAll(b, []byte("_")) + + // Remove the first line of warning from cgo + b = b[bytes.IndexByte(b, '\n')+1:] + // Modify the command in the header to include: + // mkpost, our own warning, and a build tag. + replacement := fmt.Sprintf(`$1 | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s,%s`, goarch, goos) + cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) + b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) + + // Rename Stat_t time fields + if goos == "freebsd" && goarch == "386" { + // Hide Stat_t.[AMCB]tim_ext fields + renameStatTimeExtFieldsRegex := regexp.MustCompile(`[AMCB]tim_ext`) + b = renameStatTimeExtFieldsRegex.ReplaceAll(b, []byte("_")) + } + renameStatTimeFieldsRegex := regexp.MustCompile(`([AMCB])(?:irth)?time?(?:spec)?\s+(Timespec|StTimespec)`) + b = renameStatTimeFieldsRegex.ReplaceAll(b, []byte("${1}tim ${2}")) + + // gofmt + b, err = format.Source(b) + if err != nil { + log.Fatal(err) + } + + os.Stdout.Write(b) +} diff --git a/vendor/golang.org/x/sys/unix/mksyscall.go b/vendor/golang.org/x/sys/unix/mksyscall.go new file mode 100644 index 0000000000000..9e540cc892b75 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mksyscall.go @@ -0,0 +1,402 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +This program reads a file containing function prototypes +(like syscall_darwin.go) and generates system call bodies. +The prototypes are marked by lines beginning with "//sys" +and read like func declarations if //sys is replaced by func, but: + * The parameter lists must give a name for each argument. + This includes return parameters. + * The parameter lists must give a type for each argument: + the (x, y, z int) shorthand is not allowed. + * If the return parameter is an error number, it must be named errno. + +A line beginning with //sysnb is like //sys, except that the +goroutine will not be suspended during the execution of the system +call. This must only be used for system calls which can never +block, as otherwise the system call could cause all goroutines to +hang. +*/ +package main + +import ( + "bufio" + "flag" + "fmt" + "os" + "regexp" + "strings" +) + +var ( + b32 = flag.Bool("b32", false, "32bit big-endian") + l32 = flag.Bool("l32", false, "32bit little-endian") + plan9 = flag.Bool("plan9", false, "plan9") + openbsd = flag.Bool("openbsd", false, "openbsd") + netbsd = flag.Bool("netbsd", false, "netbsd") + dragonfly = flag.Bool("dragonfly", false, "dragonfly") + arm = flag.Bool("arm", false, "arm") // 64-bit value should use (even, odd)-pair + tags = flag.String("tags", "", "build tags") + filename = flag.String("output", "", "output file name (standard output if omitted)") +) + +// cmdLine returns this programs's commandline arguments +func cmdLine() string { + return "go run mksyscall.go " + strings.Join(os.Args[1:], " ") +} + +// buildTags returns build tags +func buildTags() string { + return *tags +} + +// Param is function parameter +type Param struct { + Name string + Type string +} + +// usage prints the program usage +func usage() { + fmt.Fprintf(os.Stderr, "usage: go run mksyscall.go [-b32 | -l32] [-tags x,y] [file ...]\n") + os.Exit(1) +} + +// parseParamList parses parameter list and returns a slice of parameters +func parseParamList(list string) []string { + list = strings.TrimSpace(list) + if list == "" { + return []string{} + } + return regexp.MustCompile(`\s*,\s*`).Split(list, -1) +} + +// parseParam splits a parameter into name and type +func parseParam(p string) Param { + ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) + if ps == nil { + fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) + os.Exit(1) + } + return Param{ps[1], ps[2]} +} + +func main() { + // Get the OS and architecture (using GOARCH_TARGET if it exists) + goos := os.Getenv("GOOS") + if goos == "" { + fmt.Fprintln(os.Stderr, "GOOS not defined in environment") + os.Exit(1) + } + goarch := os.Getenv("GOARCH_TARGET") + if goarch == "" { + goarch = os.Getenv("GOARCH") + } + + // Check that we are using the Docker-based build system if we should + if goos == "linux" { + if os.Getenv("GOLANG_SYS_BUILD") != "docker" { + fmt.Fprintf(os.Stderr, "In the Docker-based build system, mksyscall should not be called directly.\n") + fmt.Fprintf(os.Stderr, "See README.md\n") + os.Exit(1) + } + } + + flag.Usage = usage + flag.Parse() + if len(flag.Args()) <= 0 { + fmt.Fprintf(os.Stderr, "no files to parse provided\n") + usage() + } + + endianness := "" + if *b32 { + endianness = "big-endian" + } else if *l32 { + endianness = "little-endian" + } + + libc := false + if goos == "darwin" && (strings.Contains(buildTags(), ",go1.12") || strings.Contains(buildTags(), ",go1.13")) { + libc = true + } + trampolines := map[string]bool{} + + text := "" + for _, path := range flag.Args() { + file, err := os.Open(path) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + s := bufio.NewScanner(file) + for s.Scan() { + t := s.Text() + t = strings.TrimSpace(t) + t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) + nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) + if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { + continue + } + + // Line must be of the form + // func Open(path string, mode int, perm int) (fd int, errno error) + // Split into name, in params, out params. + f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$`).FindStringSubmatch(t) + if f == nil { + fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) + os.Exit(1) + } + funct, inps, outps, sysname := f[2], f[3], f[4], f[5] + + // ClockGettime doesn't have a syscall number on Darwin, only generate libc wrappers. + if goos == "darwin" && !libc && funct == "ClockGettime" { + continue + } + + // Split argument lists on comma. + in := parseParamList(inps) + out := parseParamList(outps) + + // Try in vain to keep people from editing this file. + // The theory is that they jump into the middle of the file + // without reading the header. + text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" + + // Go function header. + outDecl := "" + if len(out) > 0 { + outDecl = fmt.Sprintf(" (%s)", strings.Join(out, ", ")) + } + text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outDecl) + + // Check if err return available + errvar := "" + for _, param := range out { + p := parseParam(param) + if p.Type == "error" { + errvar = p.Name + break + } + } + + // Prepare arguments to Syscall. + var args []string + n := 0 + for _, param := range in { + p := parseParam(param) + if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { + args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))") + } else if p.Type == "string" && errvar != "" { + text += fmt.Sprintf("\tvar _p%d *byte\n", n) + text += fmt.Sprintf("\t_p%d, %s = BytePtrFromString(%s)\n", n, errvar, p.Name) + text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) + args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) + n++ + } else if p.Type == "string" { + fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") + text += fmt.Sprintf("\tvar _p%d *byte\n", n) + text += fmt.Sprintf("\t_p%d, _ = BytePtrFromString(%s)\n", n, p.Name) + args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) + n++ + } else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil { + // Convert slice into pointer, length. + // Have to be careful not to take address of &a[0] if len == 0: + // pass dummy pointer in that case. + // Used to pass nil, but some OSes or simulators reject write(fd, nil, 0). + text += fmt.Sprintf("\tvar _p%d unsafe.Pointer\n", n) + text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = unsafe.Pointer(&%s[0])\n\t}", p.Name, n, p.Name) + text += fmt.Sprintf(" else {\n\t\t_p%d = unsafe.Pointer(&_zero)\n\t}\n", n) + args = append(args, fmt.Sprintf("uintptr(_p%d)", n), fmt.Sprintf("uintptr(len(%s))", p.Name)) + n++ + } else if p.Type == "int64" && (*openbsd || *netbsd) { + args = append(args, "0") + if endianness == "big-endian" { + args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) + } else if endianness == "little-endian" { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) + } else { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) + } + } else if p.Type == "int64" && *dragonfly { + if regexp.MustCompile(`^(?i)extp(read|write)`).FindStringSubmatch(funct) == nil { + args = append(args, "0") + } + if endianness == "big-endian" { + args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) + } else if endianness == "little-endian" { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) + } else { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) + } + } else if (p.Type == "int64" || p.Type == "uint64") && endianness != "" { + if len(args)%2 == 1 && *arm { + // arm abi specifies 64-bit argument uses + // (even, odd) pair + args = append(args, "0") + } + if endianness == "big-endian" { + args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) + } else { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) + } + } else { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) + } + } + + // Determine which form to use; pad args with zeros. + asm := "Syscall" + if nonblock != nil { + if errvar == "" && goos == "linux" { + asm = "RawSyscallNoError" + } else { + asm = "RawSyscall" + } + } else { + if errvar == "" && goos == "linux" { + asm = "SyscallNoError" + } + } + if len(args) <= 3 { + for len(args) < 3 { + args = append(args, "0") + } + } else if len(args) <= 6 { + asm += "6" + for len(args) < 6 { + args = append(args, "0") + } + } else if len(args) <= 9 { + asm += "9" + for len(args) < 9 { + args = append(args, "0") + } + } else { + fmt.Fprintf(os.Stderr, "%s:%s too many arguments to system call\n", path, funct) + } + + // System call number. + if sysname == "" { + sysname = "SYS_" + funct + sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`) + sysname = strings.ToUpper(sysname) + } + + var libcFn string + if libc { + asm = "syscall_" + strings.ToLower(asm[:1]) + asm[1:] // internal syscall call + sysname = strings.TrimPrefix(sysname, "SYS_") // remove SYS_ + sysname = strings.ToLower(sysname) // lowercase + libcFn = sysname + sysname = "funcPC(libc_" + sysname + "_trampoline)" + } + + // Actual call. + arglist := strings.Join(args, ", ") + call := fmt.Sprintf("%s(%s, %s)", asm, sysname, arglist) + + // Assign return values. + body := "" + ret := []string{"_", "_", "_"} + doErrno := false + for i := 0; i < len(out); i++ { + p := parseParam(out[i]) + reg := "" + if p.Name == "err" && !*plan9 { + reg = "e1" + ret[2] = reg + doErrno = true + } else if p.Name == "err" && *plan9 { + ret[0] = "r0" + ret[2] = "e1" + break + } else { + reg = fmt.Sprintf("r%d", i) + ret[i] = reg + } + if p.Type == "bool" { + reg = fmt.Sprintf("%s != 0", reg) + } + if p.Type == "int64" && endianness != "" { + // 64-bit number in r1:r0 or r0:r1. + if i+2 > len(out) { + fmt.Fprintf(os.Stderr, "%s:%s not enough registers for int64 return\n", path, funct) + } + if endianness == "big-endian" { + reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1) + } else { + reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i) + } + ret[i] = fmt.Sprintf("r%d", i) + ret[i+1] = fmt.Sprintf("r%d", i+1) + } + if reg != "e1" || *plan9 { + body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) + } + } + if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" { + text += fmt.Sprintf("\t%s\n", call) + } else { + if errvar == "" && goos == "linux" { + // raw syscall without error on Linux, see golang.org/issue/22924 + text += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], call) + } else { + text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call) + } + } + text += body + + if *plan9 && ret[2] == "e1" { + text += "\tif int32(r0) == -1 {\n" + text += "\t\terr = e1\n" + text += "\t}\n" + } else if doErrno { + text += "\tif e1 != 0 {\n" + text += "\t\terr = errnoErr(e1)\n" + text += "\t}\n" + } + text += "\treturn\n" + text += "}\n\n" + + if libc && !trampolines[libcFn] { + // some system calls share a trampoline, like read and readlen. + trampolines[libcFn] = true + // Declare assembly trampoline. + text += fmt.Sprintf("func libc_%s_trampoline()\n", libcFn) + // Assembly trampoline calls the libc_* function, which this magic + // redirects to use the function from libSystem. + text += fmt.Sprintf("//go:linkname libc_%s libc_%s\n", libcFn, libcFn) + text += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"/usr/lib/libSystem.B.dylib\"\n", libcFn, libcFn) + text += "\n" + } + } + if err := s.Err(); err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + file.Close() + } + fmt.Printf(srcTemplate, cmdLine(), buildTags(), text) +} + +const srcTemplate = `// %s +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +%s +` diff --git a/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go new file mode 100644 index 0000000000000..3be3cdfc3b6ee --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go @@ -0,0 +1,415 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +This program reads a file containing function prototypes +(like syscall_aix.go) and generates system call bodies. +The prototypes are marked by lines beginning with "//sys" +and read like func declarations if //sys is replaced by func, but: + * The parameter lists must give a name for each argument. + This includes return parameters. + * The parameter lists must give a type for each argument: + the (x, y, z int) shorthand is not allowed. + * If the return parameter is an error number, it must be named err. + * If go func name needs to be different than its libc name, + * or the function is not in libc, name could be specified + * at the end, after "=" sign, like + //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt +*/ +package main + +import ( + "bufio" + "flag" + "fmt" + "os" + "regexp" + "strings" +) + +var ( + b32 = flag.Bool("b32", false, "32bit big-endian") + l32 = flag.Bool("l32", false, "32bit little-endian") + aix = flag.Bool("aix", false, "aix") + tags = flag.String("tags", "", "build tags") +) + +// cmdLine returns this programs's commandline arguments +func cmdLine() string { + return "go run mksyscall_aix_ppc.go " + strings.Join(os.Args[1:], " ") +} + +// buildTags returns build tags +func buildTags() string { + return *tags +} + +// Param is function parameter +type Param struct { + Name string + Type string +} + +// usage prints the program usage +func usage() { + fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc.go [-b32 | -l32] [-tags x,y] [file ...]\n") + os.Exit(1) +} + +// parseParamList parses parameter list and returns a slice of parameters +func parseParamList(list string) []string { + list = strings.TrimSpace(list) + if list == "" { + return []string{} + } + return regexp.MustCompile(`\s*,\s*`).Split(list, -1) +} + +// parseParam splits a parameter into name and type +func parseParam(p string) Param { + ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) + if ps == nil { + fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) + os.Exit(1) + } + return Param{ps[1], ps[2]} +} + +func main() { + flag.Usage = usage + flag.Parse() + if len(flag.Args()) <= 0 { + fmt.Fprintf(os.Stderr, "no files to parse provided\n") + usage() + } + + endianness := "" + if *b32 { + endianness = "big-endian" + } else if *l32 { + endianness = "little-endian" + } + + pack := "" + text := "" + cExtern := "/*\n#include \n#include \n" + for _, path := range flag.Args() { + file, err := os.Open(path) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + s := bufio.NewScanner(file) + for s.Scan() { + t := s.Text() + t = strings.TrimSpace(t) + t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) + if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" { + pack = p[1] + } + nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) + if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { + continue + } + + // Line must be of the form + // func Open(path string, mode int, perm int) (fd int, err error) + // Split into name, in params, out params. + f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t) + if f == nil { + fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) + os.Exit(1) + } + funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6] + + // Split argument lists on comma. + in := parseParamList(inps) + out := parseParamList(outps) + + inps = strings.Join(in, ", ") + outps = strings.Join(out, ", ") + + // Try in vain to keep people from editing this file. + // The theory is that they jump into the middle of the file + // without reading the header. + text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" + + // Check if value return, err return available + errvar := "" + retvar := "" + rettype := "" + for _, param := range out { + p := parseParam(param) + if p.Type == "error" { + errvar = p.Name + } else { + retvar = p.Name + rettype = p.Type + } + } + + // System call name. + if sysname == "" { + sysname = funct + } + sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`) + sysname = strings.ToLower(sysname) // All libc functions are lowercase. + + cRettype := "" + if rettype == "unsafe.Pointer" { + cRettype = "uintptr_t" + } else if rettype == "uintptr" { + cRettype = "uintptr_t" + } else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil { + cRettype = "uintptr_t" + } else if rettype == "int" { + cRettype = "int" + } else if rettype == "int32" { + cRettype = "int" + } else if rettype == "int64" { + cRettype = "long long" + } else if rettype == "uint32" { + cRettype = "unsigned int" + } else if rettype == "uint64" { + cRettype = "unsigned long long" + } else { + cRettype = "int" + } + if sysname == "exit" { + cRettype = "void" + } + + // Change p.Types to c + var cIn []string + for _, param := range in { + p := parseParam(param) + if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { + cIn = append(cIn, "uintptr_t") + } else if p.Type == "string" { + cIn = append(cIn, "uintptr_t") + } else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil { + cIn = append(cIn, "uintptr_t", "size_t") + } else if p.Type == "unsafe.Pointer" { + cIn = append(cIn, "uintptr_t") + } else if p.Type == "uintptr" { + cIn = append(cIn, "uintptr_t") + } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil { + cIn = append(cIn, "uintptr_t") + } else if p.Type == "int" { + cIn = append(cIn, "int") + } else if p.Type == "int32" { + cIn = append(cIn, "int") + } else if p.Type == "int64" { + cIn = append(cIn, "long long") + } else if p.Type == "uint32" { + cIn = append(cIn, "unsigned int") + } else if p.Type == "uint64" { + cIn = append(cIn, "unsigned long long") + } else { + cIn = append(cIn, "int") + } + } + + if funct != "fcntl" && funct != "FcntlInt" && funct != "readlen" && funct != "writelen" { + if sysname == "select" { + // select is a keyword of Go. Its name is + // changed to c_select. + cExtern += "#define c_select select\n" + } + // Imports of system calls from libc + cExtern += fmt.Sprintf("%s %s", cRettype, sysname) + cIn := strings.Join(cIn, ", ") + cExtern += fmt.Sprintf("(%s);\n", cIn) + } + + // So file name. + if *aix { + if modname == "" { + modname = "libc.a/shr_64.o" + } else { + fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct) + os.Exit(1) + } + } + + strconvfunc := "C.CString" + + // Go function header. + if outps != "" { + outps = fmt.Sprintf(" (%s)", outps) + } + if text != "" { + text += "\n" + } + + text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps) + + // Prepare arguments to Syscall. + var args []string + n := 0 + argN := 0 + for _, param := range in { + p := parseParam(param) + if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { + args = append(args, "C.uintptr_t(uintptr(unsafe.Pointer("+p.Name+")))") + } else if p.Type == "string" && errvar != "" { + text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name) + args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n)) + n++ + } else if p.Type == "string" { + fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") + text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name) + args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n)) + n++ + } else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil { + // Convert slice into pointer, length. + // Have to be careful not to take address of &a[0] if len == 0: + // pass nil in that case. + text += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1]) + text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name) + args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(unsafe.Pointer(_p%d)))", n)) + n++ + text += fmt.Sprintf("\tvar _p%d int\n", n) + text += fmt.Sprintf("\t_p%d = len(%s)\n", n, p.Name) + args = append(args, fmt.Sprintf("C.size_t(_p%d)", n)) + n++ + } else if p.Type == "int64" && endianness != "" { + if endianness == "big-endian" { + args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) + } else { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) + } + n++ + } else if p.Type == "bool" { + text += fmt.Sprintf("\tvar _p%d uint32\n", n) + text += fmt.Sprintf("\tif %s {\n\t\t_p%d = 1\n\t} else {\n\t\t_p%d = 0\n\t}\n", p.Name, n, n) + args = append(args, fmt.Sprintf("_p%d", n)) + } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil { + args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name)) + } else if p.Type == "unsafe.Pointer" { + args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name)) + } else if p.Type == "int" { + if (argN == 2) && ((funct == "readlen") || (funct == "writelen")) { + args = append(args, fmt.Sprintf("C.size_t(%s)", p.Name)) + } else if argN == 0 && funct == "fcntl" { + args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) + } else if (argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt")) { + args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) + } else { + args = append(args, fmt.Sprintf("C.int(%s)", p.Name)) + } + } else if p.Type == "int32" { + args = append(args, fmt.Sprintf("C.int(%s)", p.Name)) + } else if p.Type == "int64" { + args = append(args, fmt.Sprintf("C.longlong(%s)", p.Name)) + } else if p.Type == "uint32" { + args = append(args, fmt.Sprintf("C.uint(%s)", p.Name)) + } else if p.Type == "uint64" { + args = append(args, fmt.Sprintf("C.ulonglong(%s)", p.Name)) + } else if p.Type == "uintptr" { + args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) + } else { + args = append(args, fmt.Sprintf("C.int(%s)", p.Name)) + } + argN++ + } + + // Actual call. + arglist := strings.Join(args, ", ") + call := "" + if sysname == "exit" { + if errvar != "" { + call += "er :=" + } else { + call += "" + } + } else if errvar != "" { + call += "r0,er :=" + } else if retvar != "" { + call += "r0,_ :=" + } else { + call += "" + } + if sysname == "select" { + // select is a keyword of Go. Its name is + // changed to c_select. + call += fmt.Sprintf("C.c_%s(%s)", sysname, arglist) + } else { + call += fmt.Sprintf("C.%s(%s)", sysname, arglist) + } + + // Assign return values. + body := "" + for i := 0; i < len(out); i++ { + p := parseParam(out[i]) + reg := "" + if p.Name == "err" { + reg = "e1" + } else { + reg = "r0" + } + if reg != "e1" { + body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) + } + } + + // verify return + if sysname != "exit" && errvar != "" { + if regexp.MustCompile(`^uintptr`).FindStringSubmatch(cRettype) != nil { + body += "\tif (uintptr(r0) ==^uintptr(0) && er != nil) {\n" + body += fmt.Sprintf("\t\t%s = er\n", errvar) + body += "\t}\n" + } else { + body += "\tif (r0 ==-1 && er != nil) {\n" + body += fmt.Sprintf("\t\t%s = er\n", errvar) + body += "\t}\n" + } + } else if errvar != "" { + body += "\tif (er != nil) {\n" + body += fmt.Sprintf("\t\t%s = er\n", errvar) + body += "\t}\n" + } + + text += fmt.Sprintf("\t%s\n", call) + text += body + + text += "\treturn\n" + text += "}\n" + } + if err := s.Err(); err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + file.Close() + } + imp := "" + if pack != "unix" { + imp = "import \"golang.org/x/sys/unix\"\n" + + } + fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, cExtern, imp, text) +} + +const srcTemplate = `// %s +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s + +package %s + + +%s +*/ +import "C" +import ( + "unsafe" +) + + +%s + +%s +` diff --git a/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go new file mode 100644 index 0000000000000..c960099517af0 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go @@ -0,0 +1,614 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +This program reads a file containing function prototypes +(like syscall_aix.go) and generates system call bodies. +The prototypes are marked by lines beginning with "//sys" +and read like func declarations if //sys is replaced by func, but: + * The parameter lists must give a name for each argument. + This includes return parameters. + * The parameter lists must give a type for each argument: + the (x, y, z int) shorthand is not allowed. + * If the return parameter is an error number, it must be named err. + * If go func name needs to be different than its libc name, + * or the function is not in libc, name could be specified + * at the end, after "=" sign, like + //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt + + +This program will generate three files and handle both gc and gccgo implementation: + - zsyscall_aix_ppc64.go: the common part of each implementation (error handler, pointer creation) + - zsyscall_aix_ppc64_gc.go: gc part with //go_cgo_import_dynamic and a call to syscall6 + - zsyscall_aix_ppc64_gccgo.go: gccgo part with C function and conversion to C type. + + The generated code looks like this + +zsyscall_aix_ppc64.go +func asyscall(...) (n int, err error) { + // Pointer Creation + r1, e1 := callasyscall(...) + // Type Conversion + // Error Handler + return +} + +zsyscall_aix_ppc64_gc.go +//go:cgo_import_dynamic libc_asyscall asyscall "libc.a/shr_64.o" +//go:linkname libc_asyscall libc_asyscall +var asyscall syscallFunc + +func callasyscall(...) (r1 uintptr, e1 Errno) { + r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_asyscall)), "nb_args", ... ) + return +} + +zsyscall_aix_ppc64_ggcgo.go + +// int asyscall(...) + +import "C" + +func callasyscall(...) (r1 uintptr, e1 Errno) { + r1 = uintptr(C.asyscall(...)) + e1 = syscall.GetErrno() + return +} +*/ + +package main + +import ( + "bufio" + "flag" + "fmt" + "io/ioutil" + "os" + "regexp" + "strings" +) + +var ( + b32 = flag.Bool("b32", false, "32bit big-endian") + l32 = flag.Bool("l32", false, "32bit little-endian") + aix = flag.Bool("aix", false, "aix") + tags = flag.String("tags", "", "build tags") +) + +// cmdLine returns this programs's commandline arguments +func cmdLine() string { + return "go run mksyscall_aix_ppc64.go " + strings.Join(os.Args[1:], " ") +} + +// buildTags returns build tags +func buildTags() string { + return *tags +} + +// Param is function parameter +type Param struct { + Name string + Type string +} + +// usage prints the program usage +func usage() { + fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc64.go [-b32 | -l32] [-tags x,y] [file ...]\n") + os.Exit(1) +} + +// parseParamList parses parameter list and returns a slice of parameters +func parseParamList(list string) []string { + list = strings.TrimSpace(list) + if list == "" { + return []string{} + } + return regexp.MustCompile(`\s*,\s*`).Split(list, -1) +} + +// parseParam splits a parameter into name and type +func parseParam(p string) Param { + ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) + if ps == nil { + fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) + os.Exit(1) + } + return Param{ps[1], ps[2]} +} + +func main() { + flag.Usage = usage + flag.Parse() + if len(flag.Args()) <= 0 { + fmt.Fprintf(os.Stderr, "no files to parse provided\n") + usage() + } + + endianness := "" + if *b32 { + endianness = "big-endian" + } else if *l32 { + endianness = "little-endian" + } + + pack := "" + // GCCGO + textgccgo := "" + cExtern := "/*\n#include \n" + // GC + textgc := "" + dynimports := "" + linknames := "" + var vars []string + // COMMON + textcommon := "" + for _, path := range flag.Args() { + file, err := os.Open(path) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + s := bufio.NewScanner(file) + for s.Scan() { + t := s.Text() + t = strings.TrimSpace(t) + t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) + if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" { + pack = p[1] + } + nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) + if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { + continue + } + + // Line must be of the form + // func Open(path string, mode int, perm int) (fd int, err error) + // Split into name, in params, out params. + f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t) + if f == nil { + fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) + os.Exit(1) + } + funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6] + + // Split argument lists on comma. + in := parseParamList(inps) + out := parseParamList(outps) + + inps = strings.Join(in, ", ") + outps = strings.Join(out, ", ") + + if sysname == "" { + sysname = funct + } + + onlyCommon := false + if funct == "readlen" || funct == "writelen" || funct == "FcntlInt" || funct == "FcntlFlock" { + // This function call another syscall which is already implemented. + // Therefore, the gc and gccgo part must not be generated. + onlyCommon = true + } + + // Try in vain to keep people from editing this file. + // The theory is that they jump into the middle of the file + // without reading the header. + + textcommon += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" + if !onlyCommon { + textgccgo += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" + textgc += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" + } + + // Check if value return, err return available + errvar := "" + rettype := "" + for _, param := range out { + p := parseParam(param) + if p.Type == "error" { + errvar = p.Name + } else { + rettype = p.Type + } + } + + sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`) + sysname = strings.ToLower(sysname) // All libc functions are lowercase. + + // GCCGO Prototype return type + cRettype := "" + if rettype == "unsafe.Pointer" { + cRettype = "uintptr_t" + } else if rettype == "uintptr" { + cRettype = "uintptr_t" + } else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil { + cRettype = "uintptr_t" + } else if rettype == "int" { + cRettype = "int" + } else if rettype == "int32" { + cRettype = "int" + } else if rettype == "int64" { + cRettype = "long long" + } else if rettype == "uint32" { + cRettype = "unsigned int" + } else if rettype == "uint64" { + cRettype = "unsigned long long" + } else { + cRettype = "int" + } + if sysname == "exit" { + cRettype = "void" + } + + // GCCGO Prototype arguments type + var cIn []string + for i, param := range in { + p := parseParam(param) + if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { + cIn = append(cIn, "uintptr_t") + } else if p.Type == "string" { + cIn = append(cIn, "uintptr_t") + } else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil { + cIn = append(cIn, "uintptr_t", "size_t") + } else if p.Type == "unsafe.Pointer" { + cIn = append(cIn, "uintptr_t") + } else if p.Type == "uintptr" { + cIn = append(cIn, "uintptr_t") + } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil { + cIn = append(cIn, "uintptr_t") + } else if p.Type == "int" { + if (i == 0 || i == 2) && funct == "fcntl" { + // These fcntl arguments needs to be uintptr to be able to call FcntlInt and FcntlFlock + cIn = append(cIn, "uintptr_t") + } else { + cIn = append(cIn, "int") + } + + } else if p.Type == "int32" { + cIn = append(cIn, "int") + } else if p.Type == "int64" { + cIn = append(cIn, "long long") + } else if p.Type == "uint32" { + cIn = append(cIn, "unsigned int") + } else if p.Type == "uint64" { + cIn = append(cIn, "unsigned long long") + } else { + cIn = append(cIn, "int") + } + } + + if !onlyCommon { + // GCCGO Prototype Generation + // Imports of system calls from libc + if sysname == "select" { + // select is a keyword of Go. Its name is + // changed to c_select. + cExtern += "#define c_select select\n" + } + cExtern += fmt.Sprintf("%s %s", cRettype, sysname) + cIn := strings.Join(cIn, ", ") + cExtern += fmt.Sprintf("(%s);\n", cIn) + } + // GC Library name + if modname == "" { + modname = "libc.a/shr_64.o" + } else { + fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct) + os.Exit(1) + } + sysvarname := fmt.Sprintf("libc_%s", sysname) + + if !onlyCommon { + // GC Runtime import of function to allow cross-platform builds. + dynimports += fmt.Sprintf("//go:cgo_import_dynamic %s %s \"%s\"\n", sysvarname, sysname, modname) + // GC Link symbol to proc address variable. + linknames += fmt.Sprintf("//go:linkname %s %s\n", sysvarname, sysvarname) + // GC Library proc address variable. + vars = append(vars, sysvarname) + } + + strconvfunc := "BytePtrFromString" + strconvtype := "*byte" + + // Go function header. + if outps != "" { + outps = fmt.Sprintf(" (%s)", outps) + } + if textcommon != "" { + textcommon += "\n" + } + + textcommon += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps) + + // Prepare arguments tocall. + var argscommon []string // Arguments in the common part + var argscall []string // Arguments for call prototype + var argsgc []string // Arguments for gc call (with syscall6) + var argsgccgo []string // Arguments for gccgo call (with C.name_of_syscall) + n := 0 + argN := 0 + for _, param := range in { + p := parseParam(param) + if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { + argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.Name)) + argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) + argsgc = append(argsgc, p.Name) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) + } else if p.Type == "string" && errvar != "" { + textcommon += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) + textcommon += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name) + textcommon += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) + + argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) + argscall = append(argscall, fmt.Sprintf("_p%d uintptr ", n)) + argsgc = append(argsgc, fmt.Sprintf("_p%d", n)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n)) + n++ + } else if p.Type == "string" { + fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") + textcommon += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) + textcommon += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name) + textcommon += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) + + argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) + argscall = append(argscall, fmt.Sprintf("_p%d uintptr", n)) + argsgc = append(argsgc, fmt.Sprintf("_p%d", n)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n)) + n++ + } else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil { + // Convert slice into pointer, length. + // Have to be careful not to take address of &a[0] if len == 0: + // pass nil in that case. + textcommon += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1]) + textcommon += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name) + argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n), fmt.Sprintf("len(%s)", p.Name)) + argscall = append(argscall, fmt.Sprintf("_p%d uintptr", n), fmt.Sprintf("_lenp%d int", n)) + argsgc = append(argsgc, fmt.Sprintf("_p%d", n), fmt.Sprintf("uintptr(_lenp%d)", n)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n), fmt.Sprintf("C.size_t(_lenp%d)", n)) + n++ + } else if p.Type == "int64" && endianness != "" { + fmt.Fprintf(os.Stderr, path+":"+funct+" uses int64 with 32 bits mode. Case not yet implemented\n") + } else if p.Type == "bool" { + fmt.Fprintf(os.Stderr, path+":"+funct+" uses bool. Case not yet implemented\n") + } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil || p.Type == "unsafe.Pointer" { + argscommon = append(argscommon, fmt.Sprintf("uintptr(%s)", p.Name)) + argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) + argsgc = append(argsgc, p.Name) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) + } else if p.Type == "int" { + if (argN == 0 || argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt") || (funct == "FcntlFlock")) { + // These fcntl arguments need to be uintptr to be able to call FcntlInt and FcntlFlock + argscommon = append(argscommon, fmt.Sprintf("uintptr(%s)", p.Name)) + argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) + argsgc = append(argsgc, p.Name) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) + + } else { + argscommon = append(argscommon, p.Name) + argscall = append(argscall, fmt.Sprintf("%s int", p.Name)) + argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name)) + } + } else if p.Type == "int32" { + argscommon = append(argscommon, p.Name) + argscall = append(argscall, fmt.Sprintf("%s int32", p.Name)) + argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name)) + } else if p.Type == "int64" { + argscommon = append(argscommon, p.Name) + argscall = append(argscall, fmt.Sprintf("%s int64", p.Name)) + argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.longlong(%s)", p.Name)) + } else if p.Type == "uint32" { + argscommon = append(argscommon, p.Name) + argscall = append(argscall, fmt.Sprintf("%s uint32", p.Name)) + argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uint(%s)", p.Name)) + } else if p.Type == "uint64" { + argscommon = append(argscommon, p.Name) + argscall = append(argscall, fmt.Sprintf("%s uint64", p.Name)) + argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.ulonglong(%s)", p.Name)) + } else if p.Type == "uintptr" { + argscommon = append(argscommon, p.Name) + argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) + argsgc = append(argsgc, p.Name) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) + } else { + argscommon = append(argscommon, fmt.Sprintf("int(%s)", p.Name)) + argscall = append(argscall, fmt.Sprintf("%s int", p.Name)) + argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) + argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name)) + } + argN++ + } + nargs := len(argsgc) + + // COMMON function generation + argscommonlist := strings.Join(argscommon, ", ") + callcommon := fmt.Sprintf("call%s(%s)", sysname, argscommonlist) + ret := []string{"_", "_"} + body := "" + doErrno := false + for i := 0; i < len(out); i++ { + p := parseParam(out[i]) + reg := "" + if p.Name == "err" { + reg = "e1" + ret[1] = reg + doErrno = true + } else { + reg = "r0" + ret[0] = reg + } + if p.Type == "bool" { + reg = fmt.Sprintf("%s != 0", reg) + } + if reg != "e1" { + body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) + } + } + if ret[0] == "_" && ret[1] == "_" { + textcommon += fmt.Sprintf("\t%s\n", callcommon) + } else { + textcommon += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], callcommon) + } + textcommon += body + + if doErrno { + textcommon += "\tif e1 != 0 {\n" + textcommon += "\t\terr = errnoErr(e1)\n" + textcommon += "\t}\n" + } + textcommon += "\treturn\n" + textcommon += "}\n" + + if onlyCommon { + continue + } + + // CALL Prototype + callProto := fmt.Sprintf("func call%s(%s) (r1 uintptr, e1 Errno) {\n", sysname, strings.Join(argscall, ", ")) + + // GC function generation + asm := "syscall6" + if nonblock != nil { + asm = "rawSyscall6" + } + + if len(argsgc) <= 6 { + for len(argsgc) < 6 { + argsgc = append(argsgc, "0") + } + } else { + fmt.Fprintf(os.Stderr, "%s: too many arguments to system call", funct) + os.Exit(1) + } + argsgclist := strings.Join(argsgc, ", ") + callgc := fmt.Sprintf("%s(uintptr(unsafe.Pointer(&%s)), %d, %s)", asm, sysvarname, nargs, argsgclist) + + textgc += callProto + textgc += fmt.Sprintf("\tr1, _, e1 = %s\n", callgc) + textgc += "\treturn\n}\n" + + // GCCGO function generation + argsgccgolist := strings.Join(argsgccgo, ", ") + var callgccgo string + if sysname == "select" { + // select is a keyword of Go. Its name is + // changed to c_select. + callgccgo = fmt.Sprintf("C.c_%s(%s)", sysname, argsgccgolist) + } else { + callgccgo = fmt.Sprintf("C.%s(%s)", sysname, argsgccgolist) + } + textgccgo += callProto + textgccgo += fmt.Sprintf("\tr1 = uintptr(%s)\n", callgccgo) + textgccgo += "\te1 = syscall.GetErrno()\n" + textgccgo += "\treturn\n}\n" + } + if err := s.Err(); err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + file.Close() + } + imp := "" + if pack != "unix" { + imp = "import \"golang.org/x/sys/unix\"\n" + + } + + // Print zsyscall_aix_ppc64.go + err := ioutil.WriteFile("zsyscall_aix_ppc64.go", + []byte(fmt.Sprintf(srcTemplate1, cmdLine(), buildTags(), pack, imp, textcommon)), + 0644) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + + // Print zsyscall_aix_ppc64_gc.go + vardecls := "\t" + strings.Join(vars, ",\n\t") + vardecls += " syscallFunc" + err = ioutil.WriteFile("zsyscall_aix_ppc64_gc.go", + []byte(fmt.Sprintf(srcTemplate2, cmdLine(), buildTags(), pack, imp, dynimports, linknames, vardecls, textgc)), + 0644) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + + // Print zsyscall_aix_ppc64_gccgo.go + err = ioutil.WriteFile("zsyscall_aix_ppc64_gccgo.go", + []byte(fmt.Sprintf(srcTemplate3, cmdLine(), buildTags(), pack, cExtern, imp, textgccgo)), + 0644) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } +} + +const srcTemplate1 = `// %s +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s + +package %s + +import ( + "unsafe" +) + + +%s + +%s +` +const srcTemplate2 = `// %s +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s +// +build !gccgo + +package %s + +import ( + "unsafe" +) +%s +%s +%s +type syscallFunc uintptr + +var ( +%s +) + +// Implemented in runtime/syscall_aix.go. +func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) +func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) + +%s +` +const srcTemplate3 = `// %s +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s +// +build gccgo + +package %s + +%s +*/ +import "C" +import ( + "syscall" +) + + +%s + +%s +` diff --git a/vendor/golang.org/x/sys/unix/mksyscall_solaris.go b/vendor/golang.org/x/sys/unix/mksyscall_solaris.go new file mode 100644 index 0000000000000..3d864738b6959 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mksyscall_solaris.go @@ -0,0 +1,335 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* + This program reads a file containing function prototypes + (like syscall_solaris.go) and generates system call bodies. + The prototypes are marked by lines beginning with "//sys" + and read like func declarations if //sys is replaced by func, but: + * The parameter lists must give a name for each argument. + This includes return parameters. + * The parameter lists must give a type for each argument: + the (x, y, z int) shorthand is not allowed. + * If the return parameter is an error number, it must be named err. + * If go func name needs to be different than its libc name, + * or the function is not in libc, name could be specified + * at the end, after "=" sign, like + //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt +*/ + +package main + +import ( + "bufio" + "flag" + "fmt" + "os" + "regexp" + "strings" +) + +var ( + b32 = flag.Bool("b32", false, "32bit big-endian") + l32 = flag.Bool("l32", false, "32bit little-endian") + tags = flag.String("tags", "", "build tags") +) + +// cmdLine returns this programs's commandline arguments +func cmdLine() string { + return "go run mksyscall_solaris.go " + strings.Join(os.Args[1:], " ") +} + +// buildTags returns build tags +func buildTags() string { + return *tags +} + +// Param is function parameter +type Param struct { + Name string + Type string +} + +// usage prints the program usage +func usage() { + fmt.Fprintf(os.Stderr, "usage: go run mksyscall_solaris.go [-b32 | -l32] [-tags x,y] [file ...]\n") + os.Exit(1) +} + +// parseParamList parses parameter list and returns a slice of parameters +func parseParamList(list string) []string { + list = strings.TrimSpace(list) + if list == "" { + return []string{} + } + return regexp.MustCompile(`\s*,\s*`).Split(list, -1) +} + +// parseParam splits a parameter into name and type +func parseParam(p string) Param { + ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) + if ps == nil { + fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) + os.Exit(1) + } + return Param{ps[1], ps[2]} +} + +func main() { + flag.Usage = usage + flag.Parse() + if len(flag.Args()) <= 0 { + fmt.Fprintf(os.Stderr, "no files to parse provided\n") + usage() + } + + endianness := "" + if *b32 { + endianness = "big-endian" + } else if *l32 { + endianness = "little-endian" + } + + pack := "" + text := "" + dynimports := "" + linknames := "" + var vars []string + for _, path := range flag.Args() { + file, err := os.Open(path) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + s := bufio.NewScanner(file) + for s.Scan() { + t := s.Text() + t = strings.TrimSpace(t) + t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) + if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" { + pack = p[1] + } + nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) + if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { + continue + } + + // Line must be of the form + // func Open(path string, mode int, perm int) (fd int, err error) + // Split into name, in params, out params. + f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t) + if f == nil { + fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) + os.Exit(1) + } + funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6] + + // Split argument lists on comma. + in := parseParamList(inps) + out := parseParamList(outps) + + inps = strings.Join(in, ", ") + outps = strings.Join(out, ", ") + + // Try in vain to keep people from editing this file. + // The theory is that they jump into the middle of the file + // without reading the header. + text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" + + // So file name. + if modname == "" { + modname = "libc" + } + + // System call name. + if sysname == "" { + sysname = funct + } + + // System call pointer variable name. + sysvarname := fmt.Sprintf("proc%s", sysname) + + strconvfunc := "BytePtrFromString" + strconvtype := "*byte" + + sysname = strings.ToLower(sysname) // All libc functions are lowercase. + + // Runtime import of function to allow cross-platform builds. + dynimports += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"%s.so\"\n", sysname, sysname, modname) + // Link symbol to proc address variable. + linknames += fmt.Sprintf("//go:linkname %s libc_%s\n", sysvarname, sysname) + // Library proc address variable. + vars = append(vars, sysvarname) + + // Go function header. + outlist := strings.Join(out, ", ") + if outlist != "" { + outlist = fmt.Sprintf(" (%s)", outlist) + } + if text != "" { + text += "\n" + } + text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outlist) + + // Check if err return available + errvar := "" + for _, param := range out { + p := parseParam(param) + if p.Type == "error" { + errvar = p.Name + continue + } + } + + // Prepare arguments to Syscall. + var args []string + n := 0 + for _, param := range in { + p := parseParam(param) + if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { + args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))") + } else if p.Type == "string" && errvar != "" { + text += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) + text += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name) + text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) + args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) + n++ + } else if p.Type == "string" { + fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") + text += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) + text += fmt.Sprintf("\t_p%d, _ = %s(%s)\n", n, strconvfunc, p.Name) + args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) + n++ + } else if s := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); s != nil { + // Convert slice into pointer, length. + // Have to be careful not to take address of &a[0] if len == 0: + // pass nil in that case. + text += fmt.Sprintf("\tvar _p%d *%s\n", n, s[1]) + text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name) + args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n), fmt.Sprintf("uintptr(len(%s))", p.Name)) + n++ + } else if p.Type == "int64" && endianness != "" { + if endianness == "big-endian" { + args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) + } else { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) + } + } else if p.Type == "bool" { + text += fmt.Sprintf("\tvar _p%d uint32\n", n) + text += fmt.Sprintf("\tif %s {\n\t\t_p%d = 1\n\t} else {\n\t\t_p%d = 0\n\t}\n", p.Name, n, n) + args = append(args, fmt.Sprintf("uintptr(_p%d)", n)) + n++ + } else { + args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) + } + } + nargs := len(args) + + // Determine which form to use; pad args with zeros. + asm := "sysvicall6" + if nonblock != nil { + asm = "rawSysvicall6" + } + if len(args) <= 6 { + for len(args) < 6 { + args = append(args, "0") + } + } else { + fmt.Fprintf(os.Stderr, "%s: too many arguments to system call\n", path) + os.Exit(1) + } + + // Actual call. + arglist := strings.Join(args, ", ") + call := fmt.Sprintf("%s(uintptr(unsafe.Pointer(&%s)), %d, %s)", asm, sysvarname, nargs, arglist) + + // Assign return values. + body := "" + ret := []string{"_", "_", "_"} + doErrno := false + for i := 0; i < len(out); i++ { + p := parseParam(out[i]) + reg := "" + if p.Name == "err" { + reg = "e1" + ret[2] = reg + doErrno = true + } else { + reg = fmt.Sprintf("r%d", i) + ret[i] = reg + } + if p.Type == "bool" { + reg = fmt.Sprintf("%d != 0", reg) + } + if p.Type == "int64" && endianness != "" { + // 64-bit number in r1:r0 or r0:r1. + if i+2 > len(out) { + fmt.Fprintf(os.Stderr, "%s: not enough registers for int64 return\n", path) + os.Exit(1) + } + if endianness == "big-endian" { + reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1) + } else { + reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i) + } + ret[i] = fmt.Sprintf("r%d", i) + ret[i+1] = fmt.Sprintf("r%d", i+1) + } + if reg != "e1" { + body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) + } + } + if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" { + text += fmt.Sprintf("\t%s\n", call) + } else { + text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call) + } + text += body + + if doErrno { + text += "\tif e1 != 0 {\n" + text += "\t\terr = e1\n" + text += "\t}\n" + } + text += "\treturn\n" + text += "}\n" + } + if err := s.Err(); err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + file.Close() + } + imp := "" + if pack != "unix" { + imp = "import \"golang.org/x/sys/unix\"\n" + + } + vardecls := "\t" + strings.Join(vars, ",\n\t") + vardecls += " syscallFunc" + fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, imp, dynimports, linknames, vardecls, text) +} + +const srcTemplate = `// %s +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s + +package %s + +import ( + "syscall" + "unsafe" +) +%s +%s +%s +var ( +%s +) + +%s +` diff --git a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.go b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.go new file mode 100644 index 0000000000000..b6b409909cc3c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.go @@ -0,0 +1,355 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// Parse the header files for OpenBSD and generate a Go usable sysctl MIB. +// +// Build a MIB with each entry being an array containing the level, type and +// a hash that will contain additional entries if the current entry is a node. +// We then walk this MIB and create a flattened sysctl name to OID hash. + +package main + +import ( + "bufio" + "fmt" + "os" + "path/filepath" + "regexp" + "sort" + "strings" +) + +var ( + goos, goarch string +) + +// cmdLine returns this programs's commandline arguments. +func cmdLine() string { + return "go run mksysctl_openbsd.go " + strings.Join(os.Args[1:], " ") +} + +// buildTags returns build tags. +func buildTags() string { + return fmt.Sprintf("%s,%s", goarch, goos) +} + +// reMatch performs regular expression match and stores the substring slice to value pointed by m. +func reMatch(re *regexp.Regexp, str string, m *[]string) bool { + *m = re.FindStringSubmatch(str) + if *m != nil { + return true + } + return false +} + +type nodeElement struct { + n int + t string + pE *map[string]nodeElement +} + +var ( + debugEnabled bool + mib map[string]nodeElement + node *map[string]nodeElement + nodeMap map[string]string + sysCtl []string +) + +var ( + ctlNames1RE = regexp.MustCompile(`^#define\s+(CTL_NAMES)\s+{`) + ctlNames2RE = regexp.MustCompile(`^#define\s+(CTL_(.*)_NAMES)\s+{`) + ctlNames3RE = regexp.MustCompile(`^#define\s+((.*)CTL_NAMES)\s+{`) + netInetRE = regexp.MustCompile(`^netinet/`) + netInet6RE = regexp.MustCompile(`^netinet6/`) + netRE = regexp.MustCompile(`^net/`) + bracesRE = regexp.MustCompile(`{.*}`) + ctlTypeRE = regexp.MustCompile(`{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}`) + fsNetKernRE = regexp.MustCompile(`^(fs|net|kern)_`) +) + +func debug(s string) { + if debugEnabled { + fmt.Fprintln(os.Stderr, s) + } +} + +// Walk the MIB and build a sysctl name to OID mapping. +func buildSysctl(pNode *map[string]nodeElement, name string, oid []int) { + lNode := pNode // local copy of pointer to node + var keys []string + for k := range *lNode { + keys = append(keys, k) + } + sort.Strings(keys) + + for _, key := range keys { + nodename := name + if name != "" { + nodename += "." + } + nodename += key + + nodeoid := append(oid, (*pNode)[key].n) + + if (*pNode)[key].t == `CTLTYPE_NODE` { + if _, ok := nodeMap[nodename]; ok { + lNode = &mib + ctlName := nodeMap[nodename] + for _, part := range strings.Split(ctlName, ".") { + lNode = ((*lNode)[part]).pE + } + } else { + lNode = (*pNode)[key].pE + } + buildSysctl(lNode, nodename, nodeoid) + } else if (*pNode)[key].t != "" { + oidStr := []string{} + for j := range nodeoid { + oidStr = append(oidStr, fmt.Sprintf("%d", nodeoid[j])) + } + text := "\t{ \"" + nodename + "\", []_C_int{ " + strings.Join(oidStr, ", ") + " } }, \n" + sysCtl = append(sysCtl, text) + } + } +} + +func main() { + // Get the OS (using GOOS_TARGET if it exist) + goos = os.Getenv("GOOS_TARGET") + if goos == "" { + goos = os.Getenv("GOOS") + } + // Get the architecture (using GOARCH_TARGET if it exists) + goarch = os.Getenv("GOARCH_TARGET") + if goarch == "" { + goarch = os.Getenv("GOARCH") + } + // Check if GOOS and GOARCH environment variables are defined + if goarch == "" || goos == "" { + fmt.Fprintf(os.Stderr, "GOARCH or GOOS not defined in environment\n") + os.Exit(1) + } + + mib = make(map[string]nodeElement) + headers := [...]string{ + `sys/sysctl.h`, + `sys/socket.h`, + `sys/tty.h`, + `sys/malloc.h`, + `sys/mount.h`, + `sys/namei.h`, + `sys/sem.h`, + `sys/shm.h`, + `sys/vmmeter.h`, + `uvm/uvmexp.h`, + `uvm/uvm_param.h`, + `uvm/uvm_swap_encrypt.h`, + `ddb/db_var.h`, + `net/if.h`, + `net/if_pfsync.h`, + `net/pipex.h`, + `netinet/in.h`, + `netinet/icmp_var.h`, + `netinet/igmp_var.h`, + `netinet/ip_ah.h`, + `netinet/ip_carp.h`, + `netinet/ip_divert.h`, + `netinet/ip_esp.h`, + `netinet/ip_ether.h`, + `netinet/ip_gre.h`, + `netinet/ip_ipcomp.h`, + `netinet/ip_ipip.h`, + `netinet/pim_var.h`, + `netinet/tcp_var.h`, + `netinet/udp_var.h`, + `netinet6/in6.h`, + `netinet6/ip6_divert.h`, + `netinet6/pim6_var.h`, + `netinet/icmp6.h`, + `netmpls/mpls.h`, + } + + ctls := [...]string{ + `kern`, + `vm`, + `fs`, + `net`, + //debug /* Special handling required */ + `hw`, + //machdep /* Arch specific */ + `user`, + `ddb`, + //vfs /* Special handling required */ + `fs.posix`, + `kern.forkstat`, + `kern.intrcnt`, + `kern.malloc`, + `kern.nchstats`, + `kern.seminfo`, + `kern.shminfo`, + `kern.timecounter`, + `kern.tty`, + `kern.watchdog`, + `net.bpf`, + `net.ifq`, + `net.inet`, + `net.inet.ah`, + `net.inet.carp`, + `net.inet.divert`, + `net.inet.esp`, + `net.inet.etherip`, + `net.inet.gre`, + `net.inet.icmp`, + `net.inet.igmp`, + `net.inet.ip`, + `net.inet.ip.ifq`, + `net.inet.ipcomp`, + `net.inet.ipip`, + `net.inet.mobileip`, + `net.inet.pfsync`, + `net.inet.pim`, + `net.inet.tcp`, + `net.inet.udp`, + `net.inet6`, + `net.inet6.divert`, + `net.inet6.ip6`, + `net.inet6.icmp6`, + `net.inet6.pim6`, + `net.inet6.tcp6`, + `net.inet6.udp6`, + `net.mpls`, + `net.mpls.ifq`, + `net.key`, + `net.pflow`, + `net.pfsync`, + `net.pipex`, + `net.rt`, + `vm.swapencrypt`, + //vfsgenctl /* Special handling required */ + } + + // Node name "fixups" + ctlMap := map[string]string{ + "ipproto": "net.inet", + "net.inet.ipproto": "net.inet", + "net.inet6.ipv6proto": "net.inet6", + "net.inet6.ipv6": "net.inet6.ip6", + "net.inet.icmpv6": "net.inet6.icmp6", + "net.inet6.divert6": "net.inet6.divert", + "net.inet6.tcp6": "net.inet.tcp", + "net.inet6.udp6": "net.inet.udp", + "mpls": "net.mpls", + "swpenc": "vm.swapencrypt", + } + + // Node mappings + nodeMap = map[string]string{ + "net.inet.ip.ifq": "net.ifq", + "net.inet.pfsync": "net.pfsync", + "net.mpls.ifq": "net.ifq", + } + + mCtls := make(map[string]bool) + for _, ctl := range ctls { + mCtls[ctl] = true + } + + for _, header := range headers { + debug("Processing " + header) + file, err := os.Open(filepath.Join("/usr/include", header)) + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + s := bufio.NewScanner(file) + for s.Scan() { + var sub []string + if reMatch(ctlNames1RE, s.Text(), &sub) || + reMatch(ctlNames2RE, s.Text(), &sub) || + reMatch(ctlNames3RE, s.Text(), &sub) { + if sub[1] == `CTL_NAMES` { + // Top level. + node = &mib + } else { + // Node. + nodename := strings.ToLower(sub[2]) + ctlName := "" + if reMatch(netInetRE, header, &sub) { + ctlName = "net.inet." + nodename + } else if reMatch(netInet6RE, header, &sub) { + ctlName = "net.inet6." + nodename + } else if reMatch(netRE, header, &sub) { + ctlName = "net." + nodename + } else { + ctlName = nodename + ctlName = fsNetKernRE.ReplaceAllString(ctlName, `$1.`) + } + + if val, ok := ctlMap[ctlName]; ok { + ctlName = val + } + if _, ok := mCtls[ctlName]; !ok { + debug("Ignoring " + ctlName + "...") + continue + } + + // Walk down from the top of the MIB. + node = &mib + for _, part := range strings.Split(ctlName, ".") { + if _, ok := (*node)[part]; !ok { + debug("Missing node " + part) + (*node)[part] = nodeElement{n: 0, t: "", pE: &map[string]nodeElement{}} + } + node = (*node)[part].pE + } + } + + // Populate current node with entries. + i := -1 + for !strings.HasPrefix(s.Text(), "}") { + s.Scan() + if reMatch(bracesRE, s.Text(), &sub) { + i++ + } + if !reMatch(ctlTypeRE, s.Text(), &sub) { + continue + } + (*node)[sub[1]] = nodeElement{n: i, t: sub[2], pE: &map[string]nodeElement{}} + } + } + } + err = s.Err() + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + file.Close() + } + buildSysctl(&mib, "", []int{}) + + sort.Strings(sysCtl) + text := strings.Join(sysCtl, "") + + fmt.Printf(srcTemplate, cmdLine(), buildTags(), text) +} + +const srcTemplate = `// %s +// Code generated by the command above; DO NOT EDIT. + +// +build %s + +package unix + +type mibentry struct { + ctlname string + ctloid []_C_int +} + +var sysctlMib = []mibentry { +%s +} +` diff --git a/vendor/golang.org/x/sys/unix/mksysnum.go b/vendor/golang.org/x/sys/unix/mksysnum.go new file mode 100644 index 0000000000000..baa6ecd85065d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mksysnum.go @@ -0,0 +1,190 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// Generate system call table for DragonFly, NetBSD, +// FreeBSD, OpenBSD or Darwin from master list +// (for example, /usr/src/sys/kern/syscalls.master or +// sys/syscall.h). +package main + +import ( + "bufio" + "fmt" + "io" + "io/ioutil" + "net/http" + "os" + "regexp" + "strings" +) + +var ( + goos, goarch string +) + +// cmdLine returns this programs's commandline arguments +func cmdLine() string { + return "go run mksysnum.go " + strings.Join(os.Args[1:], " ") +} + +// buildTags returns build tags +func buildTags() string { + return fmt.Sprintf("%s,%s", goarch, goos) +} + +func checkErr(err error) { + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } +} + +// source string and substring slice for regexp +type re struct { + str string // source string + sub []string // matched sub-string +} + +// Match performs regular expression match +func (r *re) Match(exp string) bool { + r.sub = regexp.MustCompile(exp).FindStringSubmatch(r.str) + if r.sub != nil { + return true + } + return false +} + +// fetchFile fetches a text file from URL +func fetchFile(URL string) io.Reader { + resp, err := http.Get(URL) + checkErr(err) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + checkErr(err) + return strings.NewReader(string(body)) +} + +// readFile reads a text file from path +func readFile(path string) io.Reader { + file, err := os.Open(os.Args[1]) + checkErr(err) + return file +} + +func format(name, num, proto string) string { + name = strings.ToUpper(name) + // There are multiple entries for enosys and nosys, so comment them out. + nm := re{str: name} + if nm.Match(`^SYS_E?NOSYS$`) { + name = fmt.Sprintf("// %s", name) + } + if name == `SYS_SYS_EXIT` { + name = `SYS_EXIT` + } + return fmt.Sprintf(" %s = %s; // %s\n", name, num, proto) +} + +func main() { + // Get the OS (using GOOS_TARGET if it exist) + goos = os.Getenv("GOOS_TARGET") + if goos == "" { + goos = os.Getenv("GOOS") + } + // Get the architecture (using GOARCH_TARGET if it exists) + goarch = os.Getenv("GOARCH_TARGET") + if goarch == "" { + goarch = os.Getenv("GOARCH") + } + // Check if GOOS and GOARCH environment variables are defined + if goarch == "" || goos == "" { + fmt.Fprintf(os.Stderr, "GOARCH or GOOS not defined in environment\n") + os.Exit(1) + } + + file := strings.TrimSpace(os.Args[1]) + var syscalls io.Reader + if strings.HasPrefix(file, "https://") || strings.HasPrefix(file, "http://") { + // Download syscalls.master file + syscalls = fetchFile(file) + } else { + syscalls = readFile(file) + } + + var text, line string + s := bufio.NewScanner(syscalls) + for s.Scan() { + t := re{str: line} + if t.Match(`^(.*)\\$`) { + // Handle continuation + line = t.sub[1] + line += strings.TrimLeft(s.Text(), " \t") + } else { + // New line + line = s.Text() + } + t = re{str: line} + if t.Match(`\\$`) { + continue + } + t = re{str: line} + + switch goos { + case "dragonfly": + if t.Match(`^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$`) { + num, proto := t.sub[1], t.sub[2] + name := fmt.Sprintf("SYS_%s", t.sub[3]) + text += format(name, num, proto) + } + case "freebsd": + if t.Match(`^([0-9]+)\s+\S+\s+(?:(?:NO)?STD|COMPAT10)\s+({ \S+\s+(\w+).*)$`) { + num, proto := t.sub[1], t.sub[2] + name := fmt.Sprintf("SYS_%s", t.sub[3]) + text += format(name, num, proto) + } + case "openbsd": + if t.Match(`^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$`) { + num, proto, name := t.sub[1], t.sub[3], t.sub[4] + text += format(name, num, proto) + } + case "netbsd": + if t.Match(`^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$`) { + num, proto, compat := t.sub[1], t.sub[6], t.sub[8] + name := t.sub[7] + "_" + t.sub[9] + if t.sub[11] != "" { + name = t.sub[7] + "_" + t.sub[11] + } + name = strings.ToUpper(name) + if compat == "" || compat == "13" || compat == "30" || compat == "50" { + text += fmt.Sprintf(" %s = %s; // %s\n", name, num, proto) + } + } + case "darwin": + if t.Match(`^#define\s+SYS_(\w+)\s+([0-9]+)`) { + name, num := t.sub[1], t.sub[2] + name = strings.ToUpper(name) + text += fmt.Sprintf(" SYS_%s = %s;\n", name, num) + } + default: + fmt.Fprintf(os.Stderr, "unrecognized GOOS=%s\n", goos) + os.Exit(1) + + } + } + err := s.Err() + checkErr(err) + + fmt.Printf(template, cmdLine(), buildTags(), text) +} + +const template = `// %s +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build %s + +package unix + +const( +%s)` diff --git a/vendor/golang.org/x/sys/unix/types_aix.go b/vendor/golang.org/x/sys/unix/types_aix.go new file mode 100644 index 0000000000000..40d2beede5565 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_aix.go @@ -0,0 +1,237 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore +// +build aix + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + + +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics + +const ( + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong + PathMax = C.PATH_MAX +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +type off64 C.off64_t +type off C.off_t +type Mode_t C.mode_t + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +type Timeval32 C.struct_timeval32 + +type Timex C.struct_timex + +type Time_t C.time_t + +type Tms C.struct_tms + +type Utimbuf C.struct_utimbuf + +type Timezone C.struct_timezone + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit64 + +type Pid_t C.pid_t + +type _Gid_t C.gid_t + +type dev_t C.dev_t + +// Files + +type Stat_t C.struct_stat + +type StatxTimestamp C.struct_statx_timestamp + +type Statx_t C.struct_statx + +type Dirent C.struct_dirent + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Cmsghdr C.struct_cmsghdr + +type ICMPv6Filter C.struct_icmp6_filter + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type Linger C.struct_linger + +type Msghdr C.struct_msghdr + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr +) + +type IfMsgHdr C.struct_if_msghdr + +// Misc + +type FdSet C.fd_set + +type Utsname C.struct_utsname + +type Ustat_t C.struct_ustat + +type Sigset_t C.sigset_t + +const ( + AT_FDCWD = C.AT_FDCWD + AT_REMOVEDIR = C.AT_REMOVEDIR + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) + +// Terminal handling + +type Termios C.struct_termios + +type Termio C.struct_termio + +type Winsize C.struct_winsize + +//poll + +type PollFd struct { + Fd int32 + Events uint16 + Revents uint16 +} + +const ( + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLIN = C.POLLIN + POLLNVAL = C.POLLNVAL + POLLOUT = C.POLLOUT + POLLPRI = C.POLLPRI + POLLRDBAND = C.POLLRDBAND + POLLRDNORM = C.POLLRDNORM + POLLWRBAND = C.POLLWRBAND + POLLWRNORM = C.POLLWRNORM +) + +//flock_t + +type Flock_t C.struct_flock64 + +// Statfs + +type Fsid_t C.struct_fsid_t +type Fsid64_t C.struct_fsid64_t + +type Statfs_t C.struct_statfs + +const RNDGETENTCNT = 0x80045200 diff --git a/vendor/golang.org/x/sys/unix/types_darwin.go b/vendor/golang.org/x/sys/unix/types_darwin.go new file mode 100644 index 0000000000000..155c2e692b45e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_darwin.go @@ -0,0 +1,283 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +Input to cgo -godefs. See README.md +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define __DARWIN_UNIX03 0 +#define KERNEL +#define _DARWIN_USE_64_BIT_INODE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics + +const ( + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +type Timeval32 C.struct_timeval32 + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat64 + +type Statfs_t C.struct_statfs64 + +type Flock_t C.struct_flock + +type Fstore_t C.struct_fstore + +type Radvisory_t C.struct_radvisory + +type Fbootstraptransfer_t C.struct_fbootstraptransfer + +type Log2phys_t C.struct_log2phys + +type Fsid C.struct_fsid + +type Dirent C.struct_dirent + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet4Pktinfo C.struct_in_pktinfo + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr + SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfmaMsghdr C.struct_ifma_msghdr + +type IfmaMsghdr2 C.struct_ifma_msghdr2 + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +// Terminal handling + +type Termios C.struct_termios + +type Winsize C.struct_winsize + +// fchmodat-like syscalls. + +const ( + AT_FDCWD = C.AT_FDCWD + AT_REMOVEDIR = C.AT_REMOVEDIR + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) + +// poll + +type PollFd C.struct_pollfd + +const ( + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLIN = C.POLLIN + POLLNVAL = C.POLLNVAL + POLLOUT = C.POLLOUT + POLLPRI = C.POLLPRI + POLLRDBAND = C.POLLRDBAND + POLLRDNORM = C.POLLRDNORM + POLLWRBAND = C.POLLWRBAND + POLLWRNORM = C.POLLWRNORM +) + +// uname + +type Utsname C.struct_utsname + +// Clockinfo + +const SizeofClockinfo = C.sizeof_struct_clockinfo + +type Clockinfo C.struct_clockinfo diff --git a/vendor/golang.org/x/sys/unix/types_dragonfly.go b/vendor/golang.org/x/sys/unix/types_dragonfly.go new file mode 100644 index 0000000000000..3365dd79d082c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_dragonfly.go @@ -0,0 +1,263 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +Input to cgo -godefs. See README.md +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics + +const ( + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat + +type Statfs_t C.struct_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type Fsid C.struct_fsid + +// File system limits + +const ( + PathMax = C.PATH_MAX +) + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfmaMsghdr C.struct_ifma_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +// Terminal handling + +type Termios C.struct_termios + +type Winsize C.struct_winsize + +// fchmodat-like syscalls. + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) + +// poll + +type PollFd C.struct_pollfd + +const ( + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLIN = C.POLLIN + POLLNVAL = C.POLLNVAL + POLLOUT = C.POLLOUT + POLLPRI = C.POLLPRI + POLLRDBAND = C.POLLRDBAND + POLLRDNORM = C.POLLRDNORM + POLLWRBAND = C.POLLWRBAND + POLLWRNORM = C.POLLWRNORM +) + +// Uname + +type Utsname C.struct_utsname diff --git a/vendor/golang.org/x/sys/unix/types_freebsd.go b/vendor/golang.org/x/sys/unix/types_freebsd.go new file mode 100644 index 0000000000000..a121dc3368f92 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_freebsd.go @@ -0,0 +1,400 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +Input to cgo -godefs. See README.md +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define _WANT_FREEBSD11_STAT 1 +#define _WANT_FREEBSD11_STATFS 1 +#define _WANT_FREEBSD11_DIRENT 1 +#define _WANT_FREEBSD11_KEVENT 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +// This structure is a duplicate of if_data on FreeBSD 8-STABLE. +// See /usr/include/net/if.h. +struct if_data8 { + u_char ifi_type; + u_char ifi_physical; + u_char ifi_addrlen; + u_char ifi_hdrlen; + u_char ifi_link_state; + u_char ifi_spare_char1; + u_char ifi_spare_char2; + u_char ifi_datalen; + u_long ifi_mtu; + u_long ifi_metric; + u_long ifi_baudrate; + u_long ifi_ipackets; + u_long ifi_ierrors; + u_long ifi_opackets; + u_long ifi_oerrors; + u_long ifi_collisions; + u_long ifi_ibytes; + u_long ifi_obytes; + u_long ifi_imcasts; + u_long ifi_omcasts; + u_long ifi_iqdrops; + u_long ifi_noproto; + u_long ifi_hwassist; +// FIXME: these are now unions, so maybe need to change definitions? +#undef ifi_epoch + time_t ifi_epoch; +#undef ifi_lastchange + struct timeval ifi_lastchange; +}; + +// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE. +// See /usr/include/net/if.h. +struct if_msghdr8 { + u_short ifm_msglen; + u_char ifm_version; + u_char ifm_type; + int ifm_addrs; + int ifm_flags; + u_short ifm_index; + struct if_data8 ifm_data; +}; +*/ +import "C" + +// Machine characteristics + +const ( + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +const ( + _statfsVersion = C.STATFS_VERSION + _dirblksiz = C.DIRBLKSIZ +) + +type Stat_t C.struct_stat + +type stat_freebsd11_t C.struct_freebsd11_stat + +type Statfs_t C.struct_statfs + +type statfs_freebsd11_t C.struct_freebsd11_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type dirent_freebsd11 C.struct_freebsd11_dirent + +type Fsid C.struct_fsid + +// File system limits + +const ( + PathMax = C.PATH_MAX +) + +// Advice to Fadvise + +const ( + FADV_NORMAL = C.POSIX_FADV_NORMAL + FADV_RANDOM = C.POSIX_FADV_RANDOM + FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL + FADV_WILLNEED = C.POSIX_FADV_WILLNEED + FADV_DONTNEED = C.POSIX_FADV_DONTNEED + FADV_NOREUSE = C.POSIX_FADV_NOREUSE +) + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPMreqn C.struct_ip_mreqn + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPMreqn = C.sizeof_struct_ip_mreqn + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_ATTACH = C.PT_ATTACH + PTRACE_CONT = C.PT_CONTINUE + PTRACE_DETACH = C.PT_DETACH + PTRACE_GETFPREGS = C.PT_GETFPREGS + PTRACE_GETFSBASE = C.PT_GETFSBASE + PTRACE_GETLWPLIST = C.PT_GETLWPLIST + PTRACE_GETNUMLWPS = C.PT_GETNUMLWPS + PTRACE_GETREGS = C.PT_GETREGS + PTRACE_GETXSTATE = C.PT_GETXSTATE + PTRACE_IO = C.PT_IO + PTRACE_KILL = C.PT_KILL + PTRACE_LWPEVENTS = C.PT_LWP_EVENTS + PTRACE_LWPINFO = C.PT_LWPINFO + PTRACE_SETFPREGS = C.PT_SETFPREGS + PTRACE_SETREGS = C.PT_SETREGS + PTRACE_SINGLESTEP = C.PT_STEP + PTRACE_TRACEME = C.PT_TRACE_ME +) + +const ( + PIOD_READ_D = C.PIOD_READ_D + PIOD_WRITE_D = C.PIOD_WRITE_D + PIOD_READ_I = C.PIOD_READ_I + PIOD_WRITE_I = C.PIOD_WRITE_I +) + +const ( + PL_FLAG_BORN = C.PL_FLAG_BORN + PL_FLAG_EXITED = C.PL_FLAG_EXITED + PL_FLAG_SI = C.PL_FLAG_SI +) + +const ( + TRAP_BRKPT = C.TRAP_BRKPT + TRAP_TRACE = C.TRAP_TRACE +) + +type PtraceLwpInfoStruct C.struct_ptrace_lwpinfo + +type __Siginfo C.struct___siginfo + +type Sigset_t C.sigset_t + +type Reg C.struct_reg + +type FpReg C.struct_fpreg + +type PtraceIoDesc C.struct_ptrace_io_desc + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent_freebsd11 + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + sizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfMsghdr = C.sizeof_struct_if_msghdr8 + sizeofIfData = C.sizeof_struct_if_data + SizeofIfData = C.sizeof_struct_if_data8 + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type ifMsghdr C.struct_if_msghdr + +type IfMsghdr C.struct_if_msghdr8 + +type ifData C.struct_if_data + +type IfData C.struct_if_data8 + +type IfaMsghdr C.struct_ifa_msghdr + +type IfmaMsghdr C.struct_ifma_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr + SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfZbuf C.struct_bpf_zbuf + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +type BpfZbufHeader C.struct_bpf_zbuf_header + +// Terminal handling + +type Termios C.struct_termios + +type Winsize C.struct_winsize + +// fchmodat-like syscalls. + +const ( + AT_FDCWD = C.AT_FDCWD + AT_REMOVEDIR = C.AT_REMOVEDIR + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) + +// poll + +type PollFd C.struct_pollfd + +const ( + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLIN = C.POLLIN + POLLINIGNEOF = C.POLLINIGNEOF + POLLNVAL = C.POLLNVAL + POLLOUT = C.POLLOUT + POLLPRI = C.POLLPRI + POLLRDBAND = C.POLLRDBAND + POLLRDNORM = C.POLLRDNORM + POLLWRBAND = C.POLLWRBAND + POLLWRNORM = C.POLLWRNORM +) + +// Capabilities + +type CapRights C.struct_cap_rights + +// Uname + +type Utsname C.struct_utsname diff --git a/vendor/golang.org/x/sys/unix/types_netbsd.go b/vendor/golang.org/x/sys/unix/types_netbsd.go new file mode 100644 index 0000000000000..4a96d72c37d18 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_netbsd.go @@ -0,0 +1,290 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +Input to cgo -godefs. See README.md +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics + +const ( + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat + +type Statfs_t C.struct_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type Fsid C.fsid_t + +// File system limits + +const ( + PathMax = C.PATH_MAX +) + +// Advice to Fadvise + +const ( + FADV_NORMAL = C.POSIX_FADV_NORMAL + FADV_RANDOM = C.POSIX_FADV_RANDOM + FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL + FADV_WILLNEED = C.POSIX_FADV_WILLNEED + FADV_DONTNEED = C.POSIX_FADV_DONTNEED + FADV_NOREUSE = C.POSIX_FADV_NOREUSE +) + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +type Mclpool C.struct_mclpool + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +type BpfTimeval C.struct_bpf_timeval + +// Terminal handling + +type Termios C.struct_termios + +type Winsize C.struct_winsize + +type Ptmget C.struct_ptmget + +// fchmodat-like syscalls. + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) + +// poll + +type PollFd C.struct_pollfd + +const ( + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLIN = C.POLLIN + POLLNVAL = C.POLLNVAL + POLLOUT = C.POLLOUT + POLLPRI = C.POLLPRI + POLLRDBAND = C.POLLRDBAND + POLLRDNORM = C.POLLRDNORM + POLLWRBAND = C.POLLWRBAND + POLLWRNORM = C.POLLWRNORM +) + +// Sysctl + +type Sysctlnode C.struct_sysctlnode + +// Uname + +type Utsname C.struct_utsname + +// Clockinfo + +const SizeofClockinfo = C.sizeof_struct_clockinfo + +type Clockinfo C.struct_clockinfo diff --git a/vendor/golang.org/x/sys/unix/types_openbsd.go b/vendor/golang.org/x/sys/unix/types_openbsd.go new file mode 100644 index 0000000000000..775cb57dc8a88 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_openbsd.go @@ -0,0 +1,283 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +Input to cgo -godefs. See README.md +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics + +const ( + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat + +type Statfs_t C.struct_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type Fsid C.fsid_t + +// File system limits + +const ( + PathMax = C.PATH_MAX +) + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +type Mclpool C.struct_mclpool + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +type BpfTimeval C.struct_bpf_timeval + +// Terminal handling + +type Termios C.struct_termios + +type Winsize C.struct_winsize + +// fchmodat-like syscalls. + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) + +// poll + +type PollFd C.struct_pollfd + +const ( + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLIN = C.POLLIN + POLLNVAL = C.POLLNVAL + POLLOUT = C.POLLOUT + POLLPRI = C.POLLPRI + POLLRDBAND = C.POLLRDBAND + POLLRDNORM = C.POLLRDNORM + POLLWRBAND = C.POLLWRBAND + POLLWRNORM = C.POLLWRNORM +) + +// Signal Sets + +type Sigset_t C.sigset_t + +// Uname + +type Utsname C.struct_utsname + +// Uvmexp + +const SizeofUvmexp = C.sizeof_struct_uvmexp + +type Uvmexp C.struct_uvmexp + +// Clockinfo + +const SizeofClockinfo = C.sizeof_struct_clockinfo + +type Clockinfo C.struct_clockinfo diff --git a/vendor/golang.org/x/sys/unix/types_solaris.go b/vendor/golang.org/x/sys/unix/types_solaris.go new file mode 100644 index 0000000000000..2b716f93481d8 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_solaris.go @@ -0,0 +1,266 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +/* +Input to cgo -godefs. See README.md +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +// These defines ensure that builds done on newer versions of Solaris are +// backwards-compatible with older versions of Solaris and +// OpenSolaris-based derivatives. +#define __USE_SUNOS_SOCKETS__ // msghdr +#define __USE_LEGACY_PROTOTYPES__ // iovec +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics + +const ( + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong + PathMax = C.PATH_MAX + MaxHostNameLen = C.MAXHOSTNAMELEN +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +type Timeval32 C.struct_timeval32 + +type Tms C.struct_tms + +type Utimbuf C.struct_utimbuf + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +// Filesystems + +type _Fsblkcnt_t C.fsblkcnt_t + +type Statvfs_t C.struct_statvfs + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Select + +type FdSet C.fd_set + +// Misc + +type Utsname C.struct_utsname + +type Ustat_t C.struct_ustat + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_REMOVEDIR = C.AT_REMOVEDIR + AT_EACCESS = C.AT_EACCESS +) + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfTimeval C.struct_bpf_timeval + +type BpfHdr C.struct_bpf_hdr + +// Terminal handling + +type Termios C.struct_termios + +type Termio C.struct_termio + +type Winsize C.struct_winsize + +// poll + +type PollFd C.struct_pollfd + +const ( + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLIN = C.POLLIN + POLLNVAL = C.POLLNVAL + POLLOUT = C.POLLOUT + POLLPRI = C.POLLPRI + POLLRDBAND = C.POLLRDBAND + POLLRDNORM = C.POLLRDNORM + POLLWRBAND = C.POLLWRBAND + POLLWRNORM = C.POLLWRNORM +) diff --git a/vendor/golang.org/x/text/encoding/internal/identifier/gen.go b/vendor/golang.org/x/text/encoding/internal/identifier/gen.go new file mode 100644 index 0000000000000..26cfef9c6b71c --- /dev/null +++ b/vendor/golang.org/x/text/encoding/internal/identifier/gen.go @@ -0,0 +1,142 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package main + +import ( + "bytes" + "encoding/xml" + "fmt" + "io" + "log" + "strings" + + "golang.org/x/text/internal/gen" +) + +type registry struct { + XMLName xml.Name `xml:"registry"` + Updated string `xml:"updated"` + Registry []struct { + ID string `xml:"id,attr"` + Record []struct { + Name string `xml:"name"` + Xref []struct { + Type string `xml:"type,attr"` + Data string `xml:"data,attr"` + } `xml:"xref"` + Desc struct { + Data string `xml:",innerxml"` + // Any []struct { + // Data string `xml:",chardata"` + // } `xml:",any"` + // Data string `xml:",chardata"` + } `xml:"description,"` + MIB string `xml:"value"` + Alias []string `xml:"alias"` + MIME string `xml:"preferred_alias"` + } `xml:"record"` + } `xml:"registry"` +} + +func main() { + r := gen.OpenIANAFile("assignments/character-sets/character-sets.xml") + reg := ®istry{} + if err := xml.NewDecoder(r).Decode(®); err != nil && err != io.EOF { + log.Fatalf("Error decoding charset registry: %v", err) + } + if len(reg.Registry) == 0 || reg.Registry[0].ID != "character-sets-1" { + log.Fatalf("Unexpected ID %s", reg.Registry[0].ID) + } + + w := &bytes.Buffer{} + fmt.Fprintf(w, "const (\n") + for _, rec := range reg.Registry[0].Record { + constName := "" + for _, a := range rec.Alias { + if strings.HasPrefix(a, "cs") && strings.IndexByte(a, '-') == -1 { + // Some of the constant definitions have comments in them. Strip those. + constName = strings.Title(strings.SplitN(a[2:], "\n", 2)[0]) + } + } + if constName == "" { + switch rec.MIB { + case "2085": + constName = "HZGB2312" // Not listed as alias for some reason. + default: + log.Fatalf("No cs alias defined for %s.", rec.MIB) + } + } + if rec.MIME != "" { + rec.MIME = fmt.Sprintf(" (MIME: %s)", rec.MIME) + } + fmt.Fprintf(w, "// %s is the MIB identifier with IANA name %s%s.\n//\n", constName, rec.Name, rec.MIME) + if len(rec.Desc.Data) > 0 { + fmt.Fprint(w, "// ") + d := xml.NewDecoder(strings.NewReader(rec.Desc.Data)) + inElem := true + attr := "" + for { + t, err := d.Token() + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + switch x := t.(type) { + case xml.CharData: + attr = "" // Don't need attribute info. + a := bytes.Split([]byte(x), []byte("\n")) + for i, b := range a { + if b = bytes.TrimSpace(b); len(b) != 0 { + if !inElem && i > 0 { + fmt.Fprint(w, "\n// ") + } + inElem = false + fmt.Fprintf(w, "%s ", string(b)) + } + } + case xml.StartElement: + if x.Name.Local == "xref" { + inElem = true + use := false + for _, a := range x.Attr { + if a.Name.Local == "type" { + use = use || a.Value != "person" + } + if a.Name.Local == "data" && use { + // Patch up URLs to use https. From some links, the + // https version is different from the http one. + s := a.Value + s = strings.Replace(s, "http://", "https://", -1) + s = strings.Replace(s, "/unicode/", "/", -1) + attr = s + " " + } + } + } + case xml.EndElement: + inElem = false + fmt.Fprint(w, attr) + } + } + fmt.Fprint(w, "\n") + } + for _, x := range rec.Xref { + switch x.Type { + case "rfc": + fmt.Fprintf(w, "// Reference: %s\n", strings.ToUpper(x.Data)) + case "uri": + fmt.Fprintf(w, "// Reference: %s\n", x.Data) + } + } + fmt.Fprintf(w, "%s MIB = %s\n", constName, rec.MIB) + fmt.Fprintln(w) + } + fmt.Fprintln(w, ")") + + gen.WriteGoFile("mib.go", "identifier", w.Bytes()) +} diff --git a/vendor/golang.org/x/text/unicode/bidi/gen.go b/vendor/golang.org/x/text/unicode/bidi/gen.go new file mode 100644 index 0000000000000..987fc169cc04a --- /dev/null +++ b/vendor/golang.org/x/text/unicode/bidi/gen.go @@ -0,0 +1,133 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package main + +import ( + "flag" + "log" + + "golang.org/x/text/internal/gen" + "golang.org/x/text/internal/triegen" + "golang.org/x/text/internal/ucd" +) + +var outputFile = flag.String("out", "tables.go", "output file") + +func main() { + gen.Init() + gen.Repackage("gen_trieval.go", "trieval.go", "bidi") + gen.Repackage("gen_ranges.go", "ranges_test.go", "bidi") + + genTables() +} + +// bidiClass names and codes taken from class "bc" in +// https://www.unicode.org/Public/8.0.0/ucd/PropertyValueAliases.txt +var bidiClass = map[string]Class{ + "AL": AL, // ArabicLetter + "AN": AN, // ArabicNumber + "B": B, // ParagraphSeparator + "BN": BN, // BoundaryNeutral + "CS": CS, // CommonSeparator + "EN": EN, // EuropeanNumber + "ES": ES, // EuropeanSeparator + "ET": ET, // EuropeanTerminator + "L": L, // LeftToRight + "NSM": NSM, // NonspacingMark + "ON": ON, // OtherNeutral + "R": R, // RightToLeft + "S": S, // SegmentSeparator + "WS": WS, // WhiteSpace + + "FSI": Control, + "PDF": Control, + "PDI": Control, + "LRE": Control, + "LRI": Control, + "LRO": Control, + "RLE": Control, + "RLI": Control, + "RLO": Control, +} + +func genTables() { + if numClass > 0x0F { + log.Fatalf("Too many Class constants (%#x > 0x0F).", numClass) + } + w := gen.NewCodeWriter() + defer w.WriteVersionedGoFile(*outputFile, "bidi") + + gen.WriteUnicodeVersion(w) + + t := triegen.NewTrie("bidi") + + // Build data about bracket mapping. These bits need to be or-ed with + // any other bits. + orMask := map[rune]uint64{} + + xorMap := map[rune]int{} + xorMasks := []rune{0} // First value is no-op. + + ucd.Parse(gen.OpenUCDFile("BidiBrackets.txt"), func(p *ucd.Parser) { + r1 := p.Rune(0) + r2 := p.Rune(1) + xor := r1 ^ r2 + if _, ok := xorMap[xor]; !ok { + xorMap[xor] = len(xorMasks) + xorMasks = append(xorMasks, xor) + } + entry := uint64(xorMap[xor]) << xorMaskShift + switch p.String(2) { + case "o": + entry |= openMask + case "c", "n": + default: + log.Fatalf("Unknown bracket class %q.", p.String(2)) + } + orMask[r1] = entry + }) + + w.WriteComment(` + xorMasks contains masks to be xor-ed with brackets to get the reverse + version.`) + w.WriteVar("xorMasks", xorMasks) + + done := map[rune]bool{} + + insert := func(r rune, c Class) { + if !done[r] { + t.Insert(r, orMask[r]|uint64(c)) + done[r] = true + } + } + + // Insert the derived BiDi properties. + ucd.Parse(gen.OpenUCDFile("extracted/DerivedBidiClass.txt"), func(p *ucd.Parser) { + r := p.Rune(0) + class, ok := bidiClass[p.String(1)] + if !ok { + log.Fatalf("%U: Unknown BiDi class %q", r, p.String(1)) + } + insert(r, class) + }) + visitDefaults(insert) + + // TODO: use sparse blocks. This would reduce table size considerably + // from the looks of it. + + sz, err := t.Gen(w) + if err != nil { + log.Fatal(err) + } + w.Size += sz +} + +// dummy values to make methods in gen_common compile. The real versions +// will be generated by this file to tables.go. +var ( + xorMasks []rune +) diff --git a/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go b/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go new file mode 100644 index 0000000000000..02c3b505d640e --- /dev/null +++ b/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go @@ -0,0 +1,57 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package main + +import ( + "unicode" + + "golang.org/x/text/internal/gen" + "golang.org/x/text/internal/ucd" + "golang.org/x/text/unicode/rangetable" +) + +// These tables are hand-extracted from: +// https://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt +func visitDefaults(fn func(r rune, c Class)) { + // first write default values for ranges listed above. + visitRunes(fn, AL, []rune{ + 0x0600, 0x07BF, // Arabic + 0x08A0, 0x08FF, // Arabic Extended-A + 0xFB50, 0xFDCF, // Arabic Presentation Forms + 0xFDF0, 0xFDFF, + 0xFE70, 0xFEFF, + 0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols + }) + visitRunes(fn, R, []rune{ + 0x0590, 0x05FF, // Hebrew + 0x07C0, 0x089F, // Nko et al. + 0xFB1D, 0xFB4F, + 0x00010800, 0x00010FFF, // Cypriot Syllabary et. al. + 0x0001E800, 0x0001EDFF, + 0x0001EF00, 0x0001EFFF, + }) + visitRunes(fn, ET, []rune{ // European Terminator + 0x20A0, 0x20Cf, // Currency symbols + }) + rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) { + fn(r, BN) // Boundary Neutral + }) + ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) { + if p.String(1) == "Default_Ignorable_Code_Point" { + fn(p.Rune(0), BN) // Boundary Neutral + } + }) +} + +func visitRunes(fn func(r rune, c Class), c Class, runes []rune) { + for i := 0; i < len(runes); i += 2 { + lo, hi := runes[i], runes[i+1] + for j := lo; j <= hi; j++ { + fn(j, c) + } + } +} diff --git a/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go b/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go new file mode 100644 index 0000000000000..9cb9942894920 --- /dev/null +++ b/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go @@ -0,0 +1,64 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package main + +// Class is the Unicode BiDi class. Each rune has a single class. +type Class uint + +const ( + L Class = iota // LeftToRight + R // RightToLeft + EN // EuropeanNumber + ES // EuropeanSeparator + ET // EuropeanTerminator + AN // ArabicNumber + CS // CommonSeparator + B // ParagraphSeparator + S // SegmentSeparator + WS // WhiteSpace + ON // OtherNeutral + BN // BoundaryNeutral + NSM // NonspacingMark + AL // ArabicLetter + Control // Control LRO - PDI + + numClass + + LRO // LeftToRightOverride + RLO // RightToLeftOverride + LRE // LeftToRightEmbedding + RLE // RightToLeftEmbedding + PDF // PopDirectionalFormat + LRI // LeftToRightIsolate + RLI // RightToLeftIsolate + FSI // FirstStrongIsolate + PDI // PopDirectionalIsolate + + unknownClass = ^Class(0) +) + +var controlToClass = map[rune]Class{ + 0x202D: LRO, // LeftToRightOverride, + 0x202E: RLO, // RightToLeftOverride, + 0x202A: LRE, // LeftToRightEmbedding, + 0x202B: RLE, // RightToLeftEmbedding, + 0x202C: PDF, // PopDirectionalFormat, + 0x2066: LRI, // LeftToRightIsolate, + 0x2067: RLI, // RightToLeftIsolate, + 0x2068: FSI, // FirstStrongIsolate, + 0x2069: PDI, // PopDirectionalIsolate, +} + +// A trie entry has the following bits: +// 7..5 XOR mask for brackets +// 4 1: Bracket open, 0: Bracket close +// 3..0 Class type + +const ( + openMask = 0x10 + xorMaskShift = 5 +) diff --git a/vendor/golang.org/x/text/unicode/norm/maketables.go b/vendor/golang.org/x/text/unicode/norm/maketables.go new file mode 100644 index 0000000000000..30a3aa93343d2 --- /dev/null +++ b/vendor/golang.org/x/text/unicode/norm/maketables.go @@ -0,0 +1,986 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// Normalization table generator. +// Data read from the web. +// See forminfo.go for a description of the trie values associated with each rune. + +package main + +import ( + "bytes" + "encoding/binary" + "flag" + "fmt" + "io" + "log" + "sort" + "strconv" + "strings" + + "golang.org/x/text/internal/gen" + "golang.org/x/text/internal/triegen" + "golang.org/x/text/internal/ucd" +) + +func main() { + gen.Init() + loadUnicodeData() + compactCCC() + loadCompositionExclusions() + completeCharFields(FCanonical) + completeCharFields(FCompatibility) + computeNonStarterCounts() + verifyComputed() + printChars() + testDerived() + printTestdata() + makeTables() +} + +var ( + tablelist = flag.String("tables", + "all", + "comma-separated list of which tables to generate; "+ + "can be 'decomp', 'recomp', 'info' and 'all'") + test = flag.Bool("test", + false, + "test existing tables against DerivedNormalizationProps and generate test data for regression testing") + verbose = flag.Bool("verbose", + false, + "write data to stdout as it is parsed") +) + +const MaxChar = 0x10FFFF // anything above this shouldn't exist + +// Quick Check properties of runes allow us to quickly +// determine whether a rune may occur in a normal form. +// For a given normal form, a rune may be guaranteed to occur +// verbatim (QC=Yes), may or may not combine with another +// rune (QC=Maybe), or may not occur (QC=No). +type QCResult int + +const ( + QCUnknown QCResult = iota + QCYes + QCNo + QCMaybe +) + +func (r QCResult) String() string { + switch r { + case QCYes: + return "Yes" + case QCNo: + return "No" + case QCMaybe: + return "Maybe" + } + return "***UNKNOWN***" +} + +const ( + FCanonical = iota // NFC or NFD + FCompatibility // NFKC or NFKD + FNumberOfFormTypes +) + +const ( + MComposed = iota // NFC or NFKC + MDecomposed // NFD or NFKD + MNumberOfModes +) + +// This contains only the properties we're interested in. +type Char struct { + name string + codePoint rune // if zero, this index is not a valid code point. + ccc uint8 // canonical combining class + origCCC uint8 + excludeInComp bool // from CompositionExclusions.txt + compatDecomp bool // it has a compatibility expansion + + nTrailingNonStarters uint8 + nLeadingNonStarters uint8 // must be equal to trailing if non-zero + + forms [FNumberOfFormTypes]FormInfo // For FCanonical and FCompatibility + + state State +} + +var chars = make([]Char, MaxChar+1) +var cccMap = make(map[uint8]uint8) + +func (c Char) String() string { + buf := new(bytes.Buffer) + + fmt.Fprintf(buf, "%U [%s]:\n", c.codePoint, c.name) + fmt.Fprintf(buf, " ccc: %v\n", c.ccc) + fmt.Fprintf(buf, " excludeInComp: %v\n", c.excludeInComp) + fmt.Fprintf(buf, " compatDecomp: %v\n", c.compatDecomp) + fmt.Fprintf(buf, " state: %v\n", c.state) + fmt.Fprintf(buf, " NFC:\n") + fmt.Fprint(buf, c.forms[FCanonical]) + fmt.Fprintf(buf, " NFKC:\n") + fmt.Fprint(buf, c.forms[FCompatibility]) + + return buf.String() +} + +// In UnicodeData.txt, some ranges are marked like this: +// 3400;;Lo;0;L;;;;;N;;;;; +// 4DB5;;Lo;0;L;;;;;N;;;;; +// parseCharacter keeps a state variable indicating the weirdness. +type State int + +const ( + SNormal State = iota // known to be zero for the type + SFirst + SLast + SMissing +) + +var lastChar = rune('\u0000') + +func (c Char) isValid() bool { + return c.codePoint != 0 && c.state != SMissing +} + +type FormInfo struct { + quickCheck [MNumberOfModes]QCResult // index: MComposed or MDecomposed + verified [MNumberOfModes]bool // index: MComposed or MDecomposed + + combinesForward bool // May combine with rune on the right + combinesBackward bool // May combine with rune on the left + isOneWay bool // Never appears in result + inDecomp bool // Some decompositions result in this char. + decomp Decomposition + expandedDecomp Decomposition +} + +func (f FormInfo) String() string { + buf := bytes.NewBuffer(make([]byte, 0)) + + fmt.Fprintf(buf, " quickCheck[C]: %v\n", f.quickCheck[MComposed]) + fmt.Fprintf(buf, " quickCheck[D]: %v\n", f.quickCheck[MDecomposed]) + fmt.Fprintf(buf, " cmbForward: %v\n", f.combinesForward) + fmt.Fprintf(buf, " cmbBackward: %v\n", f.combinesBackward) + fmt.Fprintf(buf, " isOneWay: %v\n", f.isOneWay) + fmt.Fprintf(buf, " inDecomp: %v\n", f.inDecomp) + fmt.Fprintf(buf, " decomposition: %X\n", f.decomp) + fmt.Fprintf(buf, " expandedDecomp: %X\n", f.expandedDecomp) + + return buf.String() +} + +type Decomposition []rune + +func parseDecomposition(s string, skipfirst bool) (a []rune, err error) { + decomp := strings.Split(s, " ") + if len(decomp) > 0 && skipfirst { + decomp = decomp[1:] + } + for _, d := range decomp { + point, err := strconv.ParseUint(d, 16, 64) + if err != nil { + return a, err + } + a = append(a, rune(point)) + } + return a, nil +} + +func loadUnicodeData() { + f := gen.OpenUCDFile("UnicodeData.txt") + defer f.Close() + p := ucd.New(f) + for p.Next() { + r := p.Rune(ucd.CodePoint) + char := &chars[r] + + char.ccc = uint8(p.Uint(ucd.CanonicalCombiningClass)) + decmap := p.String(ucd.DecompMapping) + + exp, err := parseDecomposition(decmap, false) + isCompat := false + if err != nil { + if len(decmap) > 0 { + exp, err = parseDecomposition(decmap, true) + if err != nil { + log.Fatalf(`%U: bad decomp |%v|: "%s"`, r, decmap, err) + } + isCompat = true + } + } + + char.name = p.String(ucd.Name) + char.codePoint = r + char.forms[FCompatibility].decomp = exp + if !isCompat { + char.forms[FCanonical].decomp = exp + } else { + char.compatDecomp = true + } + if len(decmap) > 0 { + char.forms[FCompatibility].decomp = exp + } + } + if err := p.Err(); err != nil { + log.Fatal(err) + } +} + +// compactCCC converts the sparse set of CCC values to a continguous one, +// reducing the number of bits needed from 8 to 6. +func compactCCC() { + m := make(map[uint8]uint8) + for i := range chars { + c := &chars[i] + m[c.ccc] = 0 + } + cccs := []int{} + for v, _ := range m { + cccs = append(cccs, int(v)) + } + sort.Ints(cccs) + for i, c := range cccs { + cccMap[uint8(i)] = uint8(c) + m[uint8(c)] = uint8(i) + } + for i := range chars { + c := &chars[i] + c.origCCC = c.ccc + c.ccc = m[c.ccc] + } + if len(m) >= 1<<6 { + log.Fatalf("too many difference CCC values: %d >= 64", len(m)) + } +} + +// CompositionExclusions.txt has form: +// 0958 # ... +// See https://unicode.org/reports/tr44/ for full explanation +func loadCompositionExclusions() { + f := gen.OpenUCDFile("CompositionExclusions.txt") + defer f.Close() + p := ucd.New(f) + for p.Next() { + c := &chars[p.Rune(0)] + if c.excludeInComp { + log.Fatalf("%U: Duplicate entry in exclusions.", c.codePoint) + } + c.excludeInComp = true + } + if e := p.Err(); e != nil { + log.Fatal(e) + } +} + +// hasCompatDecomp returns true if any of the recursive +// decompositions contains a compatibility expansion. +// In this case, the character may not occur in NFK*. +func hasCompatDecomp(r rune) bool { + c := &chars[r] + if c.compatDecomp { + return true + } + for _, d := range c.forms[FCompatibility].decomp { + if hasCompatDecomp(d) { + return true + } + } + return false +} + +// Hangul related constants. +const ( + HangulBase = 0xAC00 + HangulEnd = 0xD7A4 // hangulBase + Jamo combinations (19 * 21 * 28) + + JamoLBase = 0x1100 + JamoLEnd = 0x1113 + JamoVBase = 0x1161 + JamoVEnd = 0x1176 + JamoTBase = 0x11A8 + JamoTEnd = 0x11C3 + + JamoLVTCount = 19 * 21 * 28 + JamoTCount = 28 +) + +func isHangul(r rune) bool { + return HangulBase <= r && r < HangulEnd +} + +func isHangulWithoutJamoT(r rune) bool { + if !isHangul(r) { + return false + } + r -= HangulBase + return r < JamoLVTCount && r%JamoTCount == 0 +} + +func ccc(r rune) uint8 { + return chars[r].ccc +} + +// Insert a rune in a buffer, ordered by Canonical Combining Class. +func insertOrdered(b Decomposition, r rune) Decomposition { + n := len(b) + b = append(b, 0) + cc := ccc(r) + if cc > 0 { + // Use bubble sort. + for ; n > 0; n-- { + if ccc(b[n-1]) <= cc { + break + } + b[n] = b[n-1] + } + } + b[n] = r + return b +} + +// Recursively decompose. +func decomposeRecursive(form int, r rune, d Decomposition) Decomposition { + dcomp := chars[r].forms[form].decomp + if len(dcomp) == 0 { + return insertOrdered(d, r) + } + for _, c := range dcomp { + d = decomposeRecursive(form, c, d) + } + return d +} + +func completeCharFields(form int) { + // Phase 0: pre-expand decomposition. + for i := range chars { + f := &chars[i].forms[form] + if len(f.decomp) == 0 { + continue + } + exp := make(Decomposition, 0) + for _, c := range f.decomp { + exp = decomposeRecursive(form, c, exp) + } + f.expandedDecomp = exp + } + + // Phase 1: composition exclusion, mark decomposition. + for i := range chars { + c := &chars[i] + f := &c.forms[form] + + // Marks script-specific exclusions and version restricted. + f.isOneWay = c.excludeInComp + + // Singletons + f.isOneWay = f.isOneWay || len(f.decomp) == 1 + + // Non-starter decompositions + if len(f.decomp) > 1 { + chk := c.ccc != 0 || chars[f.decomp[0]].ccc != 0 + f.isOneWay = f.isOneWay || chk + } + + // Runes that decompose into more than two runes. + f.isOneWay = f.isOneWay || len(f.decomp) > 2 + + if form == FCompatibility { + f.isOneWay = f.isOneWay || hasCompatDecomp(c.codePoint) + } + + for _, r := range f.decomp { + chars[r].forms[form].inDecomp = true + } + } + + // Phase 2: forward and backward combining. + for i := range chars { + c := &chars[i] + f := &c.forms[form] + + if !f.isOneWay && len(f.decomp) == 2 { + f0 := &chars[f.decomp[0]].forms[form] + f1 := &chars[f.decomp[1]].forms[form] + if !f0.isOneWay { + f0.combinesForward = true + } + if !f1.isOneWay { + f1.combinesBackward = true + } + } + if isHangulWithoutJamoT(rune(i)) { + f.combinesForward = true + } + } + + // Phase 3: quick check values. + for i := range chars { + c := &chars[i] + f := &c.forms[form] + + switch { + case len(f.decomp) > 0: + f.quickCheck[MDecomposed] = QCNo + case isHangul(rune(i)): + f.quickCheck[MDecomposed] = QCNo + default: + f.quickCheck[MDecomposed] = QCYes + } + switch { + case f.isOneWay: + f.quickCheck[MComposed] = QCNo + case (i & 0xffff00) == JamoLBase: + f.quickCheck[MComposed] = QCYes + if JamoLBase <= i && i < JamoLEnd { + f.combinesForward = true + } + if JamoVBase <= i && i < JamoVEnd { + f.quickCheck[MComposed] = QCMaybe + f.combinesBackward = true + f.combinesForward = true + } + if JamoTBase <= i && i < JamoTEnd { + f.quickCheck[MComposed] = QCMaybe + f.combinesBackward = true + } + case !f.combinesBackward: + f.quickCheck[MComposed] = QCYes + default: + f.quickCheck[MComposed] = QCMaybe + } + } +} + +func computeNonStarterCounts() { + // Phase 4: leading and trailing non-starter count + for i := range chars { + c := &chars[i] + + runes := []rune{rune(i)} + // We always use FCompatibility so that the CGJ insertion points do not + // change for repeated normalizations with different forms. + if exp := c.forms[FCompatibility].expandedDecomp; len(exp) > 0 { + runes = exp + } + // We consider runes that combine backwards to be non-starters for the + // purpose of Stream-Safe Text Processing. + for _, r := range runes { + if cr := &chars[r]; cr.ccc == 0 && !cr.forms[FCompatibility].combinesBackward { + break + } + c.nLeadingNonStarters++ + } + for i := len(runes) - 1; i >= 0; i-- { + if cr := &chars[runes[i]]; cr.ccc == 0 && !cr.forms[FCompatibility].combinesBackward { + break + } + c.nTrailingNonStarters++ + } + if c.nTrailingNonStarters > 3 { + log.Fatalf("%U: Decomposition with more than 3 (%d) trailing modifiers (%U)", i, c.nTrailingNonStarters, runes) + } + + if isHangul(rune(i)) { + c.nTrailingNonStarters = 2 + if isHangulWithoutJamoT(rune(i)) { + c.nTrailingNonStarters = 1 + } + } + + if l, t := c.nLeadingNonStarters, c.nTrailingNonStarters; l > 0 && l != t { + log.Fatalf("%U: number of leading and trailing non-starters should be equal (%d vs %d)", i, l, t) + } + if t := c.nTrailingNonStarters; t > 3 { + log.Fatalf("%U: number of trailing non-starters is %d > 3", t) + } + } +} + +func printBytes(w io.Writer, b []byte, name string) { + fmt.Fprintf(w, "// %s: %d bytes\n", name, len(b)) + fmt.Fprintf(w, "var %s = [...]byte {", name) + for i, c := range b { + switch { + case i%64 == 0: + fmt.Fprintf(w, "\n// Bytes %x - %x\n", i, i+63) + case i%8 == 0: + fmt.Fprintf(w, "\n") + } + fmt.Fprintf(w, "0x%.2X, ", c) + } + fmt.Fprint(w, "\n}\n\n") +} + +// See forminfo.go for format. +func makeEntry(f *FormInfo, c *Char) uint16 { + e := uint16(0) + if r := c.codePoint; HangulBase <= r && r < HangulEnd { + e |= 0x40 + } + if f.combinesForward { + e |= 0x20 + } + if f.quickCheck[MDecomposed] == QCNo { + e |= 0x4 + } + switch f.quickCheck[MComposed] { + case QCYes: + case QCNo: + e |= 0x10 + case QCMaybe: + e |= 0x18 + default: + log.Fatalf("Illegal quickcheck value %v.", f.quickCheck[MComposed]) + } + e |= uint16(c.nTrailingNonStarters) + return e +} + +// decompSet keeps track of unique decompositions, grouped by whether +// the decomposition is followed by a trailing and/or leading CCC. +type decompSet [7]map[string]bool + +const ( + normalDecomp = iota + firstMulti + firstCCC + endMulti + firstLeadingCCC + firstCCCZeroExcept + firstStarterWithNLead + lastDecomp +) + +var cname = []string{"firstMulti", "firstCCC", "endMulti", "firstLeadingCCC", "firstCCCZeroExcept", "firstStarterWithNLead", "lastDecomp"} + +func makeDecompSet() decompSet { + m := decompSet{} + for i := range m { + m[i] = make(map[string]bool) + } + return m +} +func (m *decompSet) insert(key int, s string) { + m[key][s] = true +} + +func printCharInfoTables(w io.Writer) int { + mkstr := func(r rune, f *FormInfo) (int, string) { + d := f.expandedDecomp + s := string([]rune(d)) + if max := 1 << 6; len(s) >= max { + const msg = "%U: too many bytes in decomposition: %d >= %d" + log.Fatalf(msg, r, len(s), max) + } + head := uint8(len(s)) + if f.quickCheck[MComposed] != QCYes { + head |= 0x40 + } + if f.combinesForward { + head |= 0x80 + } + s = string([]byte{head}) + s + + lccc := ccc(d[0]) + tccc := ccc(d[len(d)-1]) + cc := ccc(r) + if cc != 0 && lccc == 0 && tccc == 0 { + log.Fatalf("%U: trailing and leading ccc are 0 for non-zero ccc %d", r, cc) + } + if tccc < lccc && lccc != 0 { + const msg = "%U: lccc (%d) must be <= tcc (%d)" + log.Fatalf(msg, r, lccc, tccc) + } + index := normalDecomp + nTrail := chars[r].nTrailingNonStarters + nLead := chars[r].nLeadingNonStarters + if tccc > 0 || lccc > 0 || nTrail > 0 { + tccc <<= 2 + tccc |= nTrail + s += string([]byte{tccc}) + index = endMulti + for _, r := range d[1:] { + if ccc(r) == 0 { + index = firstCCC + } + } + if lccc > 0 || nLead > 0 { + s += string([]byte{lccc}) + if index == firstCCC { + log.Fatalf("%U: multi-segment decomposition not supported for decompositions with leading CCC != 0", r) + } + index = firstLeadingCCC + } + if cc != lccc { + if cc != 0 { + log.Fatalf("%U: for lccc != ccc, expected ccc to be 0; was %d", r, cc) + } + index = firstCCCZeroExcept + } + } else if len(d) > 1 { + index = firstMulti + } + return index, s + } + + decompSet := makeDecompSet() + const nLeadStr = "\x00\x01" // 0-byte length and tccc with nTrail. + decompSet.insert(firstStarterWithNLead, nLeadStr) + + // Store the uniqued decompositions in a byte buffer, + // preceded by their byte length. + for _, c := range chars { + for _, f := range c.forms { + if len(f.expandedDecomp) == 0 { + continue + } + if f.combinesBackward { + log.Fatalf("%U: combinesBackward and decompose", c.codePoint) + } + index, s := mkstr(c.codePoint, &f) + decompSet.insert(index, s) + } + } + + decompositions := bytes.NewBuffer(make([]byte, 0, 10000)) + size := 0 + positionMap := make(map[string]uint16) + decompositions.WriteString("\000") + fmt.Fprintln(w, "const (") + for i, m := range decompSet { + sa := []string{} + for s := range m { + sa = append(sa, s) + } + sort.Strings(sa) + for _, s := range sa { + p := decompositions.Len() + decompositions.WriteString(s) + positionMap[s] = uint16(p) + } + if cname[i] != "" { + fmt.Fprintf(w, "%s = 0x%X\n", cname[i], decompositions.Len()) + } + } + fmt.Fprintln(w, "maxDecomp = 0x8000") + fmt.Fprintln(w, ")") + b := decompositions.Bytes() + printBytes(w, b, "decomps") + size += len(b) + + varnames := []string{"nfc", "nfkc"} + for i := 0; i < FNumberOfFormTypes; i++ { + trie := triegen.NewTrie(varnames[i]) + + for r, c := range chars { + f := c.forms[i] + d := f.expandedDecomp + if len(d) != 0 { + _, key := mkstr(c.codePoint, &f) + trie.Insert(rune(r), uint64(positionMap[key])) + if c.ccc != ccc(d[0]) { + // We assume the lead ccc of a decomposition !=0 in this case. + if ccc(d[0]) == 0 { + log.Fatalf("Expected leading CCC to be non-zero; ccc is %d", c.ccc) + } + } + } else if c.nLeadingNonStarters > 0 && len(f.expandedDecomp) == 0 && c.ccc == 0 && !f.combinesBackward { + // Handle cases where it can't be detected that the nLead should be equal + // to nTrail. + trie.Insert(c.codePoint, uint64(positionMap[nLeadStr])) + } else if v := makeEntry(&f, &c)<<8 | uint16(c.ccc); v != 0 { + trie.Insert(c.codePoint, uint64(0x8000|v)) + } + } + sz, err := trie.Gen(w, triegen.Compact(&normCompacter{name: varnames[i]})) + if err != nil { + log.Fatal(err) + } + size += sz + } + return size +} + +func contains(sa []string, s string) bool { + for _, a := range sa { + if a == s { + return true + } + } + return false +} + +func makeTables() { + w := &bytes.Buffer{} + + size := 0 + if *tablelist == "" { + return + } + list := strings.Split(*tablelist, ",") + if *tablelist == "all" { + list = []string{"recomp", "info"} + } + + // Compute maximum decomposition size. + max := 0 + for _, c := range chars { + if n := len(string(c.forms[FCompatibility].expandedDecomp)); n > max { + max = n + } + } + fmt.Fprintln(w, `import "sync"`) + fmt.Fprintln(w) + + fmt.Fprintln(w, "const (") + fmt.Fprintln(w, "\t// Version is the Unicode edition from which the tables are derived.") + fmt.Fprintf(w, "\tVersion = %q\n", gen.UnicodeVersion()) + fmt.Fprintln(w) + fmt.Fprintln(w, "\t// MaxTransformChunkSize indicates the maximum number of bytes that Transform") + fmt.Fprintln(w, "\t// may need to write atomically for any Form. Making a destination buffer at") + fmt.Fprintln(w, "\t// least this size ensures that Transform can always make progress and that") + fmt.Fprintln(w, "\t// the user does not need to grow the buffer on an ErrShortDst.") + fmt.Fprintf(w, "\tMaxTransformChunkSize = %d+maxNonStarters*4\n", len(string(0x034F))+max) + fmt.Fprintln(w, ")\n") + + // Print the CCC remap table. + size += len(cccMap) + fmt.Fprintf(w, "var ccc = [%d]uint8{", len(cccMap)) + for i := 0; i < len(cccMap); i++ { + if i%8 == 0 { + fmt.Fprintln(w) + } + fmt.Fprintf(w, "%3d, ", cccMap[uint8(i)]) + } + fmt.Fprintln(w, "\n}\n") + + if contains(list, "info") { + size += printCharInfoTables(w) + } + + if contains(list, "recomp") { + // Note that we use 32 bit keys, instead of 64 bit. + // This clips the bits of three entries, but we know + // this won't cause a collision. The compiler will catch + // any changes made to UnicodeData.txt that introduces + // a collision. + // Note that the recomposition map for NFC and NFKC + // are identical. + + // Recomposition map + nrentries := 0 + for _, c := range chars { + f := c.forms[FCanonical] + if !f.isOneWay && len(f.decomp) > 0 { + nrentries++ + } + } + sz := nrentries * 8 + size += sz + fmt.Fprintf(w, "// recompMap: %d bytes (entries only)\n", sz) + fmt.Fprintln(w, "var recompMap map[uint32]rune") + fmt.Fprintln(w, "var recompMapOnce sync.Once\n") + fmt.Fprintln(w, `const recompMapPacked = "" +`) + var buf [8]byte + for i, c := range chars { + f := c.forms[FCanonical] + d := f.decomp + if !f.isOneWay && len(d) > 0 { + key := uint32(uint16(d[0]))<<16 + uint32(uint16(d[1])) + binary.BigEndian.PutUint32(buf[:4], key) + binary.BigEndian.PutUint32(buf[4:], uint32(i)) + fmt.Fprintf(w, "\t\t%q + // 0x%.8X: 0x%.8X\n", string(buf[:]), key, uint32(i)) + } + } + // hack so we don't have to special case the trailing plus sign + fmt.Fprintf(w, ` ""`) + fmt.Fprintln(w) + } + + fmt.Fprintf(w, "// Total size of tables: %dKB (%d bytes)\n", (size+512)/1024, size) + gen.WriteVersionedGoFile("tables.go", "norm", w.Bytes()) +} + +func printChars() { + if *verbose { + for _, c := range chars { + if !c.isValid() || c.state == SMissing { + continue + } + fmt.Println(c) + } + } +} + +// verifyComputed does various consistency tests. +func verifyComputed() { + for i, c := range chars { + for _, f := range c.forms { + isNo := (f.quickCheck[MDecomposed] == QCNo) + if (len(f.decomp) > 0) != isNo && !isHangul(rune(i)) { + log.Fatalf("%U: NF*D QC must be No if rune decomposes", i) + } + + isMaybe := f.quickCheck[MComposed] == QCMaybe + if f.combinesBackward != isMaybe { + log.Fatalf("%U: NF*C QC must be Maybe if combinesBackward", i) + } + if len(f.decomp) > 0 && f.combinesForward && isMaybe { + log.Fatalf("%U: NF*C QC must be Yes or No if combinesForward and decomposes", i) + } + + if len(f.expandedDecomp) != 0 { + continue + } + if a, b := c.nLeadingNonStarters > 0, (c.ccc > 0 || f.combinesBackward); a != b { + // We accept these runes to be treated differently (it only affects + // segment breaking in iteration, most likely on improper use), but + // reconsider if more characters are added. + // U+FF9E HALFWIDTH KATAKANA VOICED SOUND MARK;Lm;0;L; 3099;;;;N;;;;; + // U+FF9F HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK;Lm;0;L; 309A;;;;N;;;;; + // U+3133 HANGUL LETTER KIYEOK-SIOS;Lo;0;L; 11AA;;;;N;HANGUL LETTER GIYEOG SIOS;;;; + // U+318E HANGUL LETTER ARAEAE;Lo;0;L; 11A1;;;;N;HANGUL LETTER ALAE AE;;;; + // U+FFA3 HALFWIDTH HANGUL LETTER KIYEOK-SIOS;Lo;0;L; 3133;;;;N;HALFWIDTH HANGUL LETTER GIYEOG SIOS;;;; + // U+FFDC HALFWIDTH HANGUL LETTER I;Lo;0;L; 3163;;;;N;;;;; + if i != 0xFF9E && i != 0xFF9F && !(0x3133 <= i && i <= 0x318E) && !(0xFFA3 <= i && i <= 0xFFDC) { + log.Fatalf("%U: nLead was %v; want %v", i, a, b) + } + } + } + nfc := c.forms[FCanonical] + nfkc := c.forms[FCompatibility] + if nfc.combinesBackward != nfkc.combinesBackward { + log.Fatalf("%U: Cannot combine combinesBackward\n", c.codePoint) + } + } +} + +// Use values in DerivedNormalizationProps.txt to compare against the +// values we computed. +// DerivedNormalizationProps.txt has form: +// 00C0..00C5 ; NFD_QC; N # ... +// 0374 ; NFD_QC; N # ... +// See https://unicode.org/reports/tr44/ for full explanation +func testDerived() { + f := gen.OpenUCDFile("DerivedNormalizationProps.txt") + defer f.Close() + p := ucd.New(f) + for p.Next() { + r := p.Rune(0) + c := &chars[r] + + var ftype, mode int + qt := p.String(1) + switch qt { + case "NFC_QC": + ftype, mode = FCanonical, MComposed + case "NFD_QC": + ftype, mode = FCanonical, MDecomposed + case "NFKC_QC": + ftype, mode = FCompatibility, MComposed + case "NFKD_QC": + ftype, mode = FCompatibility, MDecomposed + default: + continue + } + var qr QCResult + switch p.String(2) { + case "Y": + qr = QCYes + case "N": + qr = QCNo + case "M": + qr = QCMaybe + default: + log.Fatalf(`Unexpected quick check value "%s"`, p.String(2)) + } + if got := c.forms[ftype].quickCheck[mode]; got != qr { + log.Printf("%U: FAILED %s (was %v need %v)\n", r, qt, got, qr) + } + c.forms[ftype].verified[mode] = true + } + if err := p.Err(); err != nil { + log.Fatal(err) + } + // Any unspecified value must be QCYes. Verify this. + for i, c := range chars { + for j, fd := range c.forms { + for k, qr := range fd.quickCheck { + if !fd.verified[k] && qr != QCYes { + m := "%U: FAIL F:%d M:%d (was %v need Yes) %s\n" + log.Printf(m, i, j, k, qr, c.name) + } + } + } + } +} + +var testHeader = `const ( + Yes = iota + No + Maybe +) + +type formData struct { + qc uint8 + combinesForward bool + decomposition string +} + +type runeData struct { + r rune + ccc uint8 + nLead uint8 + nTrail uint8 + f [2]formData // 0: canonical; 1: compatibility +} + +func f(qc uint8, cf bool, dec string) [2]formData { + return [2]formData{{qc, cf, dec}, {qc, cf, dec}} +} + +func g(qc, qck uint8, cf, cfk bool, d, dk string) [2]formData { + return [2]formData{{qc, cf, d}, {qck, cfk, dk}} +} + +var testData = []runeData{ +` + +func printTestdata() { + type lastInfo struct { + ccc uint8 + nLead uint8 + nTrail uint8 + f string + } + + last := lastInfo{} + w := &bytes.Buffer{} + fmt.Fprintf(w, testHeader) + for r, c := range chars { + f := c.forms[FCanonical] + qc, cf, d := f.quickCheck[MComposed], f.combinesForward, string(f.expandedDecomp) + f = c.forms[FCompatibility] + qck, cfk, dk := f.quickCheck[MComposed], f.combinesForward, string(f.expandedDecomp) + s := "" + if d == dk && qc == qck && cf == cfk { + s = fmt.Sprintf("f(%s, %v, %q)", qc, cf, d) + } else { + s = fmt.Sprintf("g(%s, %s, %v, %v, %q, %q)", qc, qck, cf, cfk, d, dk) + } + current := lastInfo{c.ccc, c.nLeadingNonStarters, c.nTrailingNonStarters, s} + if last != current { + fmt.Fprintf(w, "\t{0x%x, %d, %d, %d, %s},\n", r, c.origCCC, c.nLeadingNonStarters, c.nTrailingNonStarters, s) + last = current + } + } + fmt.Fprintln(w, "}") + gen.WriteVersionedGoFile("data_test.go", "norm", w.Bytes()) +} diff --git a/vendor/golang.org/x/text/unicode/norm/triegen.go b/vendor/golang.org/x/text/unicode/norm/triegen.go new file mode 100644 index 0000000000000..45d711900d144 --- /dev/null +++ b/vendor/golang.org/x/text/unicode/norm/triegen.go @@ -0,0 +1,117 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// Trie table generator. +// Used by make*tables tools to generate a go file with trie data structures +// for mapping UTF-8 to a 16-bit value. All but the last byte in a UTF-8 byte +// sequence are used to lookup offsets in the index table to be used for the +// next byte. The last byte is used to index into a table with 16-bit values. + +package main + +import ( + "fmt" + "io" +) + +const maxSparseEntries = 16 + +type normCompacter struct { + sparseBlocks [][]uint64 + sparseOffset []uint16 + sparseCount int + name string +} + +func mostFrequentStride(a []uint64) int { + counts := make(map[int]int) + var v int + for _, x := range a { + if stride := int(x) - v; v != 0 && stride >= 0 { + counts[stride]++ + } + v = int(x) + } + var maxs, maxc int + for stride, cnt := range counts { + if cnt > maxc || (cnt == maxc && stride < maxs) { + maxs, maxc = stride, cnt + } + } + return maxs +} + +func countSparseEntries(a []uint64) int { + stride := mostFrequentStride(a) + var v, count int + for _, tv := range a { + if int(tv)-v != stride { + if tv != 0 { + count++ + } + } + v = int(tv) + } + return count +} + +func (c *normCompacter) Size(v []uint64) (sz int, ok bool) { + if n := countSparseEntries(v); n <= maxSparseEntries { + return (n+1)*4 + 2, true + } + return 0, false +} + +func (c *normCompacter) Store(v []uint64) uint32 { + h := uint32(len(c.sparseOffset)) + c.sparseBlocks = append(c.sparseBlocks, v) + c.sparseOffset = append(c.sparseOffset, uint16(c.sparseCount)) + c.sparseCount += countSparseEntries(v) + 1 + return h +} + +func (c *normCompacter) Handler() string { + return c.name + "Sparse.lookup" +} + +func (c *normCompacter) Print(w io.Writer) (retErr error) { + p := func(f string, x ...interface{}) { + if _, err := fmt.Fprintf(w, f, x...); retErr == nil && err != nil { + retErr = err + } + } + + ls := len(c.sparseBlocks) + p("// %sSparseOffset: %d entries, %d bytes\n", c.name, ls, ls*2) + p("var %sSparseOffset = %#v\n\n", c.name, c.sparseOffset) + + ns := c.sparseCount + p("// %sSparseValues: %d entries, %d bytes\n", c.name, ns, ns*4) + p("var %sSparseValues = [%d]valueRange {", c.name, ns) + for i, b := range c.sparseBlocks { + p("\n// Block %#x, offset %#x", i, c.sparseOffset[i]) + var v int + stride := mostFrequentStride(b) + n := countSparseEntries(b) + p("\n{value:%#04x,lo:%#02x},", stride, uint8(n)) + for i, nv := range b { + if int(nv)-v != stride { + if v != 0 { + p(",hi:%#02x},", 0x80+i-1) + } + if nv != 0 { + p("\n{value:%#04x,lo:%#02x", nv, 0x80+i) + } + } + v = int(nv) + } + if v != 0 { + p(",hi:%#02x},", 0x80+len(b)-1) + } + } + p("\n}\n\n") + return +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 386d2f0cc04c1..bc0e07e00c9b9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,43 +1,43 @@ # cloud.google.com/go v0.39.0 +cloud.google.com/go/monitoring/apiv3 +cloud.google.com/go/storage +cloud.google.com/go/spanner +cloud.google.com/go/kms/apiv1 cloud.google.com/go/civil cloud.google.com/go/compute/metadata cloud.google.com/go/iam cloud.google.com/go/internal -cloud.google.com/go/internal/fields cloud.google.com/go/internal/optional -cloud.google.com/go/internal/protostruct cloud.google.com/go/internal/trace cloud.google.com/go/internal/version -cloud.google.com/go/kms/apiv1 -cloud.google.com/go/monitoring/apiv3 -cloud.google.com/go/spanner +cloud.google.com/go/internal/fields +cloud.google.com/go/internal/protostruct cloud.google.com/go/spanner/internal/backoff -cloud.google.com/go/storage # code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f code.cloudfoundry.org/gofileutils/fileutils # contrib.go.opencensus.io/exporter/ocagent v0.4.12 contrib.go.opencensus.io/exporter/ocagent # github.com/Azure/azure-sdk-for-go v29.0.0+incompatible +github.com/Azure/azure-sdk-for-go/storage +github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac -github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization -github.com/Azure/azure-sdk-for-go/storage github.com/Azure/azure-sdk-for-go/version # github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 -github.com/Azure/go-ansiterm github.com/Azure/go-ansiterm/winterm +github.com/Azure/go-ansiterm # github.com/Azure/go-autorest v11.7.1+incompatible -github.com/Azure/go-autorest/autorest -github.com/Azure/go-autorest/autorest/adal github.com/Azure/go-autorest/autorest/azure +github.com/Azure/go-autorest/autorest github.com/Azure/go-autorest/autorest/azure/auth -github.com/Azure/go-autorest/autorest/azure/cli -github.com/Azure/go-autorest/autorest/date github.com/Azure/go-autorest/autorest/to +github.com/Azure/go-autorest/autorest/date +github.com/Azure/go-autorest/tracing github.com/Azure/go-autorest/autorest/validation +github.com/Azure/go-autorest/autorest/adal github.com/Azure/go-autorest/logger -github.com/Azure/go-autorest/tracing +github.com/Azure/go-autorest/autorest/azure/cli # github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml # github.com/DataDog/datadog-go v3.2.0+incompatible @@ -56,27 +56,27 @@ github.com/Nvveen/Gotty # github.com/SAP/go-hdb v0.14.1 github.com/SAP/go-hdb/driver github.com/SAP/go-hdb/driver/sqltrace -github.com/SAP/go-hdb/internal/bufio github.com/SAP/go-hdb/internal/protocol +github.com/SAP/go-hdb/internal/bufio github.com/SAP/go-hdb/internal/unicode github.com/SAP/go-hdb/internal/unicode/cesu8 # github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 github.com/StackExchange/wmi # github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190620160927-9418d7b0cd0f -github.com/aliyun/alibaba-cloud-sdk-go/sdk github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/providers -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers +github.com/aliyun/alibaba-cloud-sdk-go/sdk +github.com/aliyun/alibaba-cloud-sdk-go/services/kms github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints +github.com/aliyun/alibaba-cloud-sdk-go/services/sts +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils -github.com/aliyun/alibaba-cloud-sdk-go/services/kms +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider github.com/aliyun/alibaba-cloud-sdk-go/services/ram -github.com/aliyun/alibaba-cloud-sdk-go/services/sts # github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 github.com/aliyun/aliyun-oss-go-sdk/oss # github.com/apple/foundationdb/bindings/go v0.0.0-20190411004307-cd5c9d91fad2 @@ -97,53 +97,53 @@ github.com/armon/go-radix github.com/asaskevich/govalidator # github.com/aws/aws-sdk-go v1.25.41 github.com/aws/aws-sdk-go/aws +github.com/aws/aws-sdk-go/aws/credentials +github.com/aws/aws-sdk-go/aws/credentials/stscreds +github.com/aws/aws-sdk-go/aws/endpoints +github.com/aws/aws-sdk-go/aws/session +github.com/aws/aws-sdk-go/service/ec2 +github.com/aws/aws-sdk-go/service/iam +github.com/aws/aws-sdk-go/service/sts github.com/aws/aws-sdk-go/aws/arn github.com/aws/aws-sdk-go/aws/awserr -github.com/aws/aws-sdk-go/aws/awsutil +github.com/aws/aws-sdk-go/service/iam/iamiface +github.com/aws/aws-sdk-go/service/sts/stsiface +github.com/aws/aws-sdk-go/aws/ec2metadata +github.com/aws/aws-sdk-go/aws/defaults +github.com/aws/aws-sdk-go/aws/request +github.com/aws/aws-sdk-go/service/dynamodb +github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute +github.com/aws/aws-sdk-go/service/s3 +github.com/aws/aws-sdk-go/service/kms +github.com/aws/aws-sdk-go/service/kms/kmsiface +github.com/aws/aws-sdk-go/internal/sdkio +github.com/aws/aws-sdk-go/internal/ini +github.com/aws/aws-sdk-go/internal/shareddefaults github.com/aws/aws-sdk-go/aws/client -github.com/aws/aws-sdk-go/aws/client/metadata +github.com/aws/aws-sdk-go/internal/sdkrand github.com/aws/aws-sdk-go/aws/corehandlers -github.com/aws/aws-sdk-go/aws/credentials -github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds -github.com/aws/aws-sdk-go/aws/credentials/endpointcreds github.com/aws/aws-sdk-go/aws/credentials/processcreds -github.com/aws/aws-sdk-go/aws/credentials/stscreds -github.com/aws/aws-sdk-go/aws/crr github.com/aws/aws-sdk-go/aws/csm -github.com/aws/aws-sdk-go/aws/defaults -github.com/aws/aws-sdk-go/aws/ec2metadata -github.com/aws/aws-sdk-go/aws/endpoints -github.com/aws/aws-sdk-go/aws/request -github.com/aws/aws-sdk-go/aws/session +github.com/aws/aws-sdk-go/aws/awsutil +github.com/aws/aws-sdk-go/aws/client/metadata github.com/aws/aws-sdk-go/aws/signer/v4 -github.com/aws/aws-sdk-go/internal/ini -github.com/aws/aws-sdk-go/internal/s3err -github.com/aws/aws-sdk-go/internal/sdkio -github.com/aws/aws-sdk-go/internal/sdkmath -github.com/aws/aws-sdk-go/internal/sdkrand -github.com/aws/aws-sdk-go/internal/sdkuri -github.com/aws/aws-sdk-go/internal/shareddefaults github.com/aws/aws-sdk-go/private/protocol github.com/aws/aws-sdk-go/private/protocol/ec2query +github.com/aws/aws-sdk-go/private/protocol/query +github.com/aws/aws-sdk-go/internal/sdkuri +github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds +github.com/aws/aws-sdk-go/aws/credentials/endpointcreds +github.com/aws/aws-sdk-go/aws/crr +github.com/aws/aws-sdk-go/private/protocol/jsonrpc +github.com/aws/aws-sdk-go/internal/s3err github.com/aws/aws-sdk-go/private/protocol/eventstream github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi -github.com/aws/aws-sdk-go/private/protocol/json/jsonutil -github.com/aws/aws-sdk-go/private/protocol/jsonrpc -github.com/aws/aws-sdk-go/private/protocol/query -github.com/aws/aws-sdk-go/private/protocol/query/queryutil github.com/aws/aws-sdk-go/private/protocol/rest github.com/aws/aws-sdk-go/private/protocol/restxml github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil -github.com/aws/aws-sdk-go/service/dynamodb -github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute -github.com/aws/aws-sdk-go/service/ec2 -github.com/aws/aws-sdk-go/service/iam -github.com/aws/aws-sdk-go/service/iam/iamiface -github.com/aws/aws-sdk-go/service/kms -github.com/aws/aws-sdk-go/service/kms/kmsiface -github.com/aws/aws-sdk-go/service/s3 -github.com/aws/aws-sdk-go/service/sts -github.com/aws/aws-sdk-go/service/sts/stsiface +github.com/aws/aws-sdk-go/internal/sdkmath +github.com/aws/aws-sdk-go/private/protocol/query/queryutil +github.com/aws/aws-sdk-go/private/protocol/json/jsonutil # github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 github.com/beorn7/perks/quantile # github.com/bgentry/speakeasy v0.1.0 @@ -153,10 +153,10 @@ github.com/boombuler/barcode github.com/boombuler/barcode/qr github.com/boombuler/barcode/utils # github.com/briankassouf/jose v0.9.2-0.20180619214549-d2569464773f -github.com/briankassouf/jose github.com/briankassouf/jose/crypto github.com/briankassouf/jose/jws github.com/briankassouf/jose/jwt +github.com/briankassouf/jose # github.com/cenkalti/backoff v2.2.1+incompatible github.com/cenkalti/backoff # github.com/census-instrumentation/opencensus-proto v0.2.0 @@ -169,13 +169,11 @@ github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 # github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f github.com/centrify/cloud-golang-sdk/oauth github.com/centrify/cloud-golang-sdk/restapi -# github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0 -github.com/chrismalek/oktasdk-go/okta # github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible github.com/circonus-labs/circonus-gometrics github.com/circonus-labs/circonus-gometrics/api -github.com/circonus-labs/circonus-gometrics/api/config github.com/circonus-labs/circonus-gometrics/checkmgr +github.com/circonus-labs/circonus-gometrics/api/config # github.com/circonus-labs/circonusllhist v0.1.3 github.com/circonus-labs/circonusllhist # github.com/cloudfoundry-community/go-cfclient v0.0.0-20190201205600-f136f9222381 @@ -206,12 +204,12 @@ github.com/docker/go-connections/nat # github.com/docker/go-units v0.4.0 github.com/docker/go-units # github.com/dsnet/compress v0.0.1 -github.com/dsnet/compress github.com/dsnet/compress/bzip2 github.com/dsnet/compress/bzip2/internal/sais github.com/dsnet/compress/internal github.com/dsnet/compress/internal/errors github.com/dsnet/compress/internal/prefix +github.com/dsnet/compress # github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 github.com/duosecurity/duo_api_golang github.com/duosecurity/duo_api_golang/authapi @@ -242,31 +240,33 @@ github.com/go-ole/go-ole/oleutil github.com/go-sql-driver/mysql # github.com/go-test/deep v1.0.2 github.com/go-test/deep +# github.com/go-yaml/yaml v2.1.0+incompatible +github.com/go-yaml/yaml # github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df github.com/gocql/gocql github.com/gocql/gocql/internal/lru github.com/gocql/gocql/internal/murmur github.com/gocql/gocql/internal/streams # github.com/gogo/protobuf v1.2.1 -github.com/gogo/protobuf/gogoproto github.com/gogo/protobuf/io github.com/gogo/protobuf/proto -github.com/gogo/protobuf/protoc-gen-gogo/descriptor github.com/gogo/protobuf/sortkeys +github.com/gogo/protobuf/gogoproto +github.com/gogo/protobuf/protoc-gen-gogo/descriptor # github.com/golang/protobuf v1.3.2 -github.com/golang/protobuf/jsonpb github.com/golang/protobuf/proto -github.com/golang/protobuf/protoc-gen-go/descriptor -github.com/golang/protobuf/protoc-gen-go/generator -github.com/golang/protobuf/protoc-gen-go/generator/internal/remap -github.com/golang/protobuf/protoc-gen-go/plugin github.com/golang/protobuf/ptypes +github.com/golang/protobuf/ptypes/timestamp github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration -github.com/golang/protobuf/ptypes/empty github.com/golang/protobuf/ptypes/struct -github.com/golang/protobuf/ptypes/timestamp +github.com/golang/protobuf/ptypes/empty github.com/golang/protobuf/ptypes/wrappers +github.com/golang/protobuf/protoc-gen-go/descriptor +github.com/golang/protobuf/jsonpb +github.com/golang/protobuf/protoc-gen-go/generator +github.com/golang/protobuf/protoc-gen-go/generator/internal/remap +github.com/golang/protobuf/protoc-gen-go/plugin # github.com/golang/snappy v0.0.1 github.com/golang/snappy # github.com/google/go-github v17.0.0+incompatible @@ -284,19 +284,19 @@ github.com/googleapis/gax-go/v2 # github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 github.com/gorhill/cronexpr # github.com/grpc-ecosystem/grpc-gateway v1.8.5 -github.com/grpc-ecosystem/grpc-gateway/internal github.com/grpc-ecosystem/grpc-gateway/runtime github.com/grpc-ecosystem/grpc-gateway/utilities +github.com/grpc-ecosystem/grpc-gateway/internal # github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed github.com/hailocab/go-hostpool # github.com/hashicorp/consul-template v0.22.0 -github.com/hashicorp/consul-template/child github.com/hashicorp/consul-template/config -github.com/hashicorp/consul-template/dependency github.com/hashicorp/consul-template/logging github.com/hashicorp/consul-template/manager -github.com/hashicorp/consul-template/renderer github.com/hashicorp/consul-template/signals +github.com/hashicorp/consul-template/child +github.com/hashicorp/consul-template/dependency +github.com/hashicorp/consul-template/renderer github.com/hashicorp/consul-template/template github.com/hashicorp/consul-template/version github.com/hashicorp/consul-template/watch @@ -333,55 +333,55 @@ github.com/hashicorp/go-sockaddr github.com/hashicorp/go-sockaddr/template # github.com/hashicorp/go-syslog v1.0.0 github.com/hashicorp/go-syslog -# github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8 +# github.com/hashicorp/go-uuid v1.0.2 github.com/hashicorp/go-uuid # github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/go-version # github.com/hashicorp/gokrb5 v7.3.1-0.20191209171754-1a6fa9886ec3+incompatible -github.com/hashicorp/gokrb5/asn1tools +github.com/hashicorp/gokrb5/spnego github.com/hashicorp/gokrb5/client github.com/hashicorp/gokrb5/config +github.com/hashicorp/gokrb5/keytab +github.com/hashicorp/gokrb5/service +github.com/hashicorp/gokrb5/asn1tools github.com/hashicorp/gokrb5/credentials -github.com/hashicorp/gokrb5/crypto -github.com/hashicorp/gokrb5/crypto/common -github.com/hashicorp/gokrb5/crypto/etype -github.com/hashicorp/gokrb5/crypto/rfc3961 -github.com/hashicorp/gokrb5/crypto/rfc3962 -github.com/hashicorp/gokrb5/crypto/rfc4757 -github.com/hashicorp/gokrb5/crypto/rfc8009 github.com/hashicorp/gokrb5/gssapi -github.com/hashicorp/gokrb5/iana -github.com/hashicorp/gokrb5/iana/addrtype -github.com/hashicorp/gokrb5/iana/adtype -github.com/hashicorp/gokrb5/iana/asnAppTag github.com/hashicorp/gokrb5/iana/chksumtype +github.com/hashicorp/gokrb5/iana/msgtype +github.com/hashicorp/gokrb5/krberror +github.com/hashicorp/gokrb5/messages +github.com/hashicorp/gokrb5/types +github.com/hashicorp/gokrb5/crypto +github.com/hashicorp/gokrb5/crypto/etype github.com/hashicorp/gokrb5/iana/errorcode -github.com/hashicorp/gokrb5/iana/etypeID github.com/hashicorp/gokrb5/iana/flags github.com/hashicorp/gokrb5/iana/keyusage -github.com/hashicorp/gokrb5/iana/msgtype github.com/hashicorp/gokrb5/iana/nametype github.com/hashicorp/gokrb5/iana/patype github.com/hashicorp/gokrb5/kadmin -github.com/hashicorp/gokrb5/keytab -github.com/hashicorp/gokrb5/krberror -github.com/hashicorp/gokrb5/messages +github.com/hashicorp/gokrb5/iana/etypeID +github.com/hashicorp/gokrb5/iana +github.com/hashicorp/gokrb5/iana/adtype +github.com/hashicorp/gokrb5/iana/asnAppTag github.com/hashicorp/gokrb5/pac -github.com/hashicorp/gokrb5/service -github.com/hashicorp/gokrb5/spnego -github.com/hashicorp/gokrb5/types +github.com/hashicorp/gokrb5/iana/addrtype +github.com/hashicorp/gokrb5/crypto/common +github.com/hashicorp/gokrb5/crypto/rfc3961 +github.com/hashicorp/gokrb5/crypto/rfc3962 +github.com/hashicorp/gokrb5/crypto/rfc4757 +github.com/hashicorp/gokrb5/crypto/rfc8009 # github.com/hashicorp/golang-lru v0.5.3 github.com/hashicorp/golang-lru github.com/hashicorp/golang-lru/simplelru # github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/hcl github.com/hashicorp/hcl/hcl/ast -github.com/hashicorp/hcl/hcl/parser github.com/hashicorp/hcl/hcl/printer -github.com/hashicorp/hcl/hcl/scanner -github.com/hashicorp/hcl/hcl/strconv +github.com/hashicorp/hcl/hcl/parser github.com/hashicorp/hcl/hcl/token github.com/hashicorp/hcl/json/parser +github.com/hashicorp/hcl/hcl/scanner +github.com/hashicorp/hcl/hcl/strconv github.com/hashicorp/hcl/json/scanner github.com/hashicorp/hcl/json/token # github.com/hashicorp/logutils v1.0.0 @@ -404,11 +404,11 @@ github.com/hashicorp/vault-plugin-auth-azure github.com/hashicorp/vault-plugin-auth-centrify # github.com/hashicorp/vault-plugin-auth-cf v0.0.0-20190821162840-1c2205826fee github.com/hashicorp/vault-plugin-auth-cf -github.com/hashicorp/vault-plugin-auth-cf/models github.com/hashicorp/vault-plugin-auth-cf/signatures +github.com/hashicorp/vault-plugin-auth-cf/models +github.com/hashicorp/vault-plugin-auth-cf/util github.com/hashicorp/vault-plugin-auth-cf/testing/certificates github.com/hashicorp/vault-plugin-auth-cf/testing/cf -github.com/hashicorp/vault-plugin-auth-cf/util # github.com/hashicorp/vault-plugin-auth-gcp v0.5.2-0.20190930204802-acfd134850c2 github.com/hashicorp/vault-plugin-auth-gcp/plugin github.com/hashicorp/vault-plugin-auth-gcp/plugin/cache @@ -442,51 +442,51 @@ github.com/hashicorp/vault-plugin-secrets-kv # github.com/hashicorp/vault/api v1.0.5-0.20191218213558-0bc25f908162 => ./api github.com/hashicorp/vault/api # github.com/hashicorp/vault/sdk v0.1.14-0.20191218213202-9caafff72a1f => ./sdk -github.com/hashicorp/vault/sdk/database/dbplugin -github.com/hashicorp/vault/sdk/database/helper/connutil -github.com/hashicorp/vault/sdk/database/helper/credsutil -github.com/hashicorp/vault/sdk/database/helper/dbutil +github.com/hashicorp/vault/sdk/helper/salt +github.com/hashicorp/vault/sdk/helper/strutil +github.com/hashicorp/vault/sdk/helper/wrapping +github.com/hashicorp/vault/sdk/logical +github.com/hashicorp/vault/sdk/helper/parseutil github.com/hashicorp/vault/sdk/framework -github.com/hashicorp/vault/sdk/helper/base62 -github.com/hashicorp/vault/sdk/helper/certutil +github.com/hashicorp/vault/sdk/helper/policyutil +github.com/hashicorp/vault/sdk/plugin github.com/hashicorp/vault/sdk/helper/cidrutil -github.com/hashicorp/vault/sdk/helper/compressutil github.com/hashicorp/vault/sdk/helper/consts -github.com/hashicorp/vault/sdk/helper/cryptoutil +github.com/hashicorp/vault/sdk/helper/locksutil +github.com/hashicorp/vault/sdk/helper/tokenutil +github.com/hashicorp/vault/sdk/helper/jsonutil +github.com/hashicorp/vault/sdk/helper/certutil +github.com/hashicorp/vault/sdk/helper/password +github.com/hashicorp/vault/sdk/helper/ldaputil +github.com/hashicorp/vault/sdk/helper/tlsutil +github.com/hashicorp/vault/sdk/database/dbplugin +github.com/hashicorp/vault/sdk/database/helper/dbutil +github.com/hashicorp/vault/sdk/queue github.com/hashicorp/vault/sdk/helper/dbtxn -github.com/hashicorp/vault/sdk/helper/entropy github.com/hashicorp/vault/sdk/helper/errutil -github.com/hashicorp/vault/sdk/helper/hclutil -github.com/hashicorp/vault/sdk/helper/identitytpl -github.com/hashicorp/vault/sdk/helper/jsonutil -github.com/hashicorp/vault/sdk/helper/kdf github.com/hashicorp/vault/sdk/helper/keysutil -github.com/hashicorp/vault/sdk/helper/ldaputil -github.com/hashicorp/vault/sdk/helper/license -github.com/hashicorp/vault/sdk/helper/locksutil +github.com/hashicorp/vault/sdk/helper/base62 github.com/hashicorp/vault/sdk/helper/logging github.com/hashicorp/vault/sdk/helper/mlock -github.com/hashicorp/vault/sdk/helper/parseutil -github.com/hashicorp/vault/sdk/helper/password -github.com/hashicorp/vault/sdk/helper/pathmanager -github.com/hashicorp/vault/sdk/helper/pluginutil -github.com/hashicorp/vault/sdk/helper/pointerutil -github.com/hashicorp/vault/sdk/helper/policyutil -github.com/hashicorp/vault/sdk/helper/salt -github.com/hashicorp/vault/sdk/helper/strutil -github.com/hashicorp/vault/sdk/helper/tlsutil -github.com/hashicorp/vault/sdk/helper/tokenutil github.com/hashicorp/vault/sdk/helper/useragent -github.com/hashicorp/vault/sdk/helper/wrapping -github.com/hashicorp/vault/sdk/logical github.com/hashicorp/vault/sdk/physical github.com/hashicorp/vault/sdk/physical/file github.com/hashicorp/vault/sdk/physical/inmem -github.com/hashicorp/vault/sdk/plugin -github.com/hashicorp/vault/sdk/plugin/mock -github.com/hashicorp/vault/sdk/plugin/pb -github.com/hashicorp/vault/sdk/queue github.com/hashicorp/vault/sdk/version +github.com/hashicorp/vault/sdk/helper/cryptoutil +github.com/hashicorp/vault/sdk/helper/pointerutil +github.com/hashicorp/vault/sdk/helper/hclutil +github.com/hashicorp/vault/sdk/database/helper/credsutil +github.com/hashicorp/vault/sdk/helper/compressutil +github.com/hashicorp/vault/sdk/helper/pathmanager +github.com/hashicorp/vault/sdk/plugin/pb +github.com/hashicorp/vault/sdk/database/helper/connutil +github.com/hashicorp/vault/sdk/helper/identitytpl +github.com/hashicorp/vault/sdk/helper/license +github.com/hashicorp/vault/sdk/helper/pluginutil +github.com/hashicorp/vault/sdk/helper/entropy +github.com/hashicorp/vault/sdk/helper/kdf +github.com/hashicorp/vault/sdk/plugin/mock # github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d github.com/hashicorp/yamux # github.com/influxdata/influxdb v0.0.0-20190411212539-d24b7ba8c4c4 @@ -495,11 +495,11 @@ github.com/influxdata/influxdb/models github.com/influxdata/influxdb/pkg/escape # github.com/jackc/pgx v3.3.0+incompatible github.com/jackc/pgx -github.com/jackc/pgx/chunkreader github.com/jackc/pgx/internal/sanitize github.com/jackc/pgx/pgio github.com/jackc/pgx/pgproto3 github.com/jackc/pgx/pgtype +github.com/jackc/pgx/chunkreader # github.com/jcmturner/gofork v1.0.0 github.com/jcmturner/gofork/encoding/asn1 github.com/jcmturner/gofork/x/crypto/pbkdf2 @@ -514,25 +514,27 @@ github.com/jmespath/go-jmespath # github.com/joyent/triton-go v0.0.0-20190112182421-51ffac552869 github.com/joyent/triton-go github.com/joyent/triton-go/authentication -github.com/joyent/triton-go/client github.com/joyent/triton-go/errors github.com/joyent/triton-go/storage +github.com/joyent/triton-go/client # github.com/json-iterator/go v1.1.6 github.com/json-iterator/go +# github.com/kelseyhightower/envconfig v1.3.0 +github.com/kelseyhightower/envconfig # github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f +github.com/keybase/go-crypto/openpgp +github.com/keybase/go-crypto/openpgp/packet +github.com/keybase/go-crypto/openpgp/armor +github.com/keybase/go-crypto/openpgp/errors +github.com/keybase/go-crypto/openpgp/s2k +github.com/keybase/go-crypto/rsa github.com/keybase/go-crypto/brainpool github.com/keybase/go-crypto/cast5 github.com/keybase/go-crypto/curve25519 github.com/keybase/go-crypto/ed25519 -github.com/keybase/go-crypto/ed25519/internal/edwards25519 -github.com/keybase/go-crypto/openpgp -github.com/keybase/go-crypto/openpgp/armor github.com/keybase/go-crypto/openpgp/ecdh github.com/keybase/go-crypto/openpgp/elgamal -github.com/keybase/go-crypto/openpgp/errors -github.com/keybase/go-crypto/openpgp/packet -github.com/keybase/go-crypto/openpgp/s2k -github.com/keybase/go-crypto/rsa +github.com/keybase/go-crypto/ed25519/internal/edwards25519 # github.com/konsorten/go-windows-terminal-sequences v1.0.1 github.com/konsorten/go-windows-terminal-sequences # github.com/kr/pretty v0.1.0 @@ -581,18 +583,22 @@ github.com/ncw/swift github.com/nwaples/rardecode # github.com/oklog/run v1.0.0 github.com/oklog/run +# github.com/okta/okta-sdk-golang v1.0.1 => github.com/ncabatoff/okta-sdk-golang v1.0.2-0.20200113143729-b3ae90a98438 +github.com/okta/okta-sdk-golang/okta +github.com/okta/okta-sdk-golang/okta/cache +github.com/okta/okta-sdk-golang/okta/query # github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/go-digest # github.com/opencontainers/image-spec v1.0.1 -github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go/v1 +github.com/opencontainers/image-spec/specs-go # github.com/opencontainers/runc v0.1.1 github.com/opencontainers/runc/libcontainer/user # github.com/oracle/oci-go-sdk v7.0.0+incompatible github.com/oracle/oci-go-sdk/common github.com/oracle/oci-go-sdk/common/auth -github.com/oracle/oci-go-sdk/keymanagement github.com/oracle/oci-go-sdk/objectstorage +github.com/oracle/oci-go-sdk/keymanagement # github.com/ory/dockertest v3.3.5+incompatible github.com/ory/dockertest github.com/ory/dockertest/docker @@ -600,23 +606,23 @@ github.com/ory/dockertest/docker/opts github.com/ory/dockertest/docker/pkg/archive github.com/ory/dockertest/docker/pkg/fileutils github.com/ory/dockertest/docker/pkg/homedir +github.com/ory/dockertest/docker/pkg/jsonmessage +github.com/ory/dockertest/docker/pkg/stdcopy +github.com/ory/dockertest/docker/types/registry +github.com/ory/dockertest/docker/types github.com/ory/dockertest/docker/pkg/idtools github.com/ory/dockertest/docker/pkg/ioutils -github.com/ory/dockertest/docker/pkg/jsonmessage github.com/ory/dockertest/docker/pkg/longpath -github.com/ory/dockertest/docker/pkg/mount github.com/ory/dockertest/docker/pkg/pools -github.com/ory/dockertest/docker/pkg/stdcopy github.com/ory/dockertest/docker/pkg/system github.com/ory/dockertest/docker/pkg/term -github.com/ory/dockertest/docker/pkg/term/windows -github.com/ory/dockertest/docker/types -github.com/ory/dockertest/docker/types/blkiodev github.com/ory/dockertest/docker/types/container github.com/ory/dockertest/docker/types/filters github.com/ory/dockertest/docker/types/mount github.com/ory/dockertest/docker/types/network -github.com/ory/dockertest/docker/types/registry +github.com/ory/dockertest/docker/pkg/mount +github.com/ory/dockertest/docker/pkg/term/windows +github.com/ory/dockertest/docker/types/blkiodev github.com/ory/dockertest/docker/types/strslice github.com/ory/dockertest/docker/types/versions # github.com/patrickmn/go-cache v2.1.0+incompatible @@ -630,31 +636,31 @@ github.com/pkg/errors github.com/pmezard/go-difflib/difflib # github.com/posener/complete v1.2.1 github.com/posener/complete -github.com/posener/complete/cmd github.com/posener/complete/cmd/install +github.com/posener/complete/cmd github.com/posener/complete/match # github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 github.com/pquerna/cachecontrol github.com/pquerna/cachecontrol/cacheobject # github.com/pquerna/otp v1.2.1-0.20191009055518-468c2dd2b58d github.com/pquerna/otp -github.com/pquerna/otp/hotp github.com/pquerna/otp/totp +github.com/pquerna/otp/hotp # github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 github.com/prometheus/client_golang/prometheus -github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/push +github.com/prometheus/client_golang/prometheus/internal # github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f github.com/prometheus/client_model/go # github.com/prometheus/common v0.2.0 github.com/prometheus/common/expfmt -github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/model +github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg # github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 github.com/prometheus/procfs -github.com/prometheus/procfs/internal/util github.com/prometheus/procfs/nfs github.com/prometheus/procfs/xfs +github.com/prometheus/procfs/internal/util # github.com/ryanuber/columnize v2.1.0+incompatible github.com/ryanuber/columnize # github.com/ryanuber/go-glob v1.0.0 @@ -667,10 +673,10 @@ github.com/satori/go.uuid github.com/shirou/gopsutil/cpu github.com/shirou/gopsutil/disk github.com/shirou/gopsutil/host -github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/mem -github.com/shirou/gopsutil/net +github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/process +github.com/shirou/gopsutil/net # github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 github.com/shirou/w32 # github.com/sirupsen/logrus v1.4.2 @@ -684,186 +690,183 @@ github.com/tv42/httpunix github.com/ugorji/go/codec # github.com/ulikunitz/xz v0.5.6 github.com/ulikunitz/xz -github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma +github.com/ulikunitz/xz/internal/hash # github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 github.com/xi2/xz # go.etcd.io/bbolt v1.3.2 go.etcd.io/bbolt # go.etcd.io/etcd v0.0.0-20190412021913-f29b1ada1971 -go.etcd.io/etcd/auth/authpb go.etcd.io/etcd/client go.etcd.io/etcd/clientv3 +go.etcd.io/etcd/clientv3/concurrency +go.etcd.io/etcd/pkg/transport +go.etcd.io/etcd/pkg/pathutil +go.etcd.io/etcd/pkg/srv +go.etcd.io/etcd/pkg/types +go.etcd.io/etcd/version +go.etcd.io/etcd/auth/authpb go.etcd.io/etcd/clientv3/balancer go.etcd.io/etcd/clientv3/balancer/picker go.etcd.io/etcd/clientv3/balancer/resolver/endpoint -go.etcd.io/etcd/clientv3/concurrency go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes go.etcd.io/etcd/etcdserver/etcdserverpb go.etcd.io/etcd/mvcc/mvccpb go.etcd.io/etcd/pkg/logutil -go.etcd.io/etcd/pkg/pathutil -go.etcd.io/etcd/pkg/srv -go.etcd.io/etcd/pkg/systemd go.etcd.io/etcd/pkg/tlsutil -go.etcd.io/etcd/pkg/transport -go.etcd.io/etcd/pkg/types +go.etcd.io/etcd/pkg/systemd go.etcd.io/etcd/raft go.etcd.io/etcd/raft/raftpb -go.etcd.io/etcd/version # go.opencensus.io v0.21.0 -go.opencensus.io -go.opencensus.io/internal -go.opencensus.io/internal/tagencoding -go.opencensus.io/metric/metricdata -go.opencensus.io/metric/metricproducer -go.opencensus.io/plugin/ocgrpc +go.opencensus.io/stats +go.opencensus.io/stats/view go.opencensus.io/plugin/ochttp -go.opencensus.io/plugin/ochttp/propagation/b3 go.opencensus.io/plugin/ochttp/propagation/tracecontext -go.opencensus.io/resource -go.opencensus.io/stats +go.opencensus.io/trace +go.opencensus.io/metric/metricdata go.opencensus.io/stats/internal -go.opencensus.io/stats/view go.opencensus.io/tag -go.opencensus.io/trace -go.opencensus.io/trace/internal +go.opencensus.io/internal/tagencoding +go.opencensus.io/metric/metricproducer +go.opencensus.io/plugin/ocgrpc +go.opencensus.io/plugin/ochttp/propagation/b3 go.opencensus.io/trace/propagation +go.opencensus.io +go.opencensus.io/resource go.opencensus.io/trace/tracestate +go.opencensus.io/internal +go.opencensus.io/trace/internal # go.uber.org/atomic v1.4.0 go.uber.org/atomic # go.uber.org/multierr v1.1.0 go.uber.org/multierr # go.uber.org/zap v1.9.1 go.uber.org/zap -go.uber.org/zap/buffer +go.uber.org/zap/zapcore go.uber.org/zap/internal/bufferpool +go.uber.org/zap/buffer go.uber.org/zap/internal/color go.uber.org/zap/internal/exit -go.uber.org/zap/zapcore # golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4 golang.org/x/crypto/bcrypt -golang.org/x/crypto/blake2b -golang.org/x/crypto/blowfish -golang.org/x/crypto/chacha20poly1305 golang.org/x/crypto/cryptobyte golang.org/x/crypto/cryptobyte/asn1 -golang.org/x/crypto/curve25519 golang.org/x/crypto/ed25519 +golang.org/x/crypto/ssh +golang.org/x/crypto/ssh/agent +golang.org/x/crypto/curve25519 +golang.org/x/crypto/ssh/terminal +golang.org/x/crypto/blowfish +golang.org/x/crypto/md4 golang.org/x/crypto/ed25519/internal/edwards25519 -golang.org/x/crypto/hkdf golang.org/x/crypto/internal/chacha20 -golang.org/x/crypto/internal/subtle -golang.org/x/crypto/md4 +golang.org/x/crypto/poly1305 +golang.org/x/crypto/chacha20poly1305 +golang.org/x/crypto/hkdf golang.org/x/crypto/pbkdf2 +golang.org/x/crypto/blake2b golang.org/x/crypto/pkcs12 +golang.org/x/crypto/internal/subtle golang.org/x/crypto/pkcs12/internal/rc2 -golang.org/x/crypto/poly1305 -golang.org/x/crypto/ssh -golang.org/x/crypto/ssh/agent -golang.org/x/crypto/ssh/terminal # golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 -golang.org/x/net/context -golang.org/x/net/context/ctxhttp -golang.org/x/net/http/httpguts +golang.org/x/net/idna golang.org/x/net/http/httpproxy +golang.org/x/net/context golang.org/x/net/http2 +golang.org/x/net/http/httpguts golang.org/x/net/http2/hpack -golang.org/x/net/idna -golang.org/x/net/internal/timeseries golang.org/x/net/trace +golang.org/x/net/context/ctxhttp +golang.org/x/net/internal/timeseries # golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a golang.org/x/oauth2 -golang.org/x/oauth2/clientcredentials -golang.org/x/oauth2/google golang.org/x/oauth2/internal -golang.org/x/oauth2/jws +golang.org/x/oauth2/google golang.org/x/oauth2/jwt +golang.org/x/oauth2/jws +golang.org/x/oauth2/clientcredentials # golang.org/x/sync v0.0.0-20190423024810-112230192c58 golang.org/x/sync/semaphore # golang.org/x/sys v0.0.0-20191008105621-543471e840be -golang.org/x/sys/cpu golang.org/x/sys/unix golang.org/x/sys/windows +golang.org/x/sys/cpu # golang.org/x/text v0.3.2 +golang.org/x/text/secure/bidirule +golang.org/x/text/unicode/bidi +golang.org/x/text/unicode/norm +golang.org/x/text/transform +golang.org/x/text/encoding/unicode golang.org/x/text/encoding golang.org/x/text/encoding/internal golang.org/x/text/encoding/internal/identifier -golang.org/x/text/encoding/unicode golang.org/x/text/internal/utf8internal golang.org/x/text/runes -golang.org/x/text/secure/bidirule -golang.org/x/text/transform -golang.org/x/text/unicode/bidi -golang.org/x/text/unicode/norm # golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 golang.org/x/time/rate # google.golang.org/api v0.5.0 +google.golang.org/api/option +google.golang.org/api/iam/v1 +google.golang.org/api/googleapi +google.golang.org/api/iterator +google.golang.org/api/transport google.golang.org/api/cloudresourcemanager/v1 google.golang.org/api/compute/v1 -google.golang.org/api/gensupport -google.golang.org/api/googleapi -google.golang.org/api/googleapi/internal/uritemplates -google.golang.org/api/googleapi/transport -google.golang.org/api/iam/v1 google.golang.org/api/internal -google.golang.org/api/iterator google.golang.org/api/oauth2/v2 -google.golang.org/api/option +google.golang.org/api/gensupport +google.golang.org/api/transport/http google.golang.org/api/storage/v1 -google.golang.org/api/support/bundler -google.golang.org/api/transport +google.golang.org/api/googleapi/internal/uritemplates google.golang.org/api/transport/grpc -google.golang.org/api/transport/http +google.golang.org/api/googleapi/transport google.golang.org/api/transport/http/internal/propagation +google.golang.org/api/support/bundler # google.golang.org/appengine v1.6.0 -google.golang.org/appengine google.golang.org/appengine/cloudsql +google.golang.org/appengine/urlfetch +google.golang.org/appengine +google.golang.org/appengine/socket google.golang.org/appengine/internal +google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/internal/app_identity +google.golang.org/appengine/internal/modules +google.golang.org/appengine/internal/socket google.golang.org/appengine/internal/base google.golang.org/appengine/internal/datastore google.golang.org/appengine/internal/log -google.golang.org/appengine/internal/modules google.golang.org/appengine/internal/remote_api -google.golang.org/appengine/internal/socket -google.golang.org/appengine/internal/urlfetch -google.golang.org/appengine/socket -google.golang.org/appengine/urlfetch # google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 -google.golang.org/genproto/googleapis/api -google.golang.org/genproto/googleapis/api/annotations -google.golang.org/genproto/googleapis/api/distribution -google.golang.org/genproto/googleapis/api/httpbody -google.golang.org/genproto/googleapis/api/label +google.golang.org/genproto/googleapis/cloud/kms/v1 google.golang.org/genproto/googleapis/api/metric google.golang.org/genproto/googleapis/api/monitoredres -google.golang.org/genproto/googleapis/cloud/kms/v1 -google.golang.org/genproto/googleapis/iam/v1 google.golang.org/genproto/googleapis/monitoring/v3 -google.golang.org/genproto/googleapis/rpc/code +google.golang.org/genproto/googleapis/api/distribution +google.golang.org/genproto/protobuf/field_mask +google.golang.org/genproto/googleapis/iam/v1 google.golang.org/genproto/googleapis/rpc/errdetails -google.golang.org/genproto/googleapis/rpc/status google.golang.org/genproto/googleapis/spanner/v1 +google.golang.org/genproto/googleapis/rpc/status +google.golang.org/genproto/googleapis/api/annotations +google.golang.org/genproto/googleapis/api +google.golang.org/genproto/googleapis/api/label +google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/type/expr -google.golang.org/genproto/protobuf/field_mask +google.golang.org/genproto/googleapis/api/httpbody # google.golang.org/grpc v1.22.0 +google.golang.org/grpc/grpclog +google.golang.org/grpc/codes google.golang.org/grpc +google.golang.org/grpc/keepalive +google.golang.org/grpc/status +google.golang.org/grpc/metadata +google.golang.org/grpc/credentials google.golang.org/grpc/balancer -google.golang.org/grpc/balancer/base google.golang.org/grpc/balancer/roundrobin -google.golang.org/grpc/binarylog/grpc_binarylog_v1 -google.golang.org/grpc/codes google.golang.org/grpc/connectivity -google.golang.org/grpc/credentials -google.golang.org/grpc/credentials/internal -google.golang.org/grpc/credentials/oauth google.golang.org/grpc/encoding google.golang.org/grpc/encoding/proto -google.golang.org/grpc/grpclog -google.golang.org/grpc/health -google.golang.org/grpc/health/grpc_health_v1 google.golang.org/grpc/internal google.golang.org/grpc/internal/backoff google.golang.org/grpc/internal/balancerload @@ -872,10 +875,7 @@ google.golang.org/grpc/internal/channelz google.golang.org/grpc/internal/envconfig google.golang.org/grpc/internal/grpcrand google.golang.org/grpc/internal/grpcsync -google.golang.org/grpc/internal/syscall google.golang.org/grpc/internal/transport -google.golang.org/grpc/keepalive -google.golang.org/grpc/metadata google.golang.org/grpc/naming google.golang.org/grpc/peer google.golang.org/grpc/resolver @@ -883,8 +883,14 @@ google.golang.org/grpc/resolver/dns google.golang.org/grpc/resolver/passthrough google.golang.org/grpc/serviceconfig google.golang.org/grpc/stats -google.golang.org/grpc/status google.golang.org/grpc/tap +google.golang.org/grpc/health +google.golang.org/grpc/health/grpc_health_v1 +google.golang.org/grpc/credentials/internal +google.golang.org/grpc/credentials/oauth +google.golang.org/grpc/balancer/base +google.golang.org/grpc/binarylog/grpc_binarylog_v1 +google.golang.org/grpc/internal/syscall # gopkg.in/inf.v0 v0.9.1 gopkg.in/inf.v0 # gopkg.in/ini.v1 v1.42.0 @@ -901,43 +907,43 @@ gopkg.in/jcmturner/rpc.v1/ndr # gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce gopkg.in/mgo.v2 gopkg.in/mgo.v2/bson -gopkg.in/mgo.v2/internal/json gopkg.in/mgo.v2/internal/sasl gopkg.in/mgo.v2/internal/scram +gopkg.in/mgo.v2/internal/json # gopkg.in/ory-am/dockertest.v3 v3.3.4 gopkg.in/ory-am/dockertest.v3 # gopkg.in/square/go-jose.v2 v2.3.1 +gopkg.in/square/go-jose.v2/jwt gopkg.in/square/go-jose.v2 -gopkg.in/square/go-jose.v2/cipher gopkg.in/square/go-jose.v2/json -gopkg.in/square/go-jose.v2/jwt +gopkg.in/square/go-jose.v2/cipher # gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 # k8s.io/api v0.0.0-20190409092523-d687e77c8ae9 k8s.io/api/authentication/v1 # k8s.io/apimachinery v0.0.0-20190409092423-760d1845f48b k8s.io/apimachinery/pkg/api/errors -k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/apis/meta/v1 +k8s.io/apimachinery/pkg/runtime +k8s.io/apimachinery/pkg/runtime/schema +k8s.io/apimachinery/pkg/types +k8s.io/apimachinery/pkg/util/validation/field +k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/conversion -k8s.io/apimachinery/pkg/conversion/queryparams k8s.io/apimachinery/pkg/fields k8s.io/apimachinery/pkg/labels -k8s.io/apimachinery/pkg/runtime -k8s.io/apimachinery/pkg/runtime/schema k8s.io/apimachinery/pkg/selection -k8s.io/apimachinery/pkg/types -k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/intstr +k8s.io/apimachinery/pkg/util/runtime +k8s.io/apimachinery/pkg/watch +k8s.io/apimachinery/pkg/conversion/queryparams +k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/json k8s.io/apimachinery/pkg/util/naming -k8s.io/apimachinery/pkg/util/net -k8s.io/apimachinery/pkg/util/runtime k8s.io/apimachinery/pkg/util/sets -k8s.io/apimachinery/pkg/util/validation -k8s.io/apimachinery/pkg/util/validation/field -k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/reflect +k8s.io/apimachinery/pkg/util/validation +k8s.io/apimachinery/pkg/util/net # k8s.io/klog v0.0.0-20190306015804-8e90cee79f82 k8s.io/klog # layeh.com/radius v0.0.0-20190322222518-890bc1058917 From 6b420bbc7a163ec4ce69430f7ee8ddccafaf6c17 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Fri, 17 Jan 2020 11:27:45 -0500 Subject: [PATCH 4/8] Stop using my forked okta lib. Use old unofficial okta lib for no-apitoken case. Deprecate that use case. --- builtin/credential/okta/backend.go | 15 ++-- builtin/credential/okta/path_config.go | 79 ++++++++++++------- go.mod | 3 +- go.sum | 7 +- .../source/api/auth/okta/index.html.md.erb | 1 + website/source/docs/auth/okta.html.md | 6 +- 6 files changed, 70 insertions(+), 41 deletions(-) diff --git a/builtin/credential/okta/backend.go b/builtin/credential/okta/backend.go index 5b40578bb1dc1..c0ee7f13bce46 100644 --- a/builtin/credential/okta/backend.go +++ b/builtin/credential/okta/backend.go @@ -77,7 +77,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri } } - client, reqExec, err := cfg.OktaClient() + shim, err := cfg.OktaClient() if err != nil { return nil, nil, nil, err } @@ -100,7 +100,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri StateToken string `json:"stateToken"` } - authReq, err := reqExec.NewRequest("POST", "/api/v1/authn", map[string]interface{}{ + authReq, err := shim.NewRequest("POST", "/api/v1/authn", map[string]interface{}{ "username": username, "password": password, }) @@ -109,7 +109,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri } var result authResult - rsp, err := reqExec.Do(authReq, &result) + rsp, err := shim.Do(authReq, &result) if err != nil { if oe, ok := err.(*okta.Error); ok { return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed: %v (code=%v)", err, oe.ErrorCode)), nil, nil @@ -184,12 +184,12 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri payload := map[string]interface{}{ "stateToken": result.StateToken, } - verifyReq, err := reqExec.NewRequest("POST", requestPath, payload) + verifyReq, err := shim.NewRequest("POST", requestPath, payload) if err != nil { return nil, nil, nil, err } - rsp, err := reqExec.Do(verifyReq, &result) + rsp, err := shim.Do(verifyReq, &result) if err != nil { return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed: %v", err)), nil, nil } @@ -199,11 +199,11 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri for result.Status == "MFA_CHALLENGE" { switch result.FactorResult { case "WAITING": - verifyReq, err := reqExec.NewRequest("POST", requestPath, payload) + verifyReq, err := shim.NewRequest("POST", requestPath, payload) if err != nil { return nil, logical.ErrorResponse(fmt.Sprintf("okta auth failed creating verify request: %v", err)), nil, nil } - rsp, err := reqExec.Do(verifyReq, &result) + rsp, err := shim.Do(verifyReq, &result) if err != nil { return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed checking loop: %v", err)), nil, nil } @@ -258,6 +258,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri var allGroups []string // Only query the Okta API for group membership if we have a token + client := shim.Client() if client != nil { oktaGroups, err := b.getOktaGroups(client, &result.Embedded.User) if err != nil { diff --git a/builtin/credential/okta/path_config.go b/builtin/credential/okta/path_config.go index 5e5dc9f7294e5..32d8b3d959f65 100644 --- a/builtin/credential/okta/path_config.go +++ b/builtin/credential/okta/path_config.go @@ -3,13 +3,16 @@ package okta import ( "context" "fmt" + "github.com/hashicorp/go-cleanhttp" + "net/http" "net/url" "time" + oktaold "github.com/chrismalek/oktasdk-go/okta" "github.com/hashicorp/vault/sdk/framework" "github.com/hashicorp/vault/sdk/helper/tokenutil" "github.com/hashicorp/vault/sdk/logical" - okta "github.com/okta/okta-sdk-golang/okta" + oktanew "github.com/okta/okta-sdk-golang/okta" ) const ( @@ -264,8 +267,46 @@ func (b *backend) pathConfigExistenceCheck(ctx context.Context, req *logical.Req return cfg != nil, nil } +type oktaShim interface { + Client() *oktanew.Client + NewRequest(method string, url string, body interface{}) (*http.Request, error) + Do(req *http.Request, v interface{}) (interface{}, error) +} + +type oktaShimNew struct { + client *oktanew.Client +} + +func (new *oktaShimNew) Client() *oktanew.Client { + return new.client +} + +func (new *oktaShimNew) NewRequest(method string, url string, body interface{}) (*http.Request, error) { + return new.client.GetRequestExecutor().NewRequest(method, url, body) +} + +func (new *oktaShimNew) Do(req *http.Request, v interface{}) (interface{}, error) { + return new.client.GetRequestExecutor().Do(req, v) +} + +type oktaShimOld struct { + client *oktaold.Client +} + +func (new *oktaShimOld) Client() *oktanew.Client { + return nil +} + +func (new *oktaShimOld) NewRequest(method string, url string, body interface{}) (*http.Request, error) { + return new.client.NewRequest(method, url, body) +} + +func (new *oktaShimOld) Do(req *http.Request, v interface{}) (interface{}, error) { + return new.client.Do(req, v) +} + // OktaClient creates a basic okta client connection -func (c *ConfigEntry) OktaClient() (*okta.Client, *okta.RequestExecutor, error) { +func (c *ConfigEntry) OktaClient() (oktaShim, error) { baseURL := defaultBaseURL if c.Production != nil { if !*c.Production { @@ -276,38 +317,20 @@ func (c *ConfigEntry) OktaClient() (*okta.Client, *okta.RequestExecutor, error) baseURL = c.BaseURL } - oktaURL := "https://" + c.Org + "." + baseURL - // We validate config on input and errors are only returned when parsing URLs - conf := []okta.ConfigSetter{okta.WithOrgUrl(oktaURL)} if c.Token != "" { - conf = append(conf, okta.WithToken(c.Token)) - client, err := okta.NewClient(context.Background(), conf...) + client, err := oktanew.NewClient(context.Background(), + oktanew.WithOrgUrl("https://"+c.Org+"."+baseURL), + oktanew.WithToken(c.Token)) if err != nil { - return nil, nil, err + return nil, err } - return client, client.GetRequestExecutor(), nil + return &oktaShimNew{client}, nil } - - conf = append(conf, okta.WithConnectionTimeout(30), - okta.WithCache(true), - okta.WithCacheTtl(300), - okta.WithCacheTti(300), - okta.WithUserAgentExtra("")) - - config, err := okta.NewConfig(conf...) + client, err := oktaold.NewClientWithDomain(cleanhttp.DefaultClient(), c.Org, baseURL, "") if err != nil { - return nil, nil, err - } - err = okta.ValidateOktaDomain(config) - if err != nil { - return nil, nil, err - } - cache, err := okta.NewCache(config) - if err != nil { - return nil, nil, err + return nil, err } - - return nil, okta.NewRequestExecutor(&config.HttpClient, cache, config), nil + return &oktaShimOld{client}, nil } // ConfigEntry for Okta diff --git a/go.mod b/go.mod index b1924b5310d88..84eac712822f2 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,6 @@ replace github.com/hashicorp/vault/api => ./api replace github.com/hashicorp/vault/sdk => ./sdk -replace github.com/okta/okta-sdk-golang => github.com/ncabatoff/okta-sdk-golang v1.0.2-0.20200113143729-b3ae90a98438 - require ( cloud.google.com/go v0.39.0 github.com/Azure/azure-sdk-for-go v29.0.0+incompatible @@ -26,6 +24,7 @@ require ( github.com/aws/aws-sdk-go v1.25.41 github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect + github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0 github.com/cockroachdb/apd v1.1.0 // indirect github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c github.com/coreos/go-semver v0.2.0 diff --git a/go.sum b/go.sum index da5b52a8a5e82..69d21d666f181 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.0 h1:LzQXZOgg4CQfE6bFvXG github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f h1:gJzxrodnNd/CtPXjO3WYiakyNzHg3rtAi7rO74ejHYU= github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE= +github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0 h1:CWU8piLyqoi9qXEUwzOh5KFKGgmSU5ZhktJyYcq6ryQ= +github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0/go.mod h1:5d8DqS60xkj9k3aXfL3+mXBH0DPYO0FQjcKosxl+b/Q= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj7ug5D7I/orNUA= @@ -415,7 +417,6 @@ github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGU github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= github.com/jackc/pgx v3.3.0+incompatible h1:Wa90/+qsITBAPkAZjiByeIGHFcj3Ztu+VzrrIpHjL90= github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= -github.com/jarcoal/httpmock v1.0.4/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jeffchao/backoff v0.0.0-20140404060208-9d7fd7aa17f2 h1:mex1izRBCD+7WjieGgRdy7e651vD/lvB1bD9vNE/3K4= @@ -519,14 +520,14 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/ncabatoff/okta-sdk-golang v1.0.2-0.20200113143729-b3ae90a98438 h1:6YwWNKjkGAwq2r1h5zBPEwN/IbF8pZxyVFn+c1C5ULw= -github.com/ncabatoff/okta-sdk-golang v1.0.2-0.20200113143729-b3ae90a98438/go.mod h1:/XIqyXYm5Mht0ksFDgBJOvJOoTiII7uk8QMbsPfURME= github.com/ncw/swift v1.0.47 h1:4DQRPj35Y41WogBxyhOXlrI37nzGlyEcsforeudyYPQ= github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs= github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/okta/okta-sdk-golang v1.0.1 h1:1DGm5+h2JvfdHz07yVVM7+LgUVSwxnk+6RoLUOB6CwI= +github.com/okta/okta-sdk-golang v1.0.1/go.mod h1:8k//sN2mFTq8Ayo90DqGbcumCkSmYjF0+2zkIbZysec= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= diff --git a/website/source/api/auth/okta/index.html.md.erb b/website/source/api/auth/okta/index.html.md.erb index 76d6b9414d769..764d43a605e5c 100644 --- a/website/source/api/auth/okta/index.html.md.erb +++ b/website/source/api/auth/okta/index.html.md.erb @@ -33,6 +33,7 @@ distinction between the `create` and `update` capabilities inside ACL policies. - `api_token` `(string: "")` - Okta API token. This is required to query Okta for user group membership. If this is not supplied only locally configured groups will be enabled. + **Support for okta auth without api_token is deprecated in Vault 1.4 and will be removed in Vault 1.5.** - `base_url` `(string: "")` - If set, will be used as the base domain for API requests. Examples are okta.com, oktapreview.com, and okta-emea.com. - `bypass_okta_mfa` `(bool: false)` - Whether to bypass an Okta MFA request. diff --git a/website/source/docs/auth/okta.html.md b/website/source/docs/auth/okta.html.md index 5e845e133ed3d..deba035c507c9 100644 --- a/website/source/docs/auth/okta.html.md +++ b/website/source/docs/auth/okta.html.md @@ -80,7 +80,11 @@ management tool. **If no token is supplied, Vault will function, but only locally configured group membership will be available. Without a token, groups will not be - queried.** + queried. + + Support for okta auth with no API token is deprecated in Vault 1.4, + and will be removed in Vault 1.5. + ** For the complete list of configuration options, please see the API documentation. From f4fff5aa70f20cc7df2ddf6c86a35b2d8e4808b7 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Tue, 21 Jan 2020 08:53:49 -0500 Subject: [PATCH 5/8] Drop references to removing no-api-token option in 1.5. --- website/source/api/auth/okta/index.html.md.erb | 2 +- website/source/docs/auth/okta.html.md | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/website/source/api/auth/okta/index.html.md.erb b/website/source/api/auth/okta/index.html.md.erb index 764d43a605e5c..e6cbde3a1a1c1 100644 --- a/website/source/api/auth/okta/index.html.md.erb +++ b/website/source/api/auth/okta/index.html.md.erb @@ -33,7 +33,7 @@ distinction between the `create` and `update` capabilities inside ACL policies. - `api_token` `(string: "")` - Okta API token. This is required to query Okta for user group membership. If this is not supplied only locally configured groups will be enabled. - **Support for okta auth without api_token is deprecated in Vault 1.4 and will be removed in Vault 1.5.** + **Support for okta auth without api_token is deprecated in Vault 1.4** - `base_url` `(string: "")` - If set, will be used as the base domain for API requests. Examples are okta.com, oktapreview.com, and okta-emea.com. - `bypass_okta_mfa` `(bool: false)` - Whether to bypass an Okta MFA request. diff --git a/website/source/docs/auth/okta.html.md b/website/source/docs/auth/okta.html.md index deba035c507c9..b344c6acd07dd 100644 --- a/website/source/docs/auth/okta.html.md +++ b/website/source/docs/auth/okta.html.md @@ -82,9 +82,7 @@ management tool. group membership will be available. Without a token, groups will not be queried. - Support for okta auth with no API token is deprecated in Vault 1.4, - and will be removed in Vault 1.5. - ** + Support for okta auth with no API token is deprecated in Vault 1.4.** For the complete list of configuration options, please see the API documentation. From 930ed1003f6c88d23f18012067966965d55a030e Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Wed, 22 Jan 2020 16:53:47 -0500 Subject: [PATCH 6/8] go mod tidy and vendor --- go.mod | 5 +- go.sum | 7 + .../chrismalek/oktasdk-go/LICENSE.txt | 21 + .../chrismalek/oktasdk-go/okta/apps.go | 315 +++++++++ .../chrismalek/oktasdk-go/okta/factors.go | 8 + .../chrismalek/oktasdk-go/okta/groups.go | 359 ++++++++++ .../chrismalek/oktasdk-go/okta/sdk.go | 523 +++++++++++++++ .../chrismalek/oktasdk-go/okta/users.go | 625 ++++++++++++++++++ .../okta/okta-sdk-golang/okta/config.go | 47 +- .../okta/okta-sdk-golang/okta/okta.go | 39 +- .../okta-sdk-golang/okta/requestExecutor.go | 103 +-- .../okta/okta-sdk-golang/okta/validator.go | 10 +- vendor/modules.txt | 506 +++++++------- 13 files changed, 2160 insertions(+), 408 deletions(-) create mode 100644 vendor/github.com/chrismalek/oktasdk-go/LICENSE.txt create mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/apps.go create mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/factors.go create mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/groups.go create mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go create mode 100644 vendor/github.com/chrismalek/oktasdk-go/okta/users.go diff --git a/go.mod b/go.mod index 9151376ef5eeb..547d94ec26ec2 100644 --- a/go.mod +++ b/go.mod @@ -28,6 +28,7 @@ require ( github.com/cockroachdb/apd v1.1.0 // indirect github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c github.com/coreos/go-semver v0.2.0 + github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d // indirect github.com/denisenkom/go-mssqldb v0.0.0-20190412130859-3b1d194e553a github.com/dnaeon/go-vcr v1.0.1 // indirect github.com/dsnet/compress v0.0.1 // indirect @@ -47,6 +48,7 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/go-github v17.0.0+incompatible github.com/google/go-metrics-stackdriver v0.0.0-20190816035513-b52628e82e2a + github.com/google/go-querystring v1.0.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.8.5 // indirect github.com/hashicorp/consul-template v0.22.0 github.com/hashicorp/consul/api v1.1.0 @@ -95,6 +97,7 @@ require ( github.com/joyent/triton-go v0.0.0-20190112182421-51ffac552869 github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f github.com/kr/pretty v0.1.0 + github.com/kr/pty v1.1.3 // indirect github.com/kr/text v0.1.0 github.com/lib/pq v1.2.0 github.com/mattn/go-colorable v0.1.4 @@ -109,8 +112,8 @@ require ( github.com/ncw/swift v1.0.47 github.com/nwaples/rardecode v1.0.0 // indirect github.com/oklog/run v1.0.0 - github.com/oracle/oci-go-sdk v12.5.0+incompatible github.com/okta/okta-sdk-golang v1.0.1 + github.com/oracle/oci-go-sdk v12.5.0+incompatible github.com/ory/dockertest v3.3.5+incompatible github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.8.1 diff --git a/go.sum b/go.sum index c680772f4c0b4..beacd9df4af00 100644 --- a/go.sum +++ b/go.sum @@ -206,6 +206,8 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o= +github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df h1:fwXmhM0OqixzJDOGgTSyNH9eEDij9uGTXwsyWXvyR0A= github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -438,6 +440,8 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM= +github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f h1:Gsc9mVHLRqBjMgdQCghN9NObCcRncDqxJvBvEaIIQEo= github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -515,6 +519,8 @@ github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMB github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/okta/okta-sdk-golang v1.0.1 h1:1DGm5+h2JvfdHz07yVVM7+LgUVSwxnk+6RoLUOB6CwI= +github.com/okta/okta-sdk-golang v1.0.1/go.mod h1:8k//sN2mFTq8Ayo90DqGbcumCkSmYjF0+2zkIbZysec= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -545,6 +551,7 @@ github.com/oxtoacart/bpool v0.0.0-20150712133111-4e1c5567d7c2/go.mod h1:L3UMQOTh github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v0.0.0-20180815053127-5633e0862627/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= diff --git a/vendor/github.com/chrismalek/oktasdk-go/LICENSE.txt b/vendor/github.com/chrismalek/oktasdk-go/LICENSE.txt new file mode 100644 index 0000000000000..63b4b681cb65b --- /dev/null +++ b/vendor/github.com/chrismalek/oktasdk-go/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [year] [fullname] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/apps.go b/vendor/github.com/chrismalek/oktasdk-go/okta/apps.go new file mode 100644 index 0000000000000..1fe8007bca8f1 --- /dev/null +++ b/vendor/github.com/chrismalek/oktasdk-go/okta/apps.go @@ -0,0 +1,315 @@ +package okta + +import ( + "fmt" + "net/url" + "time" +) + +// AppsService is a service to retreives applications from OKTA. +type AppsService service + +// AppFilterOptions is used to generate a "Filter" to search for different Apps +// The values here coorelate to API Search paramgters on the group API +type AppFilterOptions struct { + NextURL *url.URL `url:"-"` + GetAllPages bool `url:"-"` + NumberOfPages int `url:"-"` + Limit int `url:"limit,omitempty"` +} + +// App is the Model for an OKTA Application +type App struct { + ID string `json:"id"` + Name string `json:"name"` + Label string `json:"label"` + Status string `json:"status"` + LastUpdated time.Time `json:"lastUpdated"` + Created time.Time `json:"created"` + Accessibility struct { + SelfService bool `json:"selfService"` + ErrorRedirectURL interface{} `json:"errorRedirectUrl"` + LoginRedirectURL interface{} `json:"loginRedirectUrl"` + } `json:"accessibility"` + Visibility struct { + AutoSubmitToolbar bool `json:"autoSubmitToolbar"` + Hide struct { + IOS bool `json:"iOS"` + Web bool `json:"web"` + } `json:"hide"` + AppLinks struct { + TestorgoneCustomsaml20App1Link bool `json:"testorgone_customsaml20app_1_link"` + } `json:"appLinks"` + } `json:"visibility"` + Features []interface{} `json:"features"` + SignOnMode string `json:"signOnMode"` + Credentials struct { + UserNameTemplate struct { + Template string `json:"template"` + Type string `json:"type"` + } `json:"userNameTemplate"` + Signing struct { + } `json:"signing"` + } `json:"credentials"` + Settings struct { + App struct { + } `json:"app"` + Notifications struct { + Vpn struct { + Network struct { + Connection string `json:"connection"` + } `json:"network"` + Message interface{} `json:"message"` + HelpURL interface{} `json:"helpUrl"` + } `json:"vpn"` + } `json:"notifications"` + SignOn struct { + DefaultRelayState string `json:"defaultRelayState"` + SsoAcsURL string `json:"ssoAcsUrl"` + IdpIssuer string `json:"idpIssuer"` + Audience string `json:"audience"` + Recipient string `json:"recipient"` + Destination string `json:"destination"` + SubjectNameIDTemplate string `json:"subjectNameIdTemplate"` + SubjectNameIDFormat string `json:"subjectNameIdFormat"` + ResponseSigned bool `json:"responseSigned"` + AssertionSigned bool `json:"assertionSigned"` + SignatureAlgorithm string `json:"signatureAlgorithm"` + DigestAlgorithm string `json:"digestAlgorithm"` + HonorForceAuthn bool `json:"honorForceAuthn"` + AuthnContextClassRef string `json:"authnContextClassRef"` + SpIssuer interface{} `json:"spIssuer"` + RequestCompressed bool `json:"requestCompressed"` + AttributeStatements []interface{} `json:"attributeStatements"` + } `json:"signOn"` + } `json:"settings"` + Links struct { + Logo []struct { + Name string `json:"name"` + Href string `json:"href"` + Type string `json:"type"` + } `json:"logo"` + AppLinks []struct { + Name string `json:"name"` + Href string `json:"href"` + Type string `json:"type"` + } `json:"appLinks"` + Help struct { + Href string `json:"href"` + Type string `json:"type"` + } `json:"help"` + Users struct { + Href string `json:"href"` + } `json:"users"` + Deactivate struct { + Href string `json:"href"` + } `json:"deactivate"` + Groups struct { + Href string `json:"href"` + } `json:"groups"` + Metadata struct { + Href string `json:"href"` + Type string `json:"type"` + } `json:"metadata"` + } `json:"_links"` +} + +func (a App) String() string { + // return Stringify(g) + return fmt.Sprintf("App:(ID: {%v} - Name: {%v})\n", a.ID, a.Name) +} + +// GetByID gets a group from OKTA by the Gropu ID. An error is returned if the group is not found +func (a *AppsService) GetByID(appID string) (*App, *Response, error) { + + u := fmt.Sprintf("apps/%v", appID) + req, err := a.client.NewRequest("GET", u, nil) + + if err != nil { + return nil, nil, err + } + + app := new(App) + + resp, err := a.client.Do(req, app) + + if err != nil { + return nil, resp, err + } + + return app, resp, err +} + +// AppUser is the model for a user of an OKTA App +type AppUser struct { + ID string `json:"id"` + ExternalID string `json:"externalId"` + Created time.Time `json:"created"` + LastUpdated time.Time `json:"lastUpdated"` + Scope string `json:"scope"` + Status string `json:"status"` + StatusChanged *time.Time `json:"statusChanged"` + PasswordChanged *time.Time `json:"passwordChanged"` + SyncState string `json:"syncState"` + LastSync *time.Time `json:"lastSync"` + Credentials struct { + UserName string `json:"userName"` + Password struct { + } `json:"password"` + } `json:"credentials"` + Profile struct { + SecondEmail interface{} `json:"secondEmail"` + LastName string `json:"lastName"` + MobilePhone interface{} `json:"mobilePhone"` + Email string `json:"email"` + SalesforceGroups []string `json:"salesforceGroups"` + Role string `json:"role"` + FirstName string `json:"firstName"` + Profile string `json:"profile"` + } `json:"profile"` + Links struct { + App struct { + Href string `json:"href"` + } `json:"app"` + User struct { + Href string `json:"href"` + } `json:"user"` + } `json:"_links"` +} + +// GetUsers returns the members in an App +// Pass in an optional AppFilterOptions struct to filter the results +// The Users in the app are returned +func (a *AppsService) GetUsers(appID string, opt *AppFilterOptions) (appUsers []AppUser, resp *Response, err error) { + + pagesRetreived := 0 + var u string + if opt.NextURL != nil { + u = opt.NextURL.String() + } else { + u = fmt.Sprintf("apps/%v/users", appID) + + if opt.Limit == 0 { + opt.Limit = defaultLimit + } + + u, _ = addOptions(u, opt) + } + + req, err := a.client.NewRequest("GET", u, nil) + + if err != nil { + // fmt.Printf("____ERROR HERE\n") + return nil, nil, err + } + resp, err = a.client.Do(req, &appUsers) + + if err != nil { + // fmt.Printf("____ERROR HERE 2\n") + return nil, resp, err + } + + pagesRetreived++ + + if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { + + for { + + if pagesRetreived == opt.NumberOfPages { + break + } + if resp.NextURL != nil { + + var userPage []AppUser + pageOpts := new(AppFilterOptions) + pageOpts.NextURL = resp.NextURL + pageOpts.Limit = opt.Limit + pageOpts.NumberOfPages = 1 + + userPage, resp, err = a.GetUsers(appID, pageOpts) + + if err != nil { + return appUsers, resp, err + } + appUsers = append(appUsers, userPage...) + pagesRetreived++ + } else { + break + } + + } + } + + return appUsers, resp, err +} + +// AppGroups - Groups assigned to Application +type AppGroups struct { + ID string `json:"id"` + LastUpdated time.Time `json:"lastUpdated"` + Priority int `json:"priority"` + Links struct { + User struct { + Href string `json:"href"` + } `json:"user"` + } `json:"_links"` +} + +// GetGroups returns groups assigned to the application - Input appID is the Application GUID +func (a *AppsService) GetGroups(appID string) (appGroups []AppGroups, resp *Response, err error) { + + var u string + u = fmt.Sprintf("apps/%v/groups", appID) + + req, err := a.client.NewRequest("GET", u, nil) + + if err != nil { + return nil, nil, err + } + resp, err = a.client.Do(req, &appGroups) + + if err != nil { + return nil, resp, err + } + + for { + + if resp.NextURL != nil { + + var appGroupPage []AppGroups + + appGroupPage, resp, err = a.GetGroups(appID) + + if err != nil { + return appGroups, resp, err + } else { + appGroups = append(appGroups, appGroupPage...) + + } + } else { + break + } + + } + + return appGroups, resp, err +} + +// GetUser returns the AppUser model for one app users +func (a *AppsService) GetUser(appID string, userID string) (appUser AppUser, resp *Response, err error) { + + var u string + u = fmt.Sprintf("apps/%v/users/%v", appID, userID) + + req, err := a.client.NewRequest("GET", u, nil) + + if err != nil { + return appUser, nil, err + } + resp, err = a.client.Do(req, &appUser) + + if err != nil { + return appUser, resp, err + } + return appUser, resp, nil +} diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/factors.go b/vendor/github.com/chrismalek/oktasdk-go/okta/factors.go new file mode 100644 index 0000000000000..fc926f91aa387 --- /dev/null +++ b/vendor/github.com/chrismalek/oktasdk-go/okta/factors.go @@ -0,0 +1,8 @@ +package okta + +const ( + // MFAStatusActive is a constant to represent OKTA User State returned by the API + MFAStatusActive = "ACTIVE" + // MFAStatusPending is a user MFA Status of NOT Active + MFAStatusPending = "PENDING_ACTIVATION" +) diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/groups.go b/vendor/github.com/chrismalek/oktasdk-go/okta/groups.go new file mode 100644 index 0000000000000..34584d6eb69ee --- /dev/null +++ b/vendor/github.com/chrismalek/oktasdk-go/okta/groups.go @@ -0,0 +1,359 @@ +package okta + +import ( + "errors" + "fmt" + "net/url" + "time" +) + +const ( + // GroupTypeOKTA - group type constant for an OKTA Mastered Group + GroupTypeOKTA = "OKTA_GROUP" + // GroupTypeBuiltIn - group type constant for a Built in OKTA groups + GroupTypeBuiltIn = "BUILT_IN" + // GroupTypeApp -- group type constant for app mastered group + GroupTypeApp = "APP_GROUP" + + groupTypeFilter = "type" + groupNameFilter = "q" + groupLastMembershipUpdatedFilter = "lastMembershipUpdated" + groupLastUpdatedFilter = "lastUpdated" +) + +// GroupsService handles communication with the Groups data related +// methods of the OKTA API. +type GroupsService service + +// Group represents the Group Object from the OKTA API +type Group struct { + ID string `json:"id"` + Created time.Time `json:"created"` + LastUpdated time.Time `json:"lastUpdated"` + LastMembershipUpdated time.Time `json:"lastMembershipUpdated"` + ObjectClass []string `json:"objectClass"` + Type string `json:"type"` + Profile struct { + Name string `json:"name"` + Description string `json:"description"` + SamAccountName string `json:"samAccountName"` + Dn string `json:"dn"` + WindowsDomainQualifiedName string `json:"windowsDomainQualifiedName"` + ExternalID string `json:"externalId"` + } `json:"profile"` + Links struct { + Logo []struct { + Name string `json:"name"` + Href string `json:"href"` + Type string `json:"type"` + } `json:"logo"` + Users struct { + Href string `json:"href"` + } `json:"users"` + Apps struct { + Href string `json:"href"` + } `json:"apps"` + } `json:"_links"` +} + +// GroupFilterOptions is used to generate a "Filter" to search for different groups +// The values here coorelate to API Search paramgters on the group API +type GroupFilterOptions struct { + // This will be built by internal - may not need to export + FilterString string `url:"filter,omitempty"` + NextURL *url.URL `url:"-"` + GetAllPages bool `url:"-"` + NumberOfPages int `url:"-"` + Limit int `url:"limit,omitempty"` + + NameStartsWith string `url:"q,omitempty"` + GroupTypeEqual string `url:"-"` + + LastUpdated dateFilter `url:"-"` + LastMembershipUpdated dateFilter `url:"-"` +} + +func (g Group) String() string { + // return Stringify(g) + return fmt.Sprintf("Group:(ID: {%v} - Type: {%v} - Group Name: {%v})\n", g.ID, g.Type, g.Profile.Name) +} + +// ListWithFilter - Method to list groups with different filter options. +// Pass in a GroupFilterOptions to specify filters. Values in that struct will turn into Query parameters +func (g *GroupsService) ListWithFilter(opt *GroupFilterOptions) ([]Group, *Response, error) { + + var u string + var err error + + pagesRetreived := 0 + if opt.NextURL != nil { + u = opt.NextURL.String() + } else { + if opt.GroupTypeEqual != "" { + opt.FilterString = appendToFilterString(opt.FilterString, groupTypeFilter, FilterEqualOperator, opt.GroupTypeEqual) + } + + // if opt.NameStartsWith != "" { + // opt.FilterString = appendToFilterString(opt.FilterString, groupNameFilter, filterEqualOperator, opt.NameStartsWith) + // } + if (!opt.LastMembershipUpdated.Value.IsZero()) && (opt.LastMembershipUpdated.Operator != "") { + opt.FilterString = appendToFilterString(opt.FilterString, groupLastMembershipUpdatedFilter, opt.LastMembershipUpdated.Operator, opt.LastMembershipUpdated.Value.UTC().Format(oktaFilterTimeFormat)) + } + + if (!opt.LastUpdated.Value.IsZero()) && (opt.LastUpdated.Operator != "") { + opt.FilterString = appendToFilterString(opt.FilterString, groupLastUpdatedFilter, opt.LastUpdated.Operator, opt.LastUpdated.Value.UTC().Format(oktaFilterTimeFormat)) + } + + if opt.Limit == 0 { + opt.Limit = defaultLimit + } + u, err = addOptions("groups", opt) + if err != nil { + return nil, nil, err + } + } + + req, err := g.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + groups := make([]Group, 1) + resp, err := g.client.Do(req, &groups) + if err != nil { + return nil, resp, err + } + pagesRetreived++ + + if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { + + for { + + if pagesRetreived == opt.NumberOfPages { + break + } + if resp.NextURL != nil { + var groupPage []Group + pageOption := new(GroupFilterOptions) + pageOption.NextURL = resp.NextURL + pageOption.NumberOfPages = 1 + pageOption.Limit = opt.Limit + + groupPage, resp, err = g.ListWithFilter(pageOption) + if err != nil { + return groups, resp, err + } + groups = append(groups, groupPage...) + pagesRetreived++ + + } else { + break + } + } + } + return groups, resp, err +} + +// GetByID gets a group from OKTA by the Gropu ID. An error is returned if the group is not found +func (g *GroupsService) GetByID(groupID string) (*Group, *Response, error) { + + u := fmt.Sprintf("groups/%v", groupID) + req, err := g.client.NewRequest("GET", u, nil) + + if err != nil { + return nil, nil, err + } + + group := new(Group) + + resp, err := g.client.Do(req, group) + + if err != nil { + return nil, resp, err + } + + return group, resp, err +} + +// GetUsers returns the members in a group +// Pass in an optional GroupFilterOptions struct to filter the results +// The Users in the group are returned +func (g *GroupsService) GetUsers(groupID string, opt *GroupUserFilterOptions) (users []User, resp *Response, err error) { + pagesRetreived := 0 + var u string + if opt.NextURL != nil { + u = opt.NextURL.String() + } else { + u = fmt.Sprintf("groups/%v/users", groupID) + + if opt.Limit == 0 { + opt.Limit = defaultLimit + } + + u, _ = addOptions(u, opt) + } + + req, err := g.client.NewRequest("GET", u, nil) + + if err != nil { + return nil, nil, err + } + resp, err = g.client.Do(req, &users) + + if err != nil { + return nil, resp, err + } + + pagesRetreived++ + if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { + + for { + + if pagesRetreived == opt.NumberOfPages { + break + } + if resp.NextURL != nil { + + var userPage []User + pageOpts := new(GroupUserFilterOptions) + pageOpts.NextURL = resp.NextURL + pageOpts.Limit = opt.Limit + pageOpts.NumberOfPages = 1 + + userPage, resp, err = g.GetUsers(groupID, pageOpts) + if err != nil { + return users, resp, err + } + users = append(users, userPage...) + pagesRetreived++ + } else { + break + } + + } + } + + return users, resp, err +} + +// Add - Adds an OKTA Mastered Group with name and description. GroupName is required. +func (g *GroupsService) Add(groupName string, groupDescription string) (*Group, *Response, error) { + + if groupName == "" { + return nil, nil, errors.New("groupName parameter is required for ADD") + } + + newGroup := newGroup{} + newGroup.Profile.Name = groupName + newGroup.Profile.Description = groupDescription + + u := fmt.Sprintf("groups") + + req, err := g.client.NewRequest("POST", u, newGroup) + + if err != nil { + return nil, nil, err + } + + group := new(Group) + + resp, err := g.client.Do(req, group) + + if err != nil { + return nil, resp, err + } + + return group, resp, err +} + +// Delete - Deletes an OKTA Mastered Group with ID +func (g *GroupsService) Delete(groupID string) (*Response, error) { + + if groupID == "" { + return nil, errors.New("groupID parameter is required for Delete") + } + u := fmt.Sprintf("groups/%v", groupID) + + req, err := g.client.NewRequest("DELETE", u, nil) + + if err != nil { + return nil, err + } + + resp, err := g.client.Do(req, nil) + + if err != nil { + return resp, err + } + + return resp, err +} + +// AddUserToGroup - Adds a user to a group. +func (g *GroupsService) AddUserToGroup(groupID string, userID string) (*Response, error) { + + if groupID == "" { + return nil, errors.New("groupID parameter is required for Delete") + } + if userID == "" { + return nil, errors.New("groupID parameter is required for Delete") + } + + u := fmt.Sprintf("groups/%v/users/%v", groupID, userID) + + req, err := g.client.NewRequest("PUT", u, nil) + + if err != nil { + return nil, err + } + + resp, err := g.client.Do(req, nil) + + if err != nil { + return resp, err + } + + return resp, err +} + +// RemoveUserFromGroup - Removes a user to a group. +func (g *GroupsService) RemoveUserFromGroup(groupID string, userID string) (*Response, error) { + + if groupID == "" { + return nil, errors.New("groupID parameter is required for Delete") + } + if userID == "" { + return nil, errors.New("groupID parameter is required for Delete") + } + + u := fmt.Sprintf("groups/%v/users/%v", groupID, userID) + + req, err := g.client.NewRequest("DELETE", u, nil) + + if err != nil { + return nil, err + } + + resp, err := g.client.Do(req, nil) + + if err != nil { + return resp, err + } + + return resp, err +} + +// GroupUserFilterOptions is a struct that you populate which will limit or control group fetches and searches +// The values here will coorelate to the search filtering allowed in the OKTA API. These values are turned into Query Parameters +type GroupUserFilterOptions struct { + Limit int `url:"limit,omitempty"` + NextURL *url.URL `url:"-"` + GetAllPages bool `url:"-"` + NumberOfPages int `url:"-"` +} + +type newGroup struct { + Profile struct { + Name string `json:"name"` + Description string `json:"description"` + } `json:"profile"` +} diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go b/vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go new file mode 100644 index 0000000000000..ddfc250669b09 --- /dev/null +++ b/vendor/github.com/chrismalek/oktasdk-go/okta/sdk.go @@ -0,0 +1,523 @@ +package okta + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "regexp" + "strconv" + "sync" + "time" + + "github.com/google/go-querystring/query" + + "reflect" +) + +const ( + libraryVersion = "1" + userAgent = "oktasdk-go/" + libraryVersion + productionDomain = "okta.com" + previewDomain = "oktapreview.com" + urlFormat = "https://%s.%s/api/v1/" + headerRateLimit = "X-Rate-Limit-Limit" + headerRateRemaining = "X-Rate-Limit-Remaining" + headerRateReset = "X-Rate-Limit-Reset" + headerOKTARequestID = "X-Okta-Request-Id" + headerAuthorization = "Authorization" + headerAuthorizationFormat = "SSWS %v" + mediaTypeJSON = "application/json" + defaultLimit = 50 + // FilterEqualOperator Filter Operatorid for "equal" + FilterEqualOperator = "eq" + // FilterStartsWithOperator - filter operator for "starts with" + FilterStartsWithOperator = "sw" + // FilterGreaterThanOperator - filter operator for "greater than" + FilterGreaterThanOperator = "gt" + // FilterLessThanOperator - filter operator for "less than" + FilterLessThanOperator = "lt" + + // If the API returns a "X-Rate-Limit-Remaining" header less than this the SDK will either pause + // Or throw RateLimitError depending on the client.PauseOnRateLimit value + defaultRateRemainingFloor = 100 +) + +// A Client manages communication with the API. +type Client struct { + clientMu sync.Mutex // clientMu protects the client during calls that modify the CheckRedirect func. + client *http.Client // HTTP client used to communicate with the API. + + // Base URL for API requests. + // This will be built automatically based on inputs to NewClient + // If needed you can override this if needed (your URL is not *.okta.com or *.oktapreview.com) + BaseURL *url.URL + + // User agent used when communicating with the GitHub API. + UserAgent string + + apiKey string + authorizationHeaderValue string + PauseOnRateLimit bool + + // RateRemainingFloor - If the API returns a "X-Rate-Limit-Remaining" header less than this the SDK will either pause + // Or throw RateLimitError depending on the client.PauseOnRateLimit value. It defaults to 30 + // One client doing too much work can lock out all API Access for every other client + // We are trying to be a "good API User Citizen" + RateRemainingFloor int + + rateMu sync.Mutex + mostRecentRate Rate + + Limit int + // mostRecent rateLimitCategory + + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // Services used for talking to different parts of the API. + // Service for Working with Users + Users *UsersService + + // Service for Working with Groups + Groups *GroupsService + + // Service for Working with Apps + Apps *AppsService +} + +type service struct { + client *Client +} + +// NewClient returns a new OKTA API client. If a nil httpClient is +// provided, http.DefaultClient will be used. +func NewClient(httpClient *http.Client, orgName string, apiToken string, isProduction bool) *Client { + var baseDomain string + if isProduction { + baseDomain = productionDomain + } else { + baseDomain = previewDomain + } + client, _ := NewClientWithDomain(httpClient, orgName, baseDomain, apiToken) + return client +} + +// NewClientWithDomain creates a client based on the organziation name and +// base domain for requests (okta.com, okta-emea.com, oktapreview.com, etc). +func NewClientWithDomain(httpClient *http.Client, orgName string, domain string, apiToken string) (*Client, error) { + baseURL, err := url.Parse(fmt.Sprintf(urlFormat, orgName, domain)) + if err != nil { + return nil, err + } + return NewClientWithBaseURL(httpClient, baseURL, apiToken), nil +} + +// NewClientWithBaseURL creates a client based on the full base URL and api +// token +func NewClientWithBaseURL(httpClient *http.Client, baseURL *url.URL, apiToken string) *Client { + if httpClient == nil { + httpClient = http.DefaultClient + } + + c := &Client{ + client: httpClient, + BaseURL: baseURL, + UserAgent: userAgent, + } + c.PauseOnRateLimit = true // If rate limit found it will block until that time. If false then Error will be returned + c.authorizationHeaderValue = fmt.Sprintf(headerAuthorizationFormat, apiToken) + c.apiKey = apiToken + c.Limit = defaultLimit + c.RateRemainingFloor = defaultRateRemainingFloor + c.common.client = c + + c.Users = (*UsersService)(&c.common) + c.Groups = (*GroupsService)(&c.common) + c.Apps = (*AppsService)(&c.common) + return c +} + +// Rate represents the rate limit for the current client. +type Rate struct { + // The number of requests per minute the client is currently limited to. + RatePerMinuteLimit int + + // The number of remaining requests the client can make this minute + Remaining int + + // The time at which the current rate limit will reset. + ResetTime time.Time +} + +// Response is a OKTA API response. This wraps the standard http.Response +// returned from OKTA and provides convenient access to things like +// pagination links. +type Response struct { + *http.Response + + // These fields provide the page values for paginating through a set of + // results. + + NextURL *url.URL + // PrevURL *url.URL + SelfURL *url.URL + OKTARequestID string + Rate +} + +// newResponse creates a new Response for the provided http.Response. +func newResponse(r *http.Response) *Response { + response := &Response{Response: r} + + response.OKTARequestID = r.Header.Get(headerOKTARequestID) + + response.populatePaginationURLS() + response.Rate = parseRate(r) + return response +} + +// populatePageValues parses the HTTP Link response headers and populates the +// various pagination link values in the Response. + +// OKTA LINK Header takes this form: +// Link: ; rel="next", +// ; rel="self" + +func (r *Response) populatePaginationURLS() { + + for k, v := range r.Header { + + if k == "Link" { + nextRegex := regexp.MustCompile(`<(.*?)>; rel="next"`) + // prevRegex := regexp.MustCompile(`<(.*?)>; rel="prev"`) + selfRegex := regexp.MustCompile(`<(.*?)>; rel="self"`) + + for _, linkValue := range v { + nextLinkMatch := nextRegex.FindStringSubmatch(linkValue) + if len(nextLinkMatch) != 0 { + r.NextURL, _ = url.Parse(nextLinkMatch[1]) + } + selfLinkMatch := selfRegex.FindStringSubmatch(linkValue) + if len(selfLinkMatch) != 0 { + r.SelfURL, _ = url.Parse(selfLinkMatch[1]) + } + // prevLinkMatch := prevRegex.FindStringSubmatch(linkValue) + // if len(prevLinkMatch) != 0 { + // r.PrevURL, _ = url.Parse(prevLinkMatch[1]) + // } + } + } + } + +} + +// parseRate parses the rate related headers. +func parseRate(r *http.Response) Rate { + var rate Rate + + if limit := r.Header.Get(headerRateLimit); limit != "" { + rate.RatePerMinuteLimit, _ = strconv.Atoi(limit) + } + if remaining := r.Header.Get(headerRateRemaining); remaining != "" { + rate.Remaining, _ = strconv.Atoi(remaining) + } + if reset := r.Header.Get(headerRateReset); reset != "" { + if v, _ := strconv.ParseInt(reset, 10, 64); v != 0 { + rate.ResetTime = time.Unix(v, 0) + } + } + return rate +} + +// Do sends an API request and returns the API response. The API response is +// JSON decoded and stored in the value pointed to by v, or returned as an +// error if an API error has occurred. If v implements the io.Writer +// interface, the raw response body will be written to v, without attempting to +// first decode it. If rate limit is exceeded and reset time is in the future, +// Do returns rate immediately without making a network API call. +func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) { + + // If we've hit rate limit, don't make further requests before Reset time. + if err := c.checkRateLimitBeforeDo(req); err != nil { + return nil, err + } + + resp, err := c.client.Do(req) + if err != nil { + return nil, err + } + + defer func() { + // Drain up to 512 bytes and close the body to let the Transport reuse the connection + io.CopyN(ioutil.Discard, resp.Body, 512) + resp.Body.Close() + }() + + response := newResponse(resp) + + c.rateMu.Lock() + c.mostRecentRate.RatePerMinuteLimit = response.Rate.RatePerMinuteLimit + c.mostRecentRate.Remaining = response.Rate.Remaining + c.mostRecentRate.ResetTime = response.Rate.ResetTime + c.rateMu.Unlock() + + err = CheckResponse(resp) + if err != nil { + // even though there was an error, we still return the response + // in case the caller wants to inspect it further + // fmt.Printf("Error after sdk.Do return\n") + + return response, err + } + + if v != nil { + if w, ok := v.(io.Writer); ok { + io.Copy(w, resp.Body) + } else { + err = json.NewDecoder(resp.Body).Decode(v) + if err == io.EOF { + err = nil // ignore EOF errors caused by empty response body + } + } + } + + return response, err +} + +// checkRateLimitBeforeDo does not make any network calls, but uses existing knowledge from +// current client state in order to quickly check if *RateLimitError can be immediately returned +// from Client.Do, and if so, returns it so that Client.Do can skip making a network API call unnecessarily. +// Otherwise it returns nil, and Client.Do should proceed normally. +// http://developer.okta.com/docs/api/getting_started/design_principles.html#rate-limiting +func (c *Client) checkRateLimitBeforeDo(req *http.Request) error { + + c.rateMu.Lock() + mostRecentRate := c.mostRecentRate + c.rateMu.Unlock() + // fmt.Printf("checkRateLimitBeforeDo: \t Remaining = %d, \t ResetTime = %s\n", mostRecentRate.Remaining, mostRecentRate.ResetTime.String()) + if !mostRecentRate.ResetTime.IsZero() && mostRecentRate.Remaining < c.RateRemainingFloor && time.Now().Before(mostRecentRate.ResetTime) { + + if c.PauseOnRateLimit { + // If rate limit is hitting threshold then pause until the rate limit resets + // This behavior is controlled by the client PauseOnRateLimit value + // fmt.Printf("checkRateLimitBeforeDo: \t ***pause**** \t Time Now = %s \tPause After = %s\n", time.Now().String(), mostRecentRate.ResetTime.Sub(time.Now().Add(2*time.Second)).String()) + <-time.After(mostRecentRate.ResetTime.Sub(time.Now().Add(2 * time.Second))) + } else { + // fmt.Printf("checkRateLimitBeforeDo: \t ***error****\n") + + return &RateLimitError{ + Rate: mostRecentRate, + } + } + + } + + return nil +} + +// CheckResponse checks the API response for errors, and returns them if +// present. A response is considered an error if it has a status code outside +// the 200 range. API error responses are expected to have either no response +// body, or a JSON response body that maps to ErrorResponse. Any other +// response body will be silently ignored. +// +// The error type will be *RateLimitError for rate limit exceeded errors, +// and *TwoFactorAuthError for two-factor authentication errors. +// TODO - check un-authorized +func CheckResponse(r *http.Response) error { + if c := r.StatusCode; 200 <= c && c <= 299 { + return nil + } + + errorResp := &errorResponse{Response: r} + data, err := ioutil.ReadAll(r.Body) + if err == nil && data != nil { + json.Unmarshal(data, &errorResp.ErrorDetail) + } + switch { + case r.StatusCode == http.StatusTooManyRequests: + + return &RateLimitError{ + Rate: parseRate(r), + Response: r, + ErrorDetail: errorResp.ErrorDetail} + + default: + return errorResp + } + +} + +type apiError struct { + ErrorCode string `json:"errorCode"` + ErrorSummary string `json:"errorSummary"` + ErrorLink string `json:"errorLink"` + ErrorID string `json:"errorId"` + ErrorCauses []struct { + ErrorSummary string `json:"errorSummary"` + } `json:"errorCauses"` +} + +type errorResponse struct { + Response *http.Response // + ErrorDetail apiError +} + +func (r *errorResponse) Error() string { + return fmt.Sprintf("HTTP Method: %v - URL: %v: - HTTP Status Code: %d, OKTA Error Code: %v, OKTA Error Summary: %v, OKTA Error Causes: %v", + r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, r.ErrorDetail.ErrorCode, r.ErrorDetail.ErrorSummary, r.ErrorDetail.ErrorCauses) +} + +// RateLimitError occurs when OKTA returns 429 "Too Many Requests" response with a rate limit +// remaining value of 0, and error message starts with "API rate limit exceeded for ". +type RateLimitError struct { + Rate Rate // Rate specifies last known rate limit for the client + ErrorDetail apiError + Response *http.Response // +} + +func (r *RateLimitError) Error() string { + + return fmt.Sprintf("rate reset in %v", r.Rate.ResetTime.Sub(time.Now())) + +} + +// Code stolen from Github api libary +// Stringify attempts to create a reasonable string representation of types in +// the library. It does things like resolve pointers to their values +// and omits struct fields with nil values. +func stringify(message interface{}) string { + var buf bytes.Buffer + v := reflect.ValueOf(message) + stringifyValue(&buf, v) + return buf.String() +} + +// stringifyValue was heavily inspired by the goprotobuf library. + +func stringifyValue(w io.Writer, val reflect.Value) { + if val.Kind() == reflect.Ptr && val.IsNil() { + w.Write([]byte("")) + return + } + + v := reflect.Indirect(val) + + switch v.Kind() { + case reflect.String: + fmt.Fprintf(w, `"%s"`, v) + case reflect.Slice: + w.Write([]byte{'['}) + for i := 0; i < v.Len(); i++ { + if i > 0 { + w.Write([]byte{' '}) + } + + stringifyValue(w, v.Index(i)) + } + + w.Write([]byte{']'}) + return + case reflect.Struct: + if v.Type().Name() != "" { + w.Write([]byte(v.Type().String())) + } + w.Write([]byte{'{'}) + + var sep bool + for i := 0; i < v.NumField(); i++ { + fv := v.Field(i) + if fv.Kind() == reflect.Ptr && fv.IsNil() { + continue + } + if fv.Kind() == reflect.Slice && fv.IsNil() { + continue + } + + if sep { + w.Write([]byte(", ")) + } else { + sep = true + } + + w.Write([]byte(v.Type().Field(i).Name)) + w.Write([]byte{':'}) + stringifyValue(w, fv) + } + + w.Write([]byte{'}'}) + default: + if v.CanInterface() { + fmt.Fprint(w, v.Interface()) + } + } +} + +// NewRequest creates an API request. A relative URL can be provided in urlStr, +// in which case it is resolved relative to the BaseURL of the Client. +// Relative URLs should always be specified without a preceding slash. If +// specified, the value pointed to by body is JSON encoded and included as the +// request body. +func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error) { + rel, err := url.Parse(urlStr) + if err != nil { + return nil, err + } + + u := c.BaseURL.ResolveReference(rel) + + var buf io.ReadWriter + if body != nil { + buf = new(bytes.Buffer) + err := json.NewEncoder(buf).Encode(body) + if err != nil { + return nil, err + } + } + + req, err := http.NewRequest(method, u.String(), buf) + if err != nil { + return nil, err + } + if c.apiKey != "" { + req.Header.Set(headerAuthorization, fmt.Sprintf(headerAuthorizationFormat, c.apiKey)) + } + if body != nil { + req.Header.Set("Content-Type", mediaTypeJSON) + } + + if c.UserAgent != "" { + req.Header.Set("User-Agent", c.UserAgent) + } + return req, nil +} + +// addOptions adds the parameters in opt as URL query parameters to s. opt +// must be a struct whose fields may contain "url" tags. +func addOptions(s string, opt interface{}) (string, error) { + v := reflect.ValueOf(opt) + if v.Kind() == reflect.Ptr && v.IsNil() { + return s, nil + } + + u, err := url.Parse(s) + if err != nil { + return s, err + } + + qs, err := query.Values(opt) + if err != nil { + return s, err + } + + u.RawQuery = qs.Encode() + return u.String(), nil +} + +type dateFilter struct { + Value time.Time + Operator string +} diff --git a/vendor/github.com/chrismalek/oktasdk-go/okta/users.go b/vendor/github.com/chrismalek/oktasdk-go/okta/users.go new file mode 100644 index 0000000000000..8102a819eece8 --- /dev/null +++ b/vendor/github.com/chrismalek/oktasdk-go/okta/users.go @@ -0,0 +1,625 @@ +package okta + +import ( + "errors" + "fmt" + "net/url" + "time" +) + +const ( + profileEmailFilter = "profile.email" + profileLoginFilter = "profile.login" + profileStatusFilter = "status" + profileIDFilter = "id" + profileFirstNameFilter = "profile.firstName" + profileLastNameFilter = "profile.lastName" + profileLastUpdatedFilter = "lastUpdated" + // UserStatusActive is a constant to represent OKTA User State returned by the API + UserStatusActive = "ACTIVE" + // UserStatusStaged is a constant to represent OKTA User State returned by the API + UserStatusStaged = "STAGED" + // UserStatusProvisioned is a constant to represent OKTA User State returned by the API + UserStatusProvisioned = "PROVISIONED" + // UserStatusRecovery is a constant to represent OKTA User State returned by the API + UserStatusRecovery = "RECOVERY" + // UserStatusLockedOut is a constant to represent OKTA User State returned by the API + UserStatusLockedOut = "LOCKED_OUT" + // UserStatusPasswordExpired is a constant to represent OKTA User State returned by the API + UserStatusPasswordExpired = "PASSWORD_EXPIRED" + // UserStatusSuspended is a constant to represent OKTA User State returned by the API + UserStatusSuspended = "SUSPENDED" + // UserStatusDeprovisioned is a constant to represent OKTA User State returned by the API + UserStatusDeprovisioned = "DEPROVISIONED" + + oktaFilterTimeFormat = "2006-01-02T15:05:05.000Z" +) + +// UsersService handles communication with the User data related +// methods of the OKTA API. +type UsersService service + +// ActivationResponse - Response coming back from a user activation +type ActivationResponse struct { + ActivationURL string `json:"activationUrl"` +} + +type provider struct { + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` +} + +type recoveryQuestion struct { + Question string `json:"question,omitempty"` + Answer string `json:"answer,omitempty"` +} + +type passwordValue struct { + Value string `json:"value,omitempty"` +} +type credentials struct { + Password *passwordValue `json:"password,omitempty"` + Provider *provider `json:"provider,omitempty"` + RecoveryQuestion *recoveryQuestion `json:"recovery_question,omitempty"` +} + +type userProfile struct { + Email string `json:"email"` + FirstName string `json:"firstName"` + LastName string `json:"lastName"` + Login string `json:"login"` + MobilePhone string `json:"mobilePhone,omitempty"` + SecondEmail string `json:"secondEmail,omitempty"` + PsEmplid string `json:"psEmplid,omitempty"` + NickName string `json:"nickname,omitempty"` + DisplayName string `json:"displayName,omitempty"` + + ProfileURL string `json:"profileUrl,omitempty"` + PreferredLanguage string `json:"preferredLanguage,omitempty"` + UserType string `json:"userType,omitempty"` + Organization string `json:"organization,omitempty"` + Title string `json:"title,omitempty"` + Division string `json:"division,omitempty"` + Department string `json:"department,omitempty"` + CostCenter string `json:"costCenter,omitempty"` + EmployeeNumber string `json:"employeeNumber,omitempty"` + PrimaryPhone string `json:"primaryPhone,omitempty"` + StreetAddress string `json:"streetAddress,omitempty"` + City string `json:"city,omitempty"` + State string `json:"state,omitempty"` + ZipCode string `json:"zipCode,omitempty"` + CountryCode string `json:"countryCode,omitempty"` +} + +type userLinks struct { + ChangePassword struct { + Href string `json:"href"` + } `json:"changePassword"` + ChangeRecoveryQuestion struct { + Href string `json:"href"` + } `json:"changeRecoveryQuestion"` + Deactivate struct { + Href string `json:"href"` + } `json:"deactivate"` + ExpirePassword struct { + Href string `json:"href"` + } `json:"expirePassword"` + ForgotPassword struct { + Href string `json:"href"` + } `json:"forgotPassword"` + ResetFactors struct { + Href string `json:"href"` + } `json:"resetFactors"` + ResetPassword struct { + Href string `json:"href"` + } `json:"resetPassword"` +} + +// User is a struct that represents a user object from OKTA. +type User struct { + Activated string `json:"activated,omitempty"` + Created string `json:"created,omitempty"` + Credentials credentials `json:"credentials,omitempty"` + ID string `json:"id,omitempty"` + LastLogin string `json:"lastLogin,omitempty"` + LastUpdated string `json:"lastUpdated,omitempty"` + PasswordChanged string `json:"passwordChanged,omitempty"` + Profile userProfile `json:"profile"` + Status string `json:"status,omitempty"` + StatusChanged string `json:"statusChanged,omitempty"` + Links userLinks `json:"_links,omitempty"` + MFAFactors []userMFAFactor `json:"-,"` + Groups []Group `json:"-"` +} + +type userMFAFactor struct { + ID string `json:"id,omitempty"` + FactorType string `json:"factorType,omitempty"` + Provider string `json:"provider,omitempty"` + VendorName string `json:"vendorName,omitempty"` + Status string `json:"status,omitempty"` + Created time.Time `json:"created,omitempty"` + LastUpdated time.Time `json:"lastUpdated,omitempty"` + Profile struct { + CredentialID string `json:"credentialId,omitempty"` + } `json:"profile,omitempty"` +} + +// NewUser object to create user objects in OKTA +type NewUser struct { + Profile userProfile `json:"profile"` + Credentials *credentials `json:"credentials,omitempty"` +} + +type newPasswordSet struct { + Credentials credentials `json:"credentials"` +} + +// ResetPasswordResponse struct that returns data about the password reset +type ResetPasswordResponse struct { + ResetPasswordURL string `json:"resetPasswordUrl"` +} + +// NewUser - Returns a new user object. This is used to create users in OKTA. It only has the properties that +// OKTA will take as input. The "User" object has more feilds that are OKTA returned like the ID, etc +func (s *UsersService) NewUser() NewUser { + return NewUser{} +} + +// SetPassword Adds a specified password to the new User +func (u *NewUser) SetPassword(passwordIn string) { + + if passwordIn != "" { + + pass := new(passwordValue) + pass.Value = passwordIn + + var cred *credentials + if u.Credentials == nil { + cred = new(credentials) + } else { + cred = u.Credentials + } + + cred.Password = pass + u.Credentials = cred + + } +} + +// SetRecoveryQuestion - Sets a custom security question and answer on a user object +func (u *NewUser) SetRecoveryQuestion(questionIn string, answerIn string) { + + if questionIn != "" && answerIn != "" { + recovery := new(recoveryQuestion) + + recovery.Question = questionIn + recovery.Answer = answerIn + + var cred *credentials + if u.Credentials == nil { + cred = new(credentials) + } else { + cred = u.Credentials + } + cred.RecoveryQuestion = recovery + u.Credentials = cred + + } +} + +func (u User) String() string { + return stringify(u) + // return fmt.Sprintf("ID: %v \tLogin: %v", u.ID, u.Profile.Login) +} + +// GetByID returns a user object for a specific OKTA ID. +// Generally the id input string is the cryptic OKTA key value from User.ID. However, the OKTA API may accept other values like "me", or login shortname +func (s *UsersService) GetByID(id string) (*User, *Response, error) { + u := fmt.Sprintf("users/%v", id) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + user := new(User) + resp, err := s.client.Do(req, user) + if err != nil { + return nil, resp, err + } + + return user, resp, err +} + +// UserListFilterOptions is a struct that you can populate which will "filter" user searches +// the exported struct fields should allow you to do different filters based on what is allowed in the OKTA API. +// The filter OKTA API is limited in the fields it can search +// NOTE: In the current form you can't add parenthesis and ordering +// OKTA API Supports only a limited number of properties: +// status, lastUpdated, id, profile.login, profile.email, profile.firstName, and profile.lastName. +// http://developer.okta.com/docs/api/resources/users.html#list-users-with-a-filter +type UserListFilterOptions struct { + Limit int `url:"limit,omitempty"` + EmailEqualTo string `url:"-"` + LoginEqualTo string `url:"-"` + StatusEqualTo string `url:"-"` + IDEqualTo string `url:"-"` + + FirstNameEqualTo string `url:"-"` + LastNameEqualTo string `url:"-"` + // API documenation says you can search with "starts with" but these don't work + + // FirstNameStartsWith string `url:"-"` + // LastNameStartsWith string `url:"-"` + + // This will be built by internal - may not need to export + FilterString string `url:"filter,omitempty"` + NextURL *url.URL `url:"-"` + GetAllPages bool `url:"-"` + NumberOfPages int `url:"-"` + LastUpdated dateFilter `url:"-"` +} + +// PopulateGroups will populate the groups a user is a member of. You pass in a pointer to an existing users +func (s *UsersService) PopulateGroups(user *User) (*Response, error) { + u := fmt.Sprintf("users/%v/groups", user.ID) + req, err := s.client.NewRequest("GET", u, nil) + + if err != nil { + return nil, err + } + // Get first page of users. + resp, err := s.client.Do(req, &user.Groups) + if err != nil { + return resp, err + } + // Look for any remaining user group pages. + var nextURL string + if resp.NextURL != nil { + nextURL = resp.NextURL.String() + } + for { + + if nextURL != "" { + req, err := s.client.NewRequest("GET", nextURL, nil) + userGroupsPages := []Group{} + + resp, err := s.client.Do(req, &userGroupsPages) + nextURL = "" + if err != nil { + return resp, err + } + user.Groups = append(user.Groups, userGroupsPages...) + if resp.NextURL != nil { + nextURL = resp.NextURL.String() + } + + } else { + return resp, err + } + + } + +} + +// PopulateEnrolledFactors will populate the Enrolled MFA Factors a user is a member of. +// You pass in a pointer to an existing users +// http://developer.okta.com/docs/api/resources/factors.html#list-enrolled-factors +func (s *UsersService) PopulateEnrolledFactors(user *User) (*Response, error) { + u := fmt.Sprintf("users/%v/factors", user.ID) + req, err := s.client.NewRequest("GET", u, nil) + + if err != nil { + return nil, err + } + // TODO: If user has more than 200 groups this will only return those first 200 + resp, err := s.client.Do(req, &user.MFAFactors) + if err != nil { + return resp, err + } + + return resp, err +} + +// List users with status of LOCKED_OUT +// filter=status eq "LOCKED_OUT" +// List users updated after 06/01/2013 but before 01/01/2014 +// filter=lastUpdated gt "2013-06-01T00:00:00.000Z" and lastUpdated lt "2014-01-01T00:00:00.000Z" +// List users updated after 06/01/2013 but before 01/01/2014 with a status of ACTIVE +// filter=lastUpdated gt "2013-06-01T00:00:00.000Z" and lastUpdated lt "2014-01-01T00:00:00.000Z" and status eq "ACTIVE" +// TODO - Currently no way to do parenthesis +// List users updated after 06/01/2013 but with a status of LOCKED_OUT or RECOVERY +// filter=lastUpdated gt "2013-06-01T00:00:00.000Z" and (status eq "LOCKED_OUT" or status eq "RECOVERY") + +// OTKA API docs: http://developer.okta.com/docs/api/resources/users.html#list-users-with-a-filter + +func appendToFilterString(currFilterString string, appendFilterKey string, appendFilterOperator string, appendFilterValue string) (rs string) { + if currFilterString != "" { + rs = fmt.Sprintf("%v and %v %v \"%v\"", currFilterString, appendFilterKey, appendFilterOperator, appendFilterValue) + } else { + rs = fmt.Sprintf("%v %v \"%v\"", appendFilterKey, appendFilterOperator, appendFilterValue) + } + + return rs +} + +// ListWithFilter will use the input UserListFilterOptions to find users and return a paged result set +func (s *UsersService) ListWithFilter(opt *UserListFilterOptions) ([]User, *Response, error) { + var u string + var err error + + pagesRetreived := 0 + + if opt.NextURL != nil { + u = opt.NextURL.String() + } else { + if opt.EmailEqualTo != "" { + opt.FilterString = appendToFilterString(opt.FilterString, profileEmailFilter, FilterEqualOperator, opt.EmailEqualTo) + } + if opt.LoginEqualTo != "" { + opt.FilterString = appendToFilterString(opt.FilterString, profileLoginFilter, FilterEqualOperator, opt.LoginEqualTo) + } + + if opt.StatusEqualTo != "" { + opt.FilterString = appendToFilterString(opt.FilterString, profileStatusFilter, FilterEqualOperator, opt.StatusEqualTo) + } + + if opt.IDEqualTo != "" { + opt.FilterString = appendToFilterString(opt.FilterString, profileIDFilter, FilterEqualOperator, opt.IDEqualTo) + } + + if opt.FirstNameEqualTo != "" { + opt.FilterString = appendToFilterString(opt.FilterString, profileFirstNameFilter, FilterEqualOperator, opt.FirstNameEqualTo) + } + + if opt.LastNameEqualTo != "" { + opt.FilterString = appendToFilterString(opt.FilterString, profileLastNameFilter, FilterEqualOperator, opt.LastNameEqualTo) + } + + // API documenation says you can search with "starts with" but these don't work + // if opt.FirstNameStartsWith != "" { + // opt.FilterString = appendToFilterString(opt.FilterString, profileFirstNameFilter, filterStartsWithOperator, opt.FirstNameStartsWith) + // } + + // if opt.LastNameStartsWith != "" { + // opt.FilterString = appendToFilterString(opt.FilterString, profileLastNameFilter, filterStartsWithOperator, opt.LastNameStartsWith) + // } + + if !opt.LastUpdated.Value.IsZero() { + opt.FilterString = appendToFilterString(opt.FilterString, profileLastUpdatedFilter, opt.LastUpdated.Operator, opt.LastUpdated.Value.UTC().Format(oktaFilterTimeFormat)) + } + + if opt.Limit == 0 { + opt.Limit = defaultLimit + } + + u, err = addOptions("users", opt) + + } + + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + users := make([]User, 1) + resp, err := s.client.Do(req, &users) + if err != nil { + return nil, resp, err + } + + pagesRetreived++ + + if (opt.NumberOfPages > 0 && pagesRetreived < opt.NumberOfPages) || opt.GetAllPages { + + for { + + if pagesRetreived == opt.NumberOfPages { + break + } + if resp.NextURL != nil { + var userPage []User + pageOption := new(UserListFilterOptions) + pageOption.NextURL = resp.NextURL + pageOption.NumberOfPages = 1 + pageOption.Limit = opt.Limit + + userPage, resp, err = s.ListWithFilter(pageOption) + if err != nil { + return users, resp, err + } + users = append(users, userPage...) + pagesRetreived++ + } else { + break + } + } + } + return users, resp, err +} + +// Create - Creates a new user. You must pass in a "newUser" object created from Users.NewUser() +// There are many differnt reasons that OKTA may reject the request so you have to check the error messages +func (s *UsersService) Create(userIn NewUser, createAsActive bool) (*User, *Response, error) { + + u := fmt.Sprintf("users?activate=%v", createAsActive) + + req, err := s.client.NewRequest("POST", u, userIn) + + if err != nil { + return nil, nil, err + } + + newUser := new(User) + resp, err := s.client.Do(req, newUser) + if err != nil { + return nil, resp, err + } + + return newUser, resp, err +} + +// Activate Activates a user. You can have OKTA send an email by including a "sendEmail=true" +// If you pass in sendEmail=false, then activationResponse.ActivationURL will have a string URL that +// can be sent to the end user. You can discard response if sendEmail=true +func (s *UsersService) Activate(id string, sendEmail bool) (*ActivationResponse, *Response, error) { + u := fmt.Sprintf("users/%v/lifecycle/activate?sendEmail=%v", id, sendEmail) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, nil, err + } + + activationInfo := new(ActivationResponse) + resp, err := s.client.Do(req, activationInfo) + + if err != nil { + return nil, resp, err + } + + return activationInfo, resp, err +} + +// Deactivate - Deactivates a user +func (s *UsersService) Deactivate(id string) (*Response, error) { + u := fmt.Sprintf("users/%v/lifecycle/deactivate", id) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, err + } + resp, err := s.client.Do(req, nil) + + if err != nil { + return resp, err + } + + return resp, err +} + +// Suspend - Suspends a user - If user is NOT active an Error will come back based on OKTA API: +// http://developer.okta.com/docs/api/resources/users.html#suspend-user +func (s *UsersService) Suspend(id string) (*Response, error) { + u := fmt.Sprintf("users/%v/lifecycle/suspend", id) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, err + } + resp, err := s.client.Do(req, nil) + + if err != nil { + return resp, err + } + + return resp, err +} + +// Unsuspend - Unsuspends a user - If user is NOT SUSPENDED, an Error will come back based on OKTA API: +// http://developer.okta.com/docs/api/resources/users.html#unsuspend-user +func (s *UsersService) Unsuspend(id string) (*Response, error) { + u := fmt.Sprintf("users/%v/lifecycle/unsuspend", id) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, err + } + resp, err := s.client.Do(req, nil) + + if err != nil { + return resp, err + } + + return resp, err +} + +// Unlock - Unlocks a user - Per docs, only for OKTA Mastered Account +// http://developer.okta.com/docs/api/resources/users.html#unlock-user +func (s *UsersService) Unlock(id string) (*Response, error) { + u := fmt.Sprintf("users/%v/lifecycle/unlock", id) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, err + } + resp, err := s.client.Do(req, nil) + + if err != nil { + return resp, err + } + + return resp, err +} + +// SetPassword - Sets a user password to an Admin provided String +func (s *UsersService) SetPassword(id string, newPassword string) (*User, *Response, error) { + + if id == "" || newPassword == "" { + return nil, nil, errors.New("please provide a User ID and Password") + } + + passwordUpdate := new(newPasswordSet) + + pass := new(passwordValue) + pass.Value = newPassword + + passwordUpdate.Credentials.Password = pass + + u := fmt.Sprintf("users/%v", id) + req, err := s.client.NewRequest("POST", u, passwordUpdate) + if err != nil { + return nil, nil, err + } + + user := new(User) + resp, err := s.client.Do(req, user) + if err != nil { + return nil, resp, err + } + + return user, resp, err +} + +// ResetPassword - Generates a one-time token (OTT) that can be used to reset a user’s password. +// The OTT link can be automatically emailed to the user or returned to the API caller and distributed using a custom flow. +// http://developer.okta.com/docs/api/resources/users.html#reset-password +// If you pass in sendEmail=false, then resetPasswordResponse.resetPasswordUrl will have a string URL that +// can be sent to the end user. You can discard response if sendEmail=true +func (s *UsersService) ResetPassword(id string, sendEmail bool) (*ResetPasswordResponse, *Response, error) { + u := fmt.Sprintf("users/%v/lifecycle/reset_password?sendEmail=%v", id, sendEmail) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, nil, err + } + + resetInfo := new(ResetPasswordResponse) + resp, err := s.client.Do(req, resetInfo) + + if err != nil { + return nil, resp, err + } + + return resetInfo, resp, err +} + +// PopulateMFAFactors will populate the MFA Factors a user is a member of. You pass in a pointer to an existing users +func (s *UsersService) PopulateMFAFactors(user *User) (*Response, error) { + u := fmt.Sprintf("users/%v/factors", user.ID) + + req, err := s.client.NewRequest("GET", u, nil) + + if err != nil { + return nil, err + } + + resp, err := s.client.Do(req, &user.MFAFactors) + if err != nil { + return resp, err + } + + return resp, err +} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/config.go b/vendor/github.com/okta/okta-sdk-golang/okta/config.go index e0d8c0e06f226..e25e3d2b063ff 100644 --- a/vendor/github.com/okta/okta-sdk-golang/okta/config.go +++ b/vendor/github.com/okta/okta-sdk-golang/okta/config.go @@ -36,13 +36,9 @@ type config struct { Username string `yaml:"username" envconfig:"OKTA_CLIENT_PROXY_USERNAME"` Password string `yaml:"password" envconfig:"OKTA_CLIENT_PROXY_PASSWORD"` } `yaml:"proxy"` - ConnectionTimeout int32 `yaml:"connectionTimeout" envconfig:"OKTA_CLIENT_CONNECTION_TIMEOUT"` - RequestTimeout int32 `yaml:"requestTimeout" envconfig:"OKTA_CLIENT_REQUEST_TIMEOUT"` - RateLimit struct { - MaxRetries int32 `yaml:"maxRetries" envconfig:"OKTA_CLIENT_RATE_LIMIT_MAX_RETRIES"` - } `yaml:"rateLimit"` - OrgUrl string `yaml:"orgUrl" envconfig:"OKTA_CLIENT_ORGURL"` - Token string `yaml:"token" envconfig:"OKTA_CLIENT_TOKEN"` + ConnectionTimeout int32 `yaml:"connectionTimeout" envconfig:"OKTA_CLIENT_CONNECTION_TIMEOUT"` + OrgUrl string `yaml:"orgUrl" envconfig:"OKTA_CLIENT_ORGURL"` + Token string `yaml:"token" envconfig:"OKTA_CLIENT_TOKEN"` } `yaml:"client"` Testing struct { DisableHttpsCheck bool `yaml:"disableHttpsCheck" envconfig:"OKTA_TESTING_DISABLE_HTTPS_CHECK"` @@ -53,31 +49,6 @@ type config struct { CacheManager cache.Cache } -func NewConfig(conf ...ConfigSetter) (*config, error) { - config := &config{} - - setConfigDefaults(config) - config = readConfigFromSystem(*config) - config = readConfigFromApplication(*config) - config = readConfigFromEnvironment(*config) - - for _, confSetter := range conf { - confSetter(config) - } - return config, nil -} - -func NewCache(config *config) (cache.Cache, error) { - if !config.Okta.Client.Cache.Enabled { - return cache.NewNoOpCache(), nil - } - if config.CacheManager != nil { - return config.CacheManager, nil - } - return cache.NewGoCache(config.Okta.Client.Cache.DefaultTtl, - config.Okta.Client.Cache.DefaultTti), nil -} - type ConfigSetter func(*config) func WithCache(cache bool) ConfigSetter { @@ -163,15 +134,3 @@ func WithTestingDisableHttpsCheck(httpsCheck bool) ConfigSetter { c.Okta.Testing.DisableHttpsCheck = httpsCheck } } - -func WithRequestTimeout(requestTimeout int32) ConfigSetter { - return func(c *config) { - c.Okta.Client.RequestTimeout = requestTimeout - } -} - -func WithRateLimitMaxRetries(maxRetries int32) ConfigSetter { - return func(c *config) { - c.Okta.Client.RateLimit.MaxRetries = maxRetries - } -} diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/okta.go b/vendor/github.com/okta/okta-sdk-golang/okta/okta.go index bf8d06220e318..e4838576f44f6 100644 --- a/vendor/github.com/okta/okta-sdk-golang/okta/okta.go +++ b/vendor/github.com/okta/okta-sdk-golang/okta/okta.go @@ -24,6 +24,8 @@ import ( "io/ioutil" "os/user" + "github.com/okta/okta-sdk-golang/okta/cache" + "github.com/go-yaml/yaml" "github.com/kelseyhightower/envconfig" ) @@ -51,26 +53,39 @@ type resource struct { } func NewClient(ctx context.Context, conf ...ConfigSetter) (*Client, error) { - config, err := NewConfig(conf...) - if err != nil { - return nil, err + config := &config{} + + setConfigDefaults(config) + config = readConfigFromSystem(*config) + config = readConfigFromApplication(*config) + config = readConfigFromEnvironment(*config) + + for _, confSetter := range conf { + confSetter(config) } - cache, err := NewCache(config) - if err != nil { - return nil, err + var oktaCache cache.Cache + if !config.Okta.Client.Cache.Enabled { + oktaCache = cache.NewNoOpCache() + } else { + if config.CacheManager == nil { + oktaCache = cache.NewGoCache(config.Okta.Client.Cache.DefaultTtl, + config.Okta.Client.Cache.DefaultTti) + } else { + oktaCache = config.CacheManager + } } - config.CacheManager = cache + config.CacheManager = oktaCache - config, err = ValidateConfig(config) + config, err := validateConfig(config) if err != nil { panic(err) } c := &Client{} c.config = config - c.requestExecutor = NewRequestExecutor(&config.HttpClient, cache, config) + c.requestExecutor = NewRequestExecutor(&config.HttpClient, oktaCache, config) c.resource.client = c @@ -100,10 +115,8 @@ func setConfigDefaults(c *config) { WithCache(true), WithCacheTtl(300), WithCacheTti(300), - WithUserAgentExtra(""), - WithTestingDisableHttpsCheck(false), - WithRequestTimeout(0), - WithRateLimitMaxRetries(2)) + WithUserAgentExtra("")) + WithTestingDisableHttpsCheck(false) for _, confSetter := range conf { confSetter(c) diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go b/vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go index 0907366069b8d..5ce029accc915 100644 --- a/vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go +++ b/vendor/github.com/okta/okta-sdk-golang/okta/requestExecutor.go @@ -19,15 +19,11 @@ package okta import ( "bytes" "encoding/json" - "errors" - "fmt" "io" "io/ioutil" "net/http" "net/url" "reflect" - "sort" - "strconv" "time" "github.com/okta/okta-sdk-golang/okta/cache" @@ -86,7 +82,6 @@ func (re *RequestExecutor) NewRequest(method string, url string, body interface{ } func (re *RequestExecutor) Do(req *http.Request, v interface{}) (*Response, error) { - requestStarted := time.Now().Unix() cacheKey := cache.CreateCacheKey(req) if req.Method != http.MethodGet { re.cache.Delete(cacheKey) @@ -94,23 +89,26 @@ func (re *RequestExecutor) Do(req *http.Request, v interface{}) (*Response, erro inCache := re.cache.Has(cacheKey) if !inCache { - - resp, err := re.doWithRetries(req, 0, requestStarted, nil) - + resp, err := re.httpClient.Do(req) if err != nil { return nil, err } defer resp.Body.Close() + respBody, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } + origResp := ioutil.NopCloser(bytes.NewBuffer(respBody)) resp.Body = origResp - if resp.StatusCode >= 200 && resp.StatusCode <= 299 && req.Method == http.MethodGet && reflect.TypeOf(v).Kind() != reflect.Slice { + + if req.Method == http.MethodGet && reflect.TypeOf(v).Kind() != reflect.Slice { re.cache.Set(cacheKey, resp) } + return buildResponse(resp, &v) + } resp := re.cache.Get(cacheKey) @@ -118,93 +116,6 @@ func (re *RequestExecutor) Do(req *http.Request, v interface{}) (*Response, erro } -func (re *RequestExecutor) doWithRetries(req *http.Request, retryCount int32, requestStarted int64, lastResponse *http.Response) (*http.Response, error) { - iterationStart := time.Now().Unix() - maxRetries := re.config.Okta.Client.RateLimit.MaxRetries - requestTimeout := int64(re.config.Okta.Client.RequestTimeout) - - if req.Body != nil { - bodyBytes, _ := ioutil.ReadAll(req.Body) - req.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) - } - - if requestTimeout > 0 && (iterationStart-requestStarted) >= requestTimeout { - return lastResponse, errors.New("reached the max request time") - } - - resp, err := re.httpClient.Do(req) - - if (err != nil || tooManyRequests(resp)) && retryCount < maxRetries { - if resp != nil { - err := tryDrainBody(resp.Body) - if err != nil { - return nil, err - } - } - - retryLimitReset := resp.Header.Get("X-Rate-Limit-Reset") - date := resp.Header.Get("Date") - if retryLimitReset == "" || date == "" { - return resp, errors.New("a 429 response must include the x-retry-limit-reset and date headers") - } - - if tooManyRequests(resp) { - err := backoffPause(retryCount, resp) - if err != nil { - return nil, err - } - } - retryCount++ - - req.Header.Add("X-Okta-Retry-For", resp.Header.Get("X-Okta-Request-Id")) - req.Header.Add("X-Okta-Retry-Count", fmt.Sprint(retryCount)) - - resp, err = re.doWithRetries(req, retryCount, requestStarted, resp) - } - - return resp, err -} - -func tooManyRequests(resp *http.Response) bool { - return resp != nil && resp.StatusCode == http.StatusTooManyRequests -} - -func tryDrainBody(body io.ReadCloser) error { - defer body.Close() - _, err := io.Copy(ioutil.Discard, io.LimitReader(body, 4096)) - if err != nil { - return err - } - return nil -} - -func backoffPause(retryCount int32, response *http.Response) error { - if response.StatusCode == http.StatusTooManyRequests { - backoffSeconds := Get429BackoffTime(response) - time.Sleep(time.Duration(backoffSeconds) * time.Second) - - return nil - } - - return nil -} - -func Get429BackoffTime(response *http.Response) int64 { - var limitResetMap []int - - for _, time := range response.Header["X-Rate-Limit-Reset"] { - timestamp, _ := strconv.Atoi(time) - limitResetMap = append(limitResetMap, timestamp) - } - - sort.Ints(limitResetMap) - - requestDate, _ := time.Parse("Mon, 02 Jan 2006 15:04:05 Z", response.Header.Get("Date")) - requestDateUnix := requestDate.Unix() - backoffSeconds := int64(limitResetMap[0]) - requestDateUnix + 1 - return backoffSeconds -} - type Response struct { *http.Response } diff --git a/vendor/github.com/okta/okta-sdk-golang/okta/validator.go b/vendor/github.com/okta/okta-sdk-golang/okta/validator.go index 1f3106567a89e..2a639d7a23511 100644 --- a/vendor/github.com/okta/okta-sdk-golang/okta/validator.go +++ b/vendor/github.com/okta/okta-sdk-golang/okta/validator.go @@ -5,15 +5,15 @@ import ( "strings" ) -func ValidateConfig(c *config) (*config, error) { +func validateConfig(c *config) (*config, error) { var err error - err = ValidateOktaDomain(c) + err = validateOktaDomain(c) if err != nil { return nil, err } - err = ValidateApiToken(c) + err = validateApiToken(c) if err != nil { return nil, err } @@ -21,7 +21,7 @@ func ValidateConfig(c *config) (*config, error) { return c, nil } -func ValidateOktaDomain(c *config) error { +func validateOktaDomain(c *config) error { if c.Okta.Client.OrgUrl == "" { return errors.New("your Okta URL is missing. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain") } @@ -48,7 +48,7 @@ func ValidateOktaDomain(c *config) error { return nil } -func ValidateApiToken(c *config) error { +func validateApiToken(c *config) error { if c.Okta.Client.Token == "" { return errors.New("your Okta API token is missing. You can generate one in the Okta Developer Console. Follow these instructions: https://bit.ly/get-okta-api-token") } diff --git a/vendor/modules.txt b/vendor/modules.txt index af8f3b09e05b1..5069a9a3975f9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,33 +1,33 @@ # cloud.google.com/go v0.39.0 +cloud.google.com/go/monitoring/apiv3 +cloud.google.com/go/storage +cloud.google.com/go/spanner cloud.google.com/go/civil cloud.google.com/go/compute/metadata +cloud.google.com/go/kms/apiv1 cloud.google.com/go/iam cloud.google.com/go/internal -cloud.google.com/go/internal/fields cloud.google.com/go/internal/optional -cloud.google.com/go/internal/protostruct cloud.google.com/go/internal/trace cloud.google.com/go/internal/version -cloud.google.com/go/kms/apiv1 -cloud.google.com/go/monitoring/apiv3 -cloud.google.com/go/spanner +cloud.google.com/go/internal/fields +cloud.google.com/go/internal/protostruct cloud.google.com/go/spanner/internal/backoff -cloud.google.com/go/storage # code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f code.cloudfoundry.org/gofileutils/fileutils # github.com/Azure/azure-sdk-for-go v36.2.0+incompatible +github.com/Azure/azure-sdk-for-go/storage +github.com/Azure/azure-sdk-for-go/services/keyvault/v7.0/keyvault github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac -github.com/Azure/azure-sdk-for-go/services/keyvault/v7.0/keyvault github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization -github.com/Azure/azure-sdk-for-go/storage github.com/Azure/azure-sdk-for-go/version # github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 -github.com/Azure/go-ansiterm github.com/Azure/go-ansiterm/winterm +github.com/Azure/go-ansiterm # github.com/Azure/go-autorest/autorest v0.9.2 -github.com/Azure/go-autorest/autorest github.com/Azure/go-autorest/autorest/azure +github.com/Azure/go-autorest/autorest # github.com/Azure/go-autorest/autorest/adal v0.7.0 github.com/Azure/go-autorest/autorest/adal # github.com/Azure/go-autorest/autorest/azure/auth v0.4.0 @@ -62,27 +62,27 @@ github.com/Nvveen/Gotty # github.com/SAP/go-hdb v0.14.1 github.com/SAP/go-hdb/driver github.com/SAP/go-hdb/driver/sqltrace -github.com/SAP/go-hdb/internal/bufio github.com/SAP/go-hdb/internal/protocol +github.com/SAP/go-hdb/internal/bufio github.com/SAP/go-hdb/internal/unicode github.com/SAP/go-hdb/internal/unicode/cesu8 # github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 github.com/StackExchange/wmi # github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190620160927-9418d7b0cd0f -github.com/aliyun/alibaba-cloud-sdk-go/sdk github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/providers -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints +github.com/aliyun/alibaba-cloud-sdk-go/services/sts +github.com/aliyun/alibaba-cloud-sdk-go/sdk +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils github.com/aliyun/alibaba-cloud-sdk-go/services/kms +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider github.com/aliyun/alibaba-cloud-sdk-go/services/ram -github.com/aliyun/alibaba-cloud-sdk-go/services/sts # github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 github.com/aliyun/aliyun-oss-go-sdk/oss # github.com/apple/foundationdb/bindings/go v0.0.0-20190411004307-cd5c9d91fad2 @@ -103,53 +103,53 @@ github.com/armon/go-radix github.com/asaskevich/govalidator # github.com/aws/aws-sdk-go v1.25.41 github.com/aws/aws-sdk-go/aws +github.com/aws/aws-sdk-go/aws/credentials +github.com/aws/aws-sdk-go/aws/credentials/stscreds +github.com/aws/aws-sdk-go/aws/endpoints +github.com/aws/aws-sdk-go/aws/session +github.com/aws/aws-sdk-go/service/ec2 +github.com/aws/aws-sdk-go/service/iam +github.com/aws/aws-sdk-go/service/sts github.com/aws/aws-sdk-go/aws/arn github.com/aws/aws-sdk-go/aws/awserr -github.com/aws/aws-sdk-go/aws/awsutil +github.com/aws/aws-sdk-go/service/iam/iamiface +github.com/aws/aws-sdk-go/service/sts/stsiface +github.com/aws/aws-sdk-go/aws/ec2metadata +github.com/aws/aws-sdk-go/service/dynamodb +github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute +github.com/aws/aws-sdk-go/service/s3 +github.com/aws/aws-sdk-go/internal/sdkio +github.com/aws/aws-sdk-go/internal/ini +github.com/aws/aws-sdk-go/internal/shareddefaults github.com/aws/aws-sdk-go/aws/client -github.com/aws/aws-sdk-go/aws/client/metadata +github.com/aws/aws-sdk-go/internal/sdkrand github.com/aws/aws-sdk-go/aws/corehandlers -github.com/aws/aws-sdk-go/aws/credentials -github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds -github.com/aws/aws-sdk-go/aws/credentials/endpointcreds github.com/aws/aws-sdk-go/aws/credentials/processcreds -github.com/aws/aws-sdk-go/aws/credentials/stscreds -github.com/aws/aws-sdk-go/aws/crr github.com/aws/aws-sdk-go/aws/csm github.com/aws/aws-sdk-go/aws/defaults -github.com/aws/aws-sdk-go/aws/ec2metadata -github.com/aws/aws-sdk-go/aws/endpoints github.com/aws/aws-sdk-go/aws/request -github.com/aws/aws-sdk-go/aws/session +github.com/aws/aws-sdk-go/aws/awsutil +github.com/aws/aws-sdk-go/aws/client/metadata github.com/aws/aws-sdk-go/aws/signer/v4 -github.com/aws/aws-sdk-go/internal/ini -github.com/aws/aws-sdk-go/internal/s3err -github.com/aws/aws-sdk-go/internal/sdkio -github.com/aws/aws-sdk-go/internal/sdkmath -github.com/aws/aws-sdk-go/internal/sdkrand -github.com/aws/aws-sdk-go/internal/sdkuri -github.com/aws/aws-sdk-go/internal/shareddefaults github.com/aws/aws-sdk-go/private/protocol github.com/aws/aws-sdk-go/private/protocol/ec2query +github.com/aws/aws-sdk-go/private/protocol/query +github.com/aws/aws-sdk-go/internal/sdkuri +github.com/aws/aws-sdk-go/service/kms +github.com/aws/aws-sdk-go/service/kms/kmsiface +github.com/aws/aws-sdk-go/aws/crr +github.com/aws/aws-sdk-go/private/protocol/jsonrpc +github.com/aws/aws-sdk-go/internal/s3err github.com/aws/aws-sdk-go/private/protocol/eventstream github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi -github.com/aws/aws-sdk-go/private/protocol/json/jsonutil -github.com/aws/aws-sdk-go/private/protocol/jsonrpc -github.com/aws/aws-sdk-go/private/protocol/query -github.com/aws/aws-sdk-go/private/protocol/query/queryutil github.com/aws/aws-sdk-go/private/protocol/rest github.com/aws/aws-sdk-go/private/protocol/restxml github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil -github.com/aws/aws-sdk-go/service/dynamodb -github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute -github.com/aws/aws-sdk-go/service/ec2 -github.com/aws/aws-sdk-go/service/iam -github.com/aws/aws-sdk-go/service/iam/iamiface -github.com/aws/aws-sdk-go/service/kms -github.com/aws/aws-sdk-go/service/kms/kmsiface -github.com/aws/aws-sdk-go/service/s3 -github.com/aws/aws-sdk-go/service/sts -github.com/aws/aws-sdk-go/service/sts/stsiface +github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds +github.com/aws/aws-sdk-go/aws/credentials/endpointcreds +github.com/aws/aws-sdk-go/internal/sdkmath +github.com/aws/aws-sdk-go/private/protocol/query/queryutil +github.com/aws/aws-sdk-go/private/protocol/json/jsonutil # github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 github.com/beorn7/perks/quantile # github.com/bgentry/speakeasy v0.1.0 @@ -159,10 +159,10 @@ github.com/boombuler/barcode github.com/boombuler/barcode/qr github.com/boombuler/barcode/utils # github.com/briankassouf/jose v0.9.2-0.20180619214549-d2569464773f -github.com/briankassouf/jose github.com/briankassouf/jose/crypto github.com/briankassouf/jose/jws github.com/briankassouf/jose/jwt +github.com/briankassouf/jose # github.com/cenkalti/backoff v2.2.1+incompatible github.com/cenkalti/backoff # github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f @@ -173,8 +173,8 @@ github.com/chrismalek/oktasdk-go/okta # github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible github.com/circonus-labs/circonus-gometrics github.com/circonus-labs/circonus-gometrics/api -github.com/circonus-labs/circonus-gometrics/api/config github.com/circonus-labs/circonus-gometrics/checkmgr +github.com/circonus-labs/circonus-gometrics/api/config # github.com/circonus-labs/circonusllhist v0.1.3 github.com/circonus-labs/circonusllhist # github.com/cloudfoundry-community/go-cfclient v0.0.0-20190201205600-f136f9222381 @@ -205,12 +205,12 @@ github.com/docker/go-connections/nat # github.com/docker/go-units v0.4.0 github.com/docker/go-units # github.com/dsnet/compress v0.0.1 -github.com/dsnet/compress github.com/dsnet/compress/bzip2 github.com/dsnet/compress/bzip2/internal/sais github.com/dsnet/compress/internal github.com/dsnet/compress/internal/errors github.com/dsnet/compress/internal/prefix +github.com/dsnet/compress # github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 github.com/duosecurity/duo_api_golang github.com/duosecurity/duo_api_golang/authapi @@ -241,27 +241,29 @@ github.com/go-ole/go-ole/oleutil github.com/go-sql-driver/mysql # github.com/go-test/deep v1.0.2 github.com/go-test/deep +# github.com/go-yaml/yaml v2.1.0+incompatible +github.com/go-yaml/yaml # github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df github.com/gocql/gocql github.com/gocql/gocql/internal/lru github.com/gocql/gocql/internal/murmur github.com/gocql/gocql/internal/streams # github.com/gogo/protobuf v1.2.1 -github.com/gogo/protobuf/gogoproto github.com/gogo/protobuf/io github.com/gogo/protobuf/proto -github.com/gogo/protobuf/protoc-gen-gogo/descriptor github.com/gogo/protobuf/sortkeys +github.com/gogo/protobuf/gogoproto +github.com/gogo/protobuf/protoc-gen-gogo/descriptor # github.com/golang/protobuf v1.3.2 github.com/golang/protobuf/proto -github.com/golang/protobuf/protoc-gen-go/descriptor github.com/golang/protobuf/ptypes +github.com/golang/protobuf/ptypes/timestamp github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration -github.com/golang/protobuf/ptypes/empty github.com/golang/protobuf/ptypes/struct -github.com/golang/protobuf/ptypes/timestamp +github.com/golang/protobuf/ptypes/empty github.com/golang/protobuf/ptypes/wrappers +github.com/golang/protobuf/protoc-gen-go/descriptor # github.com/golang/snappy v0.0.1 github.com/golang/snappy # github.com/google/go-github v17.0.0+incompatible @@ -283,13 +285,13 @@ github.com/gorilla/websocket # github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed github.com/hailocab/go-hostpool # github.com/hashicorp/consul-template v0.22.0 -github.com/hashicorp/consul-template/child github.com/hashicorp/consul-template/config -github.com/hashicorp/consul-template/dependency github.com/hashicorp/consul-template/logging github.com/hashicorp/consul-template/manager -github.com/hashicorp/consul-template/renderer github.com/hashicorp/consul-template/signals +github.com/hashicorp/consul-template/child +github.com/hashicorp/consul-template/dependency +github.com/hashicorp/consul-template/renderer github.com/hashicorp/consul-template/template github.com/hashicorp/consul-template/version github.com/hashicorp/consul-template/watch @@ -307,8 +309,6 @@ github.com/hashicorp/go-hclog github.com/hashicorp/go-immutable-radix # github.com/hashicorp/go-kms-wrapping v0.5.0 github.com/hashicorp/go-kms-wrapping -github.com/hashicorp/go-kms-wrapping/entropy -github.com/hashicorp/go-kms-wrapping/internal/xor github.com/hashicorp/go-kms-wrapping/wrappers/aead github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms github.com/hashicorp/go-kms-wrapping/wrappers/awskms @@ -316,6 +316,8 @@ github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms github.com/hashicorp/go-kms-wrapping/wrappers/ocikms github.com/hashicorp/go-kms-wrapping/wrappers/transit +github.com/hashicorp/go-kms-wrapping/entropy +github.com/hashicorp/go-kms-wrapping/internal/xor # github.com/hashicorp/go-memdb v1.0.2 github.com/hashicorp/go-memdb # github.com/hashicorp/go-msgpack v0.5.5 @@ -342,50 +344,50 @@ github.com/hashicorp/go-uuid # github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/go-version # github.com/hashicorp/gokrb5 v7.3.1-0.20191209171754-1a6fa9886ec3+incompatible -github.com/hashicorp/gokrb5/asn1tools +github.com/hashicorp/gokrb5/spnego github.com/hashicorp/gokrb5/client github.com/hashicorp/gokrb5/config +github.com/hashicorp/gokrb5/keytab +github.com/hashicorp/gokrb5/service +github.com/hashicorp/gokrb5/asn1tools github.com/hashicorp/gokrb5/credentials -github.com/hashicorp/gokrb5/crypto -github.com/hashicorp/gokrb5/crypto/common -github.com/hashicorp/gokrb5/crypto/etype -github.com/hashicorp/gokrb5/crypto/rfc3961 -github.com/hashicorp/gokrb5/crypto/rfc3962 -github.com/hashicorp/gokrb5/crypto/rfc4757 -github.com/hashicorp/gokrb5/crypto/rfc8009 github.com/hashicorp/gokrb5/gssapi -github.com/hashicorp/gokrb5/iana -github.com/hashicorp/gokrb5/iana/addrtype -github.com/hashicorp/gokrb5/iana/adtype -github.com/hashicorp/gokrb5/iana/asnAppTag github.com/hashicorp/gokrb5/iana/chksumtype +github.com/hashicorp/gokrb5/iana/msgtype +github.com/hashicorp/gokrb5/krberror +github.com/hashicorp/gokrb5/messages +github.com/hashicorp/gokrb5/types +github.com/hashicorp/gokrb5/crypto +github.com/hashicorp/gokrb5/crypto/etype github.com/hashicorp/gokrb5/iana/errorcode -github.com/hashicorp/gokrb5/iana/etypeID github.com/hashicorp/gokrb5/iana/flags github.com/hashicorp/gokrb5/iana/keyusage -github.com/hashicorp/gokrb5/iana/msgtype github.com/hashicorp/gokrb5/iana/nametype github.com/hashicorp/gokrb5/iana/patype github.com/hashicorp/gokrb5/kadmin -github.com/hashicorp/gokrb5/keytab -github.com/hashicorp/gokrb5/krberror -github.com/hashicorp/gokrb5/messages +github.com/hashicorp/gokrb5/iana/etypeID +github.com/hashicorp/gokrb5/iana +github.com/hashicorp/gokrb5/iana/adtype +github.com/hashicorp/gokrb5/iana/asnAppTag github.com/hashicorp/gokrb5/pac -github.com/hashicorp/gokrb5/service -github.com/hashicorp/gokrb5/spnego -github.com/hashicorp/gokrb5/types +github.com/hashicorp/gokrb5/iana/addrtype +github.com/hashicorp/gokrb5/crypto/common +github.com/hashicorp/gokrb5/crypto/rfc3961 +github.com/hashicorp/gokrb5/crypto/rfc3962 +github.com/hashicorp/gokrb5/crypto/rfc4757 +github.com/hashicorp/gokrb5/crypto/rfc8009 # github.com/hashicorp/golang-lru v0.5.3 github.com/hashicorp/golang-lru github.com/hashicorp/golang-lru/simplelru # github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/hcl github.com/hashicorp/hcl/hcl/ast -github.com/hashicorp/hcl/hcl/parser github.com/hashicorp/hcl/hcl/printer -github.com/hashicorp/hcl/hcl/scanner -github.com/hashicorp/hcl/hcl/strconv +github.com/hashicorp/hcl/hcl/parser github.com/hashicorp/hcl/hcl/token github.com/hashicorp/hcl/json/parser +github.com/hashicorp/hcl/hcl/scanner +github.com/hashicorp/hcl/hcl/strconv github.com/hashicorp/hcl/json/scanner github.com/hashicorp/hcl/json/token # github.com/hashicorp/logutils v1.0.0 @@ -408,11 +410,11 @@ github.com/hashicorp/vault-plugin-auth-azure github.com/hashicorp/vault-plugin-auth-centrify # github.com/hashicorp/vault-plugin-auth-cf v0.0.0-20190821162840-1c2205826fee github.com/hashicorp/vault-plugin-auth-cf -github.com/hashicorp/vault-plugin-auth-cf/models github.com/hashicorp/vault-plugin-auth-cf/signatures +github.com/hashicorp/vault-plugin-auth-cf/models +github.com/hashicorp/vault-plugin-auth-cf/util github.com/hashicorp/vault-plugin-auth-cf/testing/certificates github.com/hashicorp/vault-plugin-auth-cf/testing/cf -github.com/hashicorp/vault-plugin-auth-cf/util # github.com/hashicorp/vault-plugin-auth-gcp v0.5.2-0.20190930204802-acfd134850c2 github.com/hashicorp/vault-plugin-auth-gcp/plugin github.com/hashicorp/vault-plugin-auth-gcp/plugin/cache @@ -446,51 +448,51 @@ github.com/hashicorp/vault-plugin-secrets-kv # github.com/hashicorp/vault/api v1.0.5-0.20200111014044-ba76c080ad1f => ./api github.com/hashicorp/vault/api # github.com/hashicorp/vault/sdk v0.1.14-0.20200111013952-157e805b97be => ./sdk -github.com/hashicorp/vault/sdk/database/dbplugin -github.com/hashicorp/vault/sdk/database/helper/connutil -github.com/hashicorp/vault/sdk/database/helper/credsutil -github.com/hashicorp/vault/sdk/database/helper/dbutil +github.com/hashicorp/vault/sdk/helper/salt +github.com/hashicorp/vault/sdk/helper/strutil +github.com/hashicorp/vault/sdk/helper/wrapping +github.com/hashicorp/vault/sdk/logical +github.com/hashicorp/vault/sdk/helper/parseutil github.com/hashicorp/vault/sdk/framework -github.com/hashicorp/vault/sdk/helper/awsutil -github.com/hashicorp/vault/sdk/helper/base62 -github.com/hashicorp/vault/sdk/helper/certutil +github.com/hashicorp/vault/sdk/helper/policyutil +github.com/hashicorp/vault/sdk/plugin github.com/hashicorp/vault/sdk/helper/cidrutil -github.com/hashicorp/vault/sdk/helper/compressutil github.com/hashicorp/vault/sdk/helper/consts -github.com/hashicorp/vault/sdk/helper/cryptoutil +github.com/hashicorp/vault/sdk/helper/locksutil +github.com/hashicorp/vault/sdk/helper/tokenutil +github.com/hashicorp/vault/sdk/helper/awsutil +github.com/hashicorp/vault/sdk/helper/jsonutil +github.com/hashicorp/vault/sdk/helper/certutil +github.com/hashicorp/vault/sdk/helper/password +github.com/hashicorp/vault/sdk/helper/ldaputil +github.com/hashicorp/vault/sdk/helper/tlsutil +github.com/hashicorp/vault/sdk/database/dbplugin +github.com/hashicorp/vault/sdk/database/helper/dbutil +github.com/hashicorp/vault/sdk/queue github.com/hashicorp/vault/sdk/helper/dbtxn github.com/hashicorp/vault/sdk/helper/errutil -github.com/hashicorp/vault/sdk/helper/hclutil -github.com/hashicorp/vault/sdk/helper/identitytpl -github.com/hashicorp/vault/sdk/helper/jsonutil -github.com/hashicorp/vault/sdk/helper/kdf github.com/hashicorp/vault/sdk/helper/keysutil -github.com/hashicorp/vault/sdk/helper/ldaputil -github.com/hashicorp/vault/sdk/helper/license -github.com/hashicorp/vault/sdk/helper/locksutil +github.com/hashicorp/vault/sdk/helper/base62 github.com/hashicorp/vault/sdk/helper/logging github.com/hashicorp/vault/sdk/helper/mlock -github.com/hashicorp/vault/sdk/helper/parseutil -github.com/hashicorp/vault/sdk/helper/password -github.com/hashicorp/vault/sdk/helper/pathmanager -github.com/hashicorp/vault/sdk/helper/pluginutil -github.com/hashicorp/vault/sdk/helper/pointerutil -github.com/hashicorp/vault/sdk/helper/policyutil -github.com/hashicorp/vault/sdk/helper/salt -github.com/hashicorp/vault/sdk/helper/strutil -github.com/hashicorp/vault/sdk/helper/tlsutil -github.com/hashicorp/vault/sdk/helper/tokenutil github.com/hashicorp/vault/sdk/helper/useragent -github.com/hashicorp/vault/sdk/helper/wrapping -github.com/hashicorp/vault/sdk/logical github.com/hashicorp/vault/sdk/physical github.com/hashicorp/vault/sdk/physical/file github.com/hashicorp/vault/sdk/physical/inmem -github.com/hashicorp/vault/sdk/plugin -github.com/hashicorp/vault/sdk/plugin/mock -github.com/hashicorp/vault/sdk/plugin/pb -github.com/hashicorp/vault/sdk/queue github.com/hashicorp/vault/sdk/version +github.com/hashicorp/vault/sdk/helper/cryptoutil +github.com/hashicorp/vault/sdk/helper/pointerutil +github.com/hashicorp/vault/sdk/helper/hclutil +github.com/hashicorp/vault/sdk/database/helper/credsutil +github.com/hashicorp/vault/sdk/helper/compressutil +github.com/hashicorp/vault/sdk/helper/pathmanager +github.com/hashicorp/vault/sdk/plugin/pb +github.com/hashicorp/vault/sdk/database/helper/connutil +github.com/hashicorp/vault/sdk/helper/identitytpl +github.com/hashicorp/vault/sdk/helper/license +github.com/hashicorp/vault/sdk/helper/pluginutil +github.com/hashicorp/vault/sdk/helper/kdf +github.com/hashicorp/vault/sdk/plugin/mock # github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb github.com/hashicorp/yamux # github.com/influxdata/influxdb v0.0.0-20190411212539-d24b7ba8c4c4 @@ -499,11 +501,11 @@ github.com/influxdata/influxdb/models github.com/influxdata/influxdb/pkg/escape # github.com/jackc/pgx v3.3.0+incompatible github.com/jackc/pgx -github.com/jackc/pgx/chunkreader github.com/jackc/pgx/internal/sanitize github.com/jackc/pgx/pgio github.com/jackc/pgx/pgproto3 github.com/jackc/pgx/pgtype +github.com/jackc/pgx/chunkreader # github.com/jcmturner/gofork v1.0.0 github.com/jcmturner/gofork/encoding/asn1 github.com/jcmturner/gofork/x/crypto/pbkdf2 @@ -518,25 +520,27 @@ github.com/jmespath/go-jmespath # github.com/joyent/triton-go v0.0.0-20190112182421-51ffac552869 github.com/joyent/triton-go github.com/joyent/triton-go/authentication -github.com/joyent/triton-go/client github.com/joyent/triton-go/errors github.com/joyent/triton-go/storage +github.com/joyent/triton-go/client # github.com/json-iterator/go v1.1.6 github.com/json-iterator/go +# github.com/kelseyhightower/envconfig v1.3.0 +github.com/kelseyhightower/envconfig # github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f +github.com/keybase/go-crypto/openpgp +github.com/keybase/go-crypto/openpgp/packet +github.com/keybase/go-crypto/openpgp/armor +github.com/keybase/go-crypto/openpgp/errors +github.com/keybase/go-crypto/openpgp/s2k +github.com/keybase/go-crypto/rsa github.com/keybase/go-crypto/brainpool github.com/keybase/go-crypto/cast5 github.com/keybase/go-crypto/curve25519 github.com/keybase/go-crypto/ed25519 -github.com/keybase/go-crypto/ed25519/internal/edwards25519 -github.com/keybase/go-crypto/openpgp -github.com/keybase/go-crypto/openpgp/armor github.com/keybase/go-crypto/openpgp/ecdh github.com/keybase/go-crypto/openpgp/elgamal -github.com/keybase/go-crypto/openpgp/errors -github.com/keybase/go-crypto/openpgp/packet -github.com/keybase/go-crypto/openpgp/s2k -github.com/keybase/go-crypto/rsa +github.com/keybase/go-crypto/ed25519/internal/edwards25519 # github.com/konsorten/go-windows-terminal-sequences v1.0.1 github.com/konsorten/go-windows-terminal-sequences # github.com/kr/pretty v0.1.0 @@ -585,18 +589,22 @@ github.com/ncw/swift github.com/nwaples/rardecode # github.com/oklog/run v1.0.0 github.com/oklog/run +# github.com/okta/okta-sdk-golang v1.0.1 +github.com/okta/okta-sdk-golang/okta +github.com/okta/okta-sdk-golang/okta/cache +github.com/okta/okta-sdk-golang/okta/query # github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/go-digest # github.com/opencontainers/image-spec v1.0.1 -github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go/v1 +github.com/opencontainers/image-spec/specs-go # github.com/opencontainers/runc v0.1.1 github.com/opencontainers/runc/libcontainer/user # github.com/oracle/oci-go-sdk v12.5.0+incompatible github.com/oracle/oci-go-sdk/common github.com/oracle/oci-go-sdk/common/auth -github.com/oracle/oci-go-sdk/keymanagement github.com/oracle/oci-go-sdk/objectstorage +github.com/oracle/oci-go-sdk/keymanagement # github.com/ory/dockertest v3.3.5+incompatible github.com/ory/dockertest github.com/ory/dockertest/docker @@ -604,23 +612,23 @@ github.com/ory/dockertest/docker/opts github.com/ory/dockertest/docker/pkg/archive github.com/ory/dockertest/docker/pkg/fileutils github.com/ory/dockertest/docker/pkg/homedir +github.com/ory/dockertest/docker/pkg/jsonmessage +github.com/ory/dockertest/docker/pkg/stdcopy +github.com/ory/dockertest/docker/types/registry +github.com/ory/dockertest/docker/types github.com/ory/dockertest/docker/pkg/idtools github.com/ory/dockertest/docker/pkg/ioutils -github.com/ory/dockertest/docker/pkg/jsonmessage github.com/ory/dockertest/docker/pkg/longpath -github.com/ory/dockertest/docker/pkg/mount github.com/ory/dockertest/docker/pkg/pools -github.com/ory/dockertest/docker/pkg/stdcopy github.com/ory/dockertest/docker/pkg/system github.com/ory/dockertest/docker/pkg/term -github.com/ory/dockertest/docker/pkg/term/windows -github.com/ory/dockertest/docker/types -github.com/ory/dockertest/docker/types/blkiodev github.com/ory/dockertest/docker/types/container github.com/ory/dockertest/docker/types/filters github.com/ory/dockertest/docker/types/mount github.com/ory/dockertest/docker/types/network -github.com/ory/dockertest/docker/types/registry +github.com/ory/dockertest/docker/pkg/mount +github.com/ory/dockertest/docker/pkg/term/windows +github.com/ory/dockertest/docker/types/blkiodev github.com/ory/dockertest/docker/types/strslice github.com/ory/dockertest/docker/types/versions # github.com/patrickmn/go-cache v2.1.0+incompatible @@ -634,31 +642,31 @@ github.com/pkg/errors github.com/pmezard/go-difflib/difflib # github.com/posener/complete v1.2.1 github.com/posener/complete -github.com/posener/complete/cmd github.com/posener/complete/cmd/install +github.com/posener/complete/cmd github.com/posener/complete/match # github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 github.com/pquerna/cachecontrol github.com/pquerna/cachecontrol/cacheobject # github.com/pquerna/otp v1.2.1-0.20191009055518-468c2dd2b58d github.com/pquerna/otp -github.com/pquerna/otp/hotp github.com/pquerna/otp/totp +github.com/pquerna/otp/hotp # github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 github.com/prometheus/client_golang/prometheus -github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/push +github.com/prometheus/client_golang/prometheus/internal # github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f github.com/prometheus/client_model/go # github.com/prometheus/common v0.2.0 github.com/prometheus/common/expfmt -github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/model +github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg # github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 github.com/prometheus/procfs -github.com/prometheus/procfs/internal/util github.com/prometheus/procfs/nfs github.com/prometheus/procfs/xfs +github.com/prometheus/procfs/internal/util # github.com/ryanuber/columnize v2.1.0+incompatible github.com/ryanuber/columnize # github.com/ryanuber/go-glob v1.0.0 @@ -671,10 +679,10 @@ github.com/satori/go.uuid github.com/shirou/gopsutil/cpu github.com/shirou/gopsutil/disk github.com/shirou/gopsutil/host -github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/mem -github.com/shirou/gopsutil/net +github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/process +github.com/shirou/gopsutil/net # github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 github.com/shirou/w32 # github.com/sirupsen/logrus v1.4.2 @@ -688,191 +696,178 @@ github.com/tv42/httpunix github.com/ugorji/go/codec # github.com/ulikunitz/xz v0.5.6 github.com/ulikunitz/xz -github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma +github.com/ulikunitz/xz/internal/hash # github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 github.com/xi2/xz # go.etcd.io/bbolt v1.3.2 go.etcd.io/bbolt # go.etcd.io/etcd v0.0.0-20190412021913-f29b1ada1971 -go.etcd.io/etcd/auth/authpb go.etcd.io/etcd/client go.etcd.io/etcd/clientv3 +go.etcd.io/etcd/clientv3/concurrency +go.etcd.io/etcd/pkg/transport +go.etcd.io/etcd/pkg/pathutil +go.etcd.io/etcd/pkg/srv +go.etcd.io/etcd/pkg/types +go.etcd.io/etcd/version +go.etcd.io/etcd/auth/authpb go.etcd.io/etcd/clientv3/balancer go.etcd.io/etcd/clientv3/balancer/picker go.etcd.io/etcd/clientv3/balancer/resolver/endpoint -go.etcd.io/etcd/clientv3/concurrency go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes go.etcd.io/etcd/etcdserver/etcdserverpb go.etcd.io/etcd/mvcc/mvccpb go.etcd.io/etcd/pkg/logutil -go.etcd.io/etcd/pkg/pathutil -go.etcd.io/etcd/pkg/srv -go.etcd.io/etcd/pkg/systemd go.etcd.io/etcd/pkg/tlsutil -go.etcd.io/etcd/pkg/transport -go.etcd.io/etcd/pkg/types +go.etcd.io/etcd/pkg/systemd go.etcd.io/etcd/raft go.etcd.io/etcd/raft/raftpb -go.etcd.io/etcd/version # go.opencensus.io v0.21.0 -go.opencensus.io -go.opencensus.io/internal -go.opencensus.io/internal/tagencoding +go.opencensus.io/stats +go.opencensus.io/stats/view +go.opencensus.io/plugin/ochttp +go.opencensus.io/trace go.opencensus.io/metric/metricdata +go.opencensus.io/stats/internal +go.opencensus.io/tag +go.opencensus.io/internal/tagencoding go.opencensus.io/metric/metricproducer go.opencensus.io/plugin/ocgrpc -go.opencensus.io/plugin/ochttp go.opencensus.io/plugin/ochttp/propagation/b3 -go.opencensus.io/resource -go.opencensus.io/stats -go.opencensus.io/stats/internal -go.opencensus.io/stats/view -go.opencensus.io/tag -go.opencensus.io/trace -go.opencensus.io/trace/internal go.opencensus.io/trace/propagation +go.opencensus.io/internal +go.opencensus.io/trace/internal go.opencensus.io/trace/tracestate +go.opencensus.io/resource +go.opencensus.io # go.uber.org/atomic v1.4.0 go.uber.org/atomic # go.uber.org/multierr v1.1.0 go.uber.org/multierr # go.uber.org/zap v1.9.1 go.uber.org/zap -go.uber.org/zap/buffer +go.uber.org/zap/zapcore go.uber.org/zap/internal/bufferpool +go.uber.org/zap/buffer go.uber.org/zap/internal/color go.uber.org/zap/internal/exit -go.uber.org/zap/zapcore # golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4 golang.org/x/crypto/bcrypt -golang.org/x/crypto/blake2b -golang.org/x/crypto/blowfish -golang.org/x/crypto/chacha20poly1305 golang.org/x/crypto/cryptobyte golang.org/x/crypto/cryptobyte/asn1 -golang.org/x/crypto/curve25519 golang.org/x/crypto/ed25519 +golang.org/x/crypto/ssh +golang.org/x/crypto/ssh/agent +golang.org/x/crypto/curve25519 +golang.org/x/crypto/ssh/terminal +golang.org/x/crypto/blowfish +golang.org/x/crypto/md4 golang.org/x/crypto/ed25519/internal/edwards25519 -golang.org/x/crypto/hkdf golang.org/x/crypto/internal/chacha20 -golang.org/x/crypto/internal/subtle -golang.org/x/crypto/md4 +golang.org/x/crypto/poly1305 +golang.org/x/crypto/chacha20poly1305 +golang.org/x/crypto/hkdf golang.org/x/crypto/pbkdf2 +golang.org/x/crypto/blake2b +golang.org/x/crypto/internal/subtle golang.org/x/crypto/pkcs12 golang.org/x/crypto/pkcs12/internal/rc2 -golang.org/x/crypto/poly1305 -golang.org/x/crypto/ssh -golang.org/x/crypto/ssh/agent -golang.org/x/crypto/ssh/terminal # golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 -golang.org/x/net/context -golang.org/x/net/context/ctxhttp -golang.org/x/net/http/httpguts +golang.org/x/net/idna golang.org/x/net/http/httpproxy +golang.org/x/net/context golang.org/x/net/http2 +golang.org/x/net/http/httpguts golang.org/x/net/http2/hpack -golang.org/x/net/idna -golang.org/x/net/internal/timeseries golang.org/x/net/trace +golang.org/x/net/context/ctxhttp +golang.org/x/net/internal/timeseries # golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/oauth2 -golang.org/x/oauth2/clientcredentials -golang.org/x/oauth2/google golang.org/x/oauth2/internal -golang.org/x/oauth2/jws +golang.org/x/oauth2/google golang.org/x/oauth2/jwt +golang.org/x/oauth2/jws +golang.org/x/oauth2/clientcredentials # golang.org/x/sys v0.0.0-20191008105621-543471e840be -golang.org/x/sys/cpu golang.org/x/sys/unix golang.org/x/sys/windows +golang.org/x/sys/cpu # golang.org/x/text v0.3.2 +golang.org/x/text/secure/bidirule +golang.org/x/text/unicode/bidi +golang.org/x/text/unicode/norm +golang.org/x/text/transform +golang.org/x/text/encoding/unicode golang.org/x/text/encoding golang.org/x/text/encoding/internal golang.org/x/text/encoding/internal/identifier -golang.org/x/text/encoding/unicode golang.org/x/text/internal/utf8internal golang.org/x/text/runes -golang.org/x/text/secure/bidirule -golang.org/x/text/transform -golang.org/x/text/unicode/bidi -golang.org/x/text/unicode/norm # golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 golang.org/x/time/rate # google.golang.org/api v0.14.0 +google.golang.org/api/option +google.golang.org/api/iam/v1 +google.golang.org/api/googleapi +google.golang.org/api/iterator +google.golang.org/api/transport google.golang.org/api/cloudresourcemanager/v1 google.golang.org/api/compute/v1 -google.golang.org/api/googleapi -google.golang.org/api/googleapi/transport -google.golang.org/api/iam/v1 google.golang.org/api/internal -google.golang.org/api/internal/gensupport -google.golang.org/api/internal/third_party/uritemplates -google.golang.org/api/iterator google.golang.org/api/oauth2/v2 -google.golang.org/api/option +google.golang.org/api/internal/gensupport +google.golang.org/api/transport/http google.golang.org/api/storage/v1 -google.golang.org/api/transport +google.golang.org/api/internal/third_party/uritemplates google.golang.org/api/transport/grpc -google.golang.org/api/transport/http +google.golang.org/api/googleapi/transport google.golang.org/api/transport/http/internal/propagation # google.golang.org/appengine v1.6.0 -google.golang.org/appengine google.golang.org/appengine/cloudsql +google.golang.org/appengine/urlfetch +google.golang.org/appengine +google.golang.org/appengine/socket google.golang.org/appengine/internal +google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/internal/app_identity +google.golang.org/appengine/internal/modules +google.golang.org/appengine/internal/socket google.golang.org/appengine/internal/base google.golang.org/appengine/internal/datastore google.golang.org/appengine/internal/log -google.golang.org/appengine/internal/modules google.golang.org/appengine/internal/remote_api -google.golang.org/appengine/internal/socket -google.golang.org/appengine/internal/urlfetch -google.golang.org/appengine/socket -google.golang.org/appengine/urlfetch # google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 -google.golang.org/genproto/googleapis/api -google.golang.org/genproto/googleapis/api/annotations -google.golang.org/genproto/googleapis/api/distribution -google.golang.org/genproto/googleapis/api/label google.golang.org/genproto/googleapis/api/metric google.golang.org/genproto/googleapis/api/monitoredres +google.golang.org/genproto/googleapis/monitoring/v3 +google.golang.org/genproto/googleapis/api/distribution google.golang.org/genproto/googleapis/cloud/kms/v1 +google.golang.org/genproto/protobuf/field_mask google.golang.org/genproto/googleapis/iam/v1 -google.golang.org/genproto/googleapis/monitoring/v3 -google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/rpc/errdetails -google.golang.org/genproto/googleapis/rpc/status google.golang.org/genproto/googleapis/spanner/v1 +google.golang.org/genproto/googleapis/rpc/status +google.golang.org/genproto/googleapis/api +google.golang.org/genproto/googleapis/api/label +google.golang.org/genproto/googleapis/api/annotations +google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/type/expr -google.golang.org/genproto/protobuf/field_mask # google.golang.org/grpc v1.22.0 +google.golang.org/grpc/grpclog +google.golang.org/grpc/codes google.golang.org/grpc +google.golang.org/grpc/keepalive +google.golang.org/grpc/status +google.golang.org/grpc/metadata +google.golang.org/grpc/credentials google.golang.org/grpc/balancer -google.golang.org/grpc/balancer/base -google.golang.org/grpc/balancer/grpclb -google.golang.org/grpc/balancer/grpclb/grpc_lb_v1 google.golang.org/grpc/balancer/roundrobin -google.golang.org/grpc/binarylog/grpc_binarylog_v1 -google.golang.org/grpc/codes google.golang.org/grpc/connectivity -google.golang.org/grpc/credentials -google.golang.org/grpc/credentials/alts -google.golang.org/grpc/credentials/alts/internal -google.golang.org/grpc/credentials/alts/internal/authinfo -google.golang.org/grpc/credentials/alts/internal/conn -google.golang.org/grpc/credentials/alts/internal/handshaker -google.golang.org/grpc/credentials/alts/internal/handshaker/service -google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp -google.golang.org/grpc/credentials/google -google.golang.org/grpc/credentials/internal -google.golang.org/grpc/credentials/oauth google.golang.org/grpc/encoding google.golang.org/grpc/encoding/proto -google.golang.org/grpc/grpclog -google.golang.org/grpc/health -google.golang.org/grpc/health/grpc_health_v1 google.golang.org/grpc/internal google.golang.org/grpc/internal/backoff google.golang.org/grpc/internal/balancerload @@ -881,10 +876,7 @@ google.golang.org/grpc/internal/channelz google.golang.org/grpc/internal/envconfig google.golang.org/grpc/internal/grpcrand google.golang.org/grpc/internal/grpcsync -google.golang.org/grpc/internal/syscall google.golang.org/grpc/internal/transport -google.golang.org/grpc/keepalive -google.golang.org/grpc/metadata google.golang.org/grpc/naming google.golang.org/grpc/peer google.golang.org/grpc/resolver @@ -892,8 +884,24 @@ google.golang.org/grpc/resolver/dns google.golang.org/grpc/resolver/passthrough google.golang.org/grpc/serviceconfig google.golang.org/grpc/stats -google.golang.org/grpc/status google.golang.org/grpc/tap +google.golang.org/grpc/health +google.golang.org/grpc/health/grpc_health_v1 +google.golang.org/grpc/credentials/internal +google.golang.org/grpc/balancer/grpclb +google.golang.org/grpc/credentials/google +google.golang.org/grpc/credentials/oauth +google.golang.org/grpc/balancer/base +google.golang.org/grpc/binarylog/grpc_binarylog_v1 +google.golang.org/grpc/internal/syscall +google.golang.org/grpc/balancer/grpclb/grpc_lb_v1 +google.golang.org/grpc/credentials/alts +google.golang.org/grpc/credentials/alts/internal +google.golang.org/grpc/credentials/alts/internal/handshaker +google.golang.org/grpc/credentials/alts/internal/handshaker/service +google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp +google.golang.org/grpc/credentials/alts/internal/authinfo +google.golang.org/grpc/credentials/alts/internal/conn # gopkg.in/inf.v0 v0.9.1 gopkg.in/inf.v0 # gopkg.in/ini.v1 v1.42.0 @@ -910,43 +918,43 @@ gopkg.in/jcmturner/rpc.v1/ndr # gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce gopkg.in/mgo.v2 gopkg.in/mgo.v2/bson -gopkg.in/mgo.v2/internal/json gopkg.in/mgo.v2/internal/sasl gopkg.in/mgo.v2/internal/scram +gopkg.in/mgo.v2/internal/json # gopkg.in/ory-am/dockertest.v3 v3.3.4 gopkg.in/ory-am/dockertest.v3 # gopkg.in/square/go-jose.v2 v2.3.1 +gopkg.in/square/go-jose.v2/jwt gopkg.in/square/go-jose.v2 -gopkg.in/square/go-jose.v2/cipher gopkg.in/square/go-jose.v2/json -gopkg.in/square/go-jose.v2/jwt +gopkg.in/square/go-jose.v2/cipher # gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 # k8s.io/api v0.0.0-20190409092523-d687e77c8ae9 k8s.io/api/authentication/v1 # k8s.io/apimachinery v0.0.0-20190409092423-760d1845f48b k8s.io/apimachinery/pkg/api/errors -k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/apis/meta/v1 +k8s.io/apimachinery/pkg/runtime +k8s.io/apimachinery/pkg/runtime/schema +k8s.io/apimachinery/pkg/types +k8s.io/apimachinery/pkg/util/validation/field +k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/conversion -k8s.io/apimachinery/pkg/conversion/queryparams k8s.io/apimachinery/pkg/fields k8s.io/apimachinery/pkg/labels -k8s.io/apimachinery/pkg/runtime -k8s.io/apimachinery/pkg/runtime/schema k8s.io/apimachinery/pkg/selection -k8s.io/apimachinery/pkg/types -k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/intstr +k8s.io/apimachinery/pkg/util/runtime +k8s.io/apimachinery/pkg/watch +k8s.io/apimachinery/pkg/conversion/queryparams +k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/json k8s.io/apimachinery/pkg/util/naming -k8s.io/apimachinery/pkg/util/net -k8s.io/apimachinery/pkg/util/runtime k8s.io/apimachinery/pkg/util/sets -k8s.io/apimachinery/pkg/util/validation -k8s.io/apimachinery/pkg/util/validation/field -k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/reflect +k8s.io/apimachinery/pkg/util/validation +k8s.io/apimachinery/pkg/util/net # k8s.io/klog v0.0.0-20190306015804-8e90cee79f82 k8s.io/klog # layeh.com/radius v0.0.0-20190322222518-890bc1058917 From 9d2b10c28f7e4966af69a9e98a27bb135670bec1 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Mon, 3 Feb 2020 09:31:09 -0500 Subject: [PATCH 7/8] Remove redundant Sprintf. --- builtin/credential/okta/backend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/credential/okta/backend.go b/builtin/credential/okta/backend.go index c0ee7f13bce46..6d75a61883abe 100644 --- a/builtin/credential/okta/backend.go +++ b/builtin/credential/okta/backend.go @@ -112,7 +112,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri rsp, err := shim.Do(authReq, &result) if err != nil { if oe, ok := err.(*okta.Error); ok { - return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed: %v (code=%v)", err, oe.ErrorCode)), nil, nil + return nil, logical.ErrorResponse("Okta auth failed: %v (code=%v)", err, oe.ErrorCode), nil, nil } return nil, logical.ErrorResponse(fmt.Sprintf("Okta auth failed: %v", err)), nil, nil } From 97f22eefa504551540b004ec501f344fd27d8292 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Mon, 3 Feb 2020 10:30:22 -0500 Subject: [PATCH 8/8] Post-merge go mod vendor. --- vendor/github.com/go-stack/stack/xml.go | 508 ---------------------- vendor/modules.txt | 534 ++++++++++++------------ 2 files changed, 271 insertions(+), 771 deletions(-) delete mode 100644 vendor/github.com/go-stack/stack/xml.go diff --git a/vendor/github.com/go-stack/stack/xml.go b/vendor/github.com/go-stack/stack/xml.go deleted file mode 100644 index 19fc36caf3cc8..0000000000000 --- a/vendor/github.com/go-stack/stack/xml.go +++ /dev/null @@ -1,508 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build ignore - -package codec - -import "reflect" - -/* - -A strict Non-validating namespace-aware XML 1.0 parser and (en|de)coder. - -We are attempting this due to perceived issues with encoding/xml: - - Complicated. It tried to do too much, and is not as simple to use as json. - - Due to over-engineering, reflection is over-used AND performance suffers: - java is 6X faster:http://fabsk.eu/blog/category/informatique/dev/golang/ - even PYTHON performs better: http://outgoing.typepad.com/outgoing/2014/07/exploring-golang.html - -codec framework will offer the following benefits - - VASTLY improved performance (when using reflection-mode or codecgen) - - simplicity and consistency: with the rest of the supported formats - - all other benefits of codec framework (streaming, codegeneration, etc) - -codec is not a drop-in replacement for encoding/xml. -It is a replacement, based on the simplicity and performance of codec. -Look at it like JAXB for Go. - -Challenges: - - Need to output XML preamble, with all namespaces at the right location in the output. - - Each "end" block is dynamic, so we need to maintain a context-aware stack - - How to decide when to use an attribute VS an element - - How to handle chardata, attr, comment EXPLICITLY. - - Should it output fragments? - e.g. encoding a bool should just output true OR false, which is not well-formed XML. - -Extend the struct tag. See representative example: - type X struct { - ID uint8 `codec:"http://ugorji.net/x-namespace xid id,omitempty,toarray,attr,cdata"` - // format: [namespace-uri ][namespace-prefix ]local-name, ... - } - -Based on this, we encode - - fields as elements, BUT - encode as attributes if struct tag contains ",attr" and is a scalar (bool, number or string) - - text as entity-escaped text, BUT encode as CDATA if struct tag contains ",cdata". - -To handle namespaces: - - XMLHandle is denoted as being namespace-aware. - Consequently, we WILL use the ns:name pair to encode and decode if defined, else use the plain name. - - *Encoder and *Decoder know whether the Handle "prefers" namespaces. - - add *Encoder.getEncName(*structFieldInfo). - No one calls *structFieldInfo.indexForEncName directly anymore - - OR better yet: indexForEncName is namespace-aware, and helper.go is all namespace-aware - indexForEncName takes a parameter of the form namespace:local-name OR local-name - - add *Decoder.getStructFieldInfo(encName string) // encName here is either like abc, or h1:nsabc - by being a method on *Decoder, or maybe a method on the Handle itself. - No one accesses .encName anymore - - let encode.go and decode.go use these (for consistency) - - only problem exists for gen.go, where we create a big switch on encName. - Now, we also have to add a switch on strings.endsWith(kName, encNsName) - - gen.go will need to have many more methods, and then double-on the 2 switch loops like: - switch k { - case "abc" : x.abc() - case "def" : x.def() - default { - switch { - case !nsAware: panic(...) - case strings.endsWith(":abc"): x.abc() - case strings.endsWith(":def"): x.def() - default: panic(...) - } - } - } - -The structure below accommodates this: - - type typeInfo struct { - sfi []*structFieldInfo // sorted by encName - sfins // sorted by namespace - sfia // sorted, to have those with attributes at the top. Needed to write XML appropriately. - sfip // unsorted - } - type structFieldInfo struct { - encName - nsEncName - ns string - attr bool - cdata bool - } - -indexForEncName is now an internal helper function that takes a sorted array -(one of ti.sfins or ti.sfi). It is only used by *Encoder.getStructFieldInfo(...) - -There will be a separate parser from the builder. -The parser will have a method: next() xmlToken method. It has lookahead support, -so you can pop multiple tokens, make a determination, and push them back in the order popped. -This will be needed to determine whether we are "nakedly" decoding a container or not. -The stack will be implemented using a slice and push/pop happens at the [0] element. - -xmlToken has fields: - - type uint8: 0 | ElementStart | ElementEnd | AttrKey | AttrVal | Text - - value string - - ns string - -SEE: http://www.xml.com/pub/a/98/10/guide0.html?page=3#ENTDECL - -The following are skipped when parsing: - - External Entities (from external file) - - Notation Declaration e.g. - - Entity Declarations & References - - XML Declaration (assume UTF-8) - - XML Directive i.e. - - Other Declarations: Notation, etc. - - Comment - - Processing Instruction - - schema / DTD for validation: - We are not a VALIDATING parser. Validation is done elsewhere. - However, some parts of the DTD internal subset are used (SEE BELOW). - For Attribute List Declarations e.g. - - We considered using the ATTLIST to get "default" value, but not to validate the contents. (VETOED) - -The following XML features are supported - - Namespace - - Element - - Attribute - - cdata - - Unicode escape - -The following DTD (when as an internal sub-set) features are supported: - - Internal Entities e.g. - AND entities for the set: [<>&"'] - - Parameter entities e.g. - - -At decode time, a structure containing the following is kept - - namespace mapping - - default attribute values - - all internal entities (<>&"' and others written in the document) - -When decode starts, it parses XML namespace declarations and creates a map in the -xmlDecDriver. While parsing, that map continuously gets updated. -The only problem happens when a namespace declaration happens on the node that it defines. -e.g. -To handle this, each Element must be fully parsed at a time, -even if it amounts to multiple tokens which are returned one at a time on request. - -xmlns is a special attribute name. - - It is used to define namespaces, including the default - - It is never returned as an AttrKey or AttrVal. - *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.* - -Number, bool, null, mapKey, etc can all be decoded from any xmlToken. -This accommodates map[int]string for example. - -It should be possible to create a schema from the types, -or vice versa (generate types from schema with appropriate tags). -This is however out-of-scope from this parsing project. - -We should write all namespace information at the first point that it is referenced in the tree, -and use the mapping for all child nodes and attributes. This means that state is maintained -at a point in the tree. This also means that calls to Decode or MustDecode will reset some state. - -When decoding, it is important to keep track of entity references and default attribute values. -It seems these can only be stored in the DTD components. We should honor them when decoding. - -Configuration for XMLHandle will look like this: - - XMLHandle - DefaultNS string - // Encoding: - NS map[string]string // ns URI to key, used for encoding - // Decoding: in case ENTITY declared in external schema or dtd, store info needed here - Entities map[string]string // map of entity rep to character - - -During encode, if a namespace mapping is not defined for a namespace found on a struct, -then we create a mapping for it using nsN (where N is 1..1000000, and doesn't conflict -with any other namespace mapping). - -Note that different fields in a struct can have different namespaces. -However, all fields will default to the namespace on the _struct field (if defined). - -An XML document is a name, a map of attributes and a list of children. -Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example). -We have to "DecodeNaked" into something that resembles XML data. - -To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types: - type Name struct { // Preferred. Less allocations due to conversions. - Local string - Space string - } - type Element struct { - Name Name - Attrs map[Name]string - Children []interface{} // each child is either *Element or string - } -Only two "supporting" types are exposed for XML: Name and Element. - -// ------------------ - -We considered 'type Name string' where Name is like "Space Local" (space-separated). -We decided against it, because each creation of a name would lead to -double allocation (first convert []byte to string, then concatenate them into a string). -The benefit is that it is faster to read Attrs from a map. But given that Element is a value -object, we want to eschew methods and have public exposed variables. - -We also considered the following, where xml types were not value objects, and we used -intelligent accessor methods to extract information and for performance. -*** WE DECIDED AGAINST THIS. *** - type Attr struct { - Name Name - Value string - } - // Element is a ValueObject: There are no accessor methods. - // Make element self-contained. - type Element struct { - Name Name - attrsMap map[string]string // where key is "Space Local" - attrs []Attr - childrenT []string - childrenE []Element - childrenI []int // each child is a index into T or E. - } - func (x *Element) child(i) interface{} // returns string or *Element - -// ------------------ - -Per XML spec and our default handling, white space is always treated as -insignificant between elements, except in a text node. The xml:space='preserve' -attribute is ignored. - -**Note: there is no xml: namespace. The xml: attributes were defined before namespaces.** -**So treat them as just "directives" that should be interpreted to mean something**. - -On encoding, we support indenting aka prettifying markup in the same way we support it for json. - -A document or element can only be encoded/decoded from/to a struct. In this mode: - - struct name maps to element name (or tag-info from _struct field) - - fields are mapped to child elements or attributes - -A map is either encoded as attributes on current element, or as a set of child elements. -Maps are encoded as attributes iff their keys and values are primitives (number, bool, string). - -A list is encoded as a set of child elements. - -Primitives (number, bool, string) are encoded as an element, attribute or text -depending on the context. - -Extensions must encode themselves as a text string. - -Encoding is tough, specifically when encoding mappings, because we need to encode -as either attribute or element. To do this, we need to default to encoding as attributes, -and then let Encoder inform the Handle when to start encoding as nodes. -i.e. Encoder does something like: - - h.EncodeMapStart() - h.Encode(), h.Encode(), ... - h.EncodeMapNotAttrSignal() // this is not a bool, because it's a signal - h.Encode(), h.Encode(), ... - h.EncodeEnd() - -Only XMLHandle understands this, and will set itself to start encoding as elements. - -This support extends to maps. For example, if a struct field is a map, and it has -the struct tag signifying it should be attr, then all its fields are encoded as attributes. -e.g. - - type X struct { - M map[string]int `codec:"m,attr"` // encode keys as attributes named - } - -Question: - - if encoding a map, what if map keys have spaces in them??? - Then they cannot be attributes or child elements. Error. - -Options to consider adding later: - - For attribute values, normalize by trimming beginning and ending white space, - and converting every white space sequence to a single space. - - ATTLIST restrictions are enforced. - e.g. default value of xml:space, skipping xml:XYZ style attributes, etc. - - Consider supporting NON-STRICT mode (e.g. to handle HTML parsing). - Some elements e.g. br, hr, etc need not close and should be auto-closed - ... (see http://www.w3.org/TR/html4/loose.dtd) - An expansive set of entities are pre-defined. - - Have easy way to create a HTML parser: - add a HTML() method to XMLHandle, that will set Strict=false, specify AutoClose, - and add HTML Entities to the list. - - Support validating element/attribute XMLName before writing it. - Keep this behind a flag, which is set to false by default (for performance). - type XMLHandle struct { - CheckName bool - } - -Misc: - -ROADMAP (1 weeks): - - build encoder (1 day) - - build decoder (based off xmlParser) (1 day) - - implement xmlParser (2 days). - Look at encoding/xml for inspiration. - - integrate and TEST (1 days) - - write article and post it (1 day) - -// ---------- MORE NOTES FROM 2017-11-30 ------------ - -when parsing -- parse the attributes first -- then parse the nodes - -basically: -- if encoding a field: we use the field name for the wrapper -- if encoding a non-field, then just use the element type name - - map[string]string ==> abcval... or - val... OR - val1val2... <- PREFERED - []string ==> v1v2... - string v1 ==> v1 - bool true ==> true - float 1.0 ==> 1.0 - ... - - F1 map[string]string ==> abcval... OR - val... OR - val... <- PREFERED - F2 []string ==> v1v2... - F3 bool ==> true - ... - -- a scalar is encoded as: - (value) of type T ==> - (value) of field F ==> -- A kv-pair is encoded as: - (key,value) ==> OR - (key,value) of field F ==> OR -- A map or struct is just a list of kv-pairs -- A list is encoded as sequences of same node e.g. - - - value21 - value22 -- we may have to singularize the field name, when entering into xml, - and pluralize them when encoding. -- bi-directional encode->decode->encode is not a MUST. - even encoding/xml cannot decode correctly what was encoded: - - see https://play.golang.org/p/224V_nyhMS - func main() { - fmt.Println("Hello, playground") - v := []interface{}{"hello", 1, true, nil, time.Now()} - s, err := xml.Marshal(v) - fmt.Printf("err: %v, \ns: %s\n", err, s) - var v2 []interface{} - err = xml.Unmarshal(s, &v2) - fmt.Printf("err: %v, \nv2: %v\n", err, v2) - type T struct { - V []interface{} - } - v3 := T{V: v} - s, err = xml.Marshal(v3) - fmt.Printf("err: %v, \ns: %s\n", err, s) - var v4 T - err = xml.Unmarshal(s, &v4) - fmt.Printf("err: %v, \nv4: %v\n", err, v4) - } - Output: - err: , - s: hello1true - err: , - v2: [] - err: , - s: hello1true2009-11-10T23:00:00Z - err: , - v4: {[ ]} -- -*/ - -// ----------- PARSER ------------------- - -type xmlTokenType uint8 - -const ( - _ xmlTokenType = iota << 1 - xmlTokenElemStart - xmlTokenElemEnd - xmlTokenAttrKey - xmlTokenAttrVal - xmlTokenText -) - -type xmlToken struct { - Type xmlTokenType - Value string - Namespace string // blank for AttrVal and Text -} - -type xmlParser struct { - r decReader - toks []xmlToken // list of tokens. - ptr int // ptr into the toks slice - done bool // nothing else to parse. r now returns EOF. -} - -func (x *xmlParser) next() (t *xmlToken) { - // once x.done, or x.ptr == len(x.toks) == 0, then return nil (to signify finish) - if !x.done && len(x.toks) == 0 { - x.nextTag() - } - // parses one element at a time (into possible many tokens) - if x.ptr < len(x.toks) { - t = &(x.toks[x.ptr]) - x.ptr++ - if x.ptr == len(x.toks) { - x.ptr = 0 - x.toks = x.toks[:0] - } - } - return -} - -// nextTag will parses the next element and fill up toks. -// It set done flag if/once EOF is reached. -func (x *xmlParser) nextTag() { - // TODO: implement. -} - -// ----------- ENCODER ------------------- - -type xmlEncDriver struct { - e *Encoder - w encWriter - h *XMLHandle - b [64]byte // scratch - bs []byte // scratch - // s jsonStack - noBuiltInTypes -} - -// ----------- DECODER ------------------- - -type xmlDecDriver struct { - d *Decoder - h *XMLHandle - r decReader // *bytesDecReader decReader - ct valueType // container type. one of unset, array or map. - bstr [8]byte // scratch used for string \UXXX parsing - b [64]byte // scratch - - // wsSkipped bool // whitespace skipped - - // s jsonStack - - noBuiltInTypes -} - -// DecodeNaked will decode into an XMLNode - -// XMLName is a value object representing a namespace-aware NAME -type XMLName struct { - Local string - Space string -} - -// XMLNode represents a "union" of the different types of XML Nodes. -// Only one of fields (Text or *Element) is set. -type XMLNode struct { - Element *Element - Text string -} - -// XMLElement is a value object representing an fully-parsed XML element. -type XMLElement struct { - Name Name - Attrs map[XMLName]string - // Children is a list of child nodes, each being a *XMLElement or string - Children []XMLNode -} - -// ----------- HANDLE ------------------- - -type XMLHandle struct { - BasicHandle - textEncodingType - - DefaultNS string - NS map[string]string // ns URI to key, for encoding - Entities map[string]string // entity representation to string, for encoding. -} - -func (h *XMLHandle) newEncDriver(e *Encoder) encDriver { - return &xmlEncDriver{e: e, w: e.w, h: h} -} - -func (h *XMLHandle) newDecDriver(d *Decoder) decDriver { - // d := xmlDecDriver{r: r.(*bytesDecReader), h: h} - hd := xmlDecDriver{d: d, r: d.r, h: h} - hd.n.bytes = d.b[:] - return &hd -} - -func (h *XMLHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) -} - -var _ decDriver = (*xmlDecDriver)(nil) -var _ encDriver = (*xmlEncDriver)(nil) diff --git a/vendor/modules.txt b/vendor/modules.txt index ee060709a703d..8195242fb1c36 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,33 +1,33 @@ # cloud.google.com/go v0.39.0 +cloud.google.com/go/monitoring/apiv3 +cloud.google.com/go/storage +cloud.google.com/go/spanner cloud.google.com/go/civil cloud.google.com/go/compute/metadata +cloud.google.com/go/kms/apiv1 cloud.google.com/go/iam cloud.google.com/go/internal -cloud.google.com/go/internal/fields cloud.google.com/go/internal/optional -cloud.google.com/go/internal/protostruct cloud.google.com/go/internal/trace cloud.google.com/go/internal/version -cloud.google.com/go/kms/apiv1 -cloud.google.com/go/monitoring/apiv3 -cloud.google.com/go/spanner +cloud.google.com/go/internal/fields +cloud.google.com/go/internal/protostruct cloud.google.com/go/spanner/internal/backoff -cloud.google.com/go/storage # code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f code.cloudfoundry.org/gofileutils/fileutils # github.com/Azure/azure-sdk-for-go v36.2.0+incompatible +github.com/Azure/azure-sdk-for-go/storage +github.com/Azure/azure-sdk-for-go/services/keyvault/v7.0/keyvault github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac -github.com/Azure/azure-sdk-for-go/services/keyvault/v7.0/keyvault github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization -github.com/Azure/azure-sdk-for-go/storage github.com/Azure/azure-sdk-for-go/version # github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 -github.com/Azure/go-ansiterm github.com/Azure/go-ansiterm/winterm +github.com/Azure/go-ansiterm # github.com/Azure/go-autorest/autorest v0.9.2 -github.com/Azure/go-autorest/autorest github.com/Azure/go-autorest/autorest/azure +github.com/Azure/go-autorest/autorest # github.com/Azure/go-autorest/autorest/adal v0.7.0 github.com/Azure/go-autorest/autorest/adal # github.com/Azure/go-autorest/autorest/azure/auth v0.4.0 @@ -64,27 +64,27 @@ github.com/Nvveen/Gotty # github.com/SAP/go-hdb v0.14.1 github.com/SAP/go-hdb/driver github.com/SAP/go-hdb/driver/sqltrace -github.com/SAP/go-hdb/internal/bufio github.com/SAP/go-hdb/internal/protocol +github.com/SAP/go-hdb/internal/bufio github.com/SAP/go-hdb/internal/unicode github.com/SAP/go-hdb/internal/unicode/cesu8 # github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 github.com/StackExchange/wmi # github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190620160927-9418d7b0cd0f -github.com/aliyun/alibaba-cloud-sdk-go/sdk github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/providers -github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints +github.com/aliyun/alibaba-cloud-sdk-go/services/sts +github.com/aliyun/alibaba-cloud-sdk-go/sdk +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils github.com/aliyun/alibaba-cloud-sdk-go/services/kms +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider github.com/aliyun/alibaba-cloud-sdk-go/services/ram -github.com/aliyun/alibaba-cloud-sdk-go/services/sts # github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 github.com/aliyun/aliyun-oss-go-sdk/oss # github.com/apple/foundationdb/bindings/go v0.0.0-20190411004307-cd5c9d91fad2 @@ -105,53 +105,53 @@ github.com/armon/go-radix github.com/asaskevich/govalidator # github.com/aws/aws-sdk-go v1.25.41 github.com/aws/aws-sdk-go/aws +github.com/aws/aws-sdk-go/aws/credentials +github.com/aws/aws-sdk-go/aws/credentials/stscreds +github.com/aws/aws-sdk-go/aws/endpoints +github.com/aws/aws-sdk-go/aws/session +github.com/aws/aws-sdk-go/service/ec2 +github.com/aws/aws-sdk-go/service/iam +github.com/aws/aws-sdk-go/service/sts github.com/aws/aws-sdk-go/aws/arn github.com/aws/aws-sdk-go/aws/awserr -github.com/aws/aws-sdk-go/aws/awsutil +github.com/aws/aws-sdk-go/service/iam/iamiface +github.com/aws/aws-sdk-go/service/sts/stsiface +github.com/aws/aws-sdk-go/aws/ec2metadata +github.com/aws/aws-sdk-go/service/dynamodb +github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute +github.com/aws/aws-sdk-go/service/s3 +github.com/aws/aws-sdk-go/internal/sdkio +github.com/aws/aws-sdk-go/internal/ini +github.com/aws/aws-sdk-go/internal/shareddefaults github.com/aws/aws-sdk-go/aws/client -github.com/aws/aws-sdk-go/aws/client/metadata +github.com/aws/aws-sdk-go/internal/sdkrand github.com/aws/aws-sdk-go/aws/corehandlers -github.com/aws/aws-sdk-go/aws/credentials -github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds -github.com/aws/aws-sdk-go/aws/credentials/endpointcreds github.com/aws/aws-sdk-go/aws/credentials/processcreds -github.com/aws/aws-sdk-go/aws/credentials/stscreds -github.com/aws/aws-sdk-go/aws/crr github.com/aws/aws-sdk-go/aws/csm github.com/aws/aws-sdk-go/aws/defaults -github.com/aws/aws-sdk-go/aws/ec2metadata -github.com/aws/aws-sdk-go/aws/endpoints github.com/aws/aws-sdk-go/aws/request -github.com/aws/aws-sdk-go/aws/session +github.com/aws/aws-sdk-go/aws/awsutil +github.com/aws/aws-sdk-go/aws/client/metadata github.com/aws/aws-sdk-go/aws/signer/v4 -github.com/aws/aws-sdk-go/internal/ini -github.com/aws/aws-sdk-go/internal/s3err -github.com/aws/aws-sdk-go/internal/sdkio -github.com/aws/aws-sdk-go/internal/sdkmath -github.com/aws/aws-sdk-go/internal/sdkrand -github.com/aws/aws-sdk-go/internal/sdkuri -github.com/aws/aws-sdk-go/internal/shareddefaults github.com/aws/aws-sdk-go/private/protocol github.com/aws/aws-sdk-go/private/protocol/ec2query +github.com/aws/aws-sdk-go/private/protocol/query +github.com/aws/aws-sdk-go/internal/sdkuri +github.com/aws/aws-sdk-go/service/kms +github.com/aws/aws-sdk-go/service/kms/kmsiface +github.com/aws/aws-sdk-go/aws/crr +github.com/aws/aws-sdk-go/private/protocol/jsonrpc +github.com/aws/aws-sdk-go/internal/s3err github.com/aws/aws-sdk-go/private/protocol/eventstream github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi -github.com/aws/aws-sdk-go/private/protocol/json/jsonutil -github.com/aws/aws-sdk-go/private/protocol/jsonrpc -github.com/aws/aws-sdk-go/private/protocol/query -github.com/aws/aws-sdk-go/private/protocol/query/queryutil github.com/aws/aws-sdk-go/private/protocol/rest github.com/aws/aws-sdk-go/private/protocol/restxml github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil -github.com/aws/aws-sdk-go/service/dynamodb -github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute -github.com/aws/aws-sdk-go/service/ec2 -github.com/aws/aws-sdk-go/service/iam -github.com/aws/aws-sdk-go/service/iam/iamiface -github.com/aws/aws-sdk-go/service/kms -github.com/aws/aws-sdk-go/service/kms/kmsiface -github.com/aws/aws-sdk-go/service/s3 -github.com/aws/aws-sdk-go/service/sts -github.com/aws/aws-sdk-go/service/sts/stsiface +github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds +github.com/aws/aws-sdk-go/aws/credentials/endpointcreds +github.com/aws/aws-sdk-go/internal/sdkmath +github.com/aws/aws-sdk-go/private/protocol/query/queryutil +github.com/aws/aws-sdk-go/private/protocol/json/jsonutil # github.com/beorn7/perks v1.0.0 github.com/beorn7/perks/quantile # github.com/bgentry/speakeasy v0.1.0 @@ -161,10 +161,10 @@ github.com/boombuler/barcode github.com/boombuler/barcode/qr github.com/boombuler/barcode/utils # github.com/briankassouf/jose v0.9.2-0.20180619214549-d2569464773f -github.com/briankassouf/jose github.com/briankassouf/jose/crypto github.com/briankassouf/jose/jws github.com/briankassouf/jose/jwt +github.com/briankassouf/jose # github.com/cenkalti/backoff v2.2.1+incompatible github.com/cenkalti/backoff # github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f @@ -175,8 +175,8 @@ github.com/chrismalek/oktasdk-go/okta # github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible github.com/circonus-labs/circonus-gometrics github.com/circonus-labs/circonus-gometrics/api -github.com/circonus-labs/circonus-gometrics/api/config github.com/circonus-labs/circonus-gometrics/checkmgr +github.com/circonus-labs/circonus-gometrics/api/config # github.com/circonus-labs/circonusllhist v0.1.3 github.com/circonus-labs/circonusllhist # github.com/cloudfoundry-community/go-cfclient v0.0.0-20190201205600-f136f9222381 @@ -207,12 +207,12 @@ github.com/docker/go-connections/nat # github.com/docker/go-units v0.4.0 github.com/docker/go-units # github.com/dsnet/compress v0.0.1 -github.com/dsnet/compress github.com/dsnet/compress/bzip2 github.com/dsnet/compress/bzip2/internal/sais github.com/dsnet/compress/internal github.com/dsnet/compress/internal/errors github.com/dsnet/compress/internal/prefix +github.com/dsnet/compress # github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 github.com/duosecurity/duo_api_golang github.com/duosecurity/duo_api_golang/authapi @@ -245,27 +245,29 @@ github.com/go-sql-driver/mysql github.com/go-stack/stack # github.com/go-test/deep v1.0.2 github.com/go-test/deep +# github.com/go-yaml/yaml v2.1.0+incompatible +github.com/go-yaml/yaml # github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df github.com/gocql/gocql github.com/gocql/gocql/internal/lru github.com/gocql/gocql/internal/murmur github.com/gocql/gocql/internal/streams # github.com/gogo/protobuf v1.2.1 -github.com/gogo/protobuf/gogoproto github.com/gogo/protobuf/io github.com/gogo/protobuf/proto -github.com/gogo/protobuf/protoc-gen-gogo/descriptor github.com/gogo/protobuf/sortkeys +github.com/gogo/protobuf/gogoproto +github.com/gogo/protobuf/protoc-gen-gogo/descriptor # github.com/golang/protobuf v1.3.2 github.com/golang/protobuf/proto -github.com/golang/protobuf/protoc-gen-go/descriptor github.com/golang/protobuf/ptypes +github.com/golang/protobuf/ptypes/timestamp github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration -github.com/golang/protobuf/ptypes/empty github.com/golang/protobuf/ptypes/struct -github.com/golang/protobuf/ptypes/timestamp +github.com/golang/protobuf/ptypes/empty github.com/golang/protobuf/ptypes/wrappers +github.com/golang/protobuf/protoc-gen-go/descriptor # github.com/golang/snappy v0.0.1 github.com/golang/snappy # github.com/google/go-github v17.0.0+incompatible @@ -287,13 +289,13 @@ github.com/gorilla/websocket # github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed github.com/hailocab/go-hostpool # github.com/hashicorp/consul-template v0.22.0 -github.com/hashicorp/consul-template/child github.com/hashicorp/consul-template/config -github.com/hashicorp/consul-template/dependency github.com/hashicorp/consul-template/logging github.com/hashicorp/consul-template/manager -github.com/hashicorp/consul-template/renderer github.com/hashicorp/consul-template/signals +github.com/hashicorp/consul-template/child +github.com/hashicorp/consul-template/dependency +github.com/hashicorp/consul-template/renderer github.com/hashicorp/consul-template/template github.com/hashicorp/consul-template/version github.com/hashicorp/consul-template/watch @@ -311,8 +313,6 @@ github.com/hashicorp/go-hclog github.com/hashicorp/go-immutable-radix # github.com/hashicorp/go-kms-wrapping v0.5.0 github.com/hashicorp/go-kms-wrapping -github.com/hashicorp/go-kms-wrapping/entropy -github.com/hashicorp/go-kms-wrapping/internal/xor github.com/hashicorp/go-kms-wrapping/wrappers/aead github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms github.com/hashicorp/go-kms-wrapping/wrappers/awskms @@ -320,6 +320,8 @@ github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms github.com/hashicorp/go-kms-wrapping/wrappers/ocikms github.com/hashicorp/go-kms-wrapping/wrappers/transit +github.com/hashicorp/go-kms-wrapping/entropy +github.com/hashicorp/go-kms-wrapping/internal/xor # github.com/hashicorp/go-memdb v1.0.2 github.com/hashicorp/go-memdb # github.com/hashicorp/go-msgpack v0.5.5 @@ -346,50 +348,50 @@ github.com/hashicorp/go-uuid # github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/go-version # github.com/hashicorp/gokrb5 v7.3.1-0.20191209171754-1a6fa9886ec3+incompatible -github.com/hashicorp/gokrb5/asn1tools +github.com/hashicorp/gokrb5/spnego github.com/hashicorp/gokrb5/client github.com/hashicorp/gokrb5/config +github.com/hashicorp/gokrb5/keytab +github.com/hashicorp/gokrb5/service +github.com/hashicorp/gokrb5/asn1tools github.com/hashicorp/gokrb5/credentials -github.com/hashicorp/gokrb5/crypto -github.com/hashicorp/gokrb5/crypto/common -github.com/hashicorp/gokrb5/crypto/etype -github.com/hashicorp/gokrb5/crypto/rfc3961 -github.com/hashicorp/gokrb5/crypto/rfc3962 -github.com/hashicorp/gokrb5/crypto/rfc4757 -github.com/hashicorp/gokrb5/crypto/rfc8009 github.com/hashicorp/gokrb5/gssapi -github.com/hashicorp/gokrb5/iana -github.com/hashicorp/gokrb5/iana/addrtype -github.com/hashicorp/gokrb5/iana/adtype -github.com/hashicorp/gokrb5/iana/asnAppTag github.com/hashicorp/gokrb5/iana/chksumtype +github.com/hashicorp/gokrb5/iana/msgtype +github.com/hashicorp/gokrb5/krberror +github.com/hashicorp/gokrb5/messages +github.com/hashicorp/gokrb5/types +github.com/hashicorp/gokrb5/crypto +github.com/hashicorp/gokrb5/crypto/etype github.com/hashicorp/gokrb5/iana/errorcode -github.com/hashicorp/gokrb5/iana/etypeID github.com/hashicorp/gokrb5/iana/flags github.com/hashicorp/gokrb5/iana/keyusage -github.com/hashicorp/gokrb5/iana/msgtype github.com/hashicorp/gokrb5/iana/nametype github.com/hashicorp/gokrb5/iana/patype github.com/hashicorp/gokrb5/kadmin -github.com/hashicorp/gokrb5/keytab -github.com/hashicorp/gokrb5/krberror -github.com/hashicorp/gokrb5/messages +github.com/hashicorp/gokrb5/iana/etypeID +github.com/hashicorp/gokrb5/iana +github.com/hashicorp/gokrb5/iana/adtype +github.com/hashicorp/gokrb5/iana/asnAppTag github.com/hashicorp/gokrb5/pac -github.com/hashicorp/gokrb5/service -github.com/hashicorp/gokrb5/spnego -github.com/hashicorp/gokrb5/types +github.com/hashicorp/gokrb5/iana/addrtype +github.com/hashicorp/gokrb5/crypto/common +github.com/hashicorp/gokrb5/crypto/rfc3961 +github.com/hashicorp/gokrb5/crypto/rfc3962 +github.com/hashicorp/gokrb5/crypto/rfc4757 +github.com/hashicorp/gokrb5/crypto/rfc8009 # github.com/hashicorp/golang-lru v0.5.3 github.com/hashicorp/golang-lru github.com/hashicorp/golang-lru/simplelru # github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/hcl github.com/hashicorp/hcl/hcl/ast -github.com/hashicorp/hcl/hcl/parser github.com/hashicorp/hcl/hcl/printer -github.com/hashicorp/hcl/hcl/scanner -github.com/hashicorp/hcl/hcl/strconv +github.com/hashicorp/hcl/hcl/parser github.com/hashicorp/hcl/hcl/token github.com/hashicorp/hcl/json/parser +github.com/hashicorp/hcl/hcl/scanner +github.com/hashicorp/hcl/hcl/strconv github.com/hashicorp/hcl/json/scanner github.com/hashicorp/hcl/json/token # github.com/hashicorp/logutils v1.0.0 @@ -412,11 +414,11 @@ github.com/hashicorp/vault-plugin-auth-azure github.com/hashicorp/vault-plugin-auth-centrify # github.com/hashicorp/vault-plugin-auth-cf v0.0.0-20190821162840-1c2205826fee github.com/hashicorp/vault-plugin-auth-cf -github.com/hashicorp/vault-plugin-auth-cf/models github.com/hashicorp/vault-plugin-auth-cf/signatures +github.com/hashicorp/vault-plugin-auth-cf/models +github.com/hashicorp/vault-plugin-auth-cf/util github.com/hashicorp/vault-plugin-auth-cf/testing/certificates github.com/hashicorp/vault-plugin-auth-cf/testing/cf -github.com/hashicorp/vault-plugin-auth-cf/util # github.com/hashicorp/vault-plugin-auth-gcp v0.5.2-0.20190930204802-acfd134850c2 github.com/hashicorp/vault-plugin-auth-gcp/plugin github.com/hashicorp/vault-plugin-auth-gcp/plugin/cache @@ -450,52 +452,52 @@ github.com/hashicorp/vault-plugin-secrets-kv # github.com/hashicorp/vault/api v1.0.5-0.20200111014044-ba76c080ad1f => ./api github.com/hashicorp/vault/api # github.com/hashicorp/vault/sdk v0.1.14-0.20200123192413-777c45062569 => ./sdk -github.com/hashicorp/vault/sdk/database/dbplugin -github.com/hashicorp/vault/sdk/database/helper/connutil -github.com/hashicorp/vault/sdk/database/helper/credsutil -github.com/hashicorp/vault/sdk/database/helper/dbutil +github.com/hashicorp/vault/sdk/helper/salt +github.com/hashicorp/vault/sdk/helper/strutil +github.com/hashicorp/vault/sdk/helper/wrapping +github.com/hashicorp/vault/sdk/logical +github.com/hashicorp/vault/sdk/helper/parseutil github.com/hashicorp/vault/sdk/framework -github.com/hashicorp/vault/sdk/helper/awsutil -github.com/hashicorp/vault/sdk/helper/base62 -github.com/hashicorp/vault/sdk/helper/certutil +github.com/hashicorp/vault/sdk/helper/policyutil +github.com/hashicorp/vault/sdk/plugin github.com/hashicorp/vault/sdk/helper/cidrutil -github.com/hashicorp/vault/sdk/helper/compressutil github.com/hashicorp/vault/sdk/helper/consts -github.com/hashicorp/vault/sdk/helper/cryptoutil +github.com/hashicorp/vault/sdk/helper/locksutil +github.com/hashicorp/vault/sdk/helper/tokenutil +github.com/hashicorp/vault/sdk/helper/awsutil +github.com/hashicorp/vault/sdk/helper/jsonutil +github.com/hashicorp/vault/sdk/helper/certutil +github.com/hashicorp/vault/sdk/helper/password +github.com/hashicorp/vault/sdk/helper/ldaputil +github.com/hashicorp/vault/sdk/helper/tlsutil +github.com/hashicorp/vault/sdk/database/dbplugin +github.com/hashicorp/vault/sdk/database/helper/dbutil +github.com/hashicorp/vault/sdk/queue github.com/hashicorp/vault/sdk/helper/dbtxn github.com/hashicorp/vault/sdk/helper/errutil -github.com/hashicorp/vault/sdk/helper/gatedwriter -github.com/hashicorp/vault/sdk/helper/hclutil -github.com/hashicorp/vault/sdk/helper/identitytpl -github.com/hashicorp/vault/sdk/helper/jsonutil -github.com/hashicorp/vault/sdk/helper/kdf github.com/hashicorp/vault/sdk/helper/keysutil -github.com/hashicorp/vault/sdk/helper/ldaputil -github.com/hashicorp/vault/sdk/helper/license -github.com/hashicorp/vault/sdk/helper/locksutil +github.com/hashicorp/vault/sdk/helper/base62 +github.com/hashicorp/vault/sdk/helper/gatedwriter github.com/hashicorp/vault/sdk/helper/logging github.com/hashicorp/vault/sdk/helper/mlock -github.com/hashicorp/vault/sdk/helper/parseutil -github.com/hashicorp/vault/sdk/helper/password -github.com/hashicorp/vault/sdk/helper/pathmanager -github.com/hashicorp/vault/sdk/helper/pluginutil -github.com/hashicorp/vault/sdk/helper/pointerutil -github.com/hashicorp/vault/sdk/helper/policyutil -github.com/hashicorp/vault/sdk/helper/salt -github.com/hashicorp/vault/sdk/helper/strutil -github.com/hashicorp/vault/sdk/helper/tlsutil -github.com/hashicorp/vault/sdk/helper/tokenutil github.com/hashicorp/vault/sdk/helper/useragent -github.com/hashicorp/vault/sdk/helper/wrapping -github.com/hashicorp/vault/sdk/logical github.com/hashicorp/vault/sdk/physical github.com/hashicorp/vault/sdk/physical/file github.com/hashicorp/vault/sdk/physical/inmem -github.com/hashicorp/vault/sdk/plugin -github.com/hashicorp/vault/sdk/plugin/mock -github.com/hashicorp/vault/sdk/plugin/pb -github.com/hashicorp/vault/sdk/queue github.com/hashicorp/vault/sdk/version +github.com/hashicorp/vault/sdk/helper/cryptoutil +github.com/hashicorp/vault/sdk/helper/pointerutil +github.com/hashicorp/vault/sdk/helper/hclutil +github.com/hashicorp/vault/sdk/database/helper/credsutil +github.com/hashicorp/vault/sdk/helper/compressutil +github.com/hashicorp/vault/sdk/helper/pathmanager +github.com/hashicorp/vault/sdk/plugin/pb +github.com/hashicorp/vault/sdk/database/helper/connutil +github.com/hashicorp/vault/sdk/helper/identitytpl +github.com/hashicorp/vault/sdk/helper/license +github.com/hashicorp/vault/sdk/helper/pluginutil +github.com/hashicorp/vault/sdk/helper/kdf +github.com/hashicorp/vault/sdk/plugin/mock # github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb github.com/hashicorp/yamux # github.com/influxdata/influxdb v0.0.0-20190411212539-d24b7ba8c4c4 @@ -504,11 +506,11 @@ github.com/influxdata/influxdb/models github.com/influxdata/influxdb/pkg/escape # github.com/jackc/pgx v3.3.0+incompatible github.com/jackc/pgx -github.com/jackc/pgx/chunkreader github.com/jackc/pgx/internal/sanitize github.com/jackc/pgx/pgio github.com/jackc/pgx/pgproto3 github.com/jackc/pgx/pgtype +github.com/jackc/pgx/chunkreader # github.com/jcmturner/gofork v1.0.0 github.com/jcmturner/gofork/encoding/asn1 github.com/jcmturner/gofork/x/crypto/pbkdf2 @@ -523,25 +525,27 @@ github.com/jmespath/go-jmespath # github.com/joyent/triton-go v0.0.0-20190112182421-51ffac552869 github.com/joyent/triton-go github.com/joyent/triton-go/authentication -github.com/joyent/triton-go/client github.com/joyent/triton-go/errors github.com/joyent/triton-go/storage +github.com/joyent/triton-go/client # github.com/json-iterator/go v1.1.7 github.com/json-iterator/go +# github.com/kelseyhightower/envconfig v1.3.0 +github.com/kelseyhightower/envconfig # github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f +github.com/keybase/go-crypto/openpgp +github.com/keybase/go-crypto/openpgp/packet +github.com/keybase/go-crypto/openpgp/armor +github.com/keybase/go-crypto/openpgp/errors +github.com/keybase/go-crypto/openpgp/s2k +github.com/keybase/go-crypto/rsa github.com/keybase/go-crypto/brainpool github.com/keybase/go-crypto/cast5 github.com/keybase/go-crypto/curve25519 github.com/keybase/go-crypto/ed25519 -github.com/keybase/go-crypto/ed25519/internal/edwards25519 -github.com/keybase/go-crypto/openpgp -github.com/keybase/go-crypto/openpgp/armor github.com/keybase/go-crypto/openpgp/ecdh github.com/keybase/go-crypto/openpgp/elgamal -github.com/keybase/go-crypto/openpgp/errors -github.com/keybase/go-crypto/openpgp/packet -github.com/keybase/go-crypto/openpgp/s2k -github.com/keybase/go-crypto/rsa +github.com/keybase/go-crypto/ed25519/internal/edwards25519 # github.com/konsorten/go-windows-terminal-sequences v1.0.1 github.com/konsorten/go-windows-terminal-sequences # github.com/kr/pretty v0.1.0 @@ -590,18 +594,22 @@ github.com/ncw/swift github.com/nwaples/rardecode # github.com/oklog/run v1.0.0 github.com/oklog/run +# github.com/okta/okta-sdk-golang v1.0.1 +github.com/okta/okta-sdk-golang/okta +github.com/okta/okta-sdk-golang/okta/cache +github.com/okta/okta-sdk-golang/okta/query # github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/go-digest # github.com/opencontainers/image-spec v1.0.1 -github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go/v1 +github.com/opencontainers/image-spec/specs-go # github.com/opencontainers/runc v0.1.1 github.com/opencontainers/runc/libcontainer/user # github.com/oracle/oci-go-sdk v12.5.0+incompatible github.com/oracle/oci-go-sdk/common github.com/oracle/oci-go-sdk/common/auth -github.com/oracle/oci-go-sdk/keymanagement github.com/oracle/oci-go-sdk/objectstorage +github.com/oracle/oci-go-sdk/keymanagement # github.com/ory/dockertest v3.3.5+incompatible github.com/ory/dockertest github.com/ory/dockertest/docker @@ -609,23 +617,23 @@ github.com/ory/dockertest/docker/opts github.com/ory/dockertest/docker/pkg/archive github.com/ory/dockertest/docker/pkg/fileutils github.com/ory/dockertest/docker/pkg/homedir +github.com/ory/dockertest/docker/pkg/jsonmessage +github.com/ory/dockertest/docker/pkg/stdcopy +github.com/ory/dockertest/docker/types/registry +github.com/ory/dockertest/docker/types github.com/ory/dockertest/docker/pkg/idtools github.com/ory/dockertest/docker/pkg/ioutils -github.com/ory/dockertest/docker/pkg/jsonmessage github.com/ory/dockertest/docker/pkg/longpath -github.com/ory/dockertest/docker/pkg/mount github.com/ory/dockertest/docker/pkg/pools -github.com/ory/dockertest/docker/pkg/stdcopy github.com/ory/dockertest/docker/pkg/system github.com/ory/dockertest/docker/pkg/term -github.com/ory/dockertest/docker/pkg/term/windows -github.com/ory/dockertest/docker/types -github.com/ory/dockertest/docker/types/blkiodev github.com/ory/dockertest/docker/types/container github.com/ory/dockertest/docker/types/filters github.com/ory/dockertest/docker/types/mount github.com/ory/dockertest/docker/types/network -github.com/ory/dockertest/docker/types/registry +github.com/ory/dockertest/docker/pkg/mount +github.com/ory/dockertest/docker/pkg/term/windows +github.com/ory/dockertest/docker/types/blkiodev github.com/ory/dockertest/docker/types/strslice github.com/ory/dockertest/docker/types/versions # github.com/patrickmn/go-cache v2.1.0+incompatible @@ -639,26 +647,26 @@ github.com/pkg/errors github.com/pmezard/go-difflib/difflib # github.com/posener/complete v1.2.1 github.com/posener/complete -github.com/posener/complete/cmd github.com/posener/complete/cmd/install +github.com/posener/complete/cmd github.com/posener/complete/match # github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 github.com/pquerna/cachecontrol github.com/pquerna/cachecontrol/cacheobject # github.com/pquerna/otp v1.2.1-0.20191009055518-468c2dd2b58d github.com/pquerna/otp -github.com/pquerna/otp/hotp github.com/pquerna/otp/totp +github.com/pquerna/otp/hotp # github.com/prometheus/client_golang v1.0.0 github.com/prometheus/client_golang/prometheus -github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/push +github.com/prometheus/client_golang/prometheus/internal # github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 github.com/prometheus/client_model/go # github.com/prometheus/common v0.4.1 github.com/prometheus/common/expfmt -github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/model +github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg # github.com/prometheus/procfs v0.0.2 github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs @@ -674,10 +682,10 @@ github.com/satori/go.uuid github.com/shirou/gopsutil/cpu github.com/shirou/gopsutil/disk github.com/shirou/gopsutil/host -github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/mem -github.com/shirou/gopsutil/net +github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/process +github.com/shirou/gopsutil/net # github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 github.com/shirou/w32 # github.com/sirupsen/logrus v1.4.2 @@ -689,9 +697,9 @@ github.com/stretchr/testify/require github.com/tv42/httpunix # github.com/ulikunitz/xz v0.5.6 github.com/ulikunitz/xz -github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma +github.com/ulikunitz/xz/internal/hash # github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c github.com/xdg/scram # github.com/xdg/stringprep v1.0.0 @@ -701,222 +709,209 @@ github.com/xi2/xz # go.etcd.io/bbolt v1.3.3 go.etcd.io/bbolt # go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738 -go.etcd.io/etcd/auth/authpb go.etcd.io/etcd/client go.etcd.io/etcd/clientv3 +go.etcd.io/etcd/clientv3/concurrency +go.etcd.io/etcd/pkg/transport +go.etcd.io/etcd/pkg/pathutil +go.etcd.io/etcd/pkg/srv +go.etcd.io/etcd/pkg/types +go.etcd.io/etcd/version +go.etcd.io/etcd/auth/authpb go.etcd.io/etcd/clientv3/balancer -go.etcd.io/etcd/clientv3/balancer/connectivity go.etcd.io/etcd/clientv3/balancer/picker go.etcd.io/etcd/clientv3/balancer/resolver/endpoint -go.etcd.io/etcd/clientv3/concurrency go.etcd.io/etcd/clientv3/credentials go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes go.etcd.io/etcd/etcdserver/etcdserverpb go.etcd.io/etcd/mvcc/mvccpb go.etcd.io/etcd/pkg/logutil -go.etcd.io/etcd/pkg/pathutil -go.etcd.io/etcd/pkg/srv -go.etcd.io/etcd/pkg/systemd go.etcd.io/etcd/pkg/tlsutil -go.etcd.io/etcd/pkg/transport -go.etcd.io/etcd/pkg/types +go.etcd.io/etcd/clientv3/balancer/connectivity +go.etcd.io/etcd/pkg/systemd go.etcd.io/etcd/raft go.etcd.io/etcd/raft/confchange go.etcd.io/etcd/raft/quorum go.etcd.io/etcd/raft/raftpb go.etcd.io/etcd/raft/tracker -go.etcd.io/etcd/version # go.mongodb.org/mongo-driver v1.2.1 +go.mongodb.org/mongo-driver/mongo +go.mongodb.org/mongo-driver/mongo/options +go.mongodb.org/mongo-driver/mongo/readpref +go.mongodb.org/mongo-driver/mongo/writeconcern +go.mongodb.org/mongo-driver/x/mongo/driver/connstring go.mongodb.org/mongo-driver/bson go.mongodb.org/mongo-driver/bson/bsoncodec -go.mongodb.org/mongo-driver/bson/bsonoptions -go.mongodb.org/mongo-driver/bson/bsonrw go.mongodb.org/mongo-driver/bson/bsontype go.mongodb.org/mongo-driver/bson/primitive go.mongodb.org/mongo-driver/event -go.mongodb.org/mongo-driver/internal -go.mongodb.org/mongo-driver/mongo -go.mongodb.org/mongo-driver/mongo/options go.mongodb.org/mongo-driver/mongo/readconcern -go.mongodb.org/mongo-driver/mongo/readpref -go.mongodb.org/mongo-driver/mongo/writeconcern -go.mongodb.org/mongo-driver/tag -go.mongodb.org/mongo-driver/version go.mongodb.org/mongo-driver/x/bsonx go.mongodb.org/mongo-driver/x/bsonx/bsoncore go.mongodb.org/mongo-driver/x/mongo/driver -go.mongodb.org/mongo-driver/x/mongo/driver/address go.mongodb.org/mongo-driver/x/mongo/driver/auth -go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi -go.mongodb.org/mongo-driver/x/mongo/driver/connstring go.mongodb.org/mongo-driver/x/mongo/driver/description -go.mongodb.org/mongo-driver/x/mongo/driver/dns go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options go.mongodb.org/mongo-driver/x/mongo/driver/operation go.mongodb.org/mongo-driver/x/mongo/driver/session go.mongodb.org/mongo-driver/x/mongo/driver/topology go.mongodb.org/mongo-driver/x/mongo/driver/uuid +go.mongodb.org/mongo-driver/tag go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage +go.mongodb.org/mongo-driver/internal +go.mongodb.org/mongo-driver/x/mongo/driver/dns +go.mongodb.org/mongo-driver/bson/bsonrw +go.mongodb.org/mongo-driver/bson/bsonoptions +go.mongodb.org/mongo-driver/x/mongo/driver/address +go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi +go.mongodb.org/mongo-driver/version # go.opencensus.io v0.21.0 -go.opencensus.io -go.opencensus.io/internal -go.opencensus.io/internal/tagencoding +go.opencensus.io/stats +go.opencensus.io/stats/view +go.opencensus.io/plugin/ochttp +go.opencensus.io/trace go.opencensus.io/metric/metricdata +go.opencensus.io/stats/internal +go.opencensus.io/tag +go.opencensus.io/internal/tagencoding go.opencensus.io/metric/metricproducer go.opencensus.io/plugin/ocgrpc -go.opencensus.io/plugin/ochttp go.opencensus.io/plugin/ochttp/propagation/b3 -go.opencensus.io/resource -go.opencensus.io/stats -go.opencensus.io/stats/internal -go.opencensus.io/stats/view -go.opencensus.io/tag -go.opencensus.io/trace -go.opencensus.io/trace/internal go.opencensus.io/trace/propagation +go.opencensus.io/internal +go.opencensus.io/trace/internal go.opencensus.io/trace/tracestate +go.opencensus.io/resource +go.opencensus.io # go.uber.org/atomic v1.4.0 go.uber.org/atomic # go.uber.org/multierr v1.1.0 go.uber.org/multierr # go.uber.org/zap v1.10.0 go.uber.org/zap -go.uber.org/zap/buffer +go.uber.org/zap/zapcore go.uber.org/zap/internal/bufferpool +go.uber.org/zap/buffer go.uber.org/zap/internal/color go.uber.org/zap/internal/exit -go.uber.org/zap/zapcore # golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4 golang.org/x/crypto/bcrypt -golang.org/x/crypto/blake2b -golang.org/x/crypto/blowfish -golang.org/x/crypto/chacha20poly1305 golang.org/x/crypto/cryptobyte golang.org/x/crypto/cryptobyte/asn1 -golang.org/x/crypto/curve25519 golang.org/x/crypto/ed25519 +golang.org/x/crypto/ssh +golang.org/x/crypto/ssh/agent +golang.org/x/crypto/curve25519 +golang.org/x/crypto/ssh/terminal +golang.org/x/crypto/blowfish +golang.org/x/crypto/md4 golang.org/x/crypto/ed25519/internal/edwards25519 -golang.org/x/crypto/hkdf golang.org/x/crypto/internal/chacha20 -golang.org/x/crypto/internal/subtle -golang.org/x/crypto/md4 +golang.org/x/crypto/poly1305 +golang.org/x/crypto/chacha20poly1305 +golang.org/x/crypto/hkdf golang.org/x/crypto/pbkdf2 +golang.org/x/crypto/blake2b +golang.org/x/crypto/internal/subtle golang.org/x/crypto/pkcs12 golang.org/x/crypto/pkcs12/internal/rc2 -golang.org/x/crypto/poly1305 -golang.org/x/crypto/ssh -golang.org/x/crypto/ssh/agent -golang.org/x/crypto/ssh/terminal # golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 -golang.org/x/net/context -golang.org/x/net/context/ctxhttp -golang.org/x/net/http/httpguts +golang.org/x/net/idna golang.org/x/net/http/httpproxy golang.org/x/net/http2 +golang.org/x/net/context +golang.org/x/net/http/httpguts golang.org/x/net/http2/hpack -golang.org/x/net/idna -golang.org/x/net/internal/timeseries golang.org/x/net/trace +golang.org/x/net/context/ctxhttp +golang.org/x/net/internal/timeseries # golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/oauth2 -golang.org/x/oauth2/clientcredentials -golang.org/x/oauth2/google golang.org/x/oauth2/internal -golang.org/x/oauth2/jws +golang.org/x/oauth2/google golang.org/x/oauth2/jwt +golang.org/x/oauth2/jws +golang.org/x/oauth2/clientcredentials # golang.org/x/sync v0.0.0-20190423024810-112230192c58 golang.org/x/sync/semaphore # golang.org/x/sys v0.0.0-20191008105621-543471e840be -golang.org/x/sys/cpu golang.org/x/sys/unix golang.org/x/sys/windows +golang.org/x/sys/cpu # golang.org/x/text v0.3.2 +golang.org/x/text/secure/bidirule +golang.org/x/text/unicode/bidi +golang.org/x/text/unicode/norm +golang.org/x/text/transform +golang.org/x/text/encoding/unicode golang.org/x/text/encoding golang.org/x/text/encoding/internal golang.org/x/text/encoding/internal/identifier -golang.org/x/text/encoding/unicode golang.org/x/text/internal/utf8internal golang.org/x/text/runes -golang.org/x/text/secure/bidirule -golang.org/x/text/transform -golang.org/x/text/unicode/bidi -golang.org/x/text/unicode/norm # golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 golang.org/x/time/rate # google.golang.org/api v0.14.0 +google.golang.org/api/option +google.golang.org/api/iam/v1 +google.golang.org/api/googleapi +google.golang.org/api/iterator +google.golang.org/api/transport google.golang.org/api/cloudresourcemanager/v1 google.golang.org/api/compute/v1 -google.golang.org/api/googleapi -google.golang.org/api/googleapi/transport -google.golang.org/api/iam/v1 google.golang.org/api/internal -google.golang.org/api/internal/gensupport -google.golang.org/api/internal/third_party/uritemplates -google.golang.org/api/iterator google.golang.org/api/oauth2/v2 -google.golang.org/api/option +google.golang.org/api/internal/gensupport +google.golang.org/api/transport/http google.golang.org/api/storage/v1 -google.golang.org/api/transport +google.golang.org/api/internal/third_party/uritemplates google.golang.org/api/transport/grpc -google.golang.org/api/transport/http +google.golang.org/api/googleapi/transport google.golang.org/api/transport/http/internal/propagation # google.golang.org/appengine v1.6.0 -google.golang.org/appengine google.golang.org/appengine/cloudsql +google.golang.org/appengine/urlfetch +google.golang.org/appengine +google.golang.org/appengine/socket google.golang.org/appengine/internal +google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/internal/app_identity +google.golang.org/appengine/internal/modules +google.golang.org/appengine/internal/socket google.golang.org/appengine/internal/base google.golang.org/appengine/internal/datastore google.golang.org/appengine/internal/log -google.golang.org/appengine/internal/modules google.golang.org/appengine/internal/remote_api -google.golang.org/appengine/internal/socket -google.golang.org/appengine/internal/urlfetch -google.golang.org/appengine/socket -google.golang.org/appengine/urlfetch # google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 -google.golang.org/genproto/googleapis/api -google.golang.org/genproto/googleapis/api/annotations -google.golang.org/genproto/googleapis/api/distribution -google.golang.org/genproto/googleapis/api/label google.golang.org/genproto/googleapis/api/metric google.golang.org/genproto/googleapis/api/monitoredres +google.golang.org/genproto/googleapis/monitoring/v3 +google.golang.org/genproto/googleapis/api/distribution google.golang.org/genproto/googleapis/cloud/kms/v1 +google.golang.org/genproto/protobuf/field_mask google.golang.org/genproto/googleapis/iam/v1 -google.golang.org/genproto/googleapis/monitoring/v3 -google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/rpc/errdetails -google.golang.org/genproto/googleapis/rpc/status google.golang.org/genproto/googleapis/spanner/v1 +google.golang.org/genproto/googleapis/rpc/status +google.golang.org/genproto/googleapis/api +google.golang.org/genproto/googleapis/api/label +google.golang.org/genproto/googleapis/api/annotations +google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/type/expr -google.golang.org/genproto/protobuf/field_mask # google.golang.org/grpc v1.23.1 +google.golang.org/grpc/grpclog +google.golang.org/grpc/codes google.golang.org/grpc +google.golang.org/grpc/keepalive +google.golang.org/grpc/status +google.golang.org/grpc/metadata +google.golang.org/grpc/credentials google.golang.org/grpc/balancer -google.golang.org/grpc/balancer/base -google.golang.org/grpc/balancer/grpclb -google.golang.org/grpc/balancer/grpclb/grpc_lb_v1 google.golang.org/grpc/balancer/roundrobin -google.golang.org/grpc/binarylog/grpc_binarylog_v1 -google.golang.org/grpc/codes google.golang.org/grpc/connectivity -google.golang.org/grpc/credentials -google.golang.org/grpc/credentials/alts -google.golang.org/grpc/credentials/alts/internal -google.golang.org/grpc/credentials/alts/internal/authinfo -google.golang.org/grpc/credentials/alts/internal/conn -google.golang.org/grpc/credentials/alts/internal/handshaker -google.golang.org/grpc/credentials/alts/internal/handshaker/service -google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp -google.golang.org/grpc/credentials/google -google.golang.org/grpc/credentials/internal -google.golang.org/grpc/credentials/oauth google.golang.org/grpc/encoding google.golang.org/grpc/encoding/proto -google.golang.org/grpc/grpclog -google.golang.org/grpc/health -google.golang.org/grpc/health/grpc_health_v1 google.golang.org/grpc/internal google.golang.org/grpc/internal/backoff google.golang.org/grpc/internal/balancerload @@ -925,10 +920,7 @@ google.golang.org/grpc/internal/channelz google.golang.org/grpc/internal/envconfig google.golang.org/grpc/internal/grpcrand google.golang.org/grpc/internal/grpcsync -google.golang.org/grpc/internal/syscall google.golang.org/grpc/internal/transport -google.golang.org/grpc/keepalive -google.golang.org/grpc/metadata google.golang.org/grpc/naming google.golang.org/grpc/peer google.golang.org/grpc/resolver @@ -936,8 +928,24 @@ google.golang.org/grpc/resolver/dns google.golang.org/grpc/resolver/passthrough google.golang.org/grpc/serviceconfig google.golang.org/grpc/stats -google.golang.org/grpc/status google.golang.org/grpc/tap +google.golang.org/grpc/health +google.golang.org/grpc/health/grpc_health_v1 +google.golang.org/grpc/credentials/internal +google.golang.org/grpc/balancer/grpclb +google.golang.org/grpc/credentials/google +google.golang.org/grpc/credentials/oauth +google.golang.org/grpc/balancer/base +google.golang.org/grpc/binarylog/grpc_binarylog_v1 +google.golang.org/grpc/internal/syscall +google.golang.org/grpc/balancer/grpclb/grpc_lb_v1 +google.golang.org/grpc/credentials/alts +google.golang.org/grpc/credentials/alts/internal +google.golang.org/grpc/credentials/alts/internal/handshaker +google.golang.org/grpc/credentials/alts/internal/handshaker/service +google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp +google.golang.org/grpc/credentials/alts/internal/authinfo +google.golang.org/grpc/credentials/alts/internal/conn # gopkg.in/inf.v0 v0.9.1 gopkg.in/inf.v0 # gopkg.in/ini.v1 v1.42.0 @@ -954,43 +962,43 @@ gopkg.in/jcmturner/rpc.v1/ndr # gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce gopkg.in/mgo.v2 gopkg.in/mgo.v2/bson -gopkg.in/mgo.v2/internal/json gopkg.in/mgo.v2/internal/sasl gopkg.in/mgo.v2/internal/scram +gopkg.in/mgo.v2/internal/json # gopkg.in/ory-am/dockertest.v3 v3.3.4 gopkg.in/ory-am/dockertest.v3 # gopkg.in/square/go-jose.v2 v2.3.1 +gopkg.in/square/go-jose.v2/jwt gopkg.in/square/go-jose.v2 -gopkg.in/square/go-jose.v2/cipher gopkg.in/square/go-jose.v2/json -gopkg.in/square/go-jose.v2/jwt +gopkg.in/square/go-jose.v2/cipher # gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 # k8s.io/api v0.0.0-20190409092523-d687e77c8ae9 k8s.io/api/authentication/v1 # k8s.io/apimachinery v0.0.0-20190409092423-760d1845f48b k8s.io/apimachinery/pkg/api/errors -k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/apis/meta/v1 +k8s.io/apimachinery/pkg/runtime +k8s.io/apimachinery/pkg/runtime/schema +k8s.io/apimachinery/pkg/types +k8s.io/apimachinery/pkg/util/validation/field +k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/conversion -k8s.io/apimachinery/pkg/conversion/queryparams k8s.io/apimachinery/pkg/fields k8s.io/apimachinery/pkg/labels -k8s.io/apimachinery/pkg/runtime -k8s.io/apimachinery/pkg/runtime/schema k8s.io/apimachinery/pkg/selection -k8s.io/apimachinery/pkg/types -k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/intstr +k8s.io/apimachinery/pkg/util/runtime +k8s.io/apimachinery/pkg/watch +k8s.io/apimachinery/pkg/conversion/queryparams +k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/json k8s.io/apimachinery/pkg/util/naming -k8s.io/apimachinery/pkg/util/net -k8s.io/apimachinery/pkg/util/runtime k8s.io/apimachinery/pkg/util/sets -k8s.io/apimachinery/pkg/util/validation -k8s.io/apimachinery/pkg/util/validation/field -k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/reflect +k8s.io/apimachinery/pkg/util/validation +k8s.io/apimachinery/pkg/util/net # k8s.io/klog v0.0.0-20190306015804-8e90cee79f82 k8s.io/klog # layeh.com/radius v0.0.0-20190322222518-890bc1058917