Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
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
11 changes: 1 addition & 10 deletions cli/configssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"io/fs"
"net/http"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -456,15 +455,7 @@ func (r *RootCmd) configSSH() *serpent.Command {

coderdConfig, err := client.SSHConfiguration(ctx)
if err != nil {
// If the error is 404, this deployment does not support
// this endpoint yet. Do not error, just assume defaults.
// TODO: Remove this in 2 months (May 31, 2023). Just return the error
// and remove this 404 check.
var sdkErr *codersdk.Error
if !xerrors.As(err, &sdkErr) || sdkErr.StatusCode() != http.StatusNotFound {
return xerrors.Errorf("fetch coderd config failed: %w", err)
}
coderdConfig.HostnamePrefix = "coder."
return xerrors.Errorf("fetch coderd config failed: %w", err)
}

configOptions, err := mergeSSHOptions(sshConfigOpts, coderdConfig, string(root), coderBinary)
Expand Down
13 changes: 3 additions & 10 deletions coderd/httpmw/organizationparam.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,9 @@ func ExtractOrganizationParam(db database.Store) func(http.Handler) http.Handler
var organization database.Organization
var dbErr error

// If the name is exactly "default", then we fetch the default
// organization. This is a special case to make it easier
// for single org deployments.
//
// arg == uuid.Nil.String() should be a temporary workaround for
// legacy provisioners that don't provide an organization ID.
// This prevents a breaking change.
// TODO: This change was added March 2024. Nil uuid returning the
// default org should be removed some number of months after
// that date.
// If the name is exactly "default" or the nil UUID, then we fetch
// the default organization. This is a special case to make it
// easier for single org deployments.
if arg == codersdk.DefaultOrganization || arg == uuid.Nil.String() {
organization, dbErr = db.GetDefaultOrganization(ctx)
} else {
Expand Down
5 changes: 1 addition & 4 deletions coderd/httpmw/organizationparam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@ func TestOrganizationParam(t *testing.T) {
defer res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode, "by default keyword")

// Try by legacy
// TODO: This can be removed when legacy nil uuids are no longer supported.
// This is a temporary measure to ensure as legacy provisioners use
// nil uuids as the org id and expect the default org.
// Try by nil uuid, which resolves to the default org.
chi.RouteContext(r.Context()).URLParams.Add("organization", uuid.Nil.String())
chi.RouteContext(r.Context()).URLParams.Add("user", user.ID.String())
rtr.ServeHTTP(rw, r)
Expand Down
6 changes: 1 addition & 5 deletions coderd/wsbuilder/wsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1394,9 +1394,5 @@ func (b *Builder) usingDynamicParameters() bool {
if err != nil {
return false // Let another part of the code get this error
}
if tpl.UseClassicParameterFlow {
return false
}

return true
return !tpl.UseClassicParameterFlow
}
48 changes: 1 addition & 47 deletions codersdk/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package codersdk

import (
"context"
"encoding/json"
"fmt"
"net/http"
"strconv"
Expand Down Expand Up @@ -165,26 +164,7 @@ type CreateFirstUserResponse struct {
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
}

// CreateUserRequest
// Deprecated: Use CreateUserRequestWithOrgs instead. This will be removed.
// TODO: When removing, we should rename CreateUserRequestWithOrgs -> CreateUserRequest
// Then alias CreateUserRequestWithOrgs to CreateUserRequest.
// @typescript-ignore CreateUserRequest
type CreateUserRequest struct {
Email string `json:"email" validate:"required,email" format:"email"`
Username string `json:"username" validate:"required,username"`
Name string `json:"name" validate:"user_real_name"`
Password string `json:"password"`
// UserLoginType defaults to LoginTypePassword.
UserLoginType LoginType `json:"login_type"`
// DisableLogin sets the user's login type to 'none'. This prevents the user
// from being able to use a password or any other authentication method to login.
// Deprecated: Set UserLoginType=LoginTypeDisabled instead.
DisableLogin bool `json:"disable_login"`
OrganizationID uuid.UUID `json:"organization_id" validate:"" format:"uuid"`
}

type CreateUserRequestWithOrgs struct {
Email string `json:"email" validate:"required_unless=ServiceAccount true,omitempty,email" format:"email"`
Username string `json:"username" validate:"required,username"`
Name string `json:"name" validate:"user_real_name"`
Expand All @@ -201,33 +181,7 @@ type CreateUserRequestWithOrgs struct {
Roles []string `json:"roles,omitempty"`
}

// UnmarshalJSON implements the unmarshal for the legacy param "organization_id".
// To accommodate multiple organizations, the field has been switched to a slice.
// The previous field will just be appended to the slice.
// Note in the previous behavior, omitting the field would result in the
// default org being applied, but that is no longer the case.
// TODO: Remove this method in it's entirety after some period of time.
// This will be released in v1.16.0, and is associated with the multiple orgs
// feature.
func (r *CreateUserRequestWithOrgs) UnmarshalJSON(data []byte) error {
// By using a type alias, we prevent an infinite recursion when unmarshalling.
// This allows us to use the default unmarshal behavior of the original type.
type AliasedReq CreateUserRequestWithOrgs
type DeprecatedCreateUserRequest struct {
AliasedReq
OrganizationID *uuid.UUID `json:"organization_id" format:"uuid"`
}
var dep DeprecatedCreateUserRequest
err := json.Unmarshal(data, &dep)
if err != nil {
return err
}
*r = CreateUserRequestWithOrgs(dep.AliasedReq)
if dep.OrganizationID != nil {
r.OrganizationIDs = append(r.OrganizationIDs, *dep.OrganizationID)
}
return nil
}
type CreateUserRequestWithOrgs = CreateUserRequest

type UpdateUserProfileRequest struct {
Username string `json:"username" validate:"required,username"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ function terraform_apply() {
EOL
}

# TODO: remove
echo "$@" >>/tmp/blah

case "$1" in
version)
terraform_version
Expand Down
Loading