diff --git a/go.mod b/go.mod index 36a579184..09874bbf9 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,13 @@ module github.com/OctopusDeploy/terraform-provider-octopusdeploy require ( - github.com/OctopusDeploy/go-octopusdeploy v0.0.0-20190101071024-032701337fa6 + github.com/OctopusDeploy/go-octopusdeploy v1.0.0 github.com/apparentlymart/go-cidr v1.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/aws/aws-sdk-go v1.15.53 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/blang/semver v3.5.1+incompatible // indirect - github.com/dghubble/sling v1.1.0 // indirect github.com/go-ini/ini v1.38.3 // indirect - github.com/go-playground/locales v0.12.1 // indirect - github.com/go-playground/universal-translator v0.16.0 // indirect github.com/google/go-querystring v1.0.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.0 // indirect github.com/hashicorp/go-getter v0.0.0-20180809191950-4bda8fa99001 // indirect @@ -39,7 +36,6 @@ require ( github.com/zclconf/go-cty v0.0.0-20181011210859-1f835aab79c2 // indirect google.golang.org/genproto v0.0.0-20181004005441-af9cb2a35e7f // indirect google.golang.org/grpc v1.15.0 // indirect - gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v9 v9.21.0 // indirect gopkg.in/ini.v1 v1.42.0 // indirect ) diff --git a/go.sum b/go.sum index b178950f2..2ae8d573b 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/DHowett/go-plist v0.0.0-20180609054337-500bd5b9081b/go.mod h1:5paT5ZDrOm8eAJPem2Bd+q3FTi3Gxm/U4tb2tH8YIUQ= -github.com/OctopusDeploy/go-octopusdeploy v0.0.0-20190101071024-032701337fa6 h1:KZHt2zDW22EbhfTvsZLzWRzn/5Kb8Jhnnk27wJQr/lY= -github.com/OctopusDeploy/go-octopusdeploy v0.0.0-20190101071024-032701337fa6/go.mod h1:MLm+0h6BI+oIU1ucONLo9AiN3YklMo6dzc7aAH2bgYo= +github.com/OctopusDeploy/go-octopusdeploy v1.0.0 h1:JweXaa6zTIv8NOpLDLomzceVGV+v4L/zrOHN5DOZykc= +github.com/OctopusDeploy/go-octopusdeploy v1.0.0/go.mod h1:WyBvcyhFPMULbZwFFWOmt6/irqrfZ/WqCy7ufa8/CGE= github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/apparentlymart/go-cidr v1.0.0 h1:lGDvXx8Lv9QHjrAVP7jyzleG4F9+FkRhJcEsDFxeb8w= @@ -22,6 +22,7 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dghubble/sling v1.1.0 h1:DLu20Bq2qsB9cI5Hldaxj+TMPEaPpPE8IR2kvD22Atg= @@ -45,6 +46,7 @@ github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= @@ -125,6 +127,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.1.2 h1:fS9GkqLN9DIpHg9j3fAPHdj5P3LhzxuoSybQd1v26IE= github.com/posener/complete v1.1.2/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= @@ -170,6 +173,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.19.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/go-playground/validator.v9 v9.21.0 h1:wSDJGBpQBYC1wLpVnGHLmshm2JicoSNdrb38Zj+8yHI= gopkg.in/go-playground/validator.v9 v9.21.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk= diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/account.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/account.go new file mode 100644 index 000000000..bc8cbd743 --- /dev/null +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/account.go @@ -0,0 +1,140 @@ +package octopusdeploy + +import ( + "fmt" + + "github.com/dghubble/sling" + "gopkg.in/go-playground/validator.v9" +) + +type AccountService struct { + sling *sling.Sling +} + +func NewAccountService(sling *sling.Sling) *AccountService { + return &AccountService{ + sling: sling, + } +} + +type Accounts struct { + Items []Account `json:"Items"` + PagedResults +} + +type Account struct { + ID string `json:"Id"` + Name string `json:"Name"` + AccountType string `json:"AccountType"` + SubscriptionNumber string `json:"SubscriptionNumber"` + ClientId string `json:"ClientId"` + TenantId string `json:"TenantId"` + Password SensitiveValue `json:"Password"` + TenantTags []string `json:"TenantTags,omitempty"` + TenantedDeploymentParticipation string `json:"TenantedDeploymentParticipation"` +} + +func (t *Account) Validate() error { + validate := validator.New() + + err := validate.Struct(t) + + if err != nil { + return err + } + + return nil +} + +func NewAccount(name, accountType string) *Account { + return &Account{ + Name: name, + AccountType: accountType, + } +} + +func (s *AccountService) Get(accountId string) (*Account, error) { + path := fmt.Sprintf("accounts/%s", accountId) + resp, err := apiGet(s.sling, new(Account), path) + + if err != nil { + return nil, err + } + + return resp.(*Account), nil +} + +func (s *AccountService) GetAll() (*[]Account, error) { + var p []Account + + path := "accounts" + + loadNextPage := true + + for loadNextPage { + resp, err := apiGet(s.sling, new(Accounts), path) + + if err != nil { + return nil, err + } + + r := resp.(*Accounts) + + for _, item := range r.Items { + p = append(p, item) + } + + path, loadNextPage = LoadNextPage(r.PagedResults) + } + + return &p, nil +} + +func (s *AccountService) GetByName(accountName string) (*Account, error) { + var foundAccount Account + accounts, err := s.GetAll() + + if err != nil { + return nil, err + } + + for _, account := range *accounts { + if account.Name == accountName { + return &account, nil + } + } + + return &foundAccount, fmt.Errorf("no account found with account name %s", accountName) +} + +func (s *AccountService) Add(account *Account) (*Account, error) { + resp, err := apiAdd(s.sling, account, new(Account), "accounts") + + if err != nil { + return nil, err + } + + return resp.(*Account), nil +} + +func (s *AccountService) Delete(accountId string) error { + path := fmt.Sprintf("accounts/%s", accountId) + err := apiDelete(s.sling, path) + + if err != nil { + return err + } + + return nil +} + +func (s *AccountService) Update(account *Account) (*Account, error) { + path := fmt.Sprintf("accounts/%s", account.ID) + resp, err := apiUpdate(s.sling, account, new(Account), path) + + if err != nil { + return nil, err + } + + return resp.(*Account), nil +} diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/deployment_process.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/deployment_process.go index 7b5013960..c4aebfa3e 100644 --- a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/deployment_process.go +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/deployment_process.go @@ -59,21 +59,20 @@ type DeploymentAction struct { Packages []PackageReference `json:"Packages,omitempty"` } - type DeploymentStepPackageRequirement string const ( - DeploymentStepPackageRequirement_LetOctopusDecide = DeploymentStepPackageRequirement("LetOctopusDecide") + DeploymentStepPackageRequirement_LetOctopusDecide = DeploymentStepPackageRequirement("LetOctopusDecide") DeploymentStepPackageRequirement_BeforePackageAcquisition = DeploymentStepPackageRequirement("BeforePackageAcquisition") - DeploymentStepPackageRequirement_AfterPackageAcquisition = DeploymentStepPackageRequirement("AfterPackageAcquisition") + DeploymentStepPackageRequirement_AfterPackageAcquisition = DeploymentStepPackageRequirement("AfterPackageAcquisition") ) type DeploymentStepCondition string const ( - DeploymentStepCondition_Success = DeploymentStepCondition("Success") - DeploymentStepCondition_Failure = DeploymentStepCondition("Failure") - DeploymentStepCondition_Always = DeploymentStepCondition("Always") + DeploymentStepCondition_Success = DeploymentStepCondition("Success") + DeploymentStepCondition_Failure = DeploymentStepCondition("Failure") + DeploymentStepCondition_Always = DeploymentStepCondition("Always") DeploymentStepCondition_Variable = DeploymentStepCondition("Variable") ) @@ -81,7 +80,7 @@ type DeploymentStepStartTrigger string const ( DeploymentStepStartTrigger_StartAfterPrevious = DeploymentStepStartTrigger("StartAfterPrevious") - DeploymentStepStartTrigger_StartWithPrevious = DeploymentStepStartTrigger("StartWithPrevious") + DeploymentStepStartTrigger_StartWithPrevious = DeploymentStepStartTrigger("StartWithPrevious") ) type PackageReference struct { @@ -94,12 +93,11 @@ type PackageReference struct { } const ( - PackageAcquisitionLocation_Server = "Server" + PackageAcquisitionLocation_Server = "Server" PackageAcquisitionLocation_ExecutionTarget = "ExecutionTarget" - PackageAcquisitionLocation_NotAcquired = "NotAcquired" + PackageAcquisitionLocation_NotAcquired = "NotAcquired" ) - func (d *DeploymentProcess) Validate() error { validate := validator.New() diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/environment.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/environment.go index 4546794cb..edbd40a76 100644 --- a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/environment.go +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/environment.go @@ -23,11 +23,12 @@ type Environments struct { } type Environment struct { - ID string `json:"Id"` - Name string `json:"Name"` - Description string `json:"Description"` - SortOrder int `json:"SortOrder"` - UseGuidedFailure bool `json:"UseGuidedFailure"` + ID string `json:"Id"` + Name string `json:"Name"` + Description string `json:"Description"` + SortOrder int `json:"SortOrder"` + UseGuidedFailure bool `json:"UseGuidedFailure"` + AllowDynamicInfrastructure bool `json:"AllowDynamicInfrastructure"` } func (t *Environment) Validate() error { diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/feed.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/feed.go new file mode 100644 index 000000000..4c7bb22d3 --- /dev/null +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/feed.go @@ -0,0 +1,141 @@ +package octopusdeploy + +import ( + "fmt" + + "github.com/dghubble/sling" + "gopkg.in/go-playground/validator.v9" +) + +type FeedService struct { + sling *sling.Sling +} + +func NewFeedService(sling *sling.Sling) *FeedService { + return &FeedService{ + sling: sling, + } +} + +type Feeds struct { + Items []Feed `json:"Items"` + PagedResults +} + +type Feed struct { + ID string `json:"Id"` + Name string `json:"Name"` + FeedType string `json:"FeedType"` + DownloadAttempts int `json:"DownloadAttempts"` + DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"` + FeedUri string `json:"FeedUri"` + EnhancedMode bool `json:"EnhancedMode"` + Username string `json:"Username"` + Password SensitiveValue `json:"Password"` +} + +func (t *Feed) Validate() error { + validate := validator.New() + + err := validate.Struct(t) + + if err != nil { + return err + } + + return nil +} + +func NewFeed(name, feedType string, feedUri string) *Feed { + return &Feed{ + Name: name, + FeedType: feedType, + FeedUri: feedUri, + } +} + +func (s *FeedService) Get(feedId string) (*Feed, error) { + path := fmt.Sprintf("feeds/%s", feedId) + resp, err := apiGet(s.sling, new(Feed), path) + + if err != nil { + return nil, err + } + + return resp.(*Feed), nil +} + +func (s *FeedService) GetAll() (*[]Feed, error) { + var p []Feed + + path := "feeds" + + loadNextPage := true + + for loadNextPage { + resp, err := apiGet(s.sling, new(Feeds), path) + + if err != nil { + return nil, err + } + + r := resp.(*Feeds) + + for _, item := range r.Items { + p = append(p, item) + } + + path, loadNextPage = LoadNextPage(r.PagedResults) + } + + return &p, nil +} + +func (s *FeedService) GetByName(feedName string) (*Feed, error) { + var foundFeed Feed + feeds, err := s.GetAll() + + if err != nil { + return nil, err + } + + for _, feed := range *feeds { + if feed.Name == feedName { + return &feed, nil + } + } + + return &foundFeed, fmt.Errorf("no feed found with feed name %s", feedName) +} + +func (s *FeedService) Add(feed *Feed) (*Feed, error) { + resp, err := apiAdd(s.sling, feed, new(Feed), "feeds") + + if err != nil { + return nil, err + } + + return resp.(*Feed), nil +} + +func (s *FeedService) Delete(feedId string) error { + path := fmt.Sprintf("feeds/%s", feedId) + err := apiDelete(s.sling, path) + + if err != nil { + return err + } + + return nil +} + +func (s *FeedService) Update(feed *Feed) (*Feed, error) { + path := fmt.Sprintf("feeds/%s", feed.ID) + resp, err := apiUpdate(s.sling, feed, new(Feed), path) + + if err != nil { + return nil, err + } + + return resp.(*Feed), nil +} diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/library_variable_set.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/library_variable_set.go index 55b639234..e6567f0ec 100644 --- a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/library_variable_set.go +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/library_variable_set.go @@ -24,21 +24,21 @@ type LibraryVariableSets struct { } type LibraryVariableSet struct { - ID string `json:"Id,omitempty"` - Name string `json:"Name" validate:"required"` - Description string `json:"Description,omitempty"` - VariableSetId string `json:"VariableSetId,omitempty"` - ContentType VariableSetContentType `json:"ContentType" validate:"required"` + ID string `json:"Id,omitempty"` + Name string `json:"Name" validate:"required"` + Description string `json:"Description,omitempty"` + VariableSetId string `json:"VariableSetId,omitempty"` + ContentType VariableSetContentType `json:"ContentType" validate:"required"` + Templates []ActionTemplateParameter `json:"Templates,omitempty"` } type VariableSetContentType string const ( - VariableSetContentType_Variables = VariableSetContentType("Variables") + VariableSetContentType_Variables = VariableSetContentType("Variables") VariableSetContentType_ScriptModule = VariableSetContentType("ScriptModule") ) - func NewLibraryVariableSet(name string) *LibraryVariableSet { return &LibraryVariableSet{ Name: name, @@ -68,7 +68,7 @@ func (s *LibraryVariableSetService) Get(libraryVariableSetID string) (*LibraryVa // GetAll returns all libraryVariableSets in Octopus Deploy func (s *LibraryVariableSetService) GetAll() (*[]LibraryVariableSet, error) { - return s.get(""); + return s.get("") } func (s *LibraryVariableSetService) get(query string) (*[]LibraryVariableSet, error) { diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/lifecycles.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/lifecycles.go index f306660b4..43fa41c94 100644 --- a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/lifecycles.go +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/lifecycles.go @@ -35,7 +35,7 @@ type Lifecycle struct { type RetentionUnit string const ( - RetentionUnit_Days = RetentionUnit("Days") + RetentionUnit_Days = RetentionUnit("Days") RetentionUnit_Items = RetentionUnit("Items") ) @@ -46,26 +46,25 @@ type RetentionPeriod struct { } type Phase struct { - ID string `json:"Id,omitempty"` - Name string `json:"Name" validate:"required"` - MinimumEnvironmentsBeforePromotion int32 `json:"MinimumEnvironmentsBeforePromotion"` - IsOptionalPhase bool `json:"IsOptionalPhase"` + ID string `json:"Id,omitempty"` + Name string `json:"Name" validate:"required"` + MinimumEnvironmentsBeforePromotion int32 `json:"MinimumEnvironmentsBeforePromotion"` + IsOptionalPhase bool `json:"IsOptionalPhase"` ReleaseRetentionPolicy *RetentionPeriod `json:"ReleaseRetentionPolicy"` TentacleRetentionPolicy *RetentionPeriod `json:"TentacleRetentionPolicy"` - AutomaticDeploymentTargets []string `json:"AutomaticDeploymentTargets"` - OptionalDeploymentTargets []string `json:"OptionalDeploymentTargets"` + AutomaticDeploymentTargets []string `json:"AutomaticDeploymentTargets"` + OptionalDeploymentTargets []string `json:"OptionalDeploymentTargets"` } - func NewLifecycle(name string) *Lifecycle { return &Lifecycle{ Name: name, Phases: []Phase{}, - TentacleRetentionPolicy:RetentionPeriod{ - Unit:RetentionUnit_Days, + TentacleRetentionPolicy: RetentionPeriod{ + Unit: RetentionUnit_Days, }, - ReleaseRetentionPolicy:RetentionPeriod{ - Unit:RetentionUnit_Days, + ReleaseRetentionPolicy: RetentionPeriod{ + Unit: RetentionUnit_Days, }, } } @@ -108,7 +107,7 @@ func (s *LifecycleService) Get(LifecycleID string) (*Lifecycle, error) { // GetAll returns all lifecycles in Octopus Deploy func (s *LifecycleService) GetAll() (*[]Lifecycle, error) { - return s.get(""); + return s.get("") } func (s *LifecycleService) get(query string) (*[]Lifecycle, error) { diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/octopusdeploy.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/octopusdeploy.go index 12b1ed85e..6db343a68 100644 --- a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/octopusdeploy.go +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/octopusdeploy.go @@ -13,17 +13,20 @@ import ( type Client struct { sling *sling.Sling // Octopus Deploy API Services + Account *AccountService DeploymentProcess *DeploymentProcessService ProjectGroup *ProjectGroupService Project *ProjectService ProjectTrigger *ProjectTriggerService Environment *EnvironmentService + Feed *FeedService Variable *VariableService MachinePolicy *MachinePolicyService Machine *MachineService Lifecycle *LifecycleService LibraryVariableSet *LibraryVariableSetService Interruption *InterruptionsService + TagSet *TagSetService } // NewClient returns a new Client. @@ -34,17 +37,20 @@ func NewClient(httpClient *http.Client, octopusURL, octopusAPIKey string) *Clien base := sling.New().Client(httpClient).Base(baseURLWithAPI).Set("X-Octopus-ApiKey", octopusAPIKey) return &Client{ sling: base, + Account: NewAccountService(base.New()), DeploymentProcess: NewDeploymentProcessService(base.New()), ProjectGroup: NewProjectGroupService(base.New()), Project: NewProjectService(base.New()), ProjectTrigger: NewProjectTriggerService(base.New()), Environment: NewEnvironmentService(base.New()), + Feed: NewFeedService(base.New()), Variable: NewVariableService(base.New()), MachinePolicy: NewMachinePolicyService(base.New()), Machine: NewMachineService(base.New()), Lifecycle: NewLifecycleService(base.New()), LibraryVariableSet: NewLibraryVariableSetService(base.New()), Interruption: NewInterruptionService(base.New()), + TagSet: NewTagSetService(base.New()), } } diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/tag_set.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/tag_set.go new file mode 100644 index 000000000..68e0b1107 --- /dev/null +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/tag_set.go @@ -0,0 +1,139 @@ +package octopusdeploy + +import ( + "fmt" + + "github.com/dghubble/sling" + "gopkg.in/go-playground/validator.v9" +) + +type TagSetService struct { + sling *sling.Sling +} + +func NewTagSetService(sling *sling.Sling) *TagSetService { + return &TagSetService{ + sling: sling, + } +} + +type TagSets struct { + Items []TagSet `json:"Items"` + PagedResults +} + +type TagSet struct { + ID string `json:"Id"` + Name string `json:"Name"` + Tags []Tag `json:"Tags,omitempty"` +} + +type Tag struct { + ID string `json:"Id"` + Name string `json:"Name"` + Color string `json:"Color"` +} + +func (t *TagSet) Validate() error { + validate := validator.New() + + err := validate.Struct(t) + + if err != nil { + return err + } + + return nil +} + +func NewTagSet(name string) *TagSet { + return &TagSet{ + Name: name, + } +} + +func (s *TagSetService) Get(tagSetId string) (*TagSet, error) { + path := fmt.Sprintf("tagSets/%s", tagSetId) + resp, err := apiGet(s.sling, new(TagSet), path) + + if err != nil { + return nil, err + } + + return resp.(*TagSet), nil +} + +func (s *TagSetService) GetAll() (*[]TagSet, error) { + var p []TagSet + + path := "tagSets" + + loadNextPage := true + + for loadNextPage { + resp, err := apiGet(s.sling, new(TagSets), path) + + if err != nil { + return nil, err + } + + r := resp.(*TagSets) + + for _, item := range r.Items { + p = append(p, item) + } + + path, loadNextPage = LoadNextPage(r.PagedResults) + } + + return &p, nil +} + +func (s *TagSetService) GetByName(tagSetName string) (*TagSet, error) { + var foundTagSet TagSet + tagSets, err := s.GetAll() + + if err != nil { + return nil, err + } + + for _, tagSet := range *tagSets { + if tagSet.Name == tagSetName { + return &tagSet, nil + } + } + + return &foundTagSet, fmt.Errorf("no tagSet found with tagSet name %s", tagSetName) +} + +func (s *TagSetService) Add(tagSet *TagSet) (*TagSet, error) { + resp, err := apiAdd(s.sling, tagSet, new(TagSet), "tagSets") + + if err != nil { + return nil, err + } + + return resp.(*TagSet), nil +} + +func (s *TagSetService) Delete(tagSetId string) error { + path := fmt.Sprintf("tagSets/%s", tagSetId) + err := apiDelete(s.sling, path) + + if err != nil { + return err + } + + return nil +} + +func (s *TagSetService) Update(tagSet *TagSet) (*TagSet, error) { + path := fmt.Sprintf("tagSets/%s", tagSet.ID) + resp, err := apiUpdate(s.sling, tagSet, new(TagSet), path) + + if err != nil { + return nil, err + } + + return resp.(*TagSet), nil +} diff --git a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/variables.go b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/variables.go index 27ccdba22..2fc96f5f9 100644 --- a/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/variables.go +++ b/vendor/github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy/variables.go @@ -38,6 +38,11 @@ type Variable struct { IsSensitive bool `json:"IsSensitive"` } +type SensitiveValue struct { + HasValue bool `json:"HasValue"` + NewValue string `json:"NewValue"` +} + type VariableScope struct { Project []string `json:"Project,omitempty"` Environment []string `json:"Environment,omitempty"` diff --git a/vendor/modules.txt b/vendor/modules.txt index ffbcce8ce..63dbf82e9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/OctopusDeploy/go-octopusdeploy v0.0.0-20190101071024-032701337fa6 +# github.com/OctopusDeploy/go-octopusdeploy v1.0.0 github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy # github.com/agext/levenshtein v1.2.1 github.com/agext/levenshtein