8000 oh boy · coder/coder@579525d · GitHub
[go: up one dir, main page]

Skip to content

Commit 579525d

Browse files
committed
oh boy
1 parent 715e6f2 commit 579525d

File tree

9 files changed

+746
-619
lines changed

9 files changed

+746
-619
lines changed

coderd/database/migrations/000188_external_auth_providers_jsonb.down.sql

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE template_versions
2+
ALTER COLUMN external_auth_providers type jsonb
3+
using to_jsonb(external_auth_providers);
4+
-- so, that will give us ["foo"], but now we need
5+
-- {"github": {optional: false}} or [{id: "github", optional: false}]

codersdk/templateversions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type TemplateVersionExternalAuth struct {
4141
DisplayIcon string `json:"display_icon"`
4242
AuthenticateURL string `json:"authenticate_url"`
4343
Authenticated bool `json:"authenticated"`
44+
Optional bo 10000 ol `json:"optional"`
4445
}
4546

4647
type ValidationMonotonicOrder string

provisioner/terraform/resources.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ type resourceMetadataItem struct {
122122
type State struct {
123123
Resources []*proto.Resource
124124
Parameters []*proto.RichParameter
125-
ExternalAuthProviders []string
125+
ExternalAuthProviders []*proto.ExternalAuthProviderResource
126126
}
127127

128128
// ConvertState consumes Terraform state and a GraphViz representation
@@ -693,7 +693,7 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
693693
}
694694

695695
// A map is used to ensure we don't have duplicates!
696-
externalAuthProvidersMap := map[string]struct{}{}
696+
externalAuthProvidersMap := map[string]*proto.ExternalAuthProviderResource{}
697697
for _, tfResources := range tfResourcesByLabel {
698698
for _, resource := range tfResources {
699699
// Checking for `coder_git_auth` is legacy!
@@ -704,12 +704,18 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
704704
if !ok {
705705
return nil, xerrors.Errorf("external auth id is not a string")
706706
}
707-
externalAuthProvidersMap[id] = struct{}{}
707+
708+
optional := false
709+
optionalAttribute, ok := resource.AttributeValues["optional"].(bool)
710+
if ok {
711+
optional = optionalAttribute
712+
}
713+
externalAuthProvidersMap[id] = &proto.ExternalAuthProviderResource{Optional: optional}
708714
}
709715
}
710-
externalAuthProviders := make([]string, 0, len(externalAuthProvidersMap))
711-
for id := range externalAuthProvidersMap {
712-
externalAuthProviders = append(externalAuthProviders, id)
716+
externalAuthProviders := make([]*proto.ExternalAuthProviderResource, 0, len(externalAuthProvidersMap))
717+
for _, provider := range externalAuthProvidersMap {
718+
externalAuthProviders = append(externalAuthProviders, provider)
713719
}
714720

715721
return &State{

provisionerd/proto/provisionerd.pb.go

Lines changed: 161 additions & 144 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provisionerd/proto/provisionerd.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ message CompletedJob {
7777
repeated provisioner.Resource start_resources = 1;
7878
repeated provisioner.Resource stop_resources = 2;
7979
repeated provisioner.RichParameter rich_parameters = 3;
80-
repeated string external_auth_providers = 4;
80+
repeated string external_auth_providers_names = 4;
81+
repeated provisioner.ExternalAuthProviderResource external_auth_providers = 5;
8182
}
8283
message TemplateDryRun {
8384
repeated provisioner.Resource resources = 1;

provisionerd/proto/version.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0