diff --git a/go.mod b/go.mod index 4cbc2afbd07b..94729a724eba 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/hashicorp/terraform-provider-azurerm require ( github.com/Azure/azure-sdk-for-go v66.0.0+incompatible - github.com/Azure/go-autorest/autorest v0.11.27 + github.com/Azure/go-autorest/autorest v0.11.28 github.com/Azure/go-autorest/autorest/date v0.3.0 github.com/Azure/go-autorest/autorest/to v0.4.0 github.com/Azure/go-autorest/autorest/validation v0.3.1 @@ -13,15 +13,15 @@ require ( github.com/gofrs/uuid v4.0.0+incompatible github.com/google/go-cmp v0.5.9 github.com/google/uuid v1.1.2 - github.com/hashicorp/go-azure-helpers v0.47.0 - github.com/hashicorp/go-azure-sdk v0.20230130.1140358 + github.com/hashicorp/go-azure-helpers v0.51.0 + github.com/hashicorp/go-azure-sdk v0.20230202.1112019 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/hashicorp/terraform-plugin-testing v1.0.0 github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8 - github.com/manicminer/hamilton v0.50.0 + github.com/manicminer/hamilton v0.55.0 github.com/mitchellh/mapstructure v1.5.0 github.com/rickb777/date v1.12.5-0.20200422084442-6300e543c4d9 github.com/sergi/go-diff v1.2.0 @@ -34,15 +34,15 @@ require ( require ( github.com/Azure/go-autorest v14.2.0+incompatible // indirect - github.com/Azure/go-autorest/autorest/adal v0.9.18 // indirect - github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 // indirect + github.com/Azure/go-autorest/autorest/adal v0.9.22 // indirect + github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect github.com/Azure/go-autorest/logger v0.2.1 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg v1.0.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/dimchansky/utfbom v1.1.1 // indirect github.com/fatih/color v1.13.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.1 // indirect + github.com/golang-jwt/jwt/v4 v4.4.3 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect @@ -50,7 +50,7 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect github.com/hashicorp/go-hclog v1.4.0 // indirect github.com/hashicorp/go-plugin v1.4.8 // indirect - github.com/hashicorp/go-retryablehttp v0.7.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.2 // indirect github.com/hashicorp/hc-install v0.4.0 // indirect github.com/hashicorp/hcl/v2 v2.15.0 // indirect github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80 // indirect @@ -62,7 +62,7 @@ require ( github.com/hashicorp/terraform-registry-address v0.1.0 // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864 // indirect - github.com/manicminer/hamilton-autorest v0.2.0 // indirect + github.com/manicminer/hamilton-autorest v0.3.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -77,7 +77,7 @@ require ( github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.12.1 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect - golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 // indirect + golang.org/x/oauth2 v0.4.0 // indirect golang.org/x/sys v0.4.0 // indirect golang.org/x/text v0.6.0 // indirect golang.org/x/tools v0.1.12 // indirect diff --git a/go.sum b/go.sum index ee43ae8b53ba..108709cbb69c 100644 --- a/go.sum +++ b/go.sum @@ -40,18 +40,19 @@ github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSW github.com/Azure/go-autorest/autorest v0.11.3/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= github.com/Azure/go-autorest/autorest v0.11.19/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= github.com/Azure/go-autorest/autorest v0.11.24/go.mod h1:G6kyRlFnTuSbEYkQGawPfsCswgme4iYf6rfSKUDzbCc= -github.com/Azure/go-autorest/autorest v0.11.27 h1:F3R3q42aWytozkV8ihzcgMO4OA4cuqr3bNlsEuF6//A= -github.com/Azure/go-autorest/autorest v0.11.27/go.mod h1:7l8ybrIdUmGqZMTD0sRtAr8NvbHjfofbf8RSP2q7w7U= +github.com/Azure/go-autorest/autorest v0.11.28 h1:ndAExarwr5Y+GaHE6VCaY1kyS/HwwGGyuimVhWsHOEM= +github.com/Azure/go-autorest/autorest v0.11.28/go.mod h1:MrkzG3Y3AH668QyF9KRk5neJnGgmhQ6krbhR8Q5eMvA= github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= github.com/Azure/go-autorest/autorest/adal v0.9.14/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= -github.com/Azure/go-autorest/autorest/adal v0.9.18 h1:kLnPsRjzZZUF3K5REu/Kc+qMQrvuza2bwSnNdhmzLfQ= github.com/Azure/go-autorest/autorest/adal v0.9.18/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ= +github.com/Azure/go-autorest/autorest/adal v0.9.22 h1:/GblQdIudfEM3AWWZ0mrYJQSd7JS4S/Mbzh6F0ov0Xc= +github.com/Azure/go-autorest/autorest/adal v0.9.22/go.mod h1:XuAbAEUv2Tta//+voMI038TrJBqjKam0me7qR+L8Cmk= github.com/Azure/go-autorest/autorest/azure/cli v0.4.0/go.mod h1:JljT387FplPzBA31vUcvsetLKF3pec5bdAxjVU4kI2s= github.com/Azure/go-autorest/autorest/azure/cli v0.4.2/go.mod h1:7qkJkT+j6b+hIpzMOwPChJhTqS8VbsqqgULzMNRugoM= -github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 h1:0W/yGmFdTIT77fvdlGZ0LMISoLHFJ7Tx4U0yeB+uFs4= -github.com/Azure/go-autorest/autorest/azure/cli v0.4.5/go.mod h1:ADQAXrkgm7acgWVUNamOgh8YNrv4p27l3Wc55oVfpzg= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 h1:w77/uPk80ZET2F+AfQExZyEWtn+0Rk/uw17m9fv5Ajc= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.6/go.mod h1:piCfgPho7BiIDdEQ1+g4VmKyD5y+p/XtSNqE6Hc4QD0= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= @@ -141,8 +142,8 @@ github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPh github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= -github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ= -github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= +github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -204,10 +205,10 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-azure-helpers v0.12.0/go.mod h1:Zc3v4DNeX6PDdy7NljlYpnrdac1++qNW0I4U+ofGwpg= -github.com/hashicorp/go-azure-helpers v0.47.0 h1:E90ZN2hqMtzI+tfGWCnNtyLZYG4csoKSs+hWZZ8ywSM= -github.com/hashicorp/go-azure-helpers v0.47.0/go.mod h1:WiJNl0fD6PoM/MYuGTZ8yuzIaXQR3m2H2g6+EJ8nSwc= -github.com/hashicorp/go-azure-sdk v0.20230130.1140358 h1:2Z/r04wEbS5E/pHB/QuRicbKKJJZAZFx/Qg+/9uh/I8= -github.com/hashicorp/go-azure-sdk v0.20230130.1140358/go.mod h1:SFjw1090GggVoFnsRoFb8J5JUyJEz5C9zGojxtJm+kU= +github.com/hashicorp/go-azure-helpers v0.51.0 h1:8KSDGkGnWH6zOT60R3KUqsi0fk1vA7AMunaOUJZMM6k= +github.com/hashicorp/go-azure-helpers v0.51.0/go.mod h1:lsykLR4KjTUO7MiRmNWiTiX8QQtw3ILjyOvT0f5h3rw= +github.com/hashicorp/go-azure-sdk v0.20230202.1112019 h1:8E+rHeHJ2eaQ1MTWXtPp5FBIAiKE9sKsQ5cd+NThsPg= +github.com/hashicorp/go-azure-sdk v0.20230202.1112019/go.mod h1:Rx0agw+UlqcYIWQMH1qkzK5MfxCVmLv9p3HwyHzGdWY= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -225,8 +226,9 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= -github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4= github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= +github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-uuid v1.0.0/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-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= @@ -291,10 +293,10 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8 h1:HHSqLmPZaa8U66U7N2Gtx3gYptSHrUB/rB5t+6fZTkQ= github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8/go.mod h1:iMzpAzVr2v/NUVie/apAYtZlFZYFndPcp6/E0VLxgAM= github.com/manicminer/hamilton v0.43.0/go.mod h1:lbVyngC+/nCWuDp8UhC6Bw+bh7jcP/E+YwqzHTmzemk= -github.com/manicminer/hamilton v0.50.0 h1:EPne7iH6zbXUPPjP/XZvqXzmqkt1WyF5X1A21uosPM4= -github.com/manicminer/hamilton v0.50.0/go.mod h1:lbVyngC+/nCWuDp8UhC6Bw+bh7jcP/E+YwqzHTmzemk= -github.com/manicminer/hamilton-autorest v0.2.0 h1:dDL+t2DrQza0EfNYINYCvXISeNwVqzgVAQh+CH/19ZU= -github.com/manicminer/hamilton-autorest v0.2.0/go.mod h1:NselDpNTImEmOc/fa41kPg6YhDt/6S95ejWbTGZ6tlg= +github.com/manicminer/hamilton v0.55.0 h1:o8kLLmtVnwuS09V1iv0ZIfBNiVjPbLBJYeLORHHM/Bg= +github.com/manicminer/hamilton v0.55.0/go.mod h1:lbVyngC+/nCWuDp8UhC6Bw+bh7jcP/E+YwqzHTmzemk= +github.com/manicminer/hamilton-autorest v0.3.0 h1:dCj5Sy3xipwqhkhJxZRftM0a56SKkWnTZv7uliGjECo= +github.com/manicminer/hamilton-autorest v0.3.0/go.mod h1:NselDpNTImEmOc/fa41kPg6YhDt/6S95ejWbTGZ6tlg= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= @@ -392,6 +394,7 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -472,8 +475,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 h1:3B43BWw0xEBsLZ/NO1VALz6fppU3481pik+2Ksv45z8= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= +golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/internal/services/managedidentity/federated_identity_credential_resource.go b/internal/services/managedidentity/federated_identity_credential_resource.go index d920f5b6ab8d..7fcd03fa372a 100644 --- a/internal/services/managedidentity/federated_identity_credential_resource.go +++ b/internal/services/managedidentity/federated_identity_credential_resource.go @@ -60,9 +60,11 @@ func (r FederatedIdentityCredentialResource) Arguments() map[string]*pluginsdk.S }, "resource_group_name": commonschema.ResourceGroupName(), "parent_id": { - ForceNew: true, - Required: true, - Type: pluginsdk.TypeString, + // TODO: this wants renaming to `user_assigned_identity_id` (and `resource_group_name` removing in 4.0) + Type: pluginsdk.TypeString, + ForceNew: true, + Required: true, + ValidateFunc: commonids.ValidateUserAssignedIdentityID, }, "subject": { ForceNew: true, @@ -94,7 +96,7 @@ func (r FederatedIdentityCredentialResource) Create() sdk.ResourceFunc { locks.ByID(parentId.ID()) defer locks.UnlockByID(parentId.ID()) - id := managedidentities.NewFederatedIdentityCredentialID(subscriptionId, config.ResourceGroupName, parentId.ResourceName, config.Name) + id := managedidentities.NewFederatedIdentityCredentialID(subscriptionId, config.ResourceGroupName, parentId.UserAssignedIdentityName, config.Name) existing, err := client.FederatedIdentityCredentialsGet(ctx, id) if err != nil { diff --git a/internal/services/managedidentity/user_assigned_identity_resource_gen.go b/internal/services/managedidentity/user_assigned_identity_resource_gen.go index 76e68bf07e62..712d89406962 100644 --- a/internal/services/managedidentity/user_assigned_identity_resource_gen.go +++ b/internal/services/managedidentity/user_assigned_identity_resource_gen.go @@ -131,7 +131,7 @@ func (r UserAssignedIdentityResource) Read() sdk.ResourceFunc { } if model := resp.Model; model != nil { - schema.Name = id.ResourceName + schema.Name = id.UserAssignedIdentityName schema.ResourceGroupName = id.ResourceGroupName if err := r.mapIdentityToUserAssignedIdentityResourceSchema(*model, &schema); err != nil { return fmt.Errorf("flattening model: %+v", err) diff --git a/vendor/github.com/Azure/go-autorest/autorest/adal/README.md b/vendor/github.com/Azure/go-autorest/autorest/adal/README.md index fec416a9c415..b11eb07884b0 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/adal/README.md +++ b/vendor/github.com/Azure/go-autorest/autorest/adal/README.md @@ -1,3 +1,5 @@ +# NOTE: This module will go out of support by March 31, 2023. For authenticating with Azure AD, use module [azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity) instead. For help migrating from `adal` to `azidentiy` please consult the [migration guide](https://aka.ms/azsdk/go/identity/migration). General information about the retirement of this and other legacy modules can be found [here](https://azure.microsoft.com/updates/support-for-azure-sdk-libraries-that-do-not-conform-to-our-current-azure-sdk-guidelines-will-be-retired-as-of-31-march-2023/). + # Azure Active Directory authentication for Go This is a standalone package for authenticating with Azure Active @@ -18,7 +20,7 @@ go get -u github.com/Azure/go-autorest/autorest/adal ## Usage -An Active Directory application is required in order to use this library. An application can be registered in the [Azure Portal](https://portal.azure.com/) by following these [guidelines](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications) or using the [Azure CLI](https://github.com/Azure/azure-cli). +An Active Directory application is required in order to use this library. An application can be registered in the [Azure Portal](https://portal.azure.com/) by following these [guidelines](https://docs.microsoft.com/azure/active-directory/develop/active-directory-integrating-applications) or using the [Azure CLI](https://github.com/Azure/azure-cli). ### Register an Azure AD Application with secret @@ -88,7 +90,7 @@ An Active Directory application is required in order to use this library. An app ### Grant the necessary permissions Azure relies on a Role-Based Access Control (RBAC) model to manage the access to resources at a fine-grained -level. There is a set of [pre-defined roles](https://docs.microsoft.com/en-us/azure/active-directory/role-based-access-built-in-roles) +level. There is a set of [pre-defined roles](https://docs.microsoft.com/azure/active-directory/role-based-access-built-in-roles) which can be assigned to a service principal of an Azure AD application depending of your needs. ``` @@ -104,7 +106,7 @@ It is also possible to define custom role definitions. az role definition create --role-definition role-definition.json ``` -* Check [custom roles](https://docs.microsoft.com/en-us/azure/active-directory/role-based-access-control-custom-roles) for more details regarding the content of `role-definition.json` file. +* Check [custom roles](https://docs.microsoft.com/azure/active-directory/role-based-access-control-custom-roles) for more details regarding the content of `role-definition.json` file. ### Acquire Access Token diff --git a/vendor/github.com/Azure/go-autorest/autorest/adal/token.go b/vendor/github.com/Azure/go-autorest/autorest/adal/token.go index 310be07ec335..c90209a9484a 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/adal/token.go +++ b/vendor/github.com/Azure/go-autorest/autorest/adal/token.go @@ -177,7 +177,7 @@ func (t Token) WillExpireIn(d time.Duration) bool { return !t.Expires().After(time.Now().Add(d)) } -//OAuthToken return the current access token +// OAuthToken return the current access token func (t *Token) OAuthToken() string { return t.AccessToken } @@ -365,6 +365,25 @@ func (secret ServicePrincipalAuthorizationCodeSecret) MarshalJSON() ([]byte, err }) } +// ServicePrincipalFederatedSecret implements ServicePrincipalSecret for Federated JWTs. +type ServicePrincipalFederatedSecret struct { + jwt string +} + +// SetAuthenticationValues is a method of the interface ServicePrincipalSecret. +// It will populate the form submitted during OAuth Token Acquisition using a JWT signed by an OIDC issuer. +func (secret *ServicePrincipalFederatedSecret) SetAuthenticationValues(spt *ServicePrincipalToken, v *url.Values) error { + + v.Set("client_assertion", secret.jwt) + v.Set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer") + return nil +} + +// MarshalJSON implements the json.Marshaler interface. +func (secret ServicePrincipalFederatedSecret) MarshalJSON() ([]byte, error) { + return nil, errors.New("marshalling ServicePrincipalFederatedSecret is not supported") +} + // ServicePrincipalToken encapsulates a Token created for a Service Principal. type ServicePrincipalToken struct { inner servicePrincipalToken @@ -419,6 +438,8 @@ func (spt *ServicePrincipalToken) UnmarshalJSON(data []byte) error { spt.inner.Secret = &ServicePrincipalUsernamePasswordSecret{} case "ServicePrincipalAuthorizationCodeSecret": spt.inner.Secret = &ServicePrincipalAuthorizationCodeSecret{} + case "ServicePrincipalFederatedSecret": + return errors.New("unmarshalling ServicePrincipalFederatedSecret is not supported") default: return fmt.Errorf("unrecognized token type '%s'", secret["type"]) } @@ -665,6 +686,31 @@ func NewServicePrincipalTokenFromAuthorizationCode(oauthConfig OAuthConfig, clie ) } +// NewServicePrincipalTokenFromFederatedToken creates a ServicePrincipalToken from the supplied federated OIDC JWT. +func NewServicePrincipalTokenFromFederatedToken(oauthConfig OAuthConfig, clientID string, jwt string, resource string, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) { + if err := validateOAuthConfig(oauthConfig); err != nil { + return nil, err + } + if err := validateStringParam(clientID, "clientID"); err != nil { + return nil, err + } + if err := validateStringParam(resource, "resource"); err != nil { + return nil, err + } + if jwt == "" { + return nil, fmt.Errorf("parameter 'jwt' cannot be empty") + } + return NewServicePrincipalTokenWithSecret( + oauthConfig, + clientID, + resource, + &ServicePrincipalFederatedSecret{ + jwt: jwt, + }, + callbacks..., + ) +} + type msiType int const ( @@ -1058,8 +1104,8 @@ func (spt *ServicePrincipalToken) refreshInternal(ctx context.Context, resource // AAD returns expires_in as a string, ADFS returns it as an int ExpiresIn json.Number `json:"expires_in"` - // expires_on can be in two formats, a UTC time stamp or the number of seconds. - ExpiresOn string `json:"expires_on"` + // expires_on can be in three formats, a UTC time stamp, or the number of seconds as a string *or* int. + ExpiresOn interface{} `json:"expires_on"` NotBefore json.Number `json:"not_before"` Resource string `json:"resource"` @@ -1072,7 +1118,7 @@ func (spt *ServicePrincipalToken) refreshInternal(ctx context.Context, resource } expiresOn := json.Number("") // ADFS doesn't include the expires_on field - if token.ExpiresOn != "" { + if token.ExpiresOn != nil { if expiresOn, err = parseExpiresOn(token.ExpiresOn); err != nil { return newTokenRefreshError(fmt.Sprintf("adal: failed to parse expires_on: %v value '%s'", err, token.ExpiresOn), resp) } @@ -1089,18 +1135,27 @@ func (spt *ServicePrincipalToken) refreshInternal(ctx context.Context, resource } // converts expires_on to the number of seconds -func parseExpiresOn(s string) (json.Number, error) { - // convert the expiration date to the number of seconds from now +func parseExpiresOn(s interface{}) (json.Number, error) { + // the JSON unmarshaler treats JSON numbers unmarshaled into an interface{} as float64 + asFloat64, ok := s.(float64) + if ok { + // this is the number of seconds as int case + return json.Number(strconv.FormatInt(int64(asFloat64), 10)), nil + } + asStr, ok := s.(string) + if !ok { + return "", fmt.Errorf("unexpected expires_on type %T", s) + } + // convert the expiration date to the number of seconds from the unix epoch timeToDuration := func(t time.Time) json.Number { - dur := t.Sub(time.Now().UTC()) - return json.Number(strconv.FormatInt(int64(dur.Round(time.Second).Seconds()), 10)) + return json.Number(strconv.FormatInt(t.UTC().Unix(), 10)) } - if _, err := strconv.ParseInt(s, 10, 64); err == nil { + if _, err := json.Number(asStr).Int64(); err == nil { // this is the number of seconds case, no conversion required - return json.Number(s), nil - } else if eo, err := time.Parse(expiresOnDateFormatPM, s); err == nil { + return json.Number(asStr), nil + } else if eo, err := time.Parse(expiresOnDateFormatPM, asStr); err == nil { return timeToDuration(eo), nil - } else if eo, err := time.Parse(expiresOnDateFormat, s); err == nil { + } else if eo, err := time.Parse(expiresOnDateFormat, asStr); err == nil { return timeToDuration(eo), nil } else { // unknown format @@ -1317,12 +1372,25 @@ func NewMultiTenantServicePrincipalTokenFromCertificate(multiTenantCfg MultiTena // MSIAvailable returns true if the MSI endpoint is available for authentication. func MSIAvailable(ctx context.Context, s Sender) bool { + msiType, _, err := getMSIType() + + if err != nil { + return false + } + + if msiType != msiTypeIMDS { + return true + } + if s == nil { s = sender() } + resp, err := getMSIEndpoint(ctx, s) + if err == nil { resp.Body.Close() } + return err == nil } diff --git a/vendor/github.com/golang-jwt/jwt/v4/README.md b/vendor/github.com/golang-jwt/jwt/v4/README.md index 01b21646e015..30f2f2a6f70c 100644 --- a/vendor/github.com/golang-jwt/jwt/v4/README.md +++ b/vendor/github.com/golang-jwt/jwt/v4/README.md @@ -36,24 +36,39 @@ The part in the middle is the interesting bit. It's called the Claims and conta This library supports the parsing and verification as well as the generation and signing of JWTs. Current supported signing algorithms are HMAC SHA, RSA, RSA-PSS, and ECDSA, though hooks are present for adding your own. +## Installation Guidelines + +1. To install the jwt package, you first need to have [Go](https://go.dev/doc/install) installed, then you can use the command below to add `jwt-go` as a dependency in your Go program. + +```sh +go get -u github.com/golang-jwt/jwt/v4 +``` + +2. Import it in your code: + +```go +import "github.com/golang-jwt/jwt/v4" +``` + ## Examples -See [the project documentation](https://pkg.go.dev/github.com/golang-jwt/jwt) for examples of usage: +See [the project documentation](https://pkg.go.dev/github.com/golang-jwt/jwt/v4) for examples of usage: -* [Simple example of parsing and validating a token](https://pkg.go.dev/github.com/golang-jwt/jwt#example-Parse-Hmac) -* [Simple example of building and signing a token](https://pkg.go.dev/github.com/golang-jwt/jwt#example-New-Hmac) -* [Directory of Examples](https://pkg.go.dev/github.com/golang-jwt/jwt#pkg-examples) +* [Simple example of parsing and validating a token](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#example-Parse-Hmac) +* [Simple example of building and signing a token](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#example-New-Hmac) +* [Directory of Examples](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#pkg-examples) ## Extensions -This library publishes all the necessary components for adding your own signing methods. Simply implement the `SigningMethod` interface and register a factory method using `RegisterSigningMethod`. +This library publishes all the necessary components for adding your own signing methods or key functions. Simply implement the `SigningMethod` interface and register a factory method using `RegisterSigningMethod` or provide a `jwt.Keyfunc`. -A common use case would be integrating with different 3rd party signature providers, like key management services from various cloud providers or Hardware Security Modules (HSMs). +A common use case would be integrating with different 3rd party signature providers, like key management services from various cloud providers or Hardware Security Modules (HSMs) or to implement additional standards. -| Extension | Purpose | Repo | -|-----------|----------------------------------------------------------------------------------------------|--------------------------------------------| -| GCP | Integrates with multiple Google Cloud Platform signing tools (AppEngine, IAM API, Cloud KMS) | https://github.com/someone1/gcp-jwt-go | -| AWS | Integrates with AWS Key Management Service, KMS | https://github.com/matelang/jwt-go-aws-kms | +| Extension | Purpose | Repo | +| --------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------ | +| GCP | Integrates with multiple Google Cloud Platform signing tools (AppEngine, IAM API, Cloud KMS) | https://github.com/someone1/gcp-jwt-go | +| AWS | Integrates with AWS Key Management Service, KMS | https://github.com/matelang/jwt-go-aws-kms | +| JWKS | Provides support for JWKS ([RFC 7517](https://datatracker.ietf.org/doc/html/rfc7517)) as a `jwt.Keyfunc` | https://github.com/MicahParks/keyfunc | *Disclaimer*: Unless otherwise specified, these integrations are maintained by third parties and should not be considered as a primary offer by any of the mentioned cloud providers @@ -81,7 +96,7 @@ A token is simply a JSON object that is signed by its author. this tells you exa * The author of the token was in the possession of the signing secret * The data has not been modified since it was signed -It's important to know that JWT does not provide encryption, which means anyone who has access to the token can read its contents. If you need to protect (encrypt) the data, there is a companion spec, `JWE`, that provides this functionality. JWE is currently outside the scope of this library. +It's important to know that JWT does not provide encryption, which means anyone who has access to the token can read its contents. If you need to protect (encrypt) the data, there is a companion spec, `JWE`, that provides this functionality. The companion project https://github.com/golang-jwt/jwe aims at a (very) experimental implementation of the JWE standard. ### Choosing a Signing Method @@ -95,10 +110,10 @@ Asymmetric signing methods, such as RSA, use different keys for signing and veri Each signing method expects a different object type for its signing keys. See the package documentation for details. Here are the most common ones: -* The [HMAC signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation -* The [RSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation -* The [ECDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation -* The [EdDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodEd25519) (`Ed25519`) expect `ed25519.PrivateKey` for signing and `ed25519.PublicKey` for validation +* The [HMAC signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation +* The [RSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation +* The [ECDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation +* The [EdDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodEd25519) (`Ed25519`) expect `ed25519.PrivateKey` for signing and `ed25519.PublicKey` for validation ### JWT and OAuth @@ -116,7 +131,7 @@ This library uses descriptive error messages whenever possible. If you are not g ## More -Documentation can be found [on pkg.go.dev](https://pkg.go.dev/github.com/golang-jwt/jwt). +Documentation can be found [on pkg.go.dev](https://pkg.go.dev/github.com/golang-jwt/jwt/v4). The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in the documentation. diff --git a/vendor/github.com/golang-jwt/jwt/v4/SECURITY.md b/vendor/github.com/golang-jwt/jwt/v4/SECURITY.md new file mode 100644 index 000000000000..b08402c3427f --- /dev/null +++ b/vendor/github.com/golang-jwt/jwt/v4/SECURITY.md @@ -0,0 +1,19 @@ +# Security Policy + +## Supported Versions + +As of February 2022 (and until this document is updated), the latest version `v4` is supported. + +## Reporting a Vulnerability + +If you think you found a vulnerability, and even if you are not sure, please report it to jwt-go-security@googlegroups.com or one of the other [golang-jwt maintainers](https://github.com/orgs/golang-jwt/people). Please try be explicit, describe steps to reproduce the security issue with code example(s). + +You will receive a response within a timely manner. If the issue is confirmed, we will do our best to release a patch as soon as possible given the complexity of the problem. + +## Public Discussions + +Please avoid publicly discussing a potential security vulnerability. + +Let's take this offline and find a solution first, this limits the potential impact as much as possible. + +We appreciate your help! diff --git a/vendor/github.com/golang-jwt/jwt/v4/claims.go b/vendor/github.com/golang-jwt/jwt/v4/claims.go index 9d95cad2bf27..364cec8773cd 100644 --- a/vendor/github.com/golang-jwt/jwt/v4/claims.go +++ b/vendor/github.com/golang-jwt/jwt/v4/claims.go @@ -265,9 +265,5 @@ func verifyIss(iss string, cmp string, required bool) bool { if iss == "" { return !required } - if subtle.ConstantTimeCompare([]byte(iss), []byte(cmp)) != 0 { - return true - } else { - return false - } + return subtle.ConstantTimeCompare([]byte(iss), []byte(cmp)) != 0 } diff --git a/vendor/github.com/golang-jwt/jwt/v4/parser.go b/vendor/github.com/golang-jwt/jwt/v4/parser.go index 2f61a69d7fcb..c0a6f6927917 100644 --- a/vendor/github.com/golang-jwt/jwt/v4/parser.go +++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go @@ -42,6 +42,13 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc) } +// ParseWithClaims parses, validates, and verifies like Parse, but supplies a default object implementing the Claims +// interface. This provides default values which can be overridden and allows a caller to use their own type, rather +// than the default MapClaims implementation of Claims. +// +// Note: If you provide a custom claim implementation that embeds one of the standard claims (such as RegisteredClaims), +// make sure that a) you either embed a non-pointer version of the claims or b) if you are using a pointer, allocate the +// proper memory for it before passing in the overall claims, otherwise you might run into a panic. func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) { token, parts, err := p.ParseUnverified(tokenString, claims) if err != nil { diff --git a/vendor/github.com/golang-jwt/jwt/v4/rsa_pss.go b/vendor/github.com/golang-jwt/jwt/v4/rsa_pss.go index 5a8502feb34b..4fd6f9e610b0 100644 --- a/vendor/github.com/golang-jwt/jwt/v4/rsa_pss.go +++ b/vendor/github.com/golang-jwt/jwt/v4/rsa_pss.go @@ -1,3 +1,4 @@ +//go:build go1.4 // +build go1.4 package jwt diff --git a/vendor/github.com/golang-jwt/jwt/v4/token.go b/vendor/github.com/golang-jwt/jwt/v4/token.go index 09b4cde5aebd..71e909ea6538 100644 --- a/vendor/github.com/golang-jwt/jwt/v4/token.go +++ b/vendor/github.com/golang-jwt/jwt/v4/token.go @@ -7,7 +7,6 @@ import ( "time" ) - // DecodePaddingAllowed will switch the codec used for decoding JWTs respectively. Note that the JWS RFC7515 // states that the tokens will utilize a Base64url encoding with no padding. Unfortunately, some implementations // of JWT are producing non-standard tokens, and thus require support for decoding. Note that this is a global @@ -100,6 +99,11 @@ func Parse(tokenString string, keyFunc Keyfunc, options ...ParserOption) (*Token return NewParser(options...).Parse(tokenString, keyFunc) } +// ParseWithClaims is a shortcut for NewParser().ParseWithClaims(). +// +// Note: If you provide a custom claim implementation that embeds one of the standard claims (such as RegisteredClaims), +// make sure that a) you either embed a non-pointer version of the claims or b) if you are using a pointer, allocate the +// proper memory for it before passing in the overall claims, otherwise you might run into a panic. func ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc, options ...ParserOption) (*Token, error) { return NewParser(options...).ParseWithClaims(tokenString, claims, keyFunc) } diff --git a/vendor/github.com/golang-jwt/jwt/v4/types.go b/vendor/github.com/golang-jwt/jwt/v4/types.go index 2c647fd2e6d2..ac8e140eb119 100644 --- a/vendor/github.com/golang-jwt/jwt/v4/types.go +++ b/vendor/github.com/golang-jwt/jwt/v4/types.go @@ -53,9 +53,23 @@ func (date NumericDate) MarshalJSON() (b []byte, err error) { if TimePrecision < time.Second { prec = int(math.Log10(float64(time.Second) / float64(TimePrecision))) } - f := float64(date.Truncate(TimePrecision).UnixNano()) / float64(time.Second) - - return []byte(strconv.FormatFloat(f, 'f', prec, 64)), nil + truncatedDate := date.Truncate(TimePrecision) + + // For very large timestamps, UnixNano would overflow an int64, but this + // function requires nanosecond level precision, so we have to use the + // following technique to get round the issue: + // 1. Take the normal unix timestamp to form the whole number part of the + // output, + // 2. Take the result of the Nanosecond function, which retuns the offset + // within the second of the particular unix time instance, to form the + // decimal part of the output + // 3. Concatenate them to produce the final result + seconds := strconv.FormatInt(truncatedDate.Unix(), 10) + nanosecondsOffset := strconv.FormatFloat(float64(truncatedDate.Nanosecond())/float64(time.Second), 'f', prec, 64) + + output := append([]byte(seconds), []byte(nanosecondsOffset)[1:]...) + + return output, nil } // UnmarshalJSON is an implementation of the json.RawMessage interface and deserializses a diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method.go index dc8e90fbd0aa..0b5f05435542 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token.go index 6ec47d395840..91f810245208 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token_multi_tenant.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token_multi_tenant.go index 4b2245700eb9..c867331c34c5 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token_multi_tenant.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_azure_cli_token_multi_tenant.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_cert.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_cert.go index 843457b21424..6a537ede9835 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_cert.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_cert.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret.go index a7bc16020f5f..491a8ca6f1bd 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret_multi_tenant.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret_multi_tenant.go index 702976627a95..53e2e6b12e3e 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret_multi_tenant.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_client_secret_multi_tenant.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_msi.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_msi.go index c6ca3070fd0d..22f80ad6b234 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_msi.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_msi.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_oidc.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_oidc.go index 9f67922c31cf..ac3edb8d32d4 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_oidc.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/auth_method_oidc.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant.go index 78cf454ada8b..ef8409cef6de 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant_population.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant_population.go index 570a762bf0ef..78c39904f0d3 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant_population.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_cli_profile_multi_tenant_population.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_sp_objectid.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_sp_objectid.go index b5cebac095e1..67484a1eff1f 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_sp_objectid.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/azure_sp_objectid.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( @@ -199,11 +202,12 @@ func objectIdFromMsGraph(ctx context.Context, c *Config) (*string, error) { return nil, fmt.Errorf("unexpected Service Principal query result, was nil") } - if len(*result) != 1 || (*result)[0].ID == nil { + if len(*result) != 1 || (*result)[0].ID() == nil { return nil, fmt.Errorf("unexpected Service Principal query result: %+v", *result) } - return (*result)[0].ID, nil + val := (*result)[0] + return val.ID(), nil } func hamiltonRequestLogger(req *http.Request) (*http.Request, error) { diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/builder.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/builder.go index 55cb6bd7b626..643f5e6d14ee 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/builder.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/builder.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/config.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/config.go index cda3a1fb93d2..013a726c8966 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/config.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/config.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/authentication/environment.go b/vendor/github.com/hashicorp/go-azure-helpers/authentication/environment.go index fe0a53806680..cca46dff748f 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/authentication/environment.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/authentication/environment.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package authentication import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/lang/dates/parse.go b/vendor/github.com/hashicorp/go-azure-helpers/lang/dates/parse.go index 02b8ab85976b..f1fbf22bd952 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/lang/dates/parse.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/lang/dates/parse.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package dates import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/from.go b/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/from.go index e0067ffb2c04..15931af36164 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/from.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/from.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package pointer // FromBool turns a boolean into a pointer to a boolean diff --git a/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/generic.go b/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/generic.go index 61ec94ee1675..0598a9e99b90 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/generic.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/generic.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package pointer // From is a generic function that returns the value of a pointer diff --git a/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/to.go b/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/to.go index 7f607dc20010..861c1978f537 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/to.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/lang/pointer/to.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package pointer // ToBool turns a pointer to a bool into a bool, returning the default value for a bool if it's nil diff --git a/vendor/github.com/hashicorp/go-azure-helpers/lang/response/response.go b/vendor/github.com/hashicorp/go-azure-helpers/lang/response/response.go index 74495589d8bc..1fdaaeb08df6 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/lang/response/response.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/lang/response/response.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package response import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/polling/poller.go b/vendor/github.com/hashicorp/go-azure-helpers/polling/poller.go index d08c4889e02a..fca47a5daa0a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/polling/poller.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/polling/poller.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package polling import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_ip_configuration.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_ip_configuration.go index c7044a5585ee..3d65ec80f352 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_ip_configuration.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_ip_configuration.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_public_ip.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_public_ip.go index 6f07aa560619..ff4c6eb4bdc7 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_public_ip.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/cloud_services_public_ip.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/express_route_circuit_peering.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/express_route_circuit_peering.go index 4af2439cfd9b..87dac48e9d98 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/express_route_circuit_peering.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/express_route_circuit_peering.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_job.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_job.go new file mode 100644 index 000000000000..3c8f1cf55218 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_job.go @@ -0,0 +1,137 @@ +package commonids + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = HyperVSiteJobId{} + +// HyperVSiteJobId is a struct representing the Resource ID for a Hyper V Site Job +type HyperVSiteJobId struct { + SubscriptionId string + ResourceGroupName string + HyperVSiteName string + JobName string +} + +// NewHyperVSiteJobID returns a new HyperVSiteJobId struct +func NewHyperVSiteJobID(subscriptionId string, resourceGroupName string, hyperVSiteName string, jobName string) HyperVSiteJobId { + return HyperVSiteJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HyperVSiteName: hyperVSiteName, + JobName: jobName, + } +} + +// ParseHyperVSiteJobID parses 'input' into a HyperVSiteJobId +func ParseHyperVSiteJobID(input string) (*HyperVSiteJobId, error) { + parser := resourceids.NewParserFromResourceIdType(HyperVSiteJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := HyperVSiteJobId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.HyperVSiteName, ok = parsed.Parsed["hyperVSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'hyperVSiteName' was not found in the resource id %q", input) + } + + if id.JobName, ok = parsed.Parsed["jobName"]; !ok { + return nil, fmt.Errorf("the segment 'jobName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseHyperVSiteJobIDInsensitively parses 'input' case-insensitively into a HyperVSiteJobId +// note: this method should only be used for API response data and not user input +func ParseHyperVSiteJobIDInsensitively(input string) (*HyperVSiteJobId, error) { + parser := resourceids.NewParserFromResourceIdType(HyperVSiteJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := HyperVSiteJobId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.HyperVSiteName, ok = parsed.Parsed["hyperVSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'hyperVSiteName' was not found in the resource id %q", input) + } + + if id.JobName, ok = parsed.Parsed["jobName"]; !ok { + return nil, fmt.Errorf("the segment 'jobName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateHyperVSiteJobID checks that 'input' can be parsed as a Hyper V Site Job ID +func ValidateHyperVSiteJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHyperVSiteJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hyper V Site Job ID +func (id HyperVSiteJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OffAzure/hyperVSites/%s/jobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HyperVSiteName, id.JobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hyper V Site Job ID +func (id HyperVSiteJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOffAzure", "Microsoft.OffAzure", "Microsoft.OffAzure"), + resourceids.StaticSegment("staticHyperVSites", "hyperVSites", "hyperVSites"), + resourceids.UserSpecifiedSegment("hyperVSiteName", "hyperVSiteValue"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobNameValue"), + } +} + +// String returns a human-readable description of this Hyper V Site Job ID +func (id HyperVSiteJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hyper V Site Name: %q", id.HyperVSiteName), + fmt.Sprintf("Job Name: %q", id.JobName), + } + return fmt.Sprintf("Hyper V Site Job (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_machine.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_machine.go new file mode 100644 index 000000000000..1e9205ce34a2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_machine.go @@ -0,0 +1,137 @@ +package commonids + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = HyperVSiteMachineId{} + +// HyperVSiteMachineId is a struct representing the Resource ID for a Hyper V Site Machine +type HyperVSiteMachineId struct { + SubscriptionId string + ResourceGroupName string + HyperVSiteName string + MachineName string +} + +// NewHyperVSiteMachineID returns a new HyperVSiteMachineId struct +func NewHyperVSiteMachineID(subscriptionId string, resourceGroupName string, hyperVSiteName string, machineName string) HyperVSiteMachineId { + return HyperVSiteMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HyperVSiteName: hyperVSiteName, + MachineName: machineName, + } +} + +// ParseHyperVSiteMachineID parses 'input' into a HyperVSiteMachineId +func ParseHyperVSiteMachineID(input string) (*HyperVSiteMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(HyperVSiteMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := HyperVSiteMachineId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.HyperVSiteName, ok = parsed.Parsed["hyperVSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'hyperVSiteName' was not found in the resource id %q", input) + } + + if id.MachineName, ok = parsed.Parsed["machineName"]; !ok { + return nil, fmt.Errorf("the segment 'machineName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseHyperVSiteMachineIDInsensitively parses 'input' case-insensitively into a HyperVSiteMachineId +// note: this method should only be used for API response data and not user input +func ParseHyperVSiteMachineIDInsensitively(input string) (*HyperVSiteMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(HyperVSiteMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := HyperVSiteMachineId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.HyperVSiteName, ok = parsed.Parsed["hyperVSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'hyperVSiteName' was not found in the resource id %q", input) + } + + if id.MachineName, ok = parsed.Parsed["machineName"]; !ok { + return nil, fmt.Errorf("the segment 'machineName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateHyperVSiteMachineID checks that 'input' can be parsed as a Hyper V Site Machine ID +func ValidateHyperVSiteMachineID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHyperVSiteMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hyper V Site Machine ID +func (id HyperVSiteMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OffAzure/hyperVSites/%s/machines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HyperVSiteName, id.MachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hyper V Site Machine ID +func (id HyperVSiteMachineId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOffAzure", "Microsoft.OffAzure", "Microsoft.OffAzure"), + resourceids.StaticSegment("staticHyperVSites", "hyperVSites", "hyperVSites"), + resourceids.UserSpecifiedSegment("hyperVSiteName", "hyperVSiteValue"), + resourceids.StaticSegment("staticMachines", "machines", "machines"), + resourceids.UserSpecifiedSegment("machineName", "machineValue"), + } +} + +// String returns a human-readable description of this Hyper V Site Machine ID +func (id HyperVSiteMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hyper V Site Name: %q", id.HyperVSiteName), + fmt.Sprintf("Machine Name: %q", id.MachineName), + } + return fmt.Sprintf("Hyper V Site Machine (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_runasaccount.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_runasaccount.go new file mode 100644 index 000000000000..19a2956d2b0d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/hyperv_site_runasaccount.go @@ -0,0 +1,137 @@ +package commonids + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = HyperVSiteRunAsAccountId{} + +// HyperVSiteRunAsAccountId is a struct representing the Resource ID for a Hyper V Site Run As Account +type HyperVSiteRunAsAccountId struct { + SubscriptionId string + ResourceGroupName string + HyperVSiteName string + RunAsAccountName string +} + +// NewHyperVSiteRunAsAccountID returns a new HyperVSiteRunAsAccountId struct +func NewHyperVSiteRunAsAccountID(subscriptionId string, resourceGroupName string, hyperVSiteName string, runAsAccountName string) HyperVSiteRunAsAccountId { + return HyperVSiteRunAsAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HyperVSiteName: hyperVSiteName, + RunAsAccountName: runAsAccountName, + } +} + +// ParseHyperVSiteRunAsAccountID parses 'input' into a HyperVSiteRunAsAccountId +func ParseHyperVSiteRunAsAccountID(input string) (*HyperVSiteRunAsAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(HyperVSiteRunAsAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := HyperVSiteRunAsAccountId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.HyperVSiteName, ok = parsed.Parsed["hyperVSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'hyperVSiteName' was not found in the resource id %q", input) + } + + if id.RunAsAccountName, ok = parsed.Parsed["runAsAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'runAsAccountName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseHyperVSiteRunAsAccountIDInsensitively parses 'input' case-insensitively into a HyperVSiteRunAsAccountId +// note: this method should only be used for API response data and not user input +func ParseHyperVSiteRunAsAccountIDInsensitively(input string) (*HyperVSiteRunAsAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(HyperVSiteRunAsAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := HyperVSiteRunAsAccountId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.HyperVSiteName, ok = parsed.Parsed["hyperVSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'hyperVSiteName' was not found in the resource id %q", input) + } + + if id.RunAsAccountName, ok = parsed.Parsed["runAsAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'runAsAccountName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateHyperVSiteRunAsAccountID checks that 'input' can be parsed as a Hyper V Site Run As Account ID +func ValidateHyperVSiteRunAsAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHyperVSiteRunAsAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hyper V Site Run As Account ID +func (id HyperVSiteRunAsAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OffAzure/hyperVSites/%s/runAsAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HyperVSiteName, id.RunAsAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hyper V Site Run As Account ID +func (id HyperVSiteRunAsAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOffAzure", "Microsoft.OffAzure", "Microsoft.OffAzure"), + resourceids.StaticSegment("staticHyperVSites", "hyperVSites", "hyperVSites"), + resourceids.UserSpecifiedSegment("hyperVSiteName", "hyperVSiteValue"), + resourceids.StaticSegment("staticRunAsAccounts", "runAsAccounts", "runAsAccounts"), + resourceids.UserSpecifiedSegment("runAsAccountName", "runAsAccountNameValue"), + } +} + +// String returns a human-readable description of this Hyper V Site RunAsAccount ID +func (id HyperVSiteRunAsAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hyper V Site Name: %q", id.HyperVSiteName), + fmt.Sprintf("Run As Account Name: %q", id.RunAsAccountName), + } + return fmt.Sprintf("Hyper V Site Run As Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/management_group.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/management_group.go index 6ac466559443..85b9078c4f54 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/management_group.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/management_group.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface.go index 9160e851f71e..586fcb9301e3 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface_ip_configuration.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface_ip_configuration.go index 2b5df85d41d6..3c87e07d37da 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface_ip_configuration.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/network_interface_ip_configuration.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/provisioning_service.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/provisioning_service.go index a9b4598a40af..a19f98ca370c 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/provisioning_service.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/provisioning_service.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/public_ip_address.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/public_ip_address.go index 2c8016ff36a4..d1f05beba0f7 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/public_ip_address.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/public_ip_address.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/resource_group.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/resource_group.go index a0d4dd9b6d36..688affedae8f 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/resource_group.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/resource_group.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/scope.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/scope.go index 16fa1c2258f5..a68c87ba0ad7 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/scope.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/scope.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/subscription.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/subscription.go index 6309d72bbbcb..2b1b141d152a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/subscription.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/subscription.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/user_assigned_identity.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/user_assigned_identity.go index 55f28bf8f40b..e770693e3f6a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/user_assigned_identity.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/user_assigned_identity.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( @@ -11,17 +14,17 @@ var _ resourceids.ResourceId = UserAssignedIdentityId{} // UserAssignedIdentityId is a struct representing the Resource ID for a User Assigned Identity type UserAssignedIdentityId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string + SubscriptionId string + ResourceGroupName string + UserAssignedIdentityName string } // NewUserAssignedIdentityID returns a new UserAssignedIdentityId struct -func NewUserAssignedIdentityID(subscriptionId string, resourceGroupName string, resourceName string) UserAssignedIdentityId { +func NewUserAssignedIdentityID(subscriptionId string, resourceGroupName string, userAssignedIdentityName string) UserAssignedIdentityId { return UserAssignedIdentityId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + UserAssignedIdentityName: userAssignedIdentityName, } } @@ -44,8 +47,8 @@ func ParseUserAssignedIdentityID(input string) (*UserAssignedIdentityId, error) return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) } - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + if id.UserAssignedIdentityName, ok = parsed.Parsed["userAssignedIdentityName"]; !ok { + return nil, fmt.Errorf("the segment 'userAssignedIdentityName' was not found in the resource id %q", input) } return &id, nil @@ -71,8 +74,8 @@ func ParseUserAssignedIdentityIDInsensitively(input string) (*UserAssignedIdenti return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) } - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + if id.UserAssignedIdentityName, ok = parsed.Parsed["userAssignedIdentityName"]; !ok { + return nil, fmt.Errorf("the segment 'userAssignedIdentityName' was not found in the resource id %q", input) } return &id, nil @@ -96,7 +99,7 @@ func ValidateUserAssignedIdentityID(input interface{}, key string) (warnings []s // ID returns the formatted User Assigned Identity ID func (id UserAssignedIdentityId) ID() string { fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ManagedIdentity/userAssignedIdentities/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.UserAssignedIdentityName) } // Segments returns a slice of Resource ID Segments which comprise this User Assigned Identity ID @@ -109,7 +112,7 @@ func (id UserAssignedIdentityId) Segments() []resourceids.Segment { resourceids.StaticSegment("providers", "providers", "providers"), resourceids.ResourceProviderSegment("resourceProvider", "Microsoft.ManagedIdentity", "Microsoft.ManagedIdentity"), resourceids.StaticSegment("userAssignedIdentities", "userAssignedIdentities", "userAssignedIdentities"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + resourceids.UserSpecifiedSegment("userAssignedIdentityName", "userAssignedIdentityValue"), } } @@ -118,7 +121,7 @@ func (id UserAssignedIdentityId) String() string { components := []string{ fmt.Sprintf("Subscription: %q", id.SubscriptionId), fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), + fmt.Sprintf("Name: %q", id.UserAssignedIdentityName), } return fmt.Sprintf("User Assigned Identity (%s)", strings.Join(components, "\n")) } diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_bgp_connection.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_bgp_connection.go index 1ecdea809181..7304b7e59961 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_bgp_connection.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_bgp_connection.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_ip_configuration.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_ip_configuration.go index 90682f882e0f..9b98938c60fd 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_ip_configuration.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_hub_ip_configuration.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_ip_configuration.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_ip_configuration.go index 2ab313644c75..2b60f8611644 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_ip_configuration.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_ip_configuration.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_network_interface.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_network_interface.go index 818ec1598522..b097c60d8c2d 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_network_interface.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_network_interface.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_public_ip_address.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_public_ip_address.go index 681265bfdb3e..08bd4332c55b 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_public_ip_address.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_machine_scale_set_public_ip_address.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_router_peering.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_router_peering.go index ff560fbef6a8..015bf682773e 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_router_peering.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_router_peering.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_wan_p2s_vpn_gateway.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_wan_p2s_vpn_gateway.go index eda9a876307f..b410e13bc35b 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_wan_p2s_vpn_gateway.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/virtual_wan_p2s_vpn_gateway.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_job.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_job.go new file mode 100644 index 000000000000..6b02a27b7676 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_job.go @@ -0,0 +1,137 @@ +package commonids + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = VMwareSiteJobId{} + +// VMwareSiteJobId is a struct representing the Resource ID for a VMware Site Job +type VMwareSiteJobId struct { + SubscriptionId string + ResourceGroupName string + VMwareSiteName string + JobName string +} + +// NewVMwareSiteJobID returns a new VMwareSiteJobId struct +func NewVMwareSiteJobID(subscriptionId string, resourceGroupName string, vmwareSiteName string, jobName string) VMwareSiteJobId { + return VMwareSiteJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VMwareSiteName: vmwareSiteName, + JobName: jobName, + } +} + +// ParseVMwareSiteJobID parses 'input' into a VMwareSiteJobId +func ParseVMwareSiteJobID(input string) (*VMwareSiteJobId, error) { + parser := resourceids.NewParserFromResourceIdType(VMwareSiteJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VMwareSiteJobId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VMwareSiteName, ok = parsed.Parsed["vmwareSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'vmwareSiteName' was not found in the resource id %q", input) + } + + if id.JobName, ok = parsed.Parsed["jobName"]; !ok { + return nil, fmt.Errorf("the segment 'jobName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseVMwareSiteJobIDInsensitively parses 'input' case-insensitively into a VMwareSiteJobId +// note: this method should only be used for API response data and not user input +func ParseVMwareSiteJobIDInsensitively(input string) (*VMwareSiteJobId, error) { + parser := resourceids.NewParserFromResourceIdType(VMwareSiteJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VMwareSiteJobId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VMwareSiteName, ok = parsed.Parsed["vmwareSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'vmwareSiteName' was not found in the resource id %q", input) + } + + if id.JobName, ok = parsed.Parsed["jobName"]; !ok { + return nil, fmt.Errorf("the segment 'jobName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateVMwareSiteJobID checks that 'input' can be parsed as a VMware Site Job ID +func ValidateVMwareSiteJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVMwareSiteJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted VMware Site Job ID +func (id VMwareSiteJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OffAzure/vmwareSites/%s/jobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VMwareSiteName, id.JobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this VMware Site Job ID +func (id VMwareSiteJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOffAzure", "Microsoft.OffAzure", "Microsoft.OffAzure"), + resourceids.StaticSegment("staticVMwareSites", "vmwareSites", "vmwareSites"), + resourceids.UserSpecifiedSegment("vmwareSiteName", "vmwareSiteNameValue"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobNameValue"), + } +} + +// String returns a human-readable description of this VMware Site Job ID +func (id VMwareSiteJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("VMware Site Name: %q", id.VMwareSiteName), + fmt.Sprintf("Job Name: %q", id.JobName), + } + return fmt.Sprintf("VMware Site Job (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_machine.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_machine.go new file mode 100644 index 000000000000..57897933157f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_machine.go @@ -0,0 +1,137 @@ +package commonids + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = VMwareSiteMachineId{} + +// VMwareSiteMachineId is a struct representing the Resource ID for a VMware Site Machine +type VMwareSiteMachineId struct { + SubscriptionId string + ResourceGroupName string + VMwareSiteName string + MachineName string +} + +// NewVMwareSiteMachineID returns a new VMwareSiteMachineId struct +func NewVMwareSiteMachineID(subscriptionId string, resourceGroupName string, vmwareSiteName string, machineName string) VMwareSiteMachineId { + return VMwareSiteMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VMwareSiteName: vmwareSiteName, + MachineName: machineName, + } +} + +// ParseVMwareSiteMachineID parses 'input' into a VMwareSiteMachineId +func ParseVMwareSiteMachineID(input string) (*VMwareSiteMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(VMwareSiteMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VMwareSiteMachineId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VMwareSiteName, ok = parsed.Parsed["vmwareSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'vmwareSiteName' was not found in the resource id %q", input) + } + + if id.MachineName, ok = parsed.Parsed["machineName"]; !ok { + return nil, fmt.Errorf("the segment 'machineName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseVMwareSiteMachineIDInsensitively parses 'input' case-insensitively into a VMwareSiteMachineId +// note: this method should only be used for API response data and not user input +func ParseVMwareSiteMachineIDInsensitively(input string) (*VMwareSiteMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(VMwareSiteMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VMwareSiteMachineId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VMwareSiteName, ok = parsed.Parsed["vmwareSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'vmwareSiteName' was not found in the resource id %q", input) + } + + if id.MachineName, ok = parsed.Parsed["machineName"]; !ok { + return nil, fmt.Errorf("the segment 'machineName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateVMwareSiteMachineID checks that 'input' can be parsed as a VMware Site Machine ID +func ValidateVMwareSiteMachineID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVMwareSiteMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted VMware Site Machine ID +func (id VMwareSiteMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OffAzure/vmwareSites/%s/machines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VMwareSiteName, id.MachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this VMware Site Machine ID +func (id VMwareSiteMachineId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOffAzure", "Microsoft.OffAzure", "Microsoft.OffAzure"), + resourceids.StaticSegment("staticVMwareSites", "vmwareSites", "vmwareSites"), + resourceids.UserSpecifiedSegment("vmwareSiteName", "vmwareSiteNameValue"), + resourceids.StaticSegment("staticMachines", "machines", "machines"), + resourceids.UserSpecifiedSegment("machineName", "machineValue"), + } +} + +// String returns a human-readable description of this VMware Site Machine ID +func (id VMwareSiteMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("VMware Site Name: %q", id.VMwareSiteName), + fmt.Sprintf("Machine Name: %q", id.MachineName), + } + return fmt.Sprintf("VMware Site Machine (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_runasaccount.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_runasaccount.go new file mode 100644 index 000000000000..16be086e7686 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vmware_site_runasaccount.go @@ -0,0 +1,137 @@ +package commonids + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = VMwareSiteRunAsAccountId{} + +// VMwareSiteRunAsAccountId is a struct representing the Resource ID for a VMware Site Run As Account +type VMwareSiteRunAsAccountId struct { + SubscriptionId string + ResourceGroupName string + VMwareSiteName string + RunAsAccountName string +} + +// NewVMwareSiteRunAsAccountID returns a new VMwareSiteRunAsAccountId struct +func NewVMwareSiteRunAsAccountID(subscriptionId string, resourceGroupName string, vmwareSiteName string, runAsAccountName string) VMwareSiteRunAsAccountId { + return VMwareSiteRunAsAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VMwareSiteName: vmwareSiteName, + RunAsAccountName: runAsAccountName, + } +} + +// ParseVMwareSiteRunAsAccountID parses 'input' into a VMwareSiteRunAsAccountId +func ParseVMwareSiteRunAsAccountID(input string) (*VMwareSiteRunAsAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(VMwareSiteRunAsAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VMwareSiteRunAsAccountId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VMwareSiteName, ok = parsed.Parsed["vmwareSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'vmwareSiteName' was not found in the resource id %q", input) + } + + if id.RunAsAccountName, ok = parsed.Parsed["runAsAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'runAsAccountName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseVMwareSiteRunAsAccountIDInsensitively parses 'input' case-insensitively into a VMwareSiteRunAsAccountId +// note: this method should only be used for API response data and not user input +func ParseVMwareSiteRunAsAccountIDInsensitively(input string) (*VMwareSiteRunAsAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(VMwareSiteRunAsAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VMwareSiteRunAsAccountId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VMwareSiteName, ok = parsed.Parsed["vmwareSiteName"]; !ok { + return nil, fmt.Errorf("the segment 'vmwareSiteName' was not found in the resource id %q", input) + } + + if id.RunAsAccountName, ok = parsed.Parsed["runAsAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'runAsAccountName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateVMwareSiteRunAsAccountID checks that 'input' can be parsed as a VMware Site Run As Account ID +func ValidateVMwareSiteRunAsAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVMwareSiteRunAsAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted VMware Site Run As Account ID +func (id VMwareSiteRunAsAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OffAzure/vmwareSites/%s/runAsAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VMwareSiteName, id.RunAsAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this VMware Site Run As Account ID +func (id VMwareSiteRunAsAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftOffAzure", "Microsoft.OffAzure", "Microsoft.OffAzure"), + resourceids.StaticSegment("staticVMwareSites", "vmwareSites", "vmwareSites"), + resourceids.UserSpecifiedSegment("vmwareSiteName", "vmwareSiteValue"), + resourceids.StaticSegment("staticRunAsAccounts", "runAsAccounts", "runAsAccounts"), + resourceids.UserSpecifiedSegment("runAsAccountName", "runAsAccountNameValue"), + } +} + +// String returns a human-readable description of this VMware Site RunAsAccount ID +func (id VMwareSiteRunAsAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("VMware Site Name: %q", id.VMwareSiteName), + fmt.Sprintf("Run As Account Name: %q", id.RunAsAccountName), + } + return fmt.Sprintf("VMware Site Run As Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vpn_connection.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vpn_connection.go index 41f7126fcdec..d2a6d09ea633 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vpn_connection.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/vpn_connection.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/edge_zone.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/edge_zone.go index fecff8549dc9..cd9b8715f2a0 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/edge_zone.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/edge_zone.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system.go index 700a025b55ca..e9c2d2336b7a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_or_user.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_or_user.go index cd0c87fca4f8..98c10ac5fed8 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_or_user.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_or_user.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_user.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_user.go index 775de9916e2a..1904fe50cdbb 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_user.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_system_user.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_user.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_user.go index 9d4caf817750..d9b528d588a3 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_user.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/identity_user.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/location.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/location.go index 2369c8919767..77829d358071 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/location.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/location.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_group_name.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_group_name.go index 624cb4b8f77c..a31349848630 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_group_name.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_group_name.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_id_reference.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_id_reference.go index 31727e71be2d..208465b17126 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_id_reference.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/resource_id_reference.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/tags.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/tags.go index fa2ede504e00..7fc36da3526a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/tags.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/tags.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zone.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zone.go index cdd38a8d83ce..f2678bb90fc1 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zone.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zone.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zones.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zones.go index b99f5a153a74..aba7274924e9 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zones.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema/zones.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package commonschema import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/model.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/model.go index f1326f089265..3ce7fdea33ae 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/model.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/model.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package edgezones import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/normalize.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/normalize.go index 531f992a890b..e529e0c3b1a1 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/normalize.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/normalize.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package edgezones import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/schema.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/schema.go index 3883074d0e14..526b70e4f375 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/schema.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones/schema.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package edgezones import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/constants.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/constants.go index 449d44703a1d..65891e3ea462 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/constants.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/constants.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import "strings" diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_list.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_list.go index c20bba824adb..f4bc9aeb2f7e 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_list.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_list.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_map.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_map.go index b0db27d13a5f..899a63e70ae7 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_map.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/legacy_system_and_user_assigned_map.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/model.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/model.go index 4ce333357c4f..41e41ca0f761 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/model.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/model.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import "encoding/json" diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_list.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_list.go index 090e056bbb16..2e3be7b87f75 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_list.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_list.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_map.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_map.go index 27704de5172e..821362a66b0d 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_map.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_and_user_assigned_map.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_assigned.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_assigned.go index 5bcd7742d823..0d46c174638e 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_assigned.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_assigned.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_list.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_list.go index c1b631d63213..08548b1dcdd4 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_list.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_list.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_map.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_map.go index 8db3adc88c68..2d43bf059fa9 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_map.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/system_or_user_assigned_map.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/tfschema_model.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/tfschema_model.go index f787fec169f2..8f304bc0d95a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/tfschema_model.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/tfschema_model.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity type ModelUserAssigned struct { diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_list.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_list.go index b3aeb0354243..47222e6f1af5 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_list.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_list.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_map.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_map.go index 34cbe87fc31f..1bd392efa7e5 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_map.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/identity/user_assigned_map.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package identity import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/normalize.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/normalize.go index dd420edfb2fb..f53613d75b0e 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/normalize.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/normalize.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package location import "strings" diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/schema.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/schema.go index 499c3f33640a..88ed13c13b2d 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/schema.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/schema.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package location import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported.go index 3d92c0bded7e..2ead914879f0 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package location import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported_azure.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported_azure.go index a102f3298c24..efde394f98e8 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported_azure.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/supported_azure.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package location import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/validation.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/validation.go index 3abc93d7c0a9..b8fe40ebd7fd 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/validation.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/location/validation.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package location import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups/validate.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups/validate.go index 4eef55161f04..0665f4dc589a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups/validate.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups/validate.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourcegroups import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/ids.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/ids.go index a72756f85fd0..f17907e24f14 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/ids.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/ids.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourceids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/interface.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/interface.go index 3189f1181181..3bf3ae1e3e08 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/interface.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/interface.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourceids type ResourceId interface { diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/old.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/old.go index f3dc7418f42e..b167029f3cd5 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/old.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/old.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourceids // Id defines a type for a ResourceId of some kind diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/parse.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/parse.go index 609e825bdedf..a27dfa747c03 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/parse.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids/parse.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourceids import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata/model.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata/model.go index fd5d7f03407f..930a41ee454f 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata/model.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata/model.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package systemdata import "encoding/json" diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/expand.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/expand.go index c745f55e4129..4d65cc70d03b 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/expand.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/expand.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tags // Expand transforms the input Tags to a `*map[string]string` diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/flatten.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/flatten.go index 0acb5311697d..5e9558541909 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/flatten.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/flatten.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tags import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/validate.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/validate.go index 768779cd445f..099a0cd72894 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/validate.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/tags/validate.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tags import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/expand.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/expand.go index a3df9670edda..b4cc5151cbca 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/expand.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/expand.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package zones func Expand(input []string) Schema { diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/flatten.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/flatten.go index b141e50be2e0..892f88507cc2 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/flatten.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/flatten.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package zones func Flatten(input *Schema) []string { diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/schema.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/schema.go index 27fe05ae67b0..11dbd35569b0 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/schema.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/zones/schema.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package zones type Schema = []string diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go b/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go index c9c6230f2803..85b825e1de3a 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourceproviders/registration.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourceproviders import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/sender/sender.go b/vendor/github.com/hashicorp/go-azure-helpers/sender/sender.go index d1017ad3e9c7..719a3a42899d 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/sender/sender.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/sender/sender.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package sender import ( diff --git a/vendor/github.com/hashicorp/go-azure-helpers/storage/sas_token.go b/vendor/github.com/hashicorp/go-azure-helpers/storage/sas_token.go index 80e228a77ec5..438c28501e8d 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/storage/sas_token.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/storage/sas_token.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package storage import ( diff --git a/vendor/github.com/hashicorp/go-retryablehttp/client.go b/vendor/github.com/hashicorp/go-retryablehttp/client.go index adbdd92e3ba2..f40d2411cf18 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/client.go +++ b/vendor/github.com/hashicorp/go-retryablehttp/client.go @@ -69,11 +69,28 @@ var ( // scheme specified in the URL is invalid. This error isn't typed // specifically so we resort to matching on the error string. schemeErrorRe = regexp.MustCompile(`unsupported protocol scheme`) + + // A regular expression to match the error returned by net/http when the + // TLS certificate is not trusted. This error isn't typed + // specifically so we resort to matching on the error string. + notTrustedErrorRe = regexp.MustCompile(`certificate is not trusted`) ) // ReaderFunc is the type of function that can be given natively to NewRequest type ReaderFunc func() (io.Reader, error) +// ResponseHandlerFunc is a type of function that takes in a Response, and does something with it. +// The ResponseHandlerFunc is called when the HTTP client successfully receives a response and the +// CheckRetry function indicates that a retry of the base request is not necessary. +// If an error is returned from this function, the CheckRetry policy will be used to determine +// whether to retry the whole request (including this handler). +// +// Make sure to check status codes! Even if the request was completed it may have a non-2xx status code. +// +// The response body is not automatically closed. It must be closed either by the ResponseHandlerFunc or +// by the caller out-of-band. Failure to do so will result in a memory leak. +type ResponseHandlerFunc func(*http.Response) error + // LenReader is an interface implemented by many in-memory io.Reader's. Used // for automatically sending the right Content-Length header when possible. type LenReader interface { @@ -86,6 +103,8 @@ type Request struct { // used to rewind the request data in between retries. body ReaderFunc + responseHandler ResponseHandlerFunc + // Embed an HTTP request directly. This makes a *Request act exactly // like an *http.Request so that all meta methods are supported. *http.Request @@ -94,8 +113,16 @@ type Request struct { // WithContext returns wrapped Request with a shallow copy of underlying *http.Request // with its context changed to ctx. The provided ctx must be non-nil. func (r *Request) WithContext(ctx context.Context) *Request { - r.Request = r.Request.WithContext(ctx) - return r + return &Request{ + body: r.body, + responseHandler: r.responseHandler, + Request: r.Request.WithContext(ctx), + } +} + +// SetResponseHandler allows setting the response handler. +func (r *Request) SetResponseHandler(fn ResponseHandlerFunc) { + r.responseHandler = fn } // BodyBytes allows accessing the request body. It is an analogue to @@ -252,23 +279,31 @@ func FromRequest(r *http.Request) (*Request, error) { return nil, err } // Could assert contentLength == r.ContentLength - return &Request{bodyReader, r}, nil + return &Request{body: bodyReader, Request: r}, nil } // NewRequest creates a new wrapped request. func NewRequest(method, url string, rawBody interface{}) (*Request, error) { + return NewRequestWithContext(context.Background(), method, url, rawBody) +} + +// NewRequestWithContext creates a new wrapped request with the provided context. +// +// The context controls the entire lifetime of a request and its response: +// obtaining a connection, sending the request, and reading the response headers and body. +func NewRequestWithContext(ctx context.Context, method, url string, rawBody interface{}) (*Request, error) { bodyReader, contentLength, err := getBodyReaderAndContentLength(rawBody) if err != nil { return nil, err } - httpReq, err := http.NewRequest(method, url, nil) + httpReq, err := http.NewRequestWithContext(ctx, method, url, nil) if err != nil { return nil, err } httpReq.ContentLength = contentLength - return &Request{bodyReader, httpReq}, nil + return &Request{body: bodyReader, Request: httpReq}, nil } // Logger interface allows to use other loggers than @@ -435,6 +470,9 @@ func baseRetryPolicy(resp *http.Response, err error) (bool, error) { } // Don't retry if the error was due to TLS cert verification failure. + if notTrustedErrorRe.MatchString(v.Error()) { + return false, v + } if _, ok := v.Err.(x509.UnknownAuthorityError); ok { return false, v } @@ -455,7 +493,7 @@ func baseRetryPolicy(resp *http.Response, err error) (bool, error) { // the server time to recover, as 500's are typically not permanent // errors and may relate to outages on the server side. This will catch // invalid response codes as well, like 0 and 999. - if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != 501) { + if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != http.StatusNotImplemented) { return true, fmt.Errorf("unexpected HTTP status %s", resp.Status) } @@ -555,13 +593,12 @@ func (c *Client) Do(req *Request) (*http.Response, error) { var resp *http.Response var attempt int var shouldRetry bool - var doErr, checkErr error + var doErr, respErr, checkErr error for i := 0; ; i++ { + doErr, respErr = nil, nil attempt++ - var code int // HTTP response code - // Always rewind the request body when non-nil. if req.body != nil { body, err := req.body() @@ -589,19 +626,24 @@ func (c *Client) Do(req *Request) (*http.Response, error) { // Attempt the request resp, doErr = c.HTTPClient.Do(req.Request) - if resp != nil { - code = resp.StatusCode - } // Check if we should continue with retries. shouldRetry, checkErr = c.CheckRetry(req.Context(), resp, doErr) + if !shouldRetry && doErr == nil && req.responseHandler != nil { + respErr = req.responseHandler(resp) + shouldRetry, checkErr = c.CheckRetry(req.Context(), resp, respErr) + } - if doErr != nil { + err := doErr + if respErr != nil { + err = respErr + } + if err != nil { switch v := logger.(type) { case LeveledLogger: - v.Error("request failed", "error", doErr, "method", req.Method, "url", req.URL) + v.Error("request failed", "error", err, "method", req.Method, "url", req.URL) case Logger: - v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, doErr) + v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, err) } } else { // Call this here to maintain the behavior of logging all requests, @@ -636,11 +678,11 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } wait := c.Backoff(c.RetryWaitMin, c.RetryWaitMax, i, resp) - desc := fmt.Sprintf("%s %s", req.Method, req.URL) - if code > 0 { - desc = fmt.Sprintf("%s (status: %d)", desc, code) - } if logger != nil { + desc := fmt.Sprintf("%s %s", req.Method, req.URL) + if resp != nil { + desc = fmt.Sprintf("%s (status: %d)", desc, resp.StatusCode) + } switch v := logger.(type) { case LeveledLogger: v.Debug("retrying request", "request", desc, "timeout", wait, "remaining", remain) @@ -648,11 +690,13 @@ func (c *Client) Do(req *Request) (*http.Response, error) { v.Printf("[DEBUG] %s: retrying in %s (%d left)", desc, wait, remain) } } + timer := time.NewTimer(wait) select { case <-req.Context().Done(): + timer.Stop() c.HTTPClient.CloseIdleConnections() return nil, req.Context().Err() - case <-time.After(wait): + case <-timer.C: } // Make shallow copy of http Request so that we can modify its body @@ -662,15 +706,19 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } // this is the closest we have to success criteria - if doErr == nil && checkErr == nil && !shouldRetry { + if doErr == nil && respErr == nil && checkErr == nil && !shouldRetry { return resp, nil } defer c.HTTPClient.CloseIdleConnections() - err := doErr + var err error if checkErr != nil { err = checkErr + } else if respErr != nil { + err = respErr + } else { + err = doErr } if c.ErrorHandler != nil { diff --git a/vendor/github.com/manicminer/hamilton-autorest/auth/wrapper.go b/vendor/github.com/manicminer/hamilton-autorest/auth/wrapper.go index 4c0dd32c4d67..b8ca1e922b18 100644 --- a/vendor/github.com/manicminer/hamilton-autorest/auth/wrapper.go +++ b/vendor/github.com/manicminer/hamilton-autorest/auth/wrapper.go @@ -119,6 +119,8 @@ func (a *AuthorizerWrapper) Token() (*oauth2.Token, error) { var adalToken adal.Token if spToken, ok := tokenProviders[0].(ServicePrincipalToken); ok && spToken != nil { adalToken = spToken.Token() + } else if token, ok := tokenProviders[0].(*adal.Token); ok && token != nil { + adalToken = *token } if adalToken.AccessToken == "" { return nil, fmt.Errorf("could not obtain access token from token provider") diff --git a/vendor/github.com/manicminer/hamilton/auth/auth.go b/vendor/github.com/manicminer/hamilton/auth/auth.go index 360687f99832..faf7d34549f4 100644 --- a/vendor/github.com/manicminer/hamilton/auth/auth.go +++ b/vendor/github.com/manicminer/hamilton/auth/auth.go @@ -5,7 +5,7 @@ import ( "crypto/rsa" "crypto/x509" "fmt" - "io/ioutil" + "os" "strings" "golang.org/x/crypto/pkcs12" @@ -126,7 +126,7 @@ func NewMsiAuthorizer(ctx context.Context, api environments.Api, msiEndpoint, cl func NewClientCertificateAuthorizer(ctx context.Context, environment environments.Environment, api environments.Api, tokenVersion TokenVersion, tenantId string, auxTenantIds []string, clientId string, pfxData []byte, pfxPath, pfxPass string) (Authorizer, error) { if len(pfxData) == 0 { var err error - pfxData, err = ioutil.ReadFile(pfxPath) + pfxData, err = os.ReadFile(pfxPath) if err != nil { return nil, fmt.Errorf("could not read pkcs12 store at %q: %s", pfxPath, err) } diff --git a/vendor/github.com/manicminer/hamilton/auth/clientcredentials.go b/vendor/github.com/manicminer/hamilton/auth/clientcredentials.go index 5ab463a6a007..fd0e215050a1 100644 --- a/vendor/github.com/manicminer/hamilton/auth/clientcredentials.go +++ b/vendor/github.com/manicminer/hamilton/auth/clientcredentials.go @@ -15,7 +15,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strconv" @@ -410,7 +409,7 @@ func clientCredentialsToken(ctx context.Context, endpoint string, params *url.Va } defer resp.Body.Close() - body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20)) + body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) if err != nil { return nil, fmt.Errorf("clientCredentialsToken: cannot parse response: %v", err) } diff --git a/vendor/github.com/manicminer/hamilton/auth/github.go b/vendor/github.com/manicminer/hamilton/auth/github.go index 48cbf6b82e89..e18e908b83f0 100644 --- a/vendor/github.com/manicminer/hamilton/auth/github.go +++ b/vendor/github.com/manicminer/hamilton/auth/github.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" @@ -80,7 +79,7 @@ func (a *GitHubOIDCAuthorizer) githubAssertion() (*string, error) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20)) + body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) if err != nil { return nil, fmt.Errorf("githubAssertion: cannot parse response: %v", err) } diff --git a/vendor/github.com/manicminer/hamilton/auth/msi.go b/vendor/github.com/manicminer/hamilton/auth/msi.go index ab3f1a47fdbf..fb4ddeaaecb1 100644 --- a/vendor/github.com/manicminer/hamilton/auth/msi.go +++ b/vendor/github.com/manicminer/hamilton/auth/msi.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strconv" @@ -140,7 +140,7 @@ func azureMetadata(ctx context.Context, url string) (body []byte, err error) { if err != nil { return } - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { return } diff --git a/vendor/github.com/manicminer/hamilton/environments/published.go b/vendor/github.com/manicminer/hamilton/environments/published.go index 2d1944f779d2..23deeb47f382 100644 --- a/vendor/github.com/manicminer/hamilton/environments/published.go +++ b/vendor/github.com/manicminer/hamilton/environments/published.go @@ -79,6 +79,7 @@ var PublishedApis = map[string]ApiAppId{ "MicrosoftAzureFrontDoorCdn": "205478c0-bd83-4e1b-a9d6-db63a3e1e1c8", "Microsoft365DataAtRestEncryption": "c066d759-24ae-40e7-a56f-027002b5d3e4", "MicrosoftGraph": "00000003-0000-0000-c000-000000000000", + "Microsoft.StorageSync": "9469b9f5-6722-4481-a2b2-14ed560b706f", "MicrosoftInvoicing": "b6b84568-6c01-4981-a80f-09da9a20bbed", "Office365Connectors": "48af08dc-f6d2-435f-b2a7-069abd99c086", "Office365Demeter": "982bda36-4632-4165-a46a-9863b1bbcf7d", diff --git a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go index 711694e19ff6..33bbd3cd4463 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go @@ -57,7 +57,7 @@ func (c *AccessPackageResourceClient) Get(ctx context.Context, catalogId string, resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, OData: odata.Query{ - Filter: fmt.Sprintf("startswith(originId,'%s')", originId), + Filter: fmt.Sprintf("originId eq '%s'", originId), }, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ @@ -82,7 +82,11 @@ func (c *AccessPackageResourceClient) Get(ctx context.Context, catalogId string, return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) } - accessPackageResource := data.AccessPackageResources[0] + accessPackageResources := data.AccessPackageResources - return &accessPackageResource, status, nil + if len(accessPackageResources) == 0 { + return nil, status, fmt.Errorf("No accessPackageResource found with catalogId %v and originId %v", catalogId, originId) + } + + return &accessPackageResources[0], status, nil } diff --git a/vendor/github.com/manicminer/hamilton/msgraph/administrative_units.go b/vendor/github.com/manicminer/hamilton/msgraph/administrative_units.go index 04b5b3008e01..bc35feb30b76 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/administrative_units.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/administrative_units.go @@ -241,6 +241,41 @@ func (c *AdministrativeUnitsClient) GetMember(ctx context.Context, administrativ return &data.Id, status, nil } +func (c *AdministrativeUnitsClient) CreateGroup(ctx context.Context, administrativeUnitId string, group *Group) (*Group, int, error) { + var status int + odataTypeGroup := odata.TypeGroup + group.ODataType = &odataTypeGroup + body, err := json.Marshal(group) + if err != nil { + return nil, status, fmt.Errorf("json.Marshal(): %v", err) + } + response, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ + Body: body, + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{http.StatusCreated}, + Uri: Uri{ + Entity: fmt.Sprintf("/administrativeUnits/%s/members", administrativeUnitId), + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("AdministrativeUnitsClient.BaseClient.Post(): %v", err) + } + + defer response.Body.Close() + responseBody, err := io.ReadAll(response.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var newGroup Group + if err := json.Unmarshal(responseBody, &newGroup); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &newGroup, status, nil +} + // AddMembers adds new members to a AdministrativeUnit. func (c *AdministrativeUnitsClient) AddMembers(ctx context.Context, administrativeUnitId string, members *Members) (int, error) { var status int diff --git a/vendor/github.com/manicminer/hamilton/msgraph/applications.go b/vendor/github.com/manicminer/hamilton/msgraph/applications.go index a0b20ba5c532..4c3e84260abd 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/applications.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/applications.go @@ -155,7 +155,7 @@ func (c *ApplicationsClient) GetDeleted(ctx context.Context, id string, query od func (c *ApplicationsClient) Update(ctx context.Context, application Application) (int, error) { var status int - if application.ID == nil { + if application.ID() == nil { return status, errors.New("ApplicationsClient.Update(): cannot update application with nil ID") } @@ -182,7 +182,7 @@ func (c *ApplicationsClient) Update(ctx context.Context, application Application ConsistencyFailureFunc: checkApplicationConsistency, ValidStatusCodes: []int{http.StatusNoContent}, Uri: Uri{ - Entity: fmt.Sprintf("/applications/%s", *application.ID), + Entity: fmt.Sprintf("/applications/%s", *application.ID()), HasTenantId: true, }, }) @@ -378,10 +378,7 @@ func (c *ApplicationsClient) ListOwners(ctx context.Context, id string) (*[]stri } var data struct { - Owners []struct { - Type string `json:"@odata.type"` - Id string `json:"id"` - } `json:"value"` + Owners []DirectoryObject `json:"value"` } if err := json.Unmarshal(respBody, &data); err != nil { return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) @@ -389,7 +386,9 @@ func (c *ApplicationsClient) ListOwners(ctx context.Context, id string) (*[]stri ret := make([]string, len(data.Owners)) for i, v := range data.Owners { - ret[i] = v.Id + if d := v.ID(); d != nil { + ret[i] = *d + } } return &ret, status, nil @@ -438,7 +437,7 @@ func (c *ApplicationsClient) GetOwner(ctx context.Context, applicationId, ownerI func (c *ApplicationsClient) AddOwners(ctx context.Context, application *Application) (int, error) { var status int - if application.ID == nil { + if application.ID() == nil { return status, errors.New("cannot update application with nil ID") } if application.Owners == nil { @@ -465,7 +464,7 @@ func (c *ApplicationsClient) AddOwners(ctx context.Context, application *Applica ValidStatusCodes: []int{http.StatusNoContent}, ValidStatusFunc: checkOwnerAlreadyExists, Uri: Uri{ - Entity: fmt.Sprintf("/applications/%s/owners/$ref", *application.ID), + Entity: fmt.Sprintf("/applications/%s/owners/$ref", *application.ID()), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/claims_mapping_policy.go b/vendor/github.com/manicminer/hamilton/msgraph/claims_mapping_policy.go index 08e14b1c82cf..6adf9aa866e4 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/claims_mapping_policy.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/claims_mapping_policy.go @@ -125,12 +125,13 @@ func (c *ClaimsMappingPolicyClient) Get(ctx context.Context, id string, query od func (c *ClaimsMappingPolicyClient) Update(ctx context.Context, claimsMappingPolicy ClaimsMappingPolicy) (int, error) { var status int - if claimsMappingPolicy.ID == nil { + if claimsMappingPolicy.ID() == nil { return status, fmt.Errorf("cannot update ClaimsMappingPolicy with nil ID") } - claimsMappingPolicyId := *claimsMappingPolicy.ID - claimsMappingPolicy.ID = nil + claimsMappingPolicyId := *claimsMappingPolicy.ID() + claimsMappingPolicy.Id = nil + claimsMappingPolicy.ObjectId = nil body, err := json.Marshal(claimsMappingPolicy) if err != nil { diff --git a/vendor/github.com/manicminer/hamilton/msgraph/connectedorganization.go b/vendor/github.com/manicminer/hamilton/msgraph/connectedorganization.go new file mode 100644 index 000000000000..3d92790fe503 --- /dev/null +++ b/vendor/github.com/manicminer/hamilton/msgraph/connectedorganization.go @@ -0,0 +1,341 @@ +package msgraph + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + + "github.com/manicminer/hamilton/internal/utils" + "github.com/manicminer/hamilton/odata" +) + +type ConnectedOrganizationClient struct { + BaseClient Client +} + +func NewConnectedOrganizationClient(tenantId string) *ConnectedOrganizationClient { + return &ConnectedOrganizationClient{ + BaseClient: NewClient(Version10, tenantId), + } +} + +// List returns a list of ConnectedOrganization +// https://docs.microsoft.com/graph/api/entitlementmanagement-list-connectedorganizations +func (c *ConnectedOrganizationClient) List(ctx context.Context, query odata.Query) (*[]ConnectedOrganization, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + DisablePaging: query.Top > 0, + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: "/identityGovernance/entitlementManagement/connectedOrganizations", + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("ConnectedOrganizationClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var data struct { + ConnectedOrganizations []ConnectedOrganization `json:"value"` + } + if err := json.Unmarshal(respBody, &data); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &data.ConnectedOrganizations, status, nil +} + +// Create creates a new ConnectedOrganization. +// https://docs.microsoft.com/graph/api/entitlementmanagement-post-connectedorganizations +func (c *ConnectedOrganizationClient) Create(ctx context.Context, connectedOrganization ConnectedOrganization) (*ConnectedOrganization, int, error) { + var status int + body, err := json.Marshal(connectedOrganization) + if err != nil { + return nil, status, fmt.Errorf("json.Marshal(): %v", err) + } + + resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ + Body: body, + ValidStatusCodes: []int{http.StatusCreated}, + Uri: Uri{ + Entity: "/identityGovernance/entitlementManagement/connectedOrganizations", + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("ConnectedOrganizationClient.BaseClient.Post(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var newConnectedOrganization ConnectedOrganization + if err := json.Unmarshal(respBody, &newConnectedOrganization); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &newConnectedOrganization, status, nil +} + +// Get retrieves a ConnectedOrganization. +// https://docs.microsoft.com/graph/api/connectedorganization-get +func (c *ConnectedOrganizationClient) Get(ctx context.Context, id string, query odata.Query) (*ConnectedOrganization, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/connectedOrganizations/%s", id), + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("ConnectedOrganizationClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var connectedOrganization ConnectedOrganization + if err := json.Unmarshal(respBody, &connectedOrganization); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &connectedOrganization, status, nil +} + +// Update amends an existing ConnectedOrganization. +// https://docs.microsoft.com/graph/api/connectedorganization-update +func (c *ConnectedOrganizationClient) Update(ctx context.Context, connectedOrganization ConnectedOrganization) (int, error) { + var status int + + if connectedOrganization.ID == nil { + return status, errors.New("cannot update ConnectedOrganization with nil ID") + } + + // These are the only properties that can up updated. + updatedOrg := ConnectedOrganization{ + DisplayName: connectedOrganization.DisplayName, + Description: connectedOrganization.Description, + State: connectedOrganization.State, + } + + body, err := json.Marshal(updatedOrg) + if err != nil { + return status, fmt.Errorf("json.Marshal(): %v", err) + } + + _, status, _, err = c.BaseClient.Patch(ctx, PatchHttpRequestInput{ + Body: body, + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{http.StatusNoContent}, + Uri: Uri{ + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/connectedOrganizations/%s", *connectedOrganization.ID), + HasTenantId: true, + }, + }) + if err != nil { + return status, fmt.Errorf("ConnectedOrganizationClient.BaseClient.Patch(): %v", err) + } + + return status, nil +} + +// Delete removes a ConnectedOrganization. +// https://docs.microsoft.com/graph/api/connectedorganization-delete +func (c *ConnectedOrganizationClient) Delete(ctx context.Context, id string) (int, error) { + _, status, _, err := c.BaseClient.Delete(ctx, DeleteHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{http.StatusNoContent}, + Uri: Uri{ + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/connectedOrganizations/%s", id), + HasTenantId: true, + }, + }) + if err != nil { + return status, fmt.Errorf("ConnectedOrganizationClient.BaseClient.Delete(): %v", err) + } + + return status, nil +} + +// List the external sponsors for a connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-list-externalsponsors +func (c *ConnectedOrganizationClient) ListExternalSponsors(ctx context.Context, query odata.Query, id string) (*[]DirectoryObject, int, error) { + return listSponsors(&c.BaseClient, ctx, query, id, true) +} + +// List the internal sponsors for a connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-list-internalsponsors +func (c *ConnectedOrganizationClient) ListInternalSponsors(ctx context.Context, query odata.Query, id string) (*[]DirectoryObject, int, error) { + return listSponsors(&c.BaseClient, ctx, query, id, false) +} + +// Add a user as an external sponsor to the connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-post-externalsponsors +func (c *ConnectedOrganizationClient) AddExternalSponsorUser(ctx context.Context, orgId string, userId string) error { + return addSponsor(&c.BaseClient, ctx, orgId, userId, true, false) +} + +// Add a group as an external sponsor to the connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-post-externalsponsors +func (c *ConnectedOrganizationClient) AddExternalSponsorGroup(ctx context.Context, orgId string, grpId string) error { + return addSponsor(&c.BaseClient, ctx, orgId, grpId, true, true) +} + +// Add a user as an external sponsor to the connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-post-internalsponsors +func (c *ConnectedOrganizationClient) AddInternalSponsorUser(ctx context.Context, orgId string, userId string) error { + return addSponsor(&c.BaseClient, ctx, orgId, userId, false, false) +} + +// Add a group as an external sponsor to the connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-post-internalsponsors +func (c *ConnectedOrganizationClient) AddInternalSponsorGroup(ctx context.Context, orgId string, grpId string) error { + return addSponsor(&c.BaseClient, ctx, orgId, grpId, false, true) +} + +// Delete a user or group as an external sponsor to the connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-delete-externalsponsors +func (c *ConnectedOrganizationClient) DeleteExternalSponsor(ctx context.Context, orgId string, id string) error { + return deleteSponsor(&c.BaseClient, ctx, orgId, id, true) +} + +// Delete a user or group as an internal sponsor to the connected organization. +// https://docs.microsoft.com/graph/api/connectedorganization-delete-internalsponsors +func (c *ConnectedOrganizationClient) DeleteInternalSponsor(ctx context.Context, orgId string, id string) error { + return deleteSponsor(&c.BaseClient, ctx, orgId, id, false) +} + +func addSponsor(client *Client, ctx context.Context, orgId string, userOrGroupId string, external bool, group bool) error { + if !ValidateId(&orgId) { + return fmt.Errorf("the id %q is not a valid connected organization id", orgId) + } + if !ValidateId(&userOrGroupId) { + return fmt.Errorf("the id %q is not a valid user/group id", userOrGroupId) + } + + var userOrGroup string + if group { + userOrGroup = "/groups/" + } else { + userOrGroup = "/users/" + } + + extUser := Ref{ + ObjectUri: utils.StringPtr(string(client.Endpoint) + "/" + string(client.ApiVersion) + userOrGroup + userOrGroupId), + } + + body, err := json.Marshal(extUser) + if err != nil { + return fmt.Errorf("json.Marshal(): %v", err) + } + + var internalOrExternal string + if external { + internalOrExternal = "externalSponsors" + } else { + internalOrExternal = "internalSponsors" + } + + _, status, _, err := client.Post(ctx, PostHttpRequestInput{ + Uri: Uri{ + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/connectedOrganizations/%s/%s/$ref", orgId, internalOrExternal), + HasTenantId: true, + }, + ValidStatusCodes: []int{http.StatusNoContent}, + Body: body, + }) + + if err != nil { + return fmt.Errorf("AddExternalSponsorUser returned status code %d: %v", status, err) + } + + return nil +} + +// List the internal/external sponsors for a connected organization. +func listSponsors(c *Client, ctx context.Context, query odata.Query, id string, external bool) (*[]DirectoryObject, int, error) { + if !ValidateId(&id) { + return nil, 0, fmt.Errorf("the id %q is not a valid connected organization id", id) + } + + var internalOrExternal string + if external { + internalOrExternal = "externalSponsors" + } else { + internalOrExternal = "internalSponsors" + } + + resp, status, _, err := c.Get(ctx, GetHttpRequestInput{ + DisablePaging: query.Top > 0, + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/connectedOrganizations/%s/%s", id, internalOrExternal), + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("ConnectedOrganizationClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var data struct { + ExternalSponsors []DirectoryObject `json:"value"` + } + if err := json.Unmarshal(respBody, &data); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &data.ExternalSponsors, status, nil +} + +func deleteSponsor(c *Client, ctx context.Context, orgId string, id string, external bool) error { + if !ValidateId(&orgId) { + return fmt.Errorf("the id %q is not a valid connected organization id", id) + } + if !ValidateId(&id) { + return fmt.Errorf("the id %q is not a valid user/group id", id) + } + var internalOrExternal string + if external { + internalOrExternal = "externalSponsors" + } else { + internalOrExternal = "internalSponsors" + } + + _, status, _, err := c.Delete(ctx, DeleteHttpRequestInput{ + Uri: Uri{ + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/connectedOrganizations/%s/%s/%s/$ref", orgId, internalOrExternal, id), + HasTenantId: true, + }, + ValidStatusCodes: []int{http.StatusNoContent}, + }) + + if err != nil { + return fmt.Errorf("DeleteSponsor returned status code %d: %v", status, err) + } + + return nil +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go b/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go index 689fe1eef4f4..1e0103c140eb 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go @@ -46,13 +46,11 @@ func (c *DirectoryObjectsClient) Get(ctx context.Context, id string, query odata return nil, status, fmt.Errorf("io.ReadAll(): %v", err) } - var data map[string]interface{} - if err := json.Unmarshal(respBody, &data); err != nil { + directoryObject := DirectoryObject{} + if err = directoryObject.UnmarshalJSONWithAdditionalData(respBody); err != nil { return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) } - directoryObject := c.translateResultToDirectoryObject(data) - return &directoryObject, status, nil } @@ -91,7 +89,7 @@ func (c *DirectoryObjectsClient) GetByIds(ctx context.Context, ids []string, typ } var rawData struct { - Objects []map[string]interface{} `json:"value"` + Objects []json.RawMessage `json:"value"` } if err := json.Unmarshal(respBody, &rawData); err != nil { return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) @@ -101,8 +99,12 @@ func (c *DirectoryObjectsClient) GetByIds(ctx context.Context, ids []string, typ Objects []DirectoryObject `json:"value"` } - for _, row := range rawData.Objects { - data.Objects = append(data.Objects, c.translateResultToDirectoryObject(row)) + for _, rawObj := range rawData.Objects { + directoryObject := DirectoryObject{} + if err = directoryObject.UnmarshalJSONWithAdditionalData(rawObj); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + data.Objects = append(data.Objects, directoryObject) } return &data.Objects, status, nil @@ -167,7 +169,7 @@ func (c *DirectoryObjectsClient) GetMemberGroups(ctx context.Context, id string, result := make([]DirectoryObject, len(data.IDs)) for i, id := range data.IDs { - result[i].ID = utils.StringPtr(id) + result[i].Id = utils.StringPtr(id) } return &result, status, nil @@ -215,43 +217,8 @@ func (c *DirectoryObjectsClient) GetMemberObjects(ctx context.Context, id string result := make([]DirectoryObject, len(data.IDs)) for i, id := range data.IDs { - result[i].ID = utils.StringPtr(id) + result[i].Id = utils.StringPtr(id) } return &result, status, nil } - -// translateResultToDirectoryObject translates directory object data into DirectoryObject -func (c *DirectoryObjectsClient) translateResultToDirectoryObject(data map[string]interface{}) DirectoryObject { - object := DirectoryObject{ - AdditionalData: data, - } - - if val, exists := data["@odata.id"]; exists { - if v, ok := val.(string); ok { - odataId := odata.Id(v) - object.ODataId = &odataId - } - } - - if val, exists := data["@odata.type"]; exists { - if v, ok := val.(string); ok { - odataType := odata.Type(v) - object.ODataType = &odataType - } - } - - if val, exists := data["id"]; exists { - if v, ok := val.(string); ok { - object.ID = &v - } - } - - if val, exists := data["displayName"]; exists { - if v, ok := val.(string); ok { - object.DisplayName = &v - } - } - - return object -} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go b/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go index 35b546b21eed..7dd17ad44745 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go @@ -152,7 +152,7 @@ func (c *DirectoryRolesClient) ListMembers(ctx context.Context, id string) (*[]s func (c *DirectoryRolesClient) AddMembers(ctx context.Context, directoryRole *DirectoryRole) (int, error) { var status int - if directoryRole.ID == nil { + if directoryRole.ID() == nil { return status, errors.New("cannot update directory role with nil ID") } if directoryRole.Members == nil { @@ -178,7 +178,7 @@ func (c *DirectoryRolesClient) AddMembers(ctx context.Context, directoryRole *Di ValidStatusCodes: []int{http.StatusNoContent}, ValidStatusFunc: checkMemberAlreadyExists, Uri: Uri{ - Entity: fmt.Sprintf("/directoryRoles/%s/members/$ref", *directoryRole.ID), + Entity: fmt.Sprintf("/directoryRoles/%s/members/$ref", *directoryRole.ID()), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/groups.go b/vendor/github.com/manicminer/hamilton/msgraph/groups.go index 8ec7bede8753..e1a8faaef1c5 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/groups.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/groups.go @@ -62,16 +62,16 @@ func (c *GroupsClient) Create(ctx context.Context, group Group) (*Group, int, er return nil, status, fmt.Errorf("json.Marshal(): %v", err) } - ownersNotReplicated := func(resp *http.Response, o *odata.OData) bool { + consistencyFunc := func(resp *http.Response, o *odata.OData) bool { if resp != nil && resp.StatusCode == http.StatusBadRequest && o != nil && o.Error != nil { - return o.Error.Match(odata.ErrorResourceDoesNotExist) + return o.Error.Match(odata.ErrorPropertyValuesAreInvalid) || o.Error.Match(odata.ErrorResourceDoesNotExist) } return false } resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ Body: body, - ConsistencyFailureFunc: ownersNotReplicated, + ConsistencyFailureFunc: consistencyFunc, OData: odata.Query{ Metadata: odata.MetadataFull, }, @@ -206,12 +206,13 @@ func (c *GroupsClient) GetDeleted(ctx context.Context, id string, query odata.Qu func (c *GroupsClient) Update(ctx context.Context, group Group) (int, error) { var status int - if group.ID == nil { + if group.ID() == nil { return status, fmt.Errorf("cannot update group with nil ID") } - groupId := *group.ID - group.ID = nil + groupId := *group.ID() + group.Id = nil + group.ObjectId = nil body, err := json.Marshal(group) if err != nil { @@ -368,6 +369,48 @@ func (c *GroupsClient) ListMembers(ctx context.Context, id string) (*[]string, i return &ret, status, nil } +// ListTransitiveMembers retrieves a flat list of all nested members of the specified Group. +// id is the object ID of the group. +func (c *GroupsClient) ListTransitiveMembers(ctx context.Context, id string) (*[]string, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: odata.Query{ + Select: []string{"id"}, + }, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: fmt.Sprintf("/groups/%s/transitiveMembers", id), + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("GroupsClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var data struct { + Members []struct { + Type string `json:"@odata.type"` + Id string `json:"id"` + } `json:"value"` + } + if err := json.Unmarshal(respBody, &data); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + ret := make([]string, len(data.Members)) + for i, v := range data.Members { + ret[i] = v.Id + } + + return &ret, status, nil +} + // GetMember retrieves a single member of the specified Group. // groupId is the object ID of the group. // memberId is the object ID of the member object. @@ -435,7 +478,7 @@ func (c *GroupsClient) AddMembers(ctx context.Context, group *Group) (int, error ValidStatusCodes: []int{http.StatusNoContent}, ValidStatusFunc: checkMemberAlreadyExists, Uri: Uri{ - Entity: fmt.Sprintf("/groups/%s/members/$ref", *group.ID), + Entity: fmt.Sprintf("/groups/%s/members/$ref", *group.ID()), HasTenantId: true, }, }) @@ -601,7 +644,7 @@ func (c *GroupsClient) AddOwners(ctx context.Context, group *Group) (int, error) ValidStatusCodes: []int{http.StatusNoContent}, ValidStatusFunc: checkOwnerAlreadyExists, Uri: Uri{ - Entity: fmt.Sprintf("/groups/%s/owners/$ref", *group.ID), + Entity: fmt.Sprintf("/groups/%s/owners/$ref", *group.ID()), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/models.go b/vendor/github.com/manicminer/hamilton/msgraph/models.go index 9019862a3e40..b1c70c4d550a 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/models.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/models.go @@ -90,7 +90,7 @@ type AccessPackageResource struct { AccessPackageResourceEnvironment *AccessPackageResourceEnvironment `json:"accessPackageResourceEnvironment,omitempty"` AddedBy *string `json:"addedBy,omitempty"` AddedOn *time.Time `json:"addedOn,omitempty"` - Description *bool `json:"description,omitempty"` + Description *string `json:"description,omitempty"` DisplayName *string `json:"displayName,omitempty"` ID *string `json:"id,omitempty"` IsPendingOnboarding *bool `json:"isPendingOnboarding,omitempty"` @@ -202,6 +202,7 @@ type Application struct { CreatedDateTime *time.Time `json:"createdDateTime,omitempty"` DefaultRedirectUri *string `json:"defaultRedirectUri,omitempty"` DeletedDateTime *time.Time `json:"deletedDateTime,omitempty"` + Description *StringNullWhenEmpty `json:"description,omitempty"` DisabledByMicrosoftStatus interface{} `json:"disabledByMicrosoftStatus,omitempty"` DisplayName *string `json:"displayName,omitempty"` GroupMembershipClaims *[]GroupMembershipClaim `json:"-"` // see Application.MarshalJSON / Application.UnmarshalJSON @@ -667,6 +668,18 @@ type CredentialUserRegistrationDetails struct { UserPrincipalName *string `json:"UserPrincipalName,omitempty"` } +// In Azure AD entitlement management, a connected organization is a reference to a +// directory or domain of another organization whose users can request access. +type ConnectedOrganization struct { + ID *string `json:"id,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` + State *ConnectedOrganizationState `json:"state,omitempty"` + CreatedDateTime *time.Time `json:"createdDateTime,omitempty"` + ModifiedDateTime *time.Time `json:"modifiedDateTime,omitempty"` +} + type DelegatedPermissionGrant struct { Id *string `json:"id,omitempty"` ClientId *string `json:"clientId,omitempty"` @@ -749,16 +762,38 @@ type DirectoryAudit struct { type DirectoryObject struct { ODataId *odata.Id `json:"@odata.id,omitempty"` ODataType *odata.Type `json:"@odata.type,omitempty"` - ID *string `json:"id,omitempty"` + Id *string `json:"id,omitempty"` + ObjectId *string `json:"objectId,omitempty"` DisplayName *string `json:"displayName,omitempty"` AdditionalData map[string]interface{} `json:"-"` } +func (o *DirectoryObject) ID() (id *string) { + if o.Id != nil { + id = o.Id + } else if o.ObjectId != nil { + id = o.ObjectId + } + return +} + +func (o *DirectoryObject) UnmarshalJSONWithAdditionalData(data []byte) error { + type directoryObject DirectoryObject + obj := (*directoryObject)(o) + if err := json.Unmarshal(data, &obj); err != nil { + return err + } + if err := json.Unmarshal(data, &obj.AdditionalData); err != nil { + return err + } + return nil +} + func (o *DirectoryObject) Uri(endpoint environments.ApiEndpoint, apiVersion ApiVersion) string { - if o.ID == nil { + if o.Id == nil { return "" } - return fmt.Sprintf("%s/%s/directoryObjects/%s", endpoint, apiVersion, *o.ID) + return fmt.Sprintf("%s/%s/directoryObjects/%s", endpoint, apiVersion, *o.Id) } type DirectoryRole struct { @@ -871,6 +906,7 @@ type Group struct { HasMembersWithLicenseErrors *bool `json:"hasMembersWithLicenseErrors,omitempty"` HideFromAddressLists *bool `json:"hideFromAddressLists,omitempty"` HideFromOutlookClients *bool `json:"hideFromOutlookClients,omitempty"` + IsAssignableToRole *bool `json:"isAssignableToRole,omitempty"` IsSubscribedByMail *bool `json:"isSubscribedByMail,omitempty"` LicenseProcessingState *string `json:"licenseProcessingState,omitempty"` Mail *string `json:"mail,omitempty"` @@ -896,7 +932,7 @@ type Group struct { Theme *GroupTheme `json:"theme,omitempty"` UnseenCount *int `json:"unseenCount,omitempty"` Visibility *GroupVisibility `json:"visibility,omitempty"` - IsAssignableToRole *bool `json:"isAssignableToRole,omitempty"` + WritebackConfiguration *GroupWritebackConfiguration `json:"writebackConfiguration,omitempty"` } func (g Group) MarshalJSON() ([]byte, error) { @@ -977,6 +1013,11 @@ type GroupOnPremisesProvisioningError struct { Value *string `json:"value,omitempty"` } +type GroupWritebackConfiguration struct { + IsEnabled *bool `json:"isEnabled"` + OnPremisesGroupType *OnPremisesGroupType `json:"onPremisesGroupType"` +} + type Identity struct { DisplayName *string `json:"displayName,omitempty"` Id *string `json:"id,omitempty"` @@ -992,6 +1033,15 @@ type IdentityProvider struct { Name *string `json:"displayName,omitempty"` } +// Used in the identity sources of a ConnectedOrganization. +type IdentitySource struct { + ODataType *odata.Type `json:"@odata.type,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + DomainName *string `json:"domainName,omitempty"` + IssuerUri *string `json:"issuerUri,omitempty"` +} + type ImplicitGrantSettings struct { EnableAccessTokenIssuance *bool `json:"enableAccessTokenIssuance,omitempty"` EnableIdTokenIssuance *bool `json:"enableIdTokenIssuance,omitempty"` @@ -1210,6 +1260,10 @@ type Recipient struct { EmailAddress *EmailAddress `json:"emailAddress,omitempty"` } +type Ref struct { + ObjectUri *string `json:"@odata.id,omitempty"` +} + type RequestorSettings struct { ScopeType RequestorSettingsScopeType `json:"scopeType,omitempty"` AcceptRequests *bool `json:"acceptRequests,omitempty"` diff --git a/vendor/github.com/manicminer/hamilton/msgraph/role_definitions.go b/vendor/github.com/manicminer/hamilton/msgraph/role_definitions.go index eb95201dd0e5..a0fb5ab3be56 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/role_definitions.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/role_definitions.go @@ -129,7 +129,7 @@ func (c *RoleDefinitionsClient) Update(ctx context.Context, roleDefinition Unifi ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, ValidStatusCodes: []int{http.StatusNoContent}, Uri: Uri{ - Entity: fmt.Sprintf("/roleManagement/directory/roleDefinitions/%s", *roleDefinition.ID), + Entity: fmt.Sprintf("/roleManagement/directory/roleDefinitions/%s", *roleDefinition.ID()), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go b/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go index 698523bfc072..89eeed4ecc16 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go @@ -138,7 +138,7 @@ func (c *ServicePrincipalsClient) Get(ctx context.Context, id string, query odat func (c *ServicePrincipalsClient) Update(ctx context.Context, servicePrincipal ServicePrincipal) (int, error) { var status int - if servicePrincipal.ID == nil { + if servicePrincipal.ID() == nil { return status, errors.New("cannot update service principal with nil ID") } @@ -152,7 +152,7 @@ func (c *ServicePrincipalsClient) Update(ctx context.Context, servicePrincipal S ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, ValidStatusCodes: []int{http.StatusNoContent}, Uri: Uri{ - Entity: fmt.Sprintf("/servicePrincipals/%s", *servicePrincipal.ID), + Entity: fmt.Sprintf("/servicePrincipals/%s", *servicePrincipal.ID()), HasTenantId: true, }, }) @@ -265,7 +265,7 @@ func (c *ServicePrincipalsClient) GetOwner(ctx context.Context, servicePrincipal func (c *ServicePrincipalsClient) AddOwners(ctx context.Context, servicePrincipal *ServicePrincipal) (int, error) { var status int - if servicePrincipal.ID == nil { + if servicePrincipal.ID() == nil { return status, errors.New("cannot update service principal with nil ID") } if servicePrincipal.Owners == nil { @@ -292,7 +292,7 @@ func (c *ServicePrincipalsClient) AddOwners(ctx context.Context, servicePrincipa ValidStatusCodes: []int{http.StatusNoContent}, ValidStatusFunc: checkOwnerAlreadyExists, Uri: Uri{ - Entity: fmt.Sprintf("/servicePrincipals/%s/owners/$ref", *servicePrincipal.ID), + Entity: fmt.Sprintf("/servicePrincipals/%s/owners/$ref", *servicePrincipal.ID()), HasTenantId: true, }, }) @@ -352,7 +352,7 @@ func (c *ServicePrincipalsClient) RemoveOwners(ctx context.Context, servicePrinc func (c *ServicePrincipalsClient) AssignClaimsMappingPolicy(ctx context.Context, servicePrincipal *ServicePrincipal) (int, error) { var status int - if servicePrincipal.ID == nil { + if servicePrincipal.ID() == nil { return status, errors.New("cannot update service principal with nil ID") } if servicePrincipal.ClaimsMappingPolicies == nil { @@ -379,7 +379,7 @@ func (c *ServicePrincipalsClient) AssignClaimsMappingPolicy(ctx context.Context, ValidStatusCodes: []int{http.StatusNoContent}, ValidStatusFunc: checkPolicyAlreadyExists, Uri: Uri{ - Entity: fmt.Sprintf("/servicePrincipals/%s/claimsMappingPolicies/$ref", *servicePrincipal.ID), + Entity: fmt.Sprintf("/servicePrincipals/%s/claimsMappingPolicies/$ref", *servicePrincipal.ID()), HasTenantId: false, }, }) @@ -431,7 +431,7 @@ func (c *ServicePrincipalsClient) RemoveClaimsMappingPolicy(ctx context.Context, return status, errors.New("cannot remove, nil policyIds") } - assignedPolicies, _, err := c.ListClaimsMappingPolicy(ctx, *servicePrincipal.ID) + assignedPolicies, _, err := c.ListClaimsMappingPolicy(ctx, *servicePrincipal.ID()) if err != nil { return status, fmt.Errorf("ServicePrincipalsClient.BaseClient.ListClaimsMappingPolicy(): %v", err) } @@ -442,7 +442,7 @@ func (c *ServicePrincipalsClient) RemoveClaimsMappingPolicy(ctx context.Context, mapClaimsMappingPolicy := map[string]ClaimsMappingPolicy{} for _, v := range *assignedPolicies { - mapClaimsMappingPolicy[*v.ID] = v + mapClaimsMappingPolicy[*v.ID()] = v } for _, policyId := range *policyIds { @@ -465,7 +465,7 @@ func (c *ServicePrincipalsClient) RemoveClaimsMappingPolicy(ctx context.Context, ValidStatusCodes: []int{http.StatusNoContent}, ValidStatusFunc: checkPolicyStatus, Uri: Uri{ - Entity: fmt.Sprintf("/servicePrincipals/%s/claimsMappingPolicies/%s/$ref", *servicePrincipal.ID, policyId), + Entity: fmt.Sprintf("/servicePrincipals/%s/claimsMappingPolicies/%s/$ref", *servicePrincipal.ID(), policyId), HasTenantId: false, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/users.go b/vendor/github.com/manicminer/hamilton/msgraph/users.go index 11ed3ad5ac91..e503ecc40db0 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/users.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/users.go @@ -62,8 +62,16 @@ func (c *UsersClient) Create(ctx context.Context, user User) (*User, int, error) return nil, status, fmt.Errorf("json.Marshal(): %v", err) } + consistencyFunc := func(resp *http.Response, o *odata.OData) bool { + if resp != nil && resp.StatusCode == http.StatusBadRequest && o != nil && o.Error != nil { + return o.Error.Match(odata.ErrorPropertyValuesAreInvalid) + } + return false + } + resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ - Body: body, + Body: body, + ConsistencyFailureFunc: consistencyFunc, OData: odata.Query{ Metadata: odata.MetadataFull, }, @@ -208,7 +216,7 @@ func (c *UsersClient) Update(ctx context.Context, user User) (int, error) { ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, ValidStatusCodes: []int{http.StatusNoContent}, Uri: Uri{ - Entity: fmt.Sprintf("/users/%s", *user.ID), + Entity: fmt.Sprintf("/users/%s", *user.ID()), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/utils.go b/vendor/github.com/manicminer/hamilton/msgraph/utils.go index 77c1c4091cae..6b6d124b66ac 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/utils.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/utils.go @@ -1,6 +1,10 @@ package msgraph -import "encoding/json" +import ( + "encoding/json" + + "github.com/hashicorp/go-uuid" +) func MarshalDocs(docs [][]byte) ([]byte, error) { out := make(map[string]interface{}) @@ -16,3 +20,13 @@ func MarshalDocs(docs [][]byte) ([]byte, error) { } return json.Marshal(out) } + +func ValidateId(id *string) bool { + if id == nil || *id == "" { + return false + } + if _, err := uuid.ParseUUID(*id); err != nil { + return false + } + return true +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go b/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go index 1c59775636b7..11206c42b829 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go @@ -319,6 +319,14 @@ const ( ConditionalAccessRiskLevelUnknownFutureValue ConditionalAccessRiskLevel = "unknownFutureValue" ) +type ConnectedOrganizationState = string + +const ( + ConnectedOrganizationStateProposed ConnectedOrganizationState = "proposed" + ConnectedOrganizationStateConfigured ConnectedOrganizationState = "configured" + ConnectedOrganizationStateUnknownFutureValue ConnectedOrganizationState = "unknownFutureValue" +) + type DelegatedPermissionGrantConsentType = string const ( @@ -440,6 +448,14 @@ const ( KeyCredentialUsageVerify KeyCredentialUsage = "Verify" ) +type OnPremisesGroupType = string + +const ( + UniversalDistributionGroup OnPremisesGroupType = "UniversalDistributionGroup" + UniversalMailEnabledSecurityGroup OnPremisesGroupType = "UniversalMailEnabledSecurityGroup" + UniversalSecurityGroup OnPremisesGroupType = "UniversalSecurityGroup" +) + type Members []DirectoryObject func (o Members) MarshalJSON() ([]byte, error) { diff --git a/vendor/github.com/manicminer/hamilton/odata/errors.go b/vendor/github.com/manicminer/hamilton/odata/errors.go index abde41662103..f8bec32d82f9 100644 --- a/vendor/github.com/manicminer/hamilton/odata/errors.go +++ b/vendor/github.com/manicminer/hamilton/odata/errors.go @@ -5,6 +5,7 @@ const ( ErrorCannotDeleteOrUpdateEnabledEntitlement = "Permission (scope or role) cannot be deleted or updated unless disabled first" ErrorConflictingObjectPresentInDirectory = "A conflicting object with one or more of the specified property values is present in the directory" ErrorNotValidReferenceUpdate = "Not a valid reference update" + ErrorPropertyValuesAreInvalid = "One or more property values specified are invalid" ErrorResourceDoesNotExist = "Resource '.+' does not exist or one of its queried reference-property objects are not present" ErrorRemovedObjectReferencesDoNotExist = "One or more removed object references do not exist" ErrorServicePrincipalAppInOtherTenant = "When using this permission, the backing application of the service principal being created must in the local tenant" diff --git a/vendor/github.com/manicminer/hamilton/odata/http.go b/vendor/github.com/manicminer/hamilton/odata/http.go index e9a071938727..e14762f5de1f 100644 --- a/vendor/github.com/manicminer/hamilton/odata/http.go +++ b/vendor/github.com/manicminer/hamilton/odata/http.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" ) @@ -22,7 +22,7 @@ func FromResponse(resp *http.Response) (*OData, error) { contentType := strings.ToLower(resp.Header.Get("Content-Type")) if strings.HasPrefix(contentType, "application/json") { // Read the response body and close it - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) resp.Body.Close() if err != nil { return nil, fmt.Errorf("could not read response body: %s", err) @@ -34,7 +34,7 @@ func FromResponse(resp *http.Response) (*OData, error) { } // Reassign the response body - resp.Body = ioutil.NopCloser(bytes.NewBuffer(respBody)) + resp.Body = io.NopCloser(bytes.NewBuffer(respBody)) return &o, nil } diff --git a/vendor/github.com/manicminer/hamilton/odata/types.go b/vendor/github.com/manicminer/hamilton/odata/types.go index 20c31534f6f5..ed342af35da9 100644 --- a/vendor/github.com/manicminer/hamilton/odata/types.go +++ b/vendor/github.com/manicminer/hamilton/odata/types.go @@ -46,13 +46,14 @@ type Type = string const ( TypeAccessPackage Type = "#microsoft.graph.accessPackage" TypeAccessPackageAssignmentPolicy Type = "#microsoft.graph.accessPackageAssignmentPolicy" - TypeAccessPackageQuestion Type = "#microsoft.graph.accessPackageQuestion" - TypeAccessPackageTextInputQuestion Type = "#microsoft.graph.accessPackageTextInputQuestion" - TypeAccessPackageMultipleChoiceQuestion Type = "#microsoft.graph.accessPackageMultipleChoiceQuestion" TypeAccessPackageCatalog Type = "#microsoft.graph.accessPackageCatalog" + TypeAccessPackageMultipleChoiceQuestion Type = "#microsoft.graph.accessPackageMultipleChoiceQuestion" + TypeAccessPackageQuestion Type = "#microsoft.graph.accessPackageQuestion" TypeAccessPackageResourceRequest Type = "#microsoft.graph.accessPackageResourceRequest" + TypeAccessPackageTextInputQuestion Type = "#microsoft.graph.accessPackageTextInputQuestion" TypeAdministrativeUnit Type = "#microsoft.graph.administrativeUnit" TypeApplication Type = "#microsoft.graph.application" + TypeAzureActiveDirectoryTenant Type = "#microsoft.graph.azureActiveDirectoryTenant" TypeConditionalAccessPolicy Type = "#microsoft.graph.conditionalAccessPolicy" TypeConnectedOrganizationMembers Type = "#microsoft.graph.connectedOrganizationMembers" TypeConnectionInfo Type = "#microsoft.graph.connectionInfo" @@ -61,15 +62,17 @@ const ( TypeDirectoryRole Type = "#microsoft.graph.directoryRole" TypeDirectoryRoleTemplate Type = "#microsoft.graph.directoryRoleTemplate" TypeDomain Type = "#microsoft.graph.domain" + TypeDomainIdentitySource Type = "#microsoft.graph.domainIdentitySource" TypeEmailAuthenticationMethod Type = "#microsoft.graph.emailAuthenticationMethod" + TypeExternalDomainFederation Type = "#microsoft.graph.externalDomainFederation" TypeExternalSponsors Type = "#microsoft.graph.externalSponsors" TypeFido2AuthenticationMethod Type = "#microsoft.graph.fido2AuthenticationMethod" TypeGroup Type = "#microsoft.graph.group" TypeGroupMembers Type = "#microsoft.graph.groupMembers" - TypeIpNamedLocation Type = "#microsoft.graph.ipNamedLocation" TypeInternalSponsors Type = "#microsoft.graph.internalSponsors" - TypeNamedLocation Type = "#microsoft.graph.namedLocation" + TypeIpNamedLocation Type = "#microsoft.graph.ipNamedLocation" TypeMicrosoftAuthenticatorAuthenticationMethod Type = "#microsoft.graph.microsoftAuthenticatorAuthenticationMethod" + TypeNamedLocation Type = "#microsoft.graph.namedLocation" TypeOrganization Type = "#microsoft.graph.organization" TypePasswordAuthenticationMethod Type = "#microsoft.graph.passwordAuthenticationMethod" TypePhoneAuthenticationMethod Type = "#microsoft.graph.phoneAuthenticationMethod" diff --git a/vendor/golang.org/x/oauth2/AUTHORS b/vendor/golang.org/x/oauth2/AUTHORS deleted file mode 100644 index 15167cd746c5..000000000000 --- a/vendor/golang.org/x/oauth2/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/oauth2/CONTRIBUTORS b/vendor/golang.org/x/oauth2/CONTRIBUTORS deleted file mode 100644 index 1c4577e96806..000000000000 --- a/vendor/golang.org/x/oauth2/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/modules.txt b/vendor/modules.txt index e37239855061..f9986401b9f4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -71,14 +71,14 @@ github.com/Azure/azure-sdk-for-go/version # github.com/Azure/go-autorest v14.2.0+incompatible ## explicit github.com/Azure/go-autorest -# github.com/Azure/go-autorest/autorest v0.11.27 +# github.com/Azure/go-autorest/autorest v0.11.28 ## explicit; go 1.15 github.com/Azure/go-autorest/autorest github.com/Azure/go-autorest/autorest/azure -# github.com/Azure/go-autorest/autorest/adal v0.9.18 +# github.com/Azure/go-autorest/autorest/adal v0.9.22 ## explicit; go 1.15 github.com/Azure/go-autorest/autorest/adal -# github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 +# github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 ## explicit; go 1.15 github.com/Azure/go-autorest/autorest/azure/cli # github.com/Azure/go-autorest/autorest/date v0.3.0 @@ -123,7 +123,7 @@ github.com/fatih/color # github.com/gofrs/uuid v4.0.0+incompatible ## explicit github.com/gofrs/uuid -# github.com/golang-jwt/jwt/v4 v4.4.1 +# github.com/golang-jwt/jwt/v4 v4.4.3 ## explicit; go 1.16 github.com/golang-jwt/jwt/v4 # github.com/golang/protobuf v1.5.2 @@ -148,8 +148,8 @@ github.com/google/uuid # github.com/hashicorp/errwrap v1.1.0 ## explicit github.com/hashicorp/errwrap -# github.com/hashicorp/go-azure-helpers v0.47.0 -## explicit; go 1.18 +# github.com/hashicorp/go-azure-helpers v0.51.0 +## explicit; go 1.19 github.com/hashicorp/go-azure-helpers/authentication github.com/hashicorp/go-azure-helpers/lang/dates github.com/hashicorp/go-azure-helpers/lang/pointer @@ -168,8 +168,8 @@ github.com/hashicorp/go-azure-helpers/resourcemanager/zones github.com/hashicorp/go-azure-helpers/resourceproviders github.com/hashicorp/go-azure-helpers/sender github.com/hashicorp/go-azure-helpers/storage -# github.com/hashicorp/go-azure-sdk v0.20230130.1140358 -## explicit; go 1.18 +# github.com/hashicorp/go-azure-sdk v0.20230202.1112019 +## explicit; go 1.19 github.com/hashicorp/go-azure-sdk/resource-manager/aad/2021-05-01/domainservices github.com/hashicorp/go-azure-sdk/resource-manager/aadb2c/2021-04-01-preview github.com/hashicorp/go-azure-sdk/resource-manager/aadb2c/2021-04-01-preview/tenants @@ -514,7 +514,7 @@ github.com/hashicorp/go-multierror ## explicit; go 1.17 github.com/hashicorp/go-plugin github.com/hashicorp/go-plugin/internal/plugin -# github.com/hashicorp/go-retryablehttp v0.7.0 +# github.com/hashicorp/go-retryablehttp v0.7.2 ## explicit; go 1.13 github.com/hashicorp/go-retryablehttp # github.com/hashicorp/go-uuid v1.0.3 @@ -626,7 +626,7 @@ github.com/hashicorp/yamux # github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8 ## explicit; go 1.16 github.com/magodo/terraform-provider-azurerm-example-gen/examplegen -# github.com/manicminer/hamilton v0.50.0 +# github.com/manicminer/hamilton v0.55.0 ## explicit; go 1.16 github.com/manicminer/hamilton/auth github.com/manicminer/hamilton/environments @@ -634,7 +634,7 @@ github.com/manicminer/hamilton/errors github.com/manicminer/hamilton/internal/utils github.com/manicminer/hamilton/msgraph github.com/manicminer/hamilton/odata -# github.com/manicminer/hamilton-autorest v0.2.0 +# github.com/manicminer/hamilton-autorest v0.3.0 ## explicit; go 1.16 github.com/manicminer/hamilton-autorest/auth github.com/manicminer/hamilton-autorest/environments @@ -756,8 +756,8 @@ 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/oauth2 v0.0.0-20210628180205-a41e5a781914 -## explicit; go 1.11 +# golang.org/x/oauth2 v0.4.0 +## explicit; go 1.17 golang.org/x/oauth2 golang.org/x/oauth2/internal # golang.org/x/sys v0.4.0