Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 1 addition & 8 deletions commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package commands

import (
"bytes"
"cmp"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -109,9 +108,6 @@ func runInitCommand(

cnf := config.FromContext(cmd.Context())

// TODO check if this is needed
cnf.API.AIServiceURL = cmp.Or(os.Getenv(cnf.Application.EnvPrefix+"API_AI_URL"), cnf.API.AIServiceURL)

legacyCLIClient, err := auth.NewLegacyCLIClient(cmd.Context(),
makeLegacyCLIWrapper(cnf, cmd.OutOrStdout(), cmd.ErrOrStderr(), cmd.InOrStdin()))
if err != nil {
Expand Down Expand Up @@ -183,7 +179,7 @@ func runInitCommand(
}

initOptions.HTTPClient = legacyCLIClient.HTTPClient
initOptions.AIServiceURL = cnf.API.AIServiceURL
initOptions.APIURL = cnf.API.BaseURL
initOptions.UserAgent = cnf.UserAgent()
initOptions.IsInteractive = isInteractive
initOptions.Yes = viper.GetBool("yes")
Expand Down Expand Up @@ -233,9 +229,6 @@ func canUseAI(cnf *config.Config) (msg string, canUseAI bool) {
if !cnf.API.EnableOrganizations {
return "using AI requires Organizations to be enabled", false
}
if cnf.API.AIServiceURL == "" {
return "using AI requires the service URL to be set", false
}
return "", true
}

Expand Down
14 changes: 6 additions & 8 deletions internal/config/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ type Config struct {
UserAgent string `validate:"omitempty" yaml:"user_agent,omitempty"` // a template - see UserAgent method
SessionID string `validate:"omitempty,ascii" yaml:"session_id,omitempty"` // the ID for the authentication session - defaults to "default"

OAuth2ClientID string `validate:"omitempty" yaml:"oauth2_client_id,omitempty"` // e.g. "upsun-cli"
OAuth2AuthorizeURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"oauth2_auth_url,omitempty"` // e.g. "https://auth.upsun.com/oauth2/authorize"
OAuth2RevokeURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"oauth2_revoke_url,omitempty"` // e.g. "https://auth.upsun.com/oauth2/revoke"
OAuth2TokenURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"oauth2_token_url,omitempty"` // e.g. "https://auth.upsun.com/oauth2/token"
CertifierURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"certifier_url,omitempty"` // No longer used

AIServiceURL string `validate:"omitempty,url" yaml:"ai_url,omitempty"` // The AI service URL, e.g. "https://ai.upsun.com".
EnableOrganizations bool `validate:"omitempty" yaml:"organizations,omitempty"` // Whether the "organizations" feature is enabled.
OAuth2ClientID string `validate:"omitempty" yaml:"oauth2_client_id,omitempty"` // e.g. "upsun-cli"
OAuth2AuthorizeURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"oauth2_auth_url,omitempty"` // e.g. "https://auth.upsun.com/oauth2/authorize"
OAuth2RevokeURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"oauth2_revoke_url,omitempty"` // e.g. "https://auth.upsun.com/oauth2/revoke"
OAuth2TokenURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"oauth2_token_url,omitempty"` // e.g. "https://auth.upsun.com/oauth2/token"
CertifierURL string `validate:"required_without=AuthURL,omitempty,url" yaml:"certifier_url,omitempty"` // No longer used
EnableOrganizations bool `validate:"omitempty" yaml:"organizations,omitempty"` // Whether the "organizations" feature is enabled.
} `validate:"required"`
Detection struct {
GitRemoteName string `validate:"required" yaml:"git_remote_name"` // e.g. "upsun"
Expand Down
2 changes: 0 additions & 2 deletions internal/config/upsun-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ api:
auth_url: "https://auth.upsun.com"
oauth2_client_id: "upsun-cli"

ai_url: "https://ai.upsun.com"

organization_types: [flexible, fixed]
default_organization_type: flexible

Expand Down
8 changes: 4 additions & 4 deletions internal/init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Options struct {
ExtraContext string

HTTPClient *http.Client
AIServiceURL string
APIURL string
UserAgent string
RequestTimeout time.Duration // Defaults to 10 minutes

Expand All @@ -53,8 +53,8 @@ func RunAIConfig(
opts *Options,
stdout, stderr io.Writer,
) error {
if opts.AIServiceURL == "" {
return fmt.Errorf("no AI service URL available")
if opts.APIURL == "" {
return fmt.Errorf("no API URL available")
}
if opts.HTTPClient == nil {
opts.HTTPClient = http.DefaultClient
Expand Down Expand Up @@ -88,7 +88,7 @@ func RunAIConfig(
return err
}

u, err := url.Parse(opts.AIServiceURL)
u, err := url.Parse(opts.APIURL)
if err != nil {
return err
}
Expand Down
Loading