Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix requested changes
  • Loading branch information
kylecarbs committed Feb 27, 2023
commit 5fdf8ce829b039f59f590f46fd5b3997275a2dbb
4 changes: 4 additions & 0 deletions cmd/cliui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,13 @@ func main() {
var githubAuthed atomic.Bool
var gitlabAuthed atomic.Bool
go func() {
// Sleep to display the loading indicator.
time.Sleep(time.Second)
// Swap to true to display success and move onto GitLab.
githubAuthed.Store(true)
// Show the loading indicator again...
time.Sleep(time.Second * 2)
// Complete the auth!
gitlabAuthed.Store(true)
}()
return cliui.GitAuth(cmd.Context(), cmd.OutOrStdout(), cliui.GitAuthOptions{
Expand Down
14 changes: 7 additions & 7 deletions coderd/gitauth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ type Config struct {
ValidateURL string
}

// ConvertConfig converts the YAML configuration entry to the
// parsed and ready-to-consume provider type.
// ConvertConfig converts the SDK configuration entry format
// to the parsed and ready-to-consume in coderd provider type.
func ConvertConfig(entries []codersdk.GitAuthConfig, accessURL *url.URL) ([]*Config, error) {
ids := map[string]struct{}{}
configs := []*Config{}
for _, entry := range entries {
var typ codersdk.GitProvider
switch entry.Type {
case string(codersdk.GitProviderAzureDevops):
switch codersdk.GitProvider(entry.Type) {
case codersdk.GitProviderAzureDevops:
typ = codersdk.GitProviderAzureDevops
case string(codersdk.GitProviderBitBucket):
case codersdk.GitProviderBitBucket:
typ = codersdk.GitProviderBitBucket
case string(codersdk.GitProviderGitHub):
case codersdk.GitProviderGitHub:
typ = codersdk.GitProviderGitHub
case string(codersdk.GitProviderGitLab):
case codersdk.GitProviderGitLab:
typ = codersdk.GitProviderGitLab
default:
return nil, xerrors.Errorf("unknown git provider type: %q", entry.Type)
Expand Down
2 changes: 1 addition & 1 deletion coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (api *API) templateVersionGitAuth(rw http.ResponseWriter, r *http.Request)
}
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error fetching Git auth link.",
Message: "Internal error fetching git auth link.",
Detail: err.Error(),
})
return
Expand Down
6 changes: 3 additions & 3 deletions provisioner/terraform/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (e *executor) plan(ctx, killCtx context.Context, env, vars []string, logr l
}

// planResources must only be called while the lock is held.
func (e *executor) planResources(ctx, killCtx context.Context, planfilePath string) (*ConvertedState, error) {
func (e *executor) planResources(ctx, killCtx context.Context, planfilePath string) (*State, error) {
plan, err := e.showPlan(ctx, killCtx, planfilePath)
if err != nil {
return nil, xerrors.Errorf("show terraform plan file: %w", err)
Expand Down Expand Up @@ -355,7 +355,7 @@ func (e *executor) apply(
}

// stateResources must only be called while the lock is held.
func (e *executor) stateResources(ctx, killCtx context.Context) (*ConvertedState, error) {
func (e *executor) stateResources(ctx, killCtx context.Context) (*State, error) {
state, err := e.state(ctx, killCtx)
if err != nil {
return nil, err
Expand All @@ -364,7 +364,7 @@ func (e *executor) stateResources(ctx, killCtx context.Context) (*ConvertedState
if err != nil {
return nil, xerrors.Errorf("get terraform graph: %w", err)
}
converted := &ConvertedState{}
converted := &State{}
if state.Values != nil {
converted, err = ConvertState([]*tfjson.StateModule{
state.Values.RootModule,
Expand Down
7 changes: 3 additions & 4 deletions provisioner/terraform/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type metadataItem struct {
IsNull bool `mapstructure:"is_null"`
}

type ConvertedState struct {
type State struct {
Resources []*proto.Resource
Parameters []*proto.RichParameter
GitAuthProviders []string
Expand All @@ -81,7 +81,7 @@ type ConvertedState struct {
// ConvertState consumes Terraform state and a GraphViz representation
// produced by `terraform graph` to produce resources consumable by Coder.
// nolint:gocyclo
func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*ConvertedState, error) {
func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error) {
parsedGraph, err := gographviz.ParseString(rawGraph)
if err != nil {
return nil, xerrors.Errorf("parse graph: %w", err)
Expand Down Expand Up @@ -474,7 +474,6 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*ConvertedSta
gitAuthProvidersMap := map[string]struct{}{}
for _, tfResources := range tfResourcesByLabel {
for _, resource := range tfResources {
//
if resource.Type != "coder_git_auth" {
continue
}
Expand All @@ -490,7 +489,7 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*ConvertedSta
gitAuthProviders = append(gitAuthProviders, id)
}

return &ConvertedState{
return &State{
Resources: resources,
Parameters: parameters,
GitAuthProviders: gitAuthProviders,
Expand Down
2 changes: 1 addition & 1 deletion provisionerd/proto/provisionerd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ message CompletedJob {
repeated provisioner.Resource start_resources = 1;
repeated provisioner.Resource stop_resources = 2;
repeated provisioner.RichParameter rich_parameters = 3;
repeated string git_auth_providers = 4;
repeated string git_auth_providers = 4;
}
message TemplateDryRun {
repeated provisioner.Resource resources = 1;
Expand Down
2 changes: 2 additions & 0 deletions provisionerd/provisionerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ func (p *Server) connect(ctx context.Context) {
// An exponential back-off occurs when the connection is failing to dial.
// This is to prevent server spam in case of a coderd outage.
for retrier := retry.New(50*time.Millisecond, 10*time.Second); retrier.Wait(ctx); {
// It's possible for the provisioner daemon to be shut down
// before the wait is complete!
if p.isClosed() {
return
}
Expand Down
6 changes: 3 additions & 3 deletions provisionersdk/proto/provisioner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ message Provision {
message Plan {
Config config = 1;
repeated ParameterValue parameter_values = 2;
repeated RichParameterValue rich_parameter_values = 3;
repeated VariableValue variable_values = 4;
repeated GitAuthProvider git_auth_providers = 5;
repeated RichParameterValue rich_parameter_values = 3;
repeated VariableValue variable_values = 4;
repeated GitAuthProvider git_auth_providers = 5;
}

message Apply {
Expand Down