-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update api request for flags (#42)
- delete unused code - lock to latest version of flags api, which guarantees all flags are fetched - update api-client-go to latest - wrap error and failExit to make sure there's consistent err logging - set user agent (if we use release we can have it update version like it does in `ld-find-code-refs`
- Loading branch information
Showing
411 changed files
with
125,211 additions
and
94 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ldapi | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
ldapi "github.com/launchdarkly/api-client-go/v13" | ||
lcr "github.com/launchdarkly/cr-flags/config" | ||
"github.com/launchdarkly/cr-flags/internal/version" | ||
) | ||
|
||
func GetFlags(config *lcr.Config) ([]ldapi.FeatureFlag, error) { | ||
url := fmt.Sprintf("%s/api/v2/flags/%s?env=%s", config.LdInstance, config.LdProject, config.LdEnvironment) | ||
client := &http.Client{} | ||
req, err := http.NewRequest(http.MethodGet, url, nil) | ||
if err != nil { | ||
return []ldapi.FeatureFlag{}, err | ||
} | ||
req.Header.Add("Authorization", config.ApiToken) | ||
req.Header.Add("LD-API-Version", "20220603") | ||
req.Header.Add("User-Agent", fmt.Sprintf("find-code-references-pr/%s", version.Version)) | ||
|
||
resp, err := client.Do(req) | ||
if err != nil { | ||
return []ldapi.FeatureFlag{}, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
flags := ldapi.FeatureFlags{} | ||
err = json.NewDecoder(resp.Body).Decode(&flags) | ||
if err != nil { | ||
return []ldapi.FeatureFlag{}, err | ||
} | ||
|
||
return flags.Items, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package version | ||
|
||
const Version = "0.7.0-rc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
vendor/github.com/launchdarkly/api-client-go/v13/.gitignore
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
vendor/github.com/launchdarkly/api-client-go/v13/.openapi-generator-ignore
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
vendor/github.com/launchdarkly/api-client-go/v13/LICENSE.txt
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.