mirror of
https://github.com/coder/coder.git
synced 2025-07-23 21:32:07 +00:00
chore: add echo helper to create an agent with token (#6576)
This should reduce some LOC and duplication in tests!
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
protobuf "google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/spf13/afero"
|
||||
|
||||
"github.com/coder/coder/provisionersdk"
|
||||
@ -32,6 +33,28 @@ func ParameterSucceed() string {
|
||||
return formatExecValue(successKey, "")
|
||||
}
|
||||
|
||||
// ProvisionApplyWithAgent returns provision responses that will mock a fake
|
||||
// "aws_instance" resource with an agent that has the given auth token.
|
||||
func ProvisionApplyWithAgent(authToken string) []*proto.Provision_Response {
|
||||
return []*proto.Provision_Response{{
|
||||
Type: &proto.Provision_Response_Complete{
|
||||
Complete: &proto.Provision_Complete{
|
||||
Resources: []*proto.Resource{{
|
||||
Name: "example",
|
||||
Type: "aws_instance",
|
||||
Agents: []*proto.Agent{{
|
||||
Id: uuid.NewString(),
|
||||
Name: "example",
|
||||
Auth: &proto.Agent_Token{
|
||||
Token: authToken,
|
||||
},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
func formatExecValue(key, value string) string {
|
||||
return fmt.Sprintf("%s=%s", key, value)
|
||||
}
|
||||
|
Reference in New Issue
Block a user