-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8945: Introduce new immutable protocol r=npepinpe a=npepinpe ## Description Introduces a new immutable protocol directly under `protocol`, which annotates the types directly. This has several advantages: - We can now easily recursively copy the types (except for `Record`, which is a special case due to its generic typing) - It's less error prone thanks to an ArchUnit test guaranteeing we don't forget to annotate the types - It's less overhead for developers when adding new types - It allows us to easily collect metadata about the types via reflection using annotations This is the first step for #8837 - the next step will remove the immutable variants in `protocol-jackson` and replace them with this. ## Related issues related to #8837 8995: Introduce new commands to deploy resources in the Go client r=npepinpe a=npepinpe ## Description This PR reverts the previous breaking changes and instead introduces new commands to deploy decisions and decision requirements. The client must now use `client.NewDeployResourceCommand()`, and the old `client.NewDeployProcessCommand()` has been restored. Similarly, `zbctl` now supports its old `zbctl deploy <path> <path>` behavior, but also supports `zbctl deploy resource mySuper.dmn` as well, which behaves the same as the old deploy command but can deploy DMN files. ## Related issues <!-- Which issues are closed by this PR or are related --> related to #8979 Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
- Loading branch information
Showing
55 changed files
with
788 additions
and
99 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright © 2018 Camunda Services GmbH (info@camunda.com) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package commands | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"io/ioutil" | ||
) | ||
|
||
// Remove the nolint directive once deploy resource is the only command left | ||
//nolint | ||
var deployCmd = &cobra.Command{ | ||
Use: "deploy <processPath>...", | ||
Short: "Deploys new resources for each file provided", | ||
Args: cobra.MinimumNArgs(1), | ||
PreRunE: initClient, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(resourceNamesFlag) > len(args) { | ||
return fmt.Errorf("there are more resource names (%d) than process paths (%d)", len(resourceNamesFlag), len(args)) | ||
} | ||
|
||
zbCmd := client.NewDeployProcessCommand() | ||
for i := 0; i < len(resourceNamesFlag); i++ { | ||
bytes, err := ioutil.ReadFile(args[i]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
zbCmd.AddResource(bytes, resourceNamesFlag[i]) | ||
} | ||
|
||
for i := len(resourceNamesFlag); i < len(args); i++ { | ||
zbCmd = zbCmd.AddResourceFile(args[i]) | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) | ||
defer cancel() | ||
|
||
response, err := zbCmd.Send(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return printJSON(response) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(deployCmd) | ||
|
||
deployCmd.Flags().StringSliceVar(&resourceNamesFlag, "resourceNames", nil, "Resource names"+ | ||
" for the processes paths passed as arguments. The resource names are matched to processes by position. If a"+ | ||
" process does not have a matching resource name, the process path is used instead") | ||
} |
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 |
---|---|---|
@@ -1,42 +1,17 @@ | ||
{ | ||
"key": "2251799813685250", | ||
"deployments": [ | ||
"processes": [ | ||
{ | ||
"process": { | ||
"bpmnProcessId": "process", | ||
"version": 1, | ||
"processDefinitionKey": "2251799813685249", | ||
"resourceName": "model.bpmn" | ||
} | ||
"bpmnProcessId": "process", | ||
"version": 1, | ||
"processDefinitionKey": "2251799813685345", | ||
"resourceName": "model.bpmn" | ||
}, | ||
{ | ||
"decision": { | ||
"dmnDecisionId": "jedi_or_sith", | ||
"dmnDecisionName": "Jedi or Sith", | ||
"version": 1, | ||
"decisionKey": "2251799813685251", | ||
"dmnDecisionRequirementsId": "force_users", | ||
"decisionRequirementsKey": "2251799813685250" | ||
} | ||
}, | ||
{ | ||
"decision": { | ||
"dmnDecisionId": "force_user", | ||
"dmnDecisionName": "Which force user?", | ||
"version": 1, | ||
"decisionKey": "2251799813685252", | ||
"dmnDecisionRequirementsId": "force_users", | ||
"decisionRequirementsKey": "2251799813685250" | ||
} | ||
}, | ||
{ | ||
"decisionRequirements": { | ||
"dmnDecisionRequirementsId": "force_users", | ||
"dmnDecisionRequirementsName": "force_users", | ||
"version": 1, | ||
"decisionRequirementsKey": "2251799813685250", | ||
"resourceName": "drg-force-user.dmn" | ||
} | ||
"bpmnProcessId": "jobProcess", | ||
"version": 1, | ||
"processDefinitionKey": "2251799813685346", | ||
"resourceName": "job.bpmn" | ||
} | ||
] | ||
} |
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,42 @@ | ||
{ | ||
"key": "2251799813685250", | ||
"deployments": [ | ||
{ | ||
"process": { | ||
"bpmnProcessId": "process", | ||
"version": 1, | ||
"processDefinitionKey": "2251799813685249", | ||
"resourceName": "model.bpmn" | ||
} | ||
}, | ||
{ | ||
"decision": { | ||
"dmnDecisionId": "jedi_or_sith", | ||
"dmnDecisionName": "Jedi or Sith", | ||
"version": 1, | ||
"decisionKey": "2251799813685251", | ||
"dmnDecisionRequirementsId": "force_users", | ||
"decisionRequirementsKey": "2251799813685250" | ||
} | ||
}, | ||
{ | ||
"decision": { | ||
"dmnDecisionId": "force_user", | ||
"dmnDecisionName": "Which force user?", | ||
"version": 1, | ||
"decisionKey": "2251799813685252", | ||
"dmnDecisionRequirementsId": "force_users", | ||
"decisionRequirementsKey": "2251799813685250" | ||
} | ||
}, | ||
{ | ||
"decisionRequirements": { | ||
"dmnDecisionRequirementsId": "force_users", | ||
"dmnDecisionRequirementsName": "force_users", | ||
"version": 1, | ||
"decisionRequirementsKey": "2251799813685250", | ||
"resourceName": "drg-force-user.dmn" | ||
} | ||
} | ||
] | ||
} |
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,58 @@ | ||
// Copyright © 2018 Camunda Services GmbH (info@camunda.com) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package commands | ||
|
||
import ( | ||
"context" | ||
"github.com/camunda/zeebe/clients/go/pkg/pb" | ||
"io/ioutil" | ||
"log" | ||
) | ||
|
||
type DeployResourceCommand struct { | ||
Command | ||
request pb.DeployResourceRequest | ||
} | ||
|
||
func (cmd *DeployResourceCommand) AddResourceFile(path string) *DeployResourceCommand { | ||
b, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
return cmd.AddResource(b, path) | ||
} | ||
|
||
func (cmd *DeployResourceCommand) AddResource(definition []byte, name string) *DeployResourceCommand { | ||
cmd.request.Resources = append(cmd.request.Resources, &pb.Resource{Content: definition, Name: name}) | ||
return cmd | ||
} | ||
|
||
func (cmd *DeployResourceCommand) Send(ctx context.Context) (*pb.DeployResourceResponse, error) { | ||
response, err := cmd.gateway.DeployResource(ctx, &cmd.request) | ||
if cmd.shouldRetry(ctx, err) { | ||
return cmd.Send(ctx) | ||
} | ||
|
||
return response, err | ||
} | ||
|
||
func NewDeployResourceCommand(gateway pb.GatewayClient, pred retryPredicate) *DeployResourceCommand { | ||
return &DeployResourceCommand{ | ||
Command: Command{ | ||
gateway: gateway, | ||
shouldRetry: pred, | ||
}, | ||
} | ||
} |
Oops, something went wrong.